about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-20 00:33:02 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-20 19:39:58 +0100
commitda2ef4d676ff71e6ab3edf8d1a7cee8bf6b6d353 (patch)
treef73fa34a3323a70d5dcba360f781bce5325e3ed1 /spec
parent3838e6836d47797a4e8ca20afa70eebefb68da26 (diff)
Adding unified streamable notifications
Diffstat (limited to 'spec')
-rw-r--r--spec/fabricators/notification_fabricator.rb4
-rw-r--r--spec/mailers/notification_mailer_spec.rb12
-rw-r--r--spec/models/notification_spec.rb29
3 files changed, 41 insertions, 4 deletions
diff --git a/spec/fabricators/notification_fabricator.rb b/spec/fabricators/notification_fabricator.rb
new file mode 100644
index 000000000..08e984904
--- /dev/null
+++ b/spec/fabricators/notification_fabricator.rb
@@ -0,0 +1,4 @@
+Fabricator(:notification) do
+  activity_id   1
+  activity_type "MyString"
+end
diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb
index d7a956b75..d4baca5aa 100644
--- a/spec/mailers/notification_mailer_spec.rb
+++ b/spec/mailers/notification_mailer_spec.rb
@@ -7,7 +7,8 @@ RSpec.describe NotificationMailer, type: :mailer do
   let(:own_status)     { Fabricate(:status, account: receiver.account) }
 
   describe "mention" do
-    let(:mail) { NotificationMailer.mention(receiver.account, foreign_status) }
+    let(:mention) { Mention.create!(account: receiver.account, status: foreign_status) }
+    let(:mail) { NotificationMailer.mention(receiver.account, Notification.create!(account: receiver.account, activity: mention)) }
 
     it "renders the headers" do
       expect(mail.subject).to eq("You were mentioned by bob")
@@ -20,7 +21,8 @@ RSpec.describe NotificationMailer, type: :mailer do
   end
 
   describe "follow" do
-    let(:mail) { NotificationMailer.follow(receiver.account, sender) }
+    let(:follow) { sender.follow!(receiver.account) }
+    let(:mail) { NotificationMailer.follow(receiver.account, Notification.create!(account: receiver.account, activity: follow)) }
 
     it "renders the headers" do
       expect(mail.subject).to eq("bob is now following you")
@@ -33,7 +35,8 @@ RSpec.describe NotificationMailer, type: :mailer do
   end
 
   describe "favourite" do
-    let(:mail) { NotificationMailer.favourite(own_status, sender) }
+    let(:favourite) { Favourite.create!(account: sender, status: own_status) }
+    let(:mail) { NotificationMailer.favourite(own_status.account, Notification.create!(account: receiver.account, activity: favourite)) }
 
     it "renders the headers" do
       expect(mail.subject).to eq("bob favourited your status")
@@ -46,7 +49,8 @@ RSpec.describe NotificationMailer, type: :mailer do
   end
 
   describe "reblog" do
-    let(:mail) { NotificationMailer.reblog(own_status, sender) }
+    let(:reblog) { Status.create!(account: sender, reblog: own_status) }
+    let(:mail) { NotificationMailer.reblog(own_status.account, Notification.create!(account: receiver.account, activity: reblog)) }
 
     it "renders the headers" do
       expect(mail.subject).to eq("bob reblogged your status")
diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb
new file mode 100644
index 000000000..97e8095cd
--- /dev/null
+++ b/spec/models/notification_spec.rb
@@ -0,0 +1,29 @@
+require 'rails_helper'
+
+RSpec.describe Notification, type: :model do
+  describe '#from_account' do
+    pending
+  end
+
+  describe '#type' do
+    it 'returns :reblog for a Status' do
+      notification = Notification.new(activity: Status.new)
+      expect(notification.type).to eq :reblog
+    end
+
+    it 'returns :mention for a Mention' do
+      notification = Notification.new(activity: Mention.new)
+      expect(notification.type).to eq :mention
+    end
+
+    it 'returns :favourite for a Favourite' do
+      notification = Notification.new(activity: Favourite.new)
+      expect(notification.type).to eq :favourite
+    end
+
+    it 'returns :follow for a Follow' do
+      notification = Notification.new(activity: Follow.new)
+      expect(notification.type).to eq :follow
+    end
+  end
+end