about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/formatter_spec.rb16
-rw-r--r--spec/models/account_spec.rb4
2 files changed, 20 insertions, 0 deletions
diff --git a/spec/lib/formatter_spec.rb b/spec/lib/formatter_spec.rb
index b762907b2..81eaf00e8 100644
--- a/spec/lib/formatter_spec.rb
+++ b/spec/lib/formatter_spec.rb
@@ -6,6 +6,10 @@ RSpec.describe Formatter do
   let(:local_status)  { Fabricate(:status, text: local_text, account: account) }
   let(:remote_status) { Fabricate(:status, text: '<script>alert("Hello")</script> Beep boop', uri: 'beepboop', account: account) }
 
+  let(:local_text_with_mention) { "@#{account.username} @#{account.username}@example.com #{local_text}?x=@#{account.username} #hashtag" }
+  let(:local_status_with_mention) { Fabricate(:status, text: local_text_with_mention,
+                                              account: account, mentions: [Fabricate(:mention, account: account)]) }
+
   describe '#format' do
     subject { Formatter.instance.format(local_status) }
 
@@ -21,6 +25,18 @@ RSpec.describe Formatter do
       expect(subject).to match('<a href="http://google.com/" rel="nofollow noopener" target="_blank"><span class="invisible">http://</span><span class="">google.com/</span><span class="invisible"></span></a>')
     end
 
+    it 'contains a mention' do
+      result = Formatter.instance.format(local_status_with_mention)
+      expect(result).to match "<a href=\"#{TagManager.instance.url_for(account)}\" class=\"u-url mention\">@<span>#{account.username}</span></a></span>"
+      expect(result).to match %r{href=\"http://google.com/\?x=@#{account.username}}
+      expect(result).not_to match "href=\"https://example.com/@#{account.username}"
+    end
+
+    it 'contains a hashtag' do
+      result = Formatter.instance.format(local_status_with_mention)
+      expect(result).to match("/tags/hashtag\" class=\"mention hashtag\">#<span>hashtag</span></a>")
+    end
+
     context 'matches a stand-alone medium URL' do
       let(:local_text) { 'https://hackernoon.com/the-power-to-build-communities-a-response-to-mark-zuckerberg-3f2cac9148a4' }
       it 'has valid url' do
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb
index 157db633a..efd87e871 100644
--- a/spec/models/account_spec.rb
+++ b/spec/models/account_spec.rb
@@ -379,6 +379,10 @@ RSpec.describe Account, type: :model do
     it 'does not match URLs' do
       expect(subject.match('Check this out https://medium.com/@alice/some-article#.abcdef123')).to be_nil
     end
+
+    xit 'does not match URL querystring' do
+      expect(subject.match('https://example.com/?x=@alice')).to be_nil
+    end
   end
 
   describe 'validations' do