From bbb814e58e3f4494c8597f5200fb250300673959 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 20 Nov 2019 15:29:06 +0000 Subject: [PATCH] FIX: Allow advanced tutorial when title emojis are disabled We already skip validations for other uses of PostCreator in the narrative bot, so this commit adds it in the `reply_to` action as well --- .../lib/discourse_narrative_bot/actions.rb | 3 ++- .../advanced_user_narrative_spec.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/actions.rb b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/actions.rb index 80e733ef90d..71349219347 100644 --- a/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/actions.rb +++ b/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/actions.rb @@ -18,7 +18,8 @@ module DiscourseNarrativeBot raw: raw, topic_id: post.topic_id, reply_to_post_number: post.post_number, - post_alert_options: defaut_post_alert_opts + post_alert_options: defaut_post_alert_opts, + skip_validations: true } new_post = PostCreator.create!(self.discobot_user, default_opts.merge(opts)) 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 d12311eac3f..4fca6acb64c 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 @@ -125,6 +125,15 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do expect(new_post.raw).to eq(expected_raw.chomp) expect(new_post.topic.id).to_not eq(topic.id) end + + it 'should not explode if title emojis are disabled' do + SiteSetting.max_emojis_in_title = 0 + narrative.reset_bot(user, other_post) + + expect(Topic.last.title).to eq(I18n.t('discourse_narrative_bot.advanced_user_narrative.title')) + expect(new_post.topic.id).to_not eq(topic.id) + end + end end