Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ability to de-register implemented

  • Loading branch information...
commit d9b44841fcc7f9a4f59686fb72555dde0bf5dee9 1 parent b002052
Perryn authored
View
24 app/controllers/registrations_controller.rb
@@ -12,18 +12,32 @@ def create
time_slot = TimeSlot.find(params[:registration][:time_slot_id])
begin
time_slot.registration = registration
- flash[:thanks_for_registering] = "true"
+ flash[:message] = "Thanks for helping out! We have sent you a confirmation email with further instructions."
rescue TooSlowError
- flash[:too_slow] = "true"
+ flash[:warning] = "Too Slow! Someone else just registered for that time. Please choose another time."
end
end
flash[:registration] = registration
redirect_to :action => :new
end
-
- def view
+
+ def show
@registration = Registration.find(params[:id])
@day_of_action = @registration.day_of_action
end
-
+
+ def destroy
+ registration = Registration.find(params[:id])
+ submitted_email = params[:registration_registered_email_address]
+ if (submitted_email == registration.email_address)
+ day_of_action = registration.day_of_action
+ registration.destroy
+ flash[:message] = "Thanks for letting us know. Why not register for a different time?"
+ redirect_to new_days_of_action_registration_path(day_of_action)
+ else
+ flash[:warning] = "That does not seem to be the email address you registered with. Please try again."
+ redirect_to :action => :show
+ end
+ end
+
end
View
2  app/models/registration_mailer.rb
@@ -2,7 +2,7 @@ class RegistrationMailer < ActionMailer::Base
def confirmation_email(registration)
recipients registration.email_address
- from "Electronic Frontiers Australia <what@should.that.be.com>"
+ from "Electronic Frontiers Australia <email@efa.org.au>"
recipient = registration.day_of_action.recipient
time = registration.time_slot.start_time
#TODO - timezone here?
View
4 app/stylesheets/screen.sass
@@ -102,10 +102,10 @@ body.three-col
.time_zone_info
+column(8,true)
+push(1)
- .thanks_for_registering
+ .ok_message
+section(#E6EFC2, #C6D880)
- .too_slow
+ .warning
+section(#FFF6BF, #FFD324)
.errorExplanation
View
10 app/views/layouts/application.html.haml
@@ -27,6 +27,16 @@
= yield
+ - if flash[:message]
+ .ok_message
+ %h3
+ =flash[:message]
+
+ - if flash[:warning]
+ .warning
+ %h3
+ =flash[:warning]
+
#footer
made for
= link_to "Electronic Frontiers Australia","http://efa.org.au", :popup => true
View
8 app/views/registrations/new.html.haml
@@ -24,15 +24,7 @@
= f.label :email_address, "What is your email address?", :class => :large
= f.text_field :email_address, {:class => :title}
= f.submit 'Register'
- - if flash[:thanks_for_registering]
- .thanks_for_registering
- %h3
- Thanks for helping out! We have sent you a confirmation email with further instructions.
= f.error_messages :message => "Whoops, can we try that again?", :header_message => nil
- - if flash[:too_slow]
- .too_slow
- %h3
- Too Slow! Someone else just registered for that time. Please choose another time.
View
18 app/views/registrations/show.html.haml
@@ -0,0 +1,18 @@
+= content_for :tag_line do
+ We are glad you have joined us.
+
+#registration_form
+ .heading
+ You are registered to call at
+ %span#registered_time.hilite
+ = @registration.time_slot.start_time.strftime("%I:%M %p")
+ %div{:style => "clear:both"}
+ %br/
+ %br/
+ -form_for :registration, :url => registration_path(@registration) , :html => {:method => :delete } do |f|
+ %span.large
+ If you can no longer call at this time, please let us know...
+ %br/
+ = f.label :registered_email_address, "What email address did you register with?", :class => :large
+ = text_field_tag "registration_registered_email_address","",{:class => :title}
+ = f.submit "Sorry, I can't make it"
View
10 app/views/registrations/view.html.haml
@@ -1,10 +0,0 @@
-= content_for :tag_line do
- We are glad you have joined us.
-
-#registration_form
- .heading
- You are registered to call at
- %span#registered_time.hilite
- = @registration.time_slot.start_time.strftime("%I:%M %p")
- %div{:style => "clear:both"}
-
View
5 config/routes.rb
@@ -8,14 +8,13 @@
# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
# This route can be invoked with purchase_url(:id => product.id)
- map.registrations 'registrations/:id', :controller=> 'registrations', :action => 'view'
-
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
# map.resources :products
map.resources :days_of_action do |day_of_action|
day_of_action.resources :registrations
end
-
+ map.resources :registrations
# Sample resource route with options:
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
View
12 features/step_definitions/deregister_steps.rb
@@ -1,4 +1,12 @@
When /^I de\-register with email address "([^\"]*)"$/ do |email|
- fill_in(:registration_email_address, :with => email)
- click_button "Undo Registration"
+ fill_in(:registration_registered_email_address, :with => email)
+ click_button "Sorry, I can't make it"
+end
+
+Then /^I will be thanked and asked to try a different time$/ do
+ response.should have_tag(".ok_message", "Thanks for letting us know. Why not register for a different time?")
+end
+
+Then /^I will be asked to try again$/ do
+ response.should contain("Please try again")
end
View
2  features/step_definitions/register_for_timeslot_steps.rb
@@ -27,7 +27,7 @@
Then /^I will be thanked and asked to look for an email$/ do
- response.should have_tag(".thanks_for_registering")
+ response.should have_tag(".ok_message", "Thanks for helping out! We have sent you a confirmation email with further instructions.")
end
Then /^I will be reminded to enter an email address$/ do
View
2  features/step_definitions/view_registration_steps.rb
@@ -3,7 +3,7 @@
end
When /^I view my registration$/ do
- visit registrations_path @last_registration
+ visit registration_path @last_registration
end
Then /^I will be reminded that I have registered for "([^\"]*)" timeslot$/ do |time|
View
14 features/step_definitions/view_roster_steps.rb
@@ -22,6 +22,10 @@
visit new_days_of_action_registration_path -1
end
+Then /^I will be shown the roster for the day of action$/ do
+ current_url.should =~ /#{new_days_of_action_registration_path @day_of_action}/
+end
+
Then /^I will see a 404$/ do
response.code.should == "404"
end
@@ -67,7 +71,11 @@
number_of_free_slots.should eql number_of_slots
end
-Then /^the "([^\"]*)" timeslot will ?n?o?w? be shown as taken$/ do |time|
+Then /^the "([^\"]*)" timeslot will now be shown as taken$/ do |time|
+ Then "the \"#{time}\" timeslot will be shown as taken"
+end
+
+Then /^the "([^\"]*)" timeslot will be shown as taken$/ do |time|
response.should have_tag(".taken") do
with_tag "label", time
end
@@ -76,6 +84,10 @@
end
Then /^the "([^\"]*)" timeslot will still be shown as free$/ do |time|
+ Then "the \"#{time}\" timeslot will be shown as free"
+end
+
+Then /^the "([^\"]*)" timeslot will be shown as free$/ do |time|
response.should have_tag(".free") do
with_tag "label", time
end
View
24 ...olunteers_can_change_registration.feature → ...res/users_can_change_registration.feature
@@ -19,7 +19,7 @@ Feature: Volunteer changes their registration
Then I will see a blurb that explains that on "Tuesday 5th January 2010" we will call "Kevin Rudd's Office" on "(02) 6277 7700" about "The Internet Filter"
And I will be reminded that I have registered for "09:15 AM" timeslot
- Scenario: Volunteer can de-register for a timeslot
+ Scenario: Volunteer can de-register for a timeslot and re-register for a different timeslot
Given a Day of Action has been set up for:
| date | recipient | phone | subject |
| 2010-01-05 | Kevin Rudd's Office | (02) 6277 7700 | The Internet Filter |
@@ -27,13 +27,25 @@ Feature: Volunteer changes their registration
And I have registered for the "09:15" timeslot with email address "scott@tiger.com"
When I view my registration
And I de-register with email address "scott@tiger.com"
- Then I will be thanked
+ Then I will be thanked and asked to try a different time
- When I view the roster for the day of action
- Then the "09:15" timeslot will be shown as free
+ And I will be shown the roster for the day of action
+ And the "09:15" timeslot will be shown as free
+
+ When I register for the "09:15" timeslot with email address "scott@tiger.com"
+ Then I will be thanked and asked to look for an email
+ And the "09:15" timeslot will now be shown as taken
Scenario: Volunteer tries to de-register with wrong email address
-
- Scenario: Volunteer can re-register for a different timeslot
+ Given a Day of Action has been set up for:
+ | date | recipient | phone | subject |
+ | 2010-01-05 | Kevin Rudd's Office | (02) 6277 7700 | The Internet Filter |
+
+ And I have registered for the "09:15" timeslot with email address "scott@tiger.com"
+ When I view my registration
+ Then the "What email address did you register with?" field should not contain "scott@tiger.com"
+
+ When I de-register with email address "someone@else.com"
+ Then I will be asked to try again
Scenario: Reminded of time zone
View
4 public/stylesheets/compiled/screen.css
@@ -539,7 +539,7 @@ body.three-col .time_zone_info {
* html body.three-col .time_zone_info {
overflow-x: hidden; }
/* line 105, ../../../app/stylesheets/screen.sass */
-body.three-col .thanks_for_registering {
+body.three-col .ok_message {
padding: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
@@ -549,7 +549,7 @@ body.three-col .thanks_for_registering {
margin-top: 0.5em;
margin-bottom: 1em; }
/* line 108, ../../../app/stylesheets/screen.sass */
-body.three-col .too_slow {
+body.three-col .warning {
padding: 10px;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
View
56 spec/controllers/registrations_controller_spec.rb
@@ -56,11 +56,11 @@
post 'create', :registration => {:time_slot_id => "3", :foo => "bar"}
end
- it "should redirect to new after successful create with OK flag set" do
+ it "should redirect to new after successful create with message set" do
@registration.should_receive(:valid?).and_return(true)
post 'create', :registration => {:time_slot_id => "3" }
response.should redirect_to(:action => "new")
- flash[:thanks_for_registering].should_not be_nil
+ flash[:message].should_not be_nil
flash[:too_slow].should be_nil
end
@@ -74,17 +74,17 @@
flash[:too_slow].should be_nil
end
- it "should redirect to new with too slow flag set if slot is unavailable" do
+ it "should redirect to new with warning set if slot is unavailable" do
@time_slot.should_receive(:registration=).and_raise(TooSlowError)
post 'create', :registration => {:time_slot_id => "3" }
response.should redirect_to(:action => "new")
flash[:thanks_for_registering].should be_nil
- flash[:too_slow].should_not be_nil
+ flash[:warning].should_not be_nil
end
end
- describe "on view" do
+ describe "on show" do
before do
@registration = mock("registration")
@@ -94,10 +94,54 @@
it "it should find registration and expose it and its day_of_action to view" do
Registration.should_receive(:find).with("3").and_return(@registration)
- get 'view', :id => 3
+ get 'show', :id => 3
response.should be_success
assigns[:registration].should equal(@registration)
assigns[:day_of_action].should equal(@day_of_action)
end
end
+
+ describe "on destroy" do
+
+ before do
+ @registration = mock("registration")
+ @registration.stub!(:destroy)
+ @email = "foo@bar.com"
+ @registration.stub!(:email_address).and_return(@email)
+ @day_of_action = mock("day of action")
+ @registration.stub!(:day_of_action).and_return(@day_of_action)
+ Registration.stub!(:find).and_return(@registration)
+ end
+
+ describe "if email adresses match" do
+
+
+ it "should destroy the registration" do
+ @registration.should_receive(:destroy)
+ post 'destroy', {:id => 3, :registration_registered_email_address => @email}
+ end
+
+ it "should redirect to new form with message set" do
+ Registration.should_receive(:find).with("3").and_return(@registration)
+ post 'destroy', {:id => 3, :registration_registered_email_address => @email}
+ response.should redirect_to(new_days_of_action_registration_path(@day_of_action))
+ flash[:message].should_not be_nil
+ end
+ end
+
+ describe "if email adresses do not match" do
+ it "should not destroy the registration" do
+ @registration.should_not_receive(:destroy)
+ post 'destroy', {:id => 3, :registration_registered_email_address => "some other email"}
+ end
+
+ it "should redirect to show with message set" do
+ post 'destroy', {:id => 3, :registration_registered_email_address => "some other email"}
+ response.should redirect_to(:action => "show")
+ flash[:warning].should_not be_nil
+ end
+ end
+
+ end
+
end
View
2  spec/models/registration_mailer_spec.rb
@@ -29,7 +29,7 @@
RegistrationMailer.deliver_confirmation_email(@registration)
ActionMailer::Base.deliveries.size.should == 1
email = ActionMailer::Base.deliveries[0]
- email.from.should eql ["what@should.this.be.com"]
+ email.from.should eql ["email@efa.org.au"]
end
it "should send mail with subject containing important details" do
Please sign in to comment.
Something went wrong with that request. Please try again.