aboutsummaryrefslogtreecommitdiffstats
path: root/spec/support
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/pundit/policies.rb4
-rw-r--r--spec/support/pundit/shared_examples.rb26
2 files changed, 15 insertions, 15 deletions
diff --git a/spec/support/pundit/policies.rb b/spec/support/pundit/policies.rb
index 56433b2ee..02fea2944 100644
--- a/spec/support/pundit/policies.rb
+++ b/spec/support/pundit/policies.rb
@@ -24,8 +24,8 @@ module Support
into.module_eval do
subject { described_class }
let( :user_context ) { create_user_context(user: user, referential: referential) }
- let( :referentail ) { create :referential }
- let( :user ) { create :user }
+ let( :referential ) { build_stubbed :referential }
+ let( :user ) { build_stubbed :user }
end
end
def with_user_permission(permission, &blk)
diff --git a/spec/support/pundit/shared_examples.rb b/spec/support/pundit/shared_examples.rb
index 4d14c46da..33ed1ffae 100644
--- a/spec/support/pundit/shared_examples.rb
+++ b/spec/support/pundit/shared_examples.rb
@@ -3,11 +3,11 @@ RSpec.shared_examples 'permitted policy and same organisation' do
context 'permission absent → ' do
it "denies a user with a different organisation" do
- expect_it.not_to permit(user_context, referential)
+ expect_it.not_to permit(user_context, record)
end
it 'and also a user with the same organisation' do
- user.update_attribute :organisation, referential.organisation
- expect_it.not_to permit(user_context, referential)
+ user.organisation = referential.organisation
+ expect_it.not_to permit(user_context, record)
end
end
@@ -17,19 +17,19 @@ RSpec.shared_examples 'permitted policy and same organisation' do
end
it 'denies a user with a different organisation' do
- expect_it.not_to permit(user_context, referential)
+ expect_it.not_to permit(user_context, record)
end
it 'but allows it for a user with the same organisation' do
- user.update_attribute :organisation, referential.organisation
- expect_it.to permit(user_context, referential)
+ user.organisation = referential.organisation
+ expect_it.to permit(user_context, record)
end
if archived
it 'removes the permission for archived referentials' do
- user.update_attribute :organisation, referential.organisation
- referential.update_attribute :archived_at, 42.seconds.ago
- expect_it.not_to permit(user_context, referential)
+ user.organisation = referential.organisation
+ referential.archived_at = 42.seconds.ago
+ expect_it.not_to permit(user_context, record)
end
end
end
@@ -39,7 +39,7 @@ RSpec.shared_examples 'permitted policy' do
| permission, archived: false|
context 'permission absent → ' do
it "denies a user with a different organisation" do
- expect_it.not_to permit(user_context, referential)
+ expect_it.not_to permit(user_context, record)
end
end
context 'permission present → ' do
@@ -47,13 +47,13 @@ RSpec.shared_examples 'permitted policy' do
add_permissions(permission, for_user: user)
end
it 'allows a user with a different organisation' do
- expect_it.to permit(user_context, referential)
+ expect_it.to permit(user_context, record)
end
if archived
it 'removes the permission for archived referentials' do
- referential.update_attribute :archived_at, 42.seconds.ago
- expect_it.not_to permit(user_context, referential)
+ referential.archived_at = 42.seconds.ago
+ expect_it.not_to permit(user_context, record)
end
end
end