Move newsletter User scope outside UserSegments
Why: UserSegments are not only used for Newsletters or Email downloads, but also for internal Global Notifications. We don't want to have that scope hardcoded inside UserSegments as users that have opted-out from the newsletter should still be recipients of global notifications. How: Removing the scope from the UserSegments `all_users` method that acts as base for all the other segments. Including that `newsletter` scope only on the places that is relevant: * When listing recipients for a newsletter * When downloading a listing emails that can be newsletter recipients Also updated relevant tests
This commit is contained in:
@@ -6,15 +6,11 @@ describe UserSegments do
|
||||
let(:user3) { create(:user) }
|
||||
|
||||
describe "#all_users" do
|
||||
it "returns all active users with newsletter enabled" do
|
||||
active_user1 = create(:user, newsletter: true)
|
||||
active_user2 = create(:user, newsletter: true)
|
||||
active_user3 = create(:user, newsletter: false)
|
||||
it "returns all active users enabled" do
|
||||
active_user = create(:user)
|
||||
erased_user = create(:user, erased_at: Time.current)
|
||||
|
||||
expect(described_class.all_users).to include active_user1
|
||||
expect(described_class.all_users).to include active_user2
|
||||
expect(described_class.all_users).not_to include active_user3
|
||||
expect(described_class.all_users).to include active_user
|
||||
expect(described_class.all_users).not_to include erased_user
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user