From bd2b2bcf9c997fc83fc6825c49ec6488babeca91 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Mon, 7 Jun 2021 21:13:25 +0200 Subject: [PATCH] DEV: Clean up the spec --- .../jobs/onceoff/remap_old_bot_images_spec.rb | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/plugins/discourse-narrative-bot/spec/jobs/onceoff/remap_old_bot_images_spec.rb b/plugins/discourse-narrative-bot/spec/jobs/onceoff/remap_old_bot_images_spec.rb index 6543cbd9549..76cf6232fe6 100644 --- a/plugins/discourse-narrative-bot/spec/jobs/onceoff/remap_old_bot_images_spec.rb +++ b/plugins/discourse-narrative-bot/spec/jobs/onceoff/remap_old_bot_images_spec.rb @@ -2,19 +2,15 @@ require 'rails_helper' -RSpec.describe Jobs::DiscourseNarrativeBot::RemapOldBotImages do +describe Jobs::DiscourseNarrativeBot::RemapOldBotImages do context "when bot's post contains an old link" do - let(:post) do + let!(:post) do Fabricate(:post, user: ::DiscourseNarrativeBot::Base.new.discobot_user, raw: 'If you’d like to learn more, select below and **bookmark this private message**. If you do, there may be a :gift: in your future!' ) end - before do - post - end - it 'should remap the links correctly' do expected_raw = 'If you’d like to learn more, select below and **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) end end + end - context 'subfolder' do - let(:post) do - Fabricate(:post, - user: ::DiscourseNarrativeBot::Base.new.discobot_user, - raw: 'If you’d like to learn more, select below and **bookmark this private message**. If you do, there may be a :gift: in your future!' - ) - end + context 'subfolder' do + let!(:post) do + Fabricate(:post, + user: ::DiscourseNarrativeBot::Base.new.discobot_user, + raw: 'If you’d like to learn more, select below and **bookmark this private message**. If you do, there may be a :gift: in your future!' + ) + end - it 'should remap the links correctly' do - described_class.new.execute_onceoff({}) + it 'should remap the links correctly' do + described_class.new.execute_onceoff({}) - expect(post.reload.raw).to eq( - 'If you’d like to learn more, select below and **bookmark this private message**. If you do, there may be a :gift: in your future!' - ) - end + expect(post.reload.raw).to eq( + 'If you’d like to learn more, select below and **bookmark this private message**. If you do, there may be a :gift: in your future!' + ) end end end