From 024127e62fdff78f638a3864624c9439cf56605d Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 5 Feb 2023 21:13:37 +0100 Subject: [PATCH] Remove connected user transformation from TwitteredMarkdown --- app/services/twittered_markdown.rb | 12 +---------- spec/helpers/markdown_helper_spec.rb | 30 +++------------------------- 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/app/services/twittered_markdown.rb b/app/services/twittered_markdown.rb index 8787c1b4..ef71472b 100644 --- a/app/services/twittered_markdown.rb +++ b/app/services/twittered_markdown.rb @@ -7,17 +7,7 @@ class TwitteredMarkdown < Redcarpet::Render::StripDown def wrap_mentions(text) text.gsub(/(^|\s)@([a-zA-Z0-9_]{1,16})/) do - local_user = User.find_by(screen_name: $2) - if local_user.nil? - "#{$1}#{$2}" - else - service = local_user.services.where(type: "Services::Twitter").first - if service.nil? - "#{$1}#{$2}" - else - "#{$1}@#{service.nickname}" - end - end + "#{$1}#{$2}" end end end diff --git a/spec/helpers/markdown_helper_spec.rb b/spec/helpers/markdown_helper_spec.rb index b5ecf606..177b42c7 100644 --- a/spec/helpers/markdown_helper_spec.rb +++ b/spec/helpers/markdown_helper_spec.rb @@ -40,24 +40,8 @@ describe MarkdownHelper, type: :helper do end describe "#twitter_markdown" do - context "mentioned user has Twitter connected" do - let(:user) { FactoryBot.create(:user) } - let(:service) { Services::Twitter.create(user: user) } - - before do - service.nickname = "test" - service.save! - end - - it "should transform a internal mention to a Twitter mention" do - expect(twitter_markdown("@#{user.screen_name}")).to eq("@test") - end - end - - context "mentioned user doesnt have Twitter connected" do - it "should not transform the mention" do - expect(twitter_markdown("@test")).to eq("test") - end + it "should not transform the mention" do + expect(twitter_markdown("@test")).to eq("test") end it "should not strip weird hearts" do @@ -118,17 +102,9 @@ describe MarkdownHelper, type: :helper do describe "#twitter_markdown_io" do let(:user) { FactoryBot.create(:user) } - let(:service) { Services::Twitter.create(user: user) } - - before do - user.screen_name = "test" - user.save! - service.nickname = "ObamaGaming" - service.save! - end it "should return the expected text" do - expect(twitter_markdown_io("spec/fixtures/markdown/twitter.md")).to eq("@ObamaGaming") + expect(twitter_markdown_io("spec/fixtures/markdown/twitter.md")).to eq("test") end end