DEV: Prefer `fab!` for discobot specs.

This commit is contained in:
Guo Xiang Tan 2020-07-14 14:50:03 +08:00
parent 85d4370f79
commit cb68493e89
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
2 changed files with 26 additions and 26 deletions

View File

@ -3,13 +3,13 @@
require 'rails_helper' require 'rails_helper'
RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
let(:narrative_bot) { ::DiscourseNarrativeBot::Base.new } fab!(:narrative_bot) { ::DiscourseNarrativeBot::Base.new }
let(:discobot_user) { narrative_bot.discobot_user } fab!(:discobot_user) { narrative_bot.discobot_user }
let(:discobot_username) { narrative_bot.discobot_username } fab!(:discobot_username) { narrative_bot.discobot_username }
let(:first_post) { Fabricate(:post, user: discobot_user) } fab!(:first_post) { Fabricate(:post, user: discobot_user) }
let(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
let(:topic) do fab!(:topic) do
Fabricate(:private_message_topic, first_post: first_post, Fabricate(:private_message_topic, first_post: first_post,
topic_allowed_users: [ topic_allowed_users: [
Fabricate.build(:topic_allowed_user, user: discobot_user), Fabricate.build(:topic_allowed_user, user: discobot_user),
@ -18,12 +18,12 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
) )
end end
let(:post) { Fabricate(:post, topic: topic, user: user) } fab!(:post) { Fabricate(:post, topic: topic, user: user) }
let(:narrative) { described_class.new } fab!(:narrative) { described_class.new }
let(:other_topic) { Fabricate(:topic) } fab!(:other_topic) { Fabricate(:topic) }
let(:other_post) { Fabricate(:post, topic: other_topic) } fab!(:other_post) { Fabricate(:post, topic: other_topic) }
let(:skip_trigger) { DiscourseNarrativeBot::TrackSelector.skip_trigger } fab!(:skip_trigger) { DiscourseNarrativeBot::TrackSelector.skip_trigger }
let(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger } fab!(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger }
before do before do
Jobs.run_immediately! Jobs.run_immediately!

View File

@ -3,14 +3,14 @@
require 'rails_helper' require 'rails_helper'
describe DiscourseNarrativeBot::NewUserNarrative do describe DiscourseNarrativeBot::NewUserNarrative do
let!(:welcome_topic) { Fabricate(:topic, title: 'Welcome to Discourse') } fab!(:welcome_topic) { Fabricate(:topic, title: 'Welcome to Discourse') }
let(:narrative_bot) { ::DiscourseNarrativeBot::Base.new } fab!(:narrative_bot) { ::DiscourseNarrativeBot::Base.new }
let(:discobot_user) { narrative_bot.discobot_user } fab!(:discobot_user) { narrative_bot.discobot_user }
let(:discobot_username) { narrative_bot.discobot_username } fab!(:discobot_username) { narrative_bot.discobot_username }
let(:first_post) { Fabricate(:post, user: discobot_user) } fab!(:first_post) { Fabricate(:post, user: discobot_user) }
let(:user) { Fabricate(:user) } fab!(:user) { Fabricate(:user) }
let(:topic) do fab!(:topic) do
Fabricate(:private_message_topic, Fabricate(:private_message_topic,
first_post: first_post, first_post: first_post,
topic_allowed_users: [ topic_allowed_users: [
@ -20,13 +20,13 @@ describe DiscourseNarrativeBot::NewUserNarrative do
) )
end end
let(:post) { Fabricate(:post, topic: topic, user: user) } fab!(:post) { Fabricate(:post, topic: topic, user: user) }
let(:narrative) { described_class.new } fab!(:narrative) { described_class.new }
let(:other_topic) { Fabricate(:topic) } fab!(:other_topic) { Fabricate(:topic) }
let(:other_post) { Fabricate(:post, topic: other_topic) } fab!(:other_post) { Fabricate(:post, topic: other_topic) }
let(:profile_page_url) { "#{Discourse.base_url}/users/#{user.username}" } fab!(:profile_page_url) { "#{Discourse.base_url}/users/#{user.username}" }
let(:skip_trigger) { DiscourseNarrativeBot::TrackSelector.skip_trigger } fab!(:skip_trigger) { DiscourseNarrativeBot::TrackSelector.skip_trigger }
let(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger } fab!(:reset_trigger) { DiscourseNarrativeBot::TrackSelector.reset_trigger }
before do before do
Jobs.run_immediately! Jobs.run_immediately!