mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
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: '')}
|
#{I18n.t('discourse_narrative_bot.advanced_user_narrative.edit.instructions', base_uri: '')}
|
||||||
RAW
|
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,
|
expect(narrative.get_data(user)).to eq("topic_id" => topic.id,
|
||||||
"state" => "tutorial_edit",
|
"state" => "tutorial_edit",
|
||||||
@ -108,7 +108,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
|||||||
#{I18n.t('discourse_narrative_bot.advanced_user_narrative.edit.instructions', base_uri: '')}
|
#{I18n.t('discourse_narrative_bot.advanced_user_narrative.edit.instructions', base_uri: '')}
|
||||||
RAW
|
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,
|
expect(narrative.get_data(user)).to eq("topic_id" => new_post.topic.id,
|
||||||
"state" => "tutorial_edit",
|
"state" => "tutorial_edit",
|
||||||
@ -231,7 +231,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
|||||||
|
|
||||||
DiscourseNarrativeBot::TrackSelector.new(:reply, user, post_id: post.id).select
|
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(
|
expect(new_post.raw).to eq(I18n.t(
|
||||||
'discourse_narrative_bot.advanced_user_narrative.recover.instructions', base_uri: '')
|
'discourse_narrative_bot.advanced_user_narrative.recover.instructions', base_uri: '')
|
||||||
@ -267,7 +267,7 @@ RSpec.describe DiscourseNarrativeBot::AdvancedUserNarrative do
|
|||||||
RAW
|
RAW
|
||||||
|
|
||||||
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_recover)
|
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
|
end
|
||||||
|
|
||||||
context 'when user is an admin' do
|
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]")
|
post.update!(raw: "[details=\"This is a test\"]\nwooohoo\n[/details]")
|
||||||
narrative.input(:reply, user, post: post)
|
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: ''
|
'discourse_narrative_bot.advanced_user_narrative.details.reply', base_uri: ''
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ describe DiscourseNarrativeBot::NewUserNarrative do
|
|||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
|
|
||||||
let(:topic) do
|
let(:topic) do
|
||||||
Fabricate(:private_message_topic, first_post: first_post,
|
Fabricate(:private_message_topic,
|
||||||
|
first_post: first_post,
|
||||||
topic_allowed_users: [
|
topic_allowed_users: [
|
||||||
Fabricate.build(:topic_allowed_user, user: discobot_user),
|
Fabricate.build(:topic_allowed_user, user: discobot_user),
|
||||||
Fabricate.build(:topic_allowed_user, user: 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
|
DiscourseNarrativeBot::TrackSelector.new(:reply, user, post_id: post.id).select
|
||||||
end.to change { Post.count }.by(2)
|
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(
|
expect(new_post.raw).to eq(I18n.t(
|
||||||
'discourse_narrative_bot.new_user_narrative.search.reply',
|
'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(first_post.reload.raw).to eq('Hello world')
|
||||||
|
|
||||||
expect(narrative.get_data(user)).to include("state" => "end",
|
expect(narrative.get_data(user)).to include(
|
||||||
|
"state" => "end",
|
||||||
"topic_id" => new_post.topic_id,
|
"topic_id" => new_post.topic_id,
|
||||||
"track" => described_class.to_s)
|
"track" => described_class.to_s
|
||||||
|
)
|
||||||
|
|
||||||
expect(user.badges.where(name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME).exists?)
|
expect(user.badges.where(
|
||||||
.to eq(true)
|
name: DiscourseNarrativeBot::NewUserNarrative::BADGE_NAME).exists?
|
||||||
|
).to eq(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user