about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-25 02:13:30 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-25 02:13:30 +0100
commita08e724476f47b85de9bb334eeadaf882a7a23ee (patch)
treed779668fa289d2b7077c878b19fc6691a57142b7 /spec
parent9594f0e858172b9295c5598fcb6ab10506d3046d (diff)
Fix subscriptions:clear task, refactor feeds, refactor streamable activites
and atom feed generation to some extent, as well as the way mentions are
stored
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/application_helper_spec.rb25
-rw-r--r--spec/models/account_spec.rb12
-rw-r--r--spec/models/favourite_spec.rb6
-rw-r--r--spec/models/follow_spec.rb6
-rw-r--r--spec/models/status_spec.rb25
5 files changed, 24 insertions, 50 deletions
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index ca38c792c..30b3653ee 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -30,6 +30,29 @@ RSpec.describe ApplicationHelper, type: :helper do
   end
 
   describe '#linkify' do
-    pending
+    let(:alice) { Fabricate(:account, username: 'alice') }
+    let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com', url: 'http://example.com/bob') }
+
+    it 'turns mention of remote user into link' do
+      status = Fabricate(:status, text: 'Hello @bob@example.com', account: bob)
+      status.mentions.create(account: bob)
+      expect(helper.linkify(status)).to match('<a href="http://example.com/bob" class="mention">@<span>bob@example.com</span></a>')
+    end
+
+    it 'turns mention of local user into link' do
+      status = Fabricate(:status, text: 'Hello @alice', account: bob)
+      status.mentions.create(account: alice)
+      expect(helper.linkify(status)).to match('<a href="http://test.host/users/alice" class="mention">@<span>alice</span></a>')
+    end
+  end
+
+  describe '#account_from_mentions' do
+    let(:bob) { Fabricate(:account, username: 'bob', domain: 'example.com') }
+    let(:status) { Fabricate(:status, text: 'Hello @bob@example.com', account: bob) }
+    let(:mentions) { [Mention.create(status: status, account: bob)] }
+
+    it 'returns account' do
+      expect(helper.account_from_mentions('bob@example.com', mentions)).to eq bob
+    end
   end
 end
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb
index 569442c2c..059e4ee3a 100644
--- a/spec/models/account_spec.rb
+++ b/spec/models/account_spec.rb
@@ -96,18 +96,6 @@ RSpec.describe Account, type: :model do
     end
   end
 
-  describe '#title' do
-    it 'is the same as the username' do
-      expect(subject.title).to eql subject.username
-    end
-  end
-
-  describe '#content' do
-    it 'is the same as the note' do
-      expect(subject.content).to eql subject.note
-    end
-  end
-
   describe '#ping!' do
     pending
   end
diff --git a/spec/models/favourite_spec.rb b/spec/models/favourite_spec.rb
index c778b13d4..6cf3af464 100644
--- a/spec/models/favourite_spec.rb
+++ b/spec/models/favourite_spec.rb
@@ -42,12 +42,6 @@ RSpec.describe Favourite, type: :model do
     end
   end
 
-  describe '#mentions' do
-    it 'is always empty' do
-      expect(subject.mentions).to be_empty
-    end
-  end
-
   describe '#thread' do
     it 'equals the target' do
       expect(subject.thread).to eq subject.target
diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb
index 28bd41dfd..c9d02ab16 100644
--- a/spec/models/follow_spec.rb
+++ b/spec/models/follow_spec.rb
@@ -35,10 +35,4 @@ RSpec.describe Follow, type: :model do
       expect(subject.target).to eq bob
     end
   end
-
-  describe '#mentions' do
-    it 'is empty' do
-      expect(subject.mentions).to be_empty
-    end
-  end
 end
diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb
index 2bf2c744f..b9d079521 100644
--- a/spec/models/status_spec.rb
+++ b/spec/models/status_spec.rb
@@ -40,31 +40,6 @@ RSpec.describe Status, type: :model do
     end
   end
 
-  describe '#mentions' do
-    before do
-      bob # make sure the account exists
-    end
-
-    it 'is empty if the status is self-contained and does not mention anyone' do
-      expect(subject.mentions).to be_empty
-    end
-
-    it 'returns mentioned accounts' do
-      subject.mentioned_accounts.create!(account: bob)
-      expect(subject.mentions).to include bob
-    end
-
-    it 'returns account of the replied-to status' do
-      subject.thread = other
-      expect(subject.mentions).to include bob
-    end
-
-    it 'returns the account of the shared status' do
-      subject.reblog = other
-      expect(subject.mentions).to include bob
-    end
-  end
-
   describe '#verb' do
     it 'is always post' do
       expect(subject.verb).to be :post