From cb68493e891bd076023488e5ab5a40ec956f1b7c Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Tue, 14 Jul 2020 14:50:03 +0800 Subject: [PATCH] DEV: Prefer `fab!` for discobot specs. --- .../advanced_user_narrative_spec.rb | 24 ++++++++-------- .../new_user_narrative_spec.rb | 28 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb index a6d5956a8bd..10b499e9fea 100644 --- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb +++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/advanced_user_narrative_spec.rb @@ -3,13 +3,13 @@ require 'rails_helper' RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do - let(:narrative_bot) { ::DiscourseNarrativeBot::Base.new } - let(:discobot_user) { narrative_bot.discobot_user } - let(:discobot_username) { narrative_bot.discobot_username } - let(:first_post) { Fabricate(:post, user: discobot_user) } - let(:user) { Fabricate(:user) } + fab!(:narrative_bot) { ::DiscourseNarrativeBot::Base.new } + fab!(:discobot_user) { narrative_bot.discobot_user } + fab!(:discobot_username) { narrative_bot.discobot_username } + fab!(:first_post) { Fabricate(:post, user: discobot_user) } + fab!(:user) { Fabricate(:user) } - let(:topic) do + fab!(:topic) do Fabricate(:private_message_topic, first_post: first_post, topic_allowed_users: [ Fabricate.build(:topic_allowed_user, user: discobot_user), @@ -18,12 +18,12 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do ) end - let(:post) { Fabricate(:post, topic: topic, user: user) } - let(:narrative) { described_class.new } - let(:other_topic) { Fabricate(:topic) } - let(:other_post) { Fabricate(:post, topic: other_topic) } - let(:skip_trigger) { DiscourseNarrativeBot::TrackSelector.skip_trigger } - let(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger } + fab!(:post) { Fabricate(:post, topic: topic, user: user) } + fab!(:narrative) { described_class.new } + fab!(:other_topic) { Fabricate(:topic) } + fab!(:other_post) { Fabricate(:post, topic: other_topic) } + fab!(:skip_trigger) { DiscourseNarrativeBot::TrackSelector.skip_trigger } + fab!(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger } before do Jobs.run_immediately! diff --git a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb index cfb4f00b018..788d314c676 100644 --- a/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb +++ b/plugins/discourse-narrative-bot/spec/discourse_narrative_bot/new_user_narrative_spec.rb @@ -3,14 +3,14 @@ require 'rails_helper' describe DiscourseNarrativeBot::NewUserNarrative do - let!(:welcome_topic) { Fabricate(:topic, title: 'Welcome to Discourse') } - let(:narrative_bot) { ::DiscourseNarrativeBot::Base.new } - let(:discobot_user) { narrative_bot.discobot_user } - let(:discobot_username) { narrative_bot.discobot_username } - let(:first_post) { Fabricate(:post, user: discobot_user) } - let(:user) { Fabricate(:user) } + fab!(:welcome_topic) { Fabricate(:topic, title: 'Welcome to Discourse') } + fab!(:narrative_bot) { ::DiscourseNarrativeBot::Base.new } + fab!(:discobot_user) { narrative_bot.discobot_user } + fab!(:discobot_username) { narrative_bot.discobot_username } + fab!(:first_post) { Fabricate(:post, user: discobot_user) } + fab!(:user) { Fabricate(:user) } - let(:topic) do + fab!(:topic) do Fabricate(:private_message_topic, first_post: first_post, topic_allowed_users: [ @@ -20,13 +20,13 @@ describe DiscourseNarrativeBot::NewUserNarrative do ) end - let(:post) { Fabricate(:post, topic: topic, user: user) } - let(:narrative) { described_class.new } - let(:other_topic) { Fabricate(:topic) } - let(:other_post) { Fabricate(:post, topic: other_topic) } - let(:profile_page_url) { "#{Discourse.base_url}/users/#{user.username}" } - let(:skip_trigger) { DiscourseNarrativeBot::TrackSelector.skip_trigger } - let(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger } + fab!(:post) { Fabricate(:post, topic: topic, user: user) } + fab!(:narrative) { described_class.new } + fab!(:other_topic) { Fabricate(:topic) } + fab!(:other_post) { Fabricate(:post, topic: other_topic) } + fab!(:profile_page_url) { "#{Discourse.base_url}/users/#{user.username}" } + fab!(:skip_trigger) { DiscourseNarrativeBot::TrackSelector.skip_trigger } + fab!(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger } before do Jobs.run_immediately!