discourse/spec/jobs/bump_topic_spec.rb
David Taylor c9dab6fd08
DEV: Automatically require 'rails_helper' in all specs (#16077)
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors.

By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
2022-03-01 17:50:50 +00:00

36 lines
936 B
Ruby

# frozen_string_literal: true
describe Jobs::BumpTopic do
fab!(:admin) { Fabricate(:admin) }
fab!(:user) { Fabricate(:user) }
it "can bump a topic" do
topic = Fabricate(:topic_timer, user: admin).topic
create_post(topic: topic)
freeze_time (2.hours.from_now)
expect do
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
end.to change { topic.posts.count }.by (1)
expect(topic.reload.public_topic_timer).to eq(nil)
end
it "respects the guardian" do
topic = Fabricate(:topic_timer, user: user).topic
create_post(topic: topic)
topic.category = Fabricate(:private_category, group: Fabricate(:group))
topic.save!
freeze_time (2.hours.from_now)
expect do
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
end.to change { topic.posts.count }.by (0)
expect(topic.reload.public_topic_timer).to eq(nil)
end
end