mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 02:50:00 +08:00
4ea21fa2d0
This change both speeds up specs (less strings to allocate) and helps catch cases where methods in Discourse are mutating inputs. Overall we will be migrating everything to use #frozen_string_literal: true it will take a while, but this is the first and safest move in this direction
38 lines
958 B
Ruby
38 lines
958 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe Jobs::BumpTopic do
|
|
let(:admin) { Fabricate(:admin) }
|
|
let(: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
|