Permalink
Browse files

Really make sure that a users does not see RSVP reminder and that the…

… controller used Rsvp#reserved! does not bypass validations.
  • Loading branch information...
1 parent eb567a6 commit 2593d85b381810f7500f7542ef13636c3d20e896 @metaskills committed Oct 2, 2009
Showing with 24 additions and 8 deletions.
  1. +1 −1 app/models/rsvp.rb
  2. +2 −2 app/views/layouts/application.html.haml
  3. +21 −5 test/integration/visitor_story_test.rb
View
@@ -40,7 +40,7 @@ def send_open_seats(exception=nil)
def reserved!
- update_attribute :reserved, true unless reserved?
+ update_attribute :reserved, true if open_seats? && !reserved?
end
def open_seats?
@@ -39,10 +39,10 @@
#content_right
#rsvp_stuff{:style => "display:#{current_rsvp && current_rsvp.reserved? ? 'none' : 'block'};"}
- .flash_alert{:style => "display:#{Rsvp.open_seats? ? 'none' : 'block'};"}
+ .flash_alert{:style => "display:#{Rsvp.open_seats? ? 'none' : 'block'};", :id => 'rsvp_flash_alert'}
All seats reserved! Use the RSVP form to be placed on the waiting list. Follow us on Twitter for updates.
#rsvp_button{:style => "display:#{current_rsvp && !current_rsvp.reserved? ? 'none' : 'block'};"}
- .flash_indif{:style => "display:#{current_rsvp && !current_rsvp.reserved? && !session[:toggled_reservation] ? 'block' : 'none'};", :id => 'rsvp_flash_indif'}
+ .flash_indif{:style => "display:#{session[:rsvp_id] ? 'block' : 'none'};", :id => 'rsvp_flash_indif'}
Please verify your reservation by clicking the link contained in
the email we sent to you at: <strong id="your_rsvp_email">
= current_rsvp.try(:email)
@@ -29,12 +29,12 @@ def setup
# Get Presenters page again, not see post RSVP flash message, then make a reservation.
get_page :presenters
assert_element_visible('div#rsvp_button')
- assert_element_hidden('div#content_right div.flash_indif')
+ assert_element_hidden('#rsvp_flash_indif')
post rsvps_path, :rsvp => {:name => 'Some Name', :company => 'Some Company', :email => 'some@email.com', :attendees => '1'}
assert_response :ok
get_page :presenters
assert_element_hidden('div#rsvp_button')
- assert_element_visible('div#content_right div.flash_indif')
+ assert_element_visible('#rsvp_flash_indif')
# Let's assume we clicked the link in the email
rsvp = Rsvp.first
get mine_rsvp_path(:id =>rsvp.slug)
@@ -49,12 +49,28 @@ def setup
assert_element_hidden('div#content_right div.flash_indif')
end
- should 'Not see seats reserved message untill max seats have been reached' do
+ should 'Not see seats reserved message until max seats have been reached' do
get_page :home
- assert_element_hidden 'div#content_right div.flash_alert'
+ assert_element_hidden '#rsvp_flash_alert'
reserve_all_seats!
get_page :home
- assert_element_visible 'div#content_right div.flash_alert'
+ assert_element_visible '#rsvp_flash_alert'
+ end
+
+ should 'Not be allowed to confirm reservation when house is full' do
+ reserve_all_seats!
+ rsvp_email = 'unlucky@email.com'
+ post rsvps_path, :rsvp => {:name => 'Some Name', :company => 'Some Company', :email => rsvp_email, :attendees => '1'}
+ assert_response :ok
+ assert rsvp = Rsvp.find_by_email(rsvp_email)
+ assert_equal rsvp.id, session[:rsvp_id]
+ assert !rsvp.reserved?
+ get mine_rsvp_path(:id =>rsvp.slug)
+ assert_response :success
+ rsvp.reload
+ assert !rsvp.reserved?
+ assert_nil session[:rsvp_id]
+ assert_element_hidden '#rsvp_flash_indif'
end

0 comments on commit 2593d85

Please sign in to comment.