aboutsummaryrefslogtreecommitdiffstats
path: root/spec/policies/application_policy_spec.rb
blob: d7e8e5e279200988c56a98c4aa876e45998884af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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