forked from decidim/decidim
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent notifications for blocked users (decidim#13689)
* Block notifications for blocked users * Add tests for fix_blocked_user_notification task * Remove trailing whitespaces * Update RELEASE_NOTES.md * Update decidim-core/lib/tasks/upgrade/clean.rake * RELEASE_NOTES.md lint fix * Remove line 24 from RELEASE_NOTES.md * Apply suggestions from code review Co-authored-by: Andrés Pereira de Lucena <[email protected]> --------- Co-authored-by: Alexandru Emil Lupu <[email protected]> Co-authored-by: Andrés Pereira de Lucena <[email protected]>
- Loading branch information
1 parent
f2f89e2
commit 7ac8c00
Showing
6 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
decidim-core/spec/tasks/upgrade/clean_blocked_users_notifications_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe "rake decidim:upgrade:clean:fix_blocked_user_notification", type: :task do | ||
context "when executing task" do | ||
it "does not throw exceptions keys" do | ||
expect do | ||
Rake::Task[:"decidim:upgrade:clean:fix_blocked_user_notification"].invoke | ||
end.not_to raise_exception | ||
end | ||
end | ||
|
||
context "when there are blocked users" do | ||
let!(:organization) { create(:organization) } | ||
let!(:users) { create_list(:user, 4, :blocked, organization:) } | ||
|
||
it "update all blocked users" do | ||
expect(Decidim::User.blocked.where.not("notifications_sending_frequency = ?", "none").count).to eq(4) | ||
expect { task.execute }.not_to raise_error | ||
expect(Decidim::User.blocked.where.not("notifications_sending_frequency = ?", "none").count).to eq(0) | ||
end | ||
end | ||
end |