diff options
| author | Robert | 2017-05-19 17:31:41 +0200 | 
|---|---|---|
| committer | Robert | 2017-05-19 17:31:41 +0200 | 
| commit | c05cca218b943e154d46f535f21834255439556d (patch) | |
| tree | 5bcf8bc248ce1f35d02d9cec5b190a25234971df | |
| parent | 730dcc8c0676be0c9dbbaa89ff7fc9f38f9c0d73 (diff) | |
| parent | 3f9ab8052d67e4c54ae60077ff3c08468a47f058 (diff) | |
| download | chouette-core-c05cca218b943e154d46f535f21834255439556d.tar.bz2 | |
Merge branch '3326_refs_workbnch_policies'
| -rw-r--r-- | app/helpers/newapplication_helper.rb | 2 | ||||
| -rw-r--r-- | spec/policies/application_policy_spec.rb | 19 | ||||
| -rw-r--r-- | spec/policies/company_policy_spec.rb | 4 | ||||
| -rw-r--r-- | spec/policies/group_of_line_policy_spec.rb | 4 | ||||
| -rw-r--r-- | spec/policies/line_policy_spec.rb | 4 | ||||
| -rw-r--r-- | spec/policies/network_policy_spec.rb | 4 | ||||
| -rw-r--r-- | spec/policies/referential_policy_spec.rb | 4 | ||||
| -rw-r--r-- | spec/policies/stop_area_policy_spec.rb | 4 | ||||
| -rw-r--r-- | spec/support/pundit.rb | 13 | ||||
| -rw-r--r-- | spec/support/subject.rb | 11 | 
10 files changed, 44 insertions, 25 deletions
| diff --git a/app/helpers/newapplication_helper.rb b/app/helpers/newapplication_helper.rb index f03228d73..e189199a2 100644 --- a/app/helpers/newapplication_helper.rb +++ b/app/helpers/newapplication_helper.rb @@ -160,7 +160,7 @@ module NewapplicationHelper        end.join.html_safe      end -    content_tag :div, trigger + menu, class: 'btn-group' +    # content_tag :div, trigger + menu, class: 'btn-group'    end diff --git a/spec/policies/application_policy_spec.rb b/spec/policies/application_policy_spec.rb new file mode 100644 index 000000000..d7e8e5e27 --- /dev/null +++ b/spec/policies/application_policy_spec.rb @@ -0,0 +1,19 @@ +RSpec.describe ApplicationPolicy, type: :policy do + +  subject { described_class } +   +  permissions :organisation_match? do +    let( :user_context ) { create_user_context(user: user, referential: referential)  } +    let( :referentail )  { create :referential } +    let( :user )         { create :user } + +    it "denies a user with a different organisation" do +      expect_it.not_to permit(user_context, referential) +    end + +    it "allows a user with a different organisation" do +      user.update_attribute :organisation, referential.organisation +      expect_it.to permit(user_context, referential) +    end +  end +end diff --git a/spec/policies/company_policy_spec.rb b/spec/policies/company_policy_spec.rb deleted file mode 100644 index 7109b628f..000000000 --- a/spec/policies/company_policy_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe CompanyPolicy do -end diff --git a/spec/policies/group_of_line_policy_spec.rb b/spec/policies/group_of_line_policy_spec.rb deleted file mode 100644 index 04914f519..000000000 --- a/spec/policies/group_of_line_policy_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe GroupOfLinePolicy do -end diff --git a/spec/policies/line_policy_spec.rb b/spec/policies/line_policy_spec.rb deleted file mode 100644 index b76616d13..000000000 --- a/spec/policies/line_policy_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe LinePolicy do -end diff --git a/spec/policies/network_policy_spec.rb b/spec/policies/network_policy_spec.rb deleted file mode 100644 index dcdb6bdb2..000000000 --- a/spec/policies/network_policy_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe NetworkPolicy do -end diff --git a/spec/policies/referential_policy_spec.rb b/spec/policies/referential_policy_spec.rb deleted file mode 100644 index 084ecc9f0..000000000 --- a/spec/policies/referential_policy_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe ReferentialPolicy do -end diff --git a/spec/policies/stop_area_policy_spec.rb b/spec/policies/stop_area_policy_spec.rb deleted file mode 100644 index a03c87460..000000000 --- a/spec/policies/stop_area_policy_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe StopAreaPolicy do -end diff --git a/spec/support/pundit.rb b/spec/support/pundit.rb new file mode 100644 index 000000000..66225e82f --- /dev/null +++ b/spec/support/pundit.rb @@ -0,0 +1,13 @@ +require 'pundit/rspec' + +module Support +  module ApplicationPolicy +    def create_user_context(user:, referential:) +      OpenStruct.new(user: user, context: {referential: referential}) +    end +  end +end + +RSpec.configure do | c | +  c.include Support::ApplicationPolicy, type: :policy +end diff --git a/spec/support/subject.rb b/spec/support/subject.rb new file mode 100644 index 000000000..d0c070314 --- /dev/null +++ b/spec/support/subject.rb @@ -0,0 +1,11 @@ +module Support +  module Subject +    def expect_it +      expect(subject) +    end +  end +end + +RSpec.configure do |conf| +  conf.include Support::Subject +end | 
