Permalink
Browse files

Created a reserve_all_seats! test helper and moved all mocha stubs to…

… use this method. Updated copy for "No Seats Available" to start awareness of upcoming auto-notify of openings feature. Made Rsvp.send_reminders return an empty array and take no action if there are no open seats.
  • Loading branch information...
metaskills committed Oct 2, 2009
1 parent a8fcc1b commit 1cfa60c40a46cd19574c293f8af585fdb28e7458
View
@@ -26,7 +26,7 @@ def open_seats?
end
def send_reminders
- not_reserved.all.each(&:send_reminder)
+ open_seats? ? not_reserved.all.each(&:send_reminder) : []
end
end
@@ -8,7 +8,7 @@
%p
Rsvp's slug link:<br/>
- = mine_rsvp_url(:id =>@rsvp.slug)
+ = link_to mine_rsvp_url(:id =>@rsvp.slug), mine_rsvp_url(:id =>@rsvp.slug)
- form_for @rsvp do |r|
= render :partial => 'edit', :locals => {:r => r}
@@ -13,8 +13,9 @@
please let us know if your reservation changes!
%p
- If see a "No Seats Available" message, please be patient and follow us on Twitter
- at 757studio where we may announce openings as they become available.
+ If you see a <strong>"No Seats Available"</strong> message, please be patient.
+ This site is setup to email all attendees on the waiting list as soon as an opening
+ becomes available. Announcements may also appear on our Twitter page.
- form_for @rsvp, :url => mine_rsvp_path(:id => @rsvp.slug) do |r|
= render :partial => 'edit', :locals => {:r => r}
@@ -52,7 +52,7 @@ def setup
should 'Not see seats reserved message untill max seats have been reached' do
get_page :home
assert_element_hidden 'div#content_right div.flash_alert'
- Rsvp.stubs(:open_seats? => false)
+ reserve_all_seats!
get_page :home
assert_element_visible 'div#content_right div.flash_alert'
end
View
@@ -16,6 +16,10 @@ def get_page(name)
get site_path(name.to_s)
end
+ def reserve_all_seats!(count=Rsvp::MAX_SEATS)
+ Rsvp.stubs(:attendees => count)
+ end
+
def login_as_admin
returning admin = users(:admin) do
@request.env['HTTP_AUTHORIZATION'] = 'Basic ' + Base64::encode64("#{admin.email}:#{admin.password}")
@@ -53,6 +53,14 @@ class RsvpMailerTest < ActionMailer::TestCase
total_count = Rsvp.not_reserved.count
assert_emails(total_count) { Rsvp.send_reminders }
end
+
+ should 'not send reminders if there are no seats available' do
+ assert Rsvp.all.any?{ |rsvp| !rsvp.reserved? }, 'making sure there is someone to potentially mail'
+ reserve_all_seats!
+ assert_no_emails do
+ assert_equal [], Rsvp.send_reminders, 'should return an empty array'
+ end
+ end
end
View
@@ -15,7 +15,7 @@ class RsvpTest < ActiveSupport::TestCase
should 'return return open seats if available' do
assert Rsvp.attendees < Rsvp::MAX_SEATS, 'Maybe there are too many fixtures :)'
assert Rsvp.open_seats?
- Rsvp.stubs(:attendees => Rsvp::MAX_SEATS)
+ reserve_all_seats!
assert !Rsvp.open_seats?
assert !Rsvp.new.open_seats?, 'should delegate to class'
end
@@ -58,8 +58,8 @@ class RsvpTest < ActiveSupport::TestCase
assert @rsvp.reload.reserved?
end
- should 'be able to create new unreserved rsvps when open seats are false' do
- Rsvp.stubs(:open_seats? => false)
+ should 'be able to create new unreserved rsvps when open_seats? returns false' do
+ reserve_all_seats!
assert_nothing_raised() { @rsvp.save! }
@rsvp.toggle(:reserved)
assert_raise(ActiveRecord::RecordInvalid) { @rsvp.save! }

0 comments on commit 1cfa60c

Please sign in to comment.