push_subscription_spec.rb 873 B

12345678910111213141516
  1. require 'rails_helper'
  2. RSpec.describe Web::PushSubscription, type: :model do
  3. let(:alerts) { { mention: true, reblog: false, follow: true, follow_request: false, favourite: true } }
  4. let(:push_subscription) { Web::PushSubscription.new(data: { alerts: alerts }) }
  5. describe '#pushable?' do
  6. it 'obeys alert settings' do
  7. expect(push_subscription.send(:pushable?, Notification.new(activity_type: 'Mention'))).to eq true
  8. expect(push_subscription.send(:pushable?, Notification.new(activity_type: 'Status'))).to eq false
  9. expect(push_subscription.send(:pushable?, Notification.new(activity_type: 'Follow'))).to eq true
  10. expect(push_subscription.send(:pushable?, Notification.new(activity_type: 'FollowRequest'))).to eq false
  11. expect(push_subscription.send(:pushable?, Notification.new(activity_type: 'Favourite'))).to eq true
  12. end
  13. end
  14. end