mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 19:54:14 +08:00
FIX: TL2 promotion message from discobot didn't use user locale
Includes a small refactor/fix, because `return` isn't allowed in blocks.
This commit is contained in:

committed by
Alan Guo Xiang Tan

parent
bbcd70e8b5
commit
ae744693d8
@ -757,4 +757,20 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
||||
expect(Topic.last.title).to eq(I18n.t("discourse_narrative_bot.tl2_promotion_message.subject_template"))
|
||||
expect(Topic.last.topic_users.map(&:user_id).sort).to eq([DiscourseNarrativeBot::Base.new.discobot_user.id, recipient.id])
|
||||
end
|
||||
|
||||
it "invites to advanced training using the user's effective locale" do
|
||||
SiteSetting.allow_user_locale = true
|
||||
recipient = Fabricate(:user, locale: "de")
|
||||
|
||||
TranslationOverride.upsert!("de", 'discourse_narrative_bot.tl2_promotion_message.subject_template', 'german title')
|
||||
TranslationOverride.upsert!("de", 'discourse_narrative_bot.tl2_promotion_message.text_body_template', 'german body')
|
||||
|
||||
expect {
|
||||
DiscourseEvent.trigger(:system_message_sent, post: Post.last, message_type: 'tl2_promotion_message')
|
||||
}.to change { Topic.count }
|
||||
|
||||
topic = Topic.last
|
||||
expect(topic.title).to eq("german title")
|
||||
expect(topic.first_post.raw).to eq("german body")
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user