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