Simplify creating notifications in specs
This commit is contained in:
@@ -21,11 +21,8 @@ describe EmailDigest do
|
||||
it "returns only proposal notifications" do
|
||||
user = create(:user)
|
||||
|
||||
proposal_notification = create(:proposal_notification)
|
||||
comment = create(:comment)
|
||||
|
||||
notification1 = create(:notification, notifiable: proposal_notification, user: user)
|
||||
notification2 = create(:notification, notifiable: comment, user: user)
|
||||
notification1 = create(:notification, :for_proposal_notification, user: user)
|
||||
notification2 = create(:notification, :for_comment, user: user)
|
||||
|
||||
email_digest = EmailDigest.new(user)
|
||||
|
||||
@@ -40,8 +37,7 @@ describe EmailDigest do
|
||||
it "returns true when notifications have not been emailed" do
|
||||
user = create(:user)
|
||||
|
||||
proposal_notification = create(:proposal_notification)
|
||||
notification = create(:notification, notifiable: proposal_notification, user: user)
|
||||
notification = create(:notification, :for_proposal_notification, user: user)
|
||||
|
||||
email_digest = EmailDigest.new(user)
|
||||
expect(email_digest.pending_notifications?).to be
|
||||
@@ -50,8 +46,7 @@ describe EmailDigest do
|
||||
it "returns false when notifications have been emailed" do
|
||||
user = create(:user)
|
||||
|
||||
proposal_notification = create(:proposal_notification)
|
||||
notification = create(:notification, notifiable: 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)
|
||||
expect(email_digest.pending_notifications?).not_to be
|
||||
@@ -70,8 +65,7 @@ describe EmailDigest do
|
||||
it "delivers email if notifications pending" do
|
||||
user = create(:user)
|
||||
|
||||
proposal_notification = create(:proposal_notification)
|
||||
notification = create(:notification, notifiable: proposal_notification, user: user)
|
||||
notification = create(:notification, :for_proposal_notification, user: user)
|
||||
|
||||
reset_mailer
|
||||
email_digest = EmailDigest.new(user)
|
||||
@@ -84,8 +78,7 @@ describe EmailDigest do
|
||||
it "does not deliver email if no notifications pending" do
|
||||
user = create(:user)
|
||||
|
||||
proposal_notification = create(:proposal_notification)
|
||||
create(:notification, notifiable: proposal_notification, user: user, emailed_at: Time.current)
|
||||
create(:notification, :for_proposal_notification, user: user, emailed_at: Time.current)
|
||||
|
||||
reset_mailer
|
||||
email_digest = EmailDigest.new(user)
|
||||
|
||||
Reference in New Issue
Block a user