Skip to content

Commit

Permalink
Fix inaccurate test data in emails_controller_spec
Browse files Browse the repository at this point in the history
Rails never really sends `cc_organizers` as "false": from
the form, it's either the string 'true' or not present in
the params at all.

Without the fix, Rails 5 causes a test to fail because the
boolean `false` turns into the string `"false"`
  • Loading branch information
tjgrathwell committed Feb 28, 2017
1 parent 131ede2 commit 2be3a99
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions spec/controllers/events/emails_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

it "sends no emails if a subject or body is omitted" do
expect {
post :create, event_id: @event.id, event_email: {cc_organizers: false}
post :create, event_id: @event.id, event_email: {recipients: [@student.id]}
}.not_to change(ActionMailer::Base.deliveries, :count)
end

Expand All @@ -39,7 +39,11 @@
expect {
post :create,
event_id: @event.id,
event_email: mail_params.merge(recipients: [@student.id], attendee_group: Role::STUDENT.id, cc_organizers: true)
event_email: mail_params.merge(
recipients: [@student.id],
attendee_group: Role::STUDENT.id,
cc_organizers: 'true'
)
}.to change(ActionMailer::Base.deliveries, :count).by(1)

expect(recipients).to match_array([@student.email, @organizer.email, another_organizer.email])
Expand All @@ -51,7 +55,10 @@
expect {
post :create,
event_id: @event.id,
event_email: mail_params.merge(recipients: [@student.id], attendee_group: Role::STUDENT.id, cc_organizers: false)
event_email: mail_params.merge(
recipients: [@student.id],
attendee_group: Role::STUDENT.id
)
}.to change(ActionMailer::Base.deliveries, :count).by(1)

expect(recipients).to match_array([@student.email, @organizer.email])
Expand All @@ -63,7 +70,10 @@
expect {
post :create,
event_id: @event.id,
event_email: mail_params.merge(recipients: [@volunteer.id, @student.id], attendee_group: 'All')
event_email: mail_params.merge(
recipients: [@volunteer.id, @student.id],
attendee_group: 'All'
)
}.to change(@event.event_emails, :count).by(1)

email = @event.event_emails.last
Expand All @@ -82,7 +92,10 @@
it "describes the event as 'upcoming'" do
post :create,
event_id: @event.id,
event_email: mail_params.merge(recipients: [], attendee_group: 'All')
event_email: mail_params.merge(
recipients: [],
attendee_group: 'All'
)
email = ActionMailer::Base.deliveries.last
expect(email.body).to include('upcoming event')
end
Expand All @@ -96,7 +109,10 @@
it "describes the event as 'past'" do
post :create,
event_id: @event.id,
event_email: mail_params.merge(recipients: [], attendee_group: 'All')
event_email: mail_params.merge(
recipients: [],
attendee_group: 'All'
)
email = ActionMailer::Base.deliveries.last
expect(email.body).to include('past event')
end
Expand Down

0 comments on commit 2be3a99

Please sign in to comment.