A platform for community discussion. Free, open, simple.
Fix broken discourse narrative bot spec after upgrade.
Guo Xiang Tan610510ebad05
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.rbindex 8ec9fc24b93..0f560a561c8 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@@ -78,7 +78,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do#{I18n.t('discourse_narrative_bot.advanced_user_narrative.edit.instructions', base_uri: '')}RAW- new_post = Post.offset(1).last+ new_post = topic.ordered_posts.last(2).firstexpect(narrative.get_data(user)).to eq("topic_id" => topic.id,"state" => "tutorial_edit",@@ -108,7 +108,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do#{I18n.t('discourse_narrative_bot.advanced_user_narrative.edit.instructions', base_uri: '')}RAW- new_post = Post.offset(1).last+ new_post = topic.ordered_posts.last(2).firstexpect(narrative.get_data(user)).to eq("topic_id" => new_post.topic.id,"state" => "tutorial_edit",@@ -231,7 +231,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative doDiscourseNarrativeBot::TrackSelector.new(:reply, user, post_id: post.id).select- new_post = Post.offset(1).last+ new_post = topic.ordered_posts.last(2).firstexpect(new_post.raw).to eq(I18n.t('discourse_narrative_bot.advanced_user_narrative.recover.instructions', base_uri: '')@@ -267,7 +267,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative doRAWexpect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_recover)- expect(Post.offset(1).last.raw).to eq(expected_raw.chomp)+ expect(topic.ordered_posts.last(2).first.raw).to eq(expected_raw.chomp)endcontext 'when user is an admin' do@@ -675,7 +675,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative dopost.update!(raw: "[details=\"This is a test\"]\nwooohoo\n[/details]")narrative.input(:reply, user, post: post)- expect(Post.offset(1).last.raw).to eq(I18n.t(+ expect(topic.ordered_posts.last(2).first.raw).to eq(I18n.t('discourse_narrative_bot.advanced_user_narrative.details.reply', base_uri: ''))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.rbindex 31ce253ce06..2a5af3af7b5 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@@ -7,8 +7,9 @@ describe DiscourseNarrativeBot::NewUserNarrative dolet(:user) { Fabricate(:user) }let(:topic) do- Fabricate(:private_message_topic, first_post: first_post,- topic_allowed_users: [+ Fabricate(:private_message_topic,+ first_post: first_post,+ topic_allowed_users: [Fabricate.build(:topic_allowed_user, user: discobot_user),Fabricate.build(:topic_allowed_user, user: user),]@@ -926,7 +927,7 @@ describe DiscourseNarrativeBot::NewUserNarrative doDiscourseNarrativeBot::TrackSelector.new(:reply, user, post_id: post.id).selectend.to change { Post.count }.by(2)- new_post = Post.offset(1).last+ new_post = topic.ordered_posts.last(2).firstexpect(new_post.raw).to eq(I18n.t('discourse_narrative_bot.new_user_narrative.search.reply',@@ -935,12 +936,15 @@ describe DiscourseNarrativeBot::NewUserNarrative doexpect(first_post.reload.raw).to eq('Hello world')- expect(narrative.get_data(user)).to include("state" => "end",- "topic_id" => new_post.topic_id,- "track" => described_class.to_s)+ expect(narrative.get_data(user)).to include(+ "state" => "end",+ "topic_id" => new_post.topic_id,+ "track" => described_class.to_s+ )- expect(user.badges.where(name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME).exists?)- .to eq(true)+ expect(user.badges.where(+ name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME).exists?+ ).to eq(true)endendend