Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fazendo pagina de confirmacao da inscricao, para poder escolher o tam…

…anho da camiseta
  • Loading branch information...
commit e6f6604f0aa8245d7cff613a15413fcaf9da2c82 1 parent a64ff84
@fabioperrella authored
View
10 app/controllers/subscriptions_controller.rb
@@ -1,12 +1,14 @@
class SubscriptionsController < ApplicationController
def create
@race = Race.find(params[:race_id])
- subscription = Subscription.new(:user => current_user, :race => @race, :shirt_size => params[:shirt_size])
+ @subscription = Subscription.new(:user => current_user, :race => @race, :shirt_size => current_user.shirt_size)
- if subscription.save
- flash[:notice] = I18n.t(:subscription_saved_successfull, :race_name => @race.name)
+ if @subscription.save
+ render "confirm"
+ return
+ #flash[:notice] = I18n.t(:subscription_saved_successfull, :race_name => @race.name)
else
- flash[:alert] = subscription.errors.full_messages
+ flash[:alert] = @subscription.errors.full_messages
end
redirect_to races_path
View
9 app/views/subscriptions/confirm.html.erb
@@ -0,0 +1,9 @@
+<p>
+<%= t(:confirm_subscription?) %>
+</p>
+<p>
+ <%= t(:race)%>: <%= @subscription.race.name %>
+</p>
+<p>
+ <%= t(:shirt_size)%>: <%= @subscription.shirt_size %>
+</p>
View
21 spec/controllers/subscriptions_controller_spec.rb
@@ -13,15 +13,34 @@
end
describe "POST create" do
+ it "sets shirt_size as the shirt size of logged user" do
+ post :create, { :race_id => @race }
+
+ Subscription.first.shirt_size.should == @user.shirt_size
+ end
+
it "creates a subscription with a race" do
- post :create, { :race_id => @race, :shirt_size => @user.shirt_size }
+ post :create, { :race_id => @race }
subscription = Subscription.first
subscription.race.should == @race
subscription.user.should == @user
end
+ it "assigns subscription" do
+ post :create, { :race_id => @race }
+ assigns[:subscription].should == Subscription.first
+ end
+
+ it "renders confirmation page" do
+ post :create, { :race_id => @race }
+ response.should render_template("subscriptions/confirm")
+ end
+ end
+
+ describe "GET confirm" do
it "flashes confimation notice" do
+ pending
post :create, { :race_id => @race, :shirt_size => @user.shirt_size }
flash[:notice].should_not be_nil
end
Please sign in to comment.
Something went wrong with that request. Please try again.