2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe Jobs::BumpTopic do
|
2023-11-09 17:47:59 -05:00
|
|
|
fab!(:admin)
|
|
|
|
fab!(:user)
|
2019-01-04 08:08:04 -05:00
|
|
|
|
|
|
|
it "can bump a topic" do
|
|
|
|
topic = Fabricate(:topic_timer, user: admin).topic
|
|
|
|
create_post(topic: topic)
|
|
|
|
|
2023-12-06 17:25:00 -05:00
|
|
|
freeze_time(2.hours.from_now)
|
2019-01-04 08:08:04 -05:00
|
|
|
|
|
|
|
expect do
|
|
|
|
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
|
2023-12-06 17:25:00 -05:00
|
|
|
end.to change { topic.posts.count }.by(1)
|
2019-01-04 08:08:04 -05:00
|
|
|
|
|
|
|
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!
|
|
|
|
|
2023-12-06 17:25:00 -05:00
|
|
|
freeze_time(2.hours.from_now)
|
2019-01-04 08:08:04 -05:00
|
|
|
|
|
|
|
expect do
|
|
|
|
described_class.new.execute(topic_timer_id: topic.public_topic_timer.id)
|
2023-12-06 17:25:00 -05:00
|
|
|
end.not_to change { topic.posts.count }
|
2019-01-04 08:08:04 -05:00
|
|
|
|
|
|
|
expect(topic.reload.public_topic_timer).to eq(nil)
|
|
|
|
end
|
|
|
|
end
|