Send newsletter emails in order

The list of emails for sending newsletters will always be ordered by
user creation date, so it will be easier to debug and to know for
which users the email has been sent.
This commit is contained in:
Julian Herrero
2019-01-31 17:07:46 +01:00
parent c6f2aacb51
commit fc69c21ebb
2 changed files with 12 additions and 1 deletions

View File

@@ -190,4 +190,15 @@ describe UserSegments do
end
end
describe "#user_segment_emails" do
it "returns list of emails sorted by user creation date" do
create(:user, email: "first@email.com", created_at: 1.day.ago)
create(:user, email: "last@email.com")
emails = described_class.user_segment_emails(:all_users)
expect(emails.first).to eq "first@email.com"
expect(emails.last).to eq "last@email.com"
end
end
end