diff --git a/plugins/discourse-narrative-bot/spec/user_spec.rb b/plugins/discourse-narrative-bot/spec/user_spec.rb index 216e2d66fcc..9779c2414fa 100644 --- a/plugins/discourse-narrative-bot/spec/user_spec.rb +++ b/plugins/discourse-narrative-bot/spec/user_spec.rb @@ -4,6 +4,14 @@ describe User do let(:user) { Fabricate(:user) } let(:profile_page_url) { "#{Discourse.base_url}/users/#{user.username}" } + def i18n_post_args(extra = {}) + { base_uri: "" }.merge(extra) + end + + def i18n_t(key, params = {}) + I18n.t(key, i18n_post_args.merge(params)) + end + before do SiteSetting.queue_jobs = false SiteSetting.discourse_narrative_bot_enabled = true @@ -15,7 +23,7 @@ describe User do user - expected_raw = I18n.t('discourse_narrative_bot.new_user_narrative.hello.message', + expected_raw = i18n_t('discourse_narrative_bot.new_user_narrative.hello.message', username: user.username, title: SiteSetting.title ) @@ -42,7 +50,7 @@ describe User do it 'initiates the bot' do expect { user }.to change { Topic.count }.by(1) - expect(Topic.last.title).to eq(I18n.t( + expect(Topic.last.title).to eq(i18n_t( 'discourse_narrative_bot.new_user_narrative.hello.title' ).gsub(/:robot:/, '').strip) end @@ -56,7 +64,7 @@ describe User do it 'initiate the bot' do expect { user }.to change { Topic.count }.by(1) - expect(Topic.last.title).to eq(I18n.t( + expect(Topic.last.title).to eq(i18n_t( 'discourse_narrative_bot.new_user_narrative.hello.title' )) end @@ -69,7 +77,7 @@ describe User do it 'should send the right welcome message' do expect { user }.to change { Topic.count }.by(1) - expect(Topic.last.title).to eq(I18n.t( + expect(Topic.last.title).to eq(i18n_t( "system_messages.welcome_user.subject_template", site_name: SiteSetting.title ))