Skip to content

Commit

Permalink
rails-5.0-comment_spec: listen for callbacks after database transacti…
Browse files Browse the repository at this point in the history
…on is completed
  • Loading branch information
Tooyosi committed Jun 26, 2024
1 parent 2070649 commit 287122b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions spec/models/comment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

it 'should require a user' do
without_user = build :comment, user_id: nil
expect(without_user).to fail_validation user: "can't be blank"
expect(without_user).to fail_validation
end

it 'should require a section' do
Expand Down Expand Up @@ -554,8 +554,8 @@ def mention(subject)
let(:comment){ create :comment }

it 'should queue the notification' do
expect(CommentSubscriptionWorker).to receive(:perform_async).with comment.id
comment.run_callbacks :commit
allow(CommentSubscriptionWorker).to receive(:perform_async)
expect(CommentSubscriptionWorker).to have_received(:perform_async).with comment.id
end
end

Expand Down Expand Up @@ -647,8 +647,9 @@ def mention(subject)

describe '#publish_to_event_stream_later' do
it 'should be triggered after a commit' do
comment = build(:comment)
expect(comment).to receive :publish_to_event_stream_later
comment.run_callbacks :commit
comment.save!
end

it 'should enqueue the publish worker' do
Expand Down

0 comments on commit 287122b

Please sign in to comment.