docbrown/spec/services/notifications/remove_all_spec.rb
rhymes 5a2cae4fbb
Rubocop: enable and fix new Rails cops (#9537)
* Enable new Rails/* cops and use autocorrect on them

* Fixed Rails/PluckInWhere leftovers

* Fix Rails/DefaultScope

* Enable and fix Rails/PluckId

* Fix manual mistake with forcing autocorrection on Rails/PluckId

* Apply PR feedback to remove Rails/PluckId inline disables

* Apply PR feedback to get rid of Rails/PluckInWhere inline
2020-07-29 11:14:19 +02:00

22 lines
1 KiB
Ruby

require "rails_helper"
RSpec.describe Notifications::RemoveAll, type: :service do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:article) { create(:article, user_id: user.id) }
let(:comment) { create(:comment, user_id: user.id, commentable: article) }
let(:comment2) { create(:comment, user_id: user2.id, commentable: article) }
let(:mention) { create(:mention, user_id: user.id, mentionable_id: comment.id, mentionable_type: "Comment") }
let(:mention2) { create(:mention, user_id: user2.id, mentionable_id: comment2.id, mentionable_type: "Comment") }
let(:notifiable_collection_ids) { [mention.id, mention2.id] }
before do
create(:notification, user_id: mention.user.id, notifiable_id: mention.id, notifiable_type: "Mention")
create(:notification, user_id: mention2.user.id, notifiable_id: mention2.id, notifiable_type: "Mention")
end
it "checks all notifiables are deleted" do
notifiables = Mention.all
expect { described_class.call(notifiables.ids, "Mention") }.to change(Notification, :count).by(-2)
end
end