docbrown/spec/models/notification_spec.rb
Andy Zhao 2db2dd1e5a WIP Refactor/notifications (#1131)
* Add new columns to notifications table

* Remove stream from notifications and add new methods

* Turn off moderation comment notifications

* Add notifiable_type index to migration

* Stop creation of Stream-based notification model instances

* Add notification model create hooks

* Add badge achievement notification creation hook

* Fix some specs

* Add missing @ symbol

* Fix for tests and rename a few things

* forgot to uncomment code sigh
2018-11-19 16:09:02 -05:00

30 lines
1.1 KiB
Ruby

require "rails_helper"
RSpec.describe Notification, type: :model do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
let(:article) { create(:article, user_id: user.id) }
let(:follow_instance) { user.follow(user2) }
describe "#send_new_follower_notification" do
before { Notification.send_new_follower_notification(follow_instance) }
it "creates a notification belonging to the person being followed" do
expect(Notification.first.user_id).to eq user2.id
end
it "creates a notification from the follow instance" do
notifiable_data = { notifiable_id: Notification.first.notifiable_id, notifiable_type: Notification.first.notifiable_type }
follow_data = { notifiable_id: follow_instance.id, notifiable_type: follow_instance.class.name }
expect(notifiable_data).to eq follow_data
end
end
# describe "#send_to_followers" do
# before do
# user2.follow user
# Notification.send_to_followers(article, user.followers, "Published")
# end
# end
end