From 48a9860f07f69cb9e2fec357413b9c01b893f603 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan <tgx_world@hotmail.com> Date: Fri, 7 Apr 2017 13:58:52 +0800 Subject: [PATCH] FIX: Publish topic to a category should unlist it as well. --- app/jobs/regular/publish_topic_to_category.rb | 1 + spec/jobs/publish_topic_to_category_spec.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/jobs/regular/publish_topic_to_category.rb b/app/jobs/regular/publish_topic_to_category.rb index fe96de346b6..ab88d5e6ae3 100644 --- a/app/jobs/regular/publish_topic_to_category.rb +++ b/app/jobs/regular/publish_topic_to_category.rb @@ -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 diff --git a/spec/jobs/publish_topic_to_category_spec.rb b/spec/jobs/publish_topic_to_category_spec.rb index bda35cc3f5e..98226ac6717 100644 --- a/spec/jobs/publish_topic_to_category_spec.rb +++ b/spec/jobs/publish_topic_to_category_spec.rb @@ -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)