From fa09a02201cd10f95659a905a8c70776378b274e Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 24 Jul 2017 15:56:08 +0900 Subject: [PATCH] Fix specs. --- spec/components/post_creator_spec.rb | 12 +++++------- spec/integration/managing_topic_status_spec.rb | 2 +- spec/jobs/toggle_topic_closed_spec.rb | 4 +--- spec/models/topic_spec.rb | 4 +--- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/spec/components/post_creator_spec.rb b/spec/components/post_creator_spec.rb index 5e3441784f5..49cf2daef5a 100644 --- a/spec/components/post_creator_spec.rb +++ b/spec/components/post_creator_spec.rb @@ -301,13 +301,11 @@ describe PostCreator do it "updates topic's auto close date when it's based on last post" do Timecop.freeze do - topic = Fabricate(:topic, - topic_timers: [Fabricate(:topic_timer, - based_on_last_post: true, - execute_at: Time.zone.now - 12.hours, - created_at: Time.zone.now - 24.hours - )] - ) + topic = Fabricate(:topic_timer, + based_on_last_post: true, + execute_at: Time.zone.now - 12.hours, + created_at: Time.zone.now - 24.hours + ).topic Fabricate(:post, topic: topic) diff --git a/spec/integration/managing_topic_status_spec.rb b/spec/integration/managing_topic_status_spec.rb index 0673c279597..eede1cbb096 100644 --- a/spec/integration/managing_topic_status_spec.rb +++ b/spec/integration/managing_topic_status_spec.rb @@ -60,7 +60,7 @@ RSpec.describe "Managing a topic's status update", type: :request do end it 'should be able to delete a topic status update' do - topic.update!(topic_timers: [Fabricate(:topic_timer)]) + Fabricate(:topic_timer, topic: topic) post "/t/#{topic.id}/timer.json", time: nil, diff --git a/spec/jobs/toggle_topic_closed_spec.rb b/spec/jobs/toggle_topic_closed_spec.rb index b1460e3c62a..e6ef2997211 100644 --- a/spec/jobs/toggle_topic_closed_spec.rb +++ b/spec/jobs/toggle_topic_closed_spec.rb @@ -60,9 +60,7 @@ describe Jobs::ToggleTopicClosed do describe 'when user is not authorized to close topics' do let(:topic) do - Fabricate(:topic, - topic_timers: [Fabricate(:topic_timer, execute_at: 2.hours.from_now)] - ) + Fabricate(:topic_timer, execute_at: 2.hours.from_now).topic end it 'should not do anything' do diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index be8fef69227..d2627fa9fbf 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -1155,9 +1155,7 @@ describe Topic do let(:topic) { Fabricate.build(:topic) } let(:closing_topic) do - Fabricate(:topic, - topic_timers: [Fabricate(:topic_timer, execute_at: 5.hours.from_now)] - ) + Fabricate(:topic_timer, execute_at: 5.hours.from_now).topic end let(:admin) { Fabricate(:admin) }