Skip to content

Commit

Permalink
Do not include blocked users in the newsletter recipients
Browse files Browse the repository at this point in the history
  • Loading branch information
ahukkanen committed Dec 10, 2024
1 parent b98c003 commit 237fbbc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def query
def recipients_base_query
Decidim::User
.entire_collection
.available
.where(organization: @form.current_organization)
.where.not(newsletter_notifications_at: nil)
.where.not(email: nil)
Expand Down
9 changes: 9 additions & 0 deletions spec/queries/decidim/admin/newsletter_recipients_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@
expect(recipients.count).to eq 5
end
end

context "with blocked accounts" do
let!(:blocked_recipients) { create_list(:user, 5, :confirmed, :blocked, newsletter_notifications_at: Time.current, organization:) }

it "returns all not blocked users" do
expect(subject.query).to match_array recipients
expect(recipients.count).to eq 5
end
end
end

context "when sending to followers" do
Expand Down

0 comments on commit 237fbbc

Please sign in to comment.