Fix broken discourse narrative bot spec after upgrade.
This commit is contained in:
parent
e51b8d3198
commit
610510ebad
|
@ -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).first
|
||||
|
||||
expect(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).first
|
||||
|
||||
expect(narrative.get_data(user)).to eq("topic_id" => new_post.topic.id,
|
||||
"state" => "tutorial_edit",
|
||||
|
@ -231,7 +231,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
|||
|
||||
DiscourseNarrativeBot::TrackSelector.new(:reply, user, post_id: post.id).select
|
||||
|
||||
new_post = Post.offset(1).last
|
||||
new_post = topic.ordered_posts.last(2).first
|
||||
|
||||
expect(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 do
|
|||
RAW
|
||||
|
||||
expect(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)
|
||||
end
|
||||
|
||||
context 'when user is an admin' do
|
||||
|
@ -675,7 +675,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
|||
post.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: ''
|
||||
))
|
||||
|
||||
|
|
|
@ -7,8 +7,9 @@ describe DiscourseNarrativeBot::NewUserNarrative do
|
|||
let(: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 do
|
|||
DiscourseNarrativeBot::TrackSelector.new(:reply, user, post_id: post.id).select
|
||||
end.to change { Post.count }.by(2)
|
||||
|
||||
new_post = Post.offset(1).last
|
||||
new_post = topic.ordered_posts.last(2).first
|
||||
|
||||
expect(new_post.raw).to eq(I18n.t(
|
||||
'discourse_narrative_bot.new_user_narrative.search.reply',
|
||||
|
@ -935,12 +936,15 @@ describe DiscourseNarrativeBot::NewUserNarrative do
|
|||
|
||||
expect(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)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue