Skip to content

Commit

Permalink
Fix organizer email sending
Browse files Browse the repository at this point in the history
Due to a mishandling of checkboxes, all emails were only being sent to
attendees who have been 'checked-in' to a workshop. Which is usually no-one.
  • Loading branch information
tjgrathwell committed Oct 19, 2013
1 parent de6613f commit bf56bfa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/views/events/emails/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@

<div class='span6'>
<%= label_tag do %>
<%= f.check_box(:include_waitlisted, class: 'include-waitlisted') %> Include waitlisted students
<%= f.check_box(:include_waitlisted, {class: 'include-waitlisted'}, true, false) %> Include waitlisted students
<% end %>
<%= label_tag do %>
<%= f.check_box(:only_checked_in, class: 'only-checked-in') %> Only attendees who checked in (Good for
<%= f.check_box(:only_checked_in, {class: 'only-checked-in'}, true, false) %> Only attendees who checked in (Good for
post-event emails)
<% end %>
</div>
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/events/emails_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

it "allows emails to be sent to waitlisted students" do
expect {
post :create, event_id: @event.id, event_email: mail_params.merge(attendee_group: Role::STUDENT.id, include_waitlisted: true)
post :create, event_id: @event.id, event_email: mail_params.merge(attendee_group: Role::STUDENT.id, include_waitlisted: "true")
}.to change(ActionMailer::Base.deliveries, :count).by(1)
recipients.should =~ [@student.email, @waitlisted.email, @organizer.email]
end
Expand All @@ -47,7 +47,7 @@

it "allows emails to be sent exclusively to checked-in attendees" do
expect {
post :create, event_id: @event.id, event_email: mail_params.merge(attendee_group: 'All', only_checked_in: true)
post :create, event_id: @event.id, event_email: mail_params.merge(attendee_group: 'All', only_checked_in: "true")
}.to change(ActionMailer::Base.deliveries, :count).by(1)
recipients.should =~ [@volunteer.email, @organizer.email]
end
Expand Down
11 changes: 11 additions & 0 deletions spec/features/event_email_request_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require 'spec_helper'

describe "the email page" do
let(:recipients) { JSON.parse(ActionMailer::Base.deliveries.last.header['X-SMTPAPI'].to_s)['to'] }

before do
event = create(:event, student_rsvp_limit: 1)

Expand Down Expand Up @@ -42,4 +44,13 @@
check 'Only attendees who checked in'
page.should have_content("1 person")
end

it "sends an email to the selected people" do
choose 'All Attendees'
fill_in 'Subject', with: 'Hello, Railsbridgers'
fill_in 'Body', with: 'This is a cool email body!'
click_button 'Send Mail'

recipients.length.should == 4
end
end

0 comments on commit bf56bfa

Please sign in to comment.