Remove duplication in email specs using let
This commit is contained in:
@@ -33,27 +33,23 @@ describe EmailDigest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "pending_notifications?" do
|
describe "pending_notifications?" do
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
|
||||||
it "returns true when notifications have not been emailed" do
|
it "returns true when notifications have not been emailed" do
|
||||||
user = create(:user)
|
create(:notification, :for_proposal_notification, user: user)
|
||||||
|
|
||||||
notification = create(:notification, :for_proposal_notification, user: user)
|
|
||||||
|
|
||||||
email_digest = EmailDigest.new(user)
|
email_digest = EmailDigest.new(user)
|
||||||
expect(email_digest.pending_notifications?).to be
|
expect(email_digest.pending_notifications?).to be
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when notifications have been emailed" do
|
it "returns false when notifications have been emailed" do
|
||||||
user = create(:user)
|
create(:notification, :for_proposal_notification, user: user, emailed_at: Time.current)
|
||||||
|
|
||||||
notification = create(:notification, :for_proposal_notification, user: user, emailed_at: Time.current)
|
|
||||||
|
|
||||||
email_digest = EmailDigest.new(user)
|
email_digest = EmailDigest.new(user)
|
||||||
expect(email_digest.pending_notifications?).not_to be
|
expect(email_digest.pending_notifications?).not_to be
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns false when there are no notifications for a user" do
|
it "returns false when there are no notifications for a user" do
|
||||||
user = create(:user)
|
|
||||||
email_digest = EmailDigest.new(user)
|
email_digest = EmailDigest.new(user)
|
||||||
expect(email_digest.pending_notifications?).not_to be
|
expect(email_digest.pending_notifications?).not_to be
|
||||||
end
|
end
|
||||||
@@ -61,11 +57,10 @@ describe EmailDigest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe "deliver" do
|
describe "deliver" do
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
|
||||||
it "delivers email if notifications pending" do
|
it "delivers email if notifications pending" do
|
||||||
user = create(:user)
|
create(:notification, :for_proposal_notification, user: user)
|
||||||
|
|
||||||
notification = create(:notification, :for_proposal_notification, user: user)
|
|
||||||
|
|
||||||
reset_mailer
|
reset_mailer
|
||||||
email_digest = EmailDigest.new(user)
|
email_digest = EmailDigest.new(user)
|
||||||
@@ -76,8 +71,6 @@ describe EmailDigest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "does not deliver email if no notifications pending" do
|
it "does not deliver email if no notifications pending" do
|
||||||
user = create(:user)
|
|
||||||
|
|
||||||
create(:notification, :for_proposal_notification, user: user, emailed_at: Time.current)
|
create(:notification, :for_proposal_notification, user: user, emailed_at: Time.current)
|
||||||
|
|
||||||
reset_mailer
|
reset_mailer
|
||||||
|
|||||||
Reference in New Issue
Block a user