mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
DEV: Clean up the spec
This commit is contained in:

committed by
Alan Guo Xiang Tan

parent
f875079b1a
commit
bd2b2bcf9c
@ -2,19 +2,15 @@
|
|||||||
|
|
||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Jobs::DiscourseNarrativeBot::RemapOldBotImages do
|
describe Jobs::DiscourseNarrativeBot::RemapOldBotImages do
|
||||||
context "when bot's post contains an old link" do
|
context "when bot's post contains an old link" do
|
||||||
let(:post) do
|
let!(:post) do
|
||||||
Fabricate(:post,
|
Fabricate(:post,
|
||||||
user: ::DiscourseNarrativeBot::Base.new.discobot_user,
|
user: ::DiscourseNarrativeBot::Base.new.discobot_user,
|
||||||
raw: 'If you’d like to learn more, select <img src="/images/font-awesome-gear.png" width="16" height="16"> <img src="/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
raw: 'If you’d like to learn more, select <img src="/images/font-awesome-gear.png" width="16" height="16"> <img src="/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
|
||||||
post
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should remap the links correctly' do
|
it 'should remap the links correctly' do
|
||||||
expected_raw = 'If you’d like to learn more, select <img src="/plugins/discourse-narrative-bot/images/font-awesome-gear.png" width="16" height="16"> <img src="/plugins/discourse-narrative-bot/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/plugins/discourse-narrative-bot/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
expected_raw = 'If you’d like to learn more, select <img src="/plugins/discourse-narrative-bot/images/font-awesome-gear.png" width="16" height="16"> <img src="/plugins/discourse-narrative-bot/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/plugins/discourse-narrative-bot/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
||||||
|
|
||||||
@ -23,22 +19,22 @@ RSpec.describe Jobs::DiscourseNarrativeBot::RemapOldBotImages do
|
|||||||
expect(post.reload.raw).to eq(expected_raw)
|
expect(post.reload.raw).to eq(expected_raw)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'subfolder' do
|
context 'subfolder' do
|
||||||
let(:post) do
|
let!(:post) do
|
||||||
Fabricate(:post,
|
Fabricate(:post,
|
||||||
user: ::DiscourseNarrativeBot::Base.new.discobot_user,
|
user: ::DiscourseNarrativeBot::Base.new.discobot_user,
|
||||||
raw: 'If you’d like to learn more, select <img src="/community/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/community/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
raw: 'If you’d like to learn more, select <img src="/community/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/community/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should remap the links correctly' do
|
it 'should remap the links correctly' do
|
||||||
described_class.new.execute_onceoff({})
|
described_class.new.execute_onceoff({})
|
||||||
|
|
||||||
expect(post.reload.raw).to eq(
|
expect(post.reload.raw).to eq(
|
||||||
'If you’d like to learn more, select <img src="/community/plugins/discourse-narrative-bot/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/community/plugins/discourse-narrative-bot/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
'If you’d like to learn more, select <img src="/community/plugins/discourse-narrative-bot/images/font-awesome-ellipsis.png" width="16" height="16"> below and <img src="/community/plugins/discourse-narrative-bot/images/font-awesome-bookmark.png" width="16" height="16"> **bookmark this private message**. If you do, there may be a :gift: in your future!'
|
||||||
)
|
)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user