Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 5 - Fix discussion_spec.rb #341

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions spec/models/discussion_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

it 'should require a user' do
without_user = build :discussion, 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 @@ -190,11 +190,20 @@ def create_discussion(position: nil)
end

describe '#notify_subscribers_later' do
let(:discussion){ create :discussion }

it 'should queue the notification' do
expect(DiscussionSubscriptionWorker).to receive(:perform_async).with discussion.id
discussion.run_callbacks :commit
# TODO: Once on Rails 5, Can Remove this Version Check
# In Rails Versions < 5, commit callbacks are not getting called in transactional tests.
# See https://stackoverflow.com/a/30901628/15768801 for more details.
if Rails.version.starts_with?('5')
allow(DiscussionSubscriptionWorker).to receive(:perform_async)
discussion = build :discussion
discussion.save!
expect(DiscussionSubscriptionWorker).to have_received(:perform_async).with discussion.id
else
discussion = create :discussion
expect(DiscussionSubscriptionWorker).to receive(:perform_async).with discussion.id
discussion.run_callbacks :commit
end
end
end

Expand Down
Loading