Skip to content

Commit

Permalink
update post policy spec
Browse files Browse the repository at this point in the history
  • Loading branch information
toyhammered committed Nov 1, 2020
1 parent ae78d02 commit 647e961
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion spec/factories/posts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
content { Faker::Lorem.sentence }

trait :locked do
locked_by { user.id }
association :locked_by, factory: :user, strategy: :build
locked_at { DateTime.now }
locked_reason { :SPAM }
end
Expand Down
7 changes: 7 additions & 0 deletions spec/policies/post_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
end
end

permissions :update_lock? do
let(:post) { build(:post, :locked, user: owner.resource_owner) }

it('should allow admin') { should permit(admin, post) }
it('should not allow owner') { should_not permit(owner, post) }
end

permissions :create? do
it('should allow owner') { should permit(owner, post) }
it('should not allow admin') { should_not permit(admin, post) }
Expand Down

0 comments on commit 647e961

Please sign in to comment.