mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Add specs for post action guardian
This commit is contained in:
22
spec/components/post_action_creator_spec.rb
Normal file
22
spec/components/post_action_creator_spec.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
require 'rails_helper'
|
||||
require 'post_action_creator'
|
||||
|
||||
describe PostCreator do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:post) { Fabricate(:post) }
|
||||
let(:group) { Fabricate(:group) }
|
||||
let(:like_type_id) { PostActionType.types[:like] }
|
||||
|
||||
|
||||
describe 'perform' do
|
||||
it 'creates a post action' do
|
||||
expect { PostActionCreator.new(user, post).perform(like_type_id) }.to change { PostAction.count }.by(1)
|
||||
expect(PostAction.find_by(user: user, post: post, post_action_type_id: like_type_id)).to be_present
|
||||
end
|
||||
|
||||
it 'does not create an invalid post action' do
|
||||
expect { PostActionCreator.new(user, nil).perform(like_type_id) }.to raise_error(Discourse::InvalidAccess)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user