FIX: Publish topic to a category should unlist it as well.

This commit is contained in:
Guo Xiang Tan 2017-04-07 13:58:52 +08:00
parent 708f65f740
commit 48a9860f07
2 changed files with 3 additions and 1 deletions

View File

@ -9,6 +9,7 @@ module Jobs
PostTimestampChanger.new(timestamp: Time.zone.now, topic: topic).change! do
topic.change_category_to_id(topic_status_update.category_id)
topic.update_columns(visible: true)
end
end
end

View File

@ -38,12 +38,13 @@ RSpec.describe Jobs::PublishTopicToCategory do
end
it 'should publish the topic to the new category correctly' do
Timecop.travel(1.hour.ago) { topic }
Timecop.travel(1.hour.ago) { topic.update!(visible: false) }
described_class.new.execute(topic_status_update_id: topic.topic_status_update.id)
topic.reload
expect(topic.category).to eq(another_category)
expect(topic.visible).to eq(true)
%w{created_at bumped_at updated_at last_posted_at}.each do |attribute|
expect(topic.public_send(attribute)).to be_within(1.second).of(Time.zone.now)