Commit cc365895 by vulehuan

rspec: card - step 4

parent ce237467
...@@ -169,7 +169,7 @@ class CardsController < ApplicationController ...@@ -169,7 +169,7 @@ class CardsController < ApplicationController
end end
xml_data += '<total>' + total.to_s + '</total>' xml_data += '<total>' + total.to_s + '</total>'
xml_data += '</root>' xml_data += '</root>'
MyCard.create!( new_card = MyCard.create!(
full_name: customer_info[:full_name], full_name: customer_info[:full_name],
email: customer_info[:email], email: customer_info[:email],
phone: customer_info[:phone], phone: customer_info[:phone],
...@@ -178,11 +178,15 @@ class CardsController < ApplicationController ...@@ -178,11 +178,15 @@ class CardsController < ApplicationController
items: xml_data items: xml_data
) )
UserMailer.card_send_to_consignee(customer_info[:email], @card_infos).deliver UserMailer.card_send_to_consignee(customer_info[:email], @card_infos).deliver
redirect_to url_for(action: 'thankyou') redirect_to url_for(action: 'thankyou', card_id: new_card.id)
end end
end end
def thankyou def thankyou
if params[:card_id].nil? || !MyCard.exists?(params[:card_id])
flash[:error] = "Invalid card request"
redirect_to root_path and return
end
add_breadcrumb "Thank out", url_for(action: 'thankyou') add_breadcrumb "Thank out", url_for(action: 'thankyou')
session[:SHOPPING_CARD_SESSION_NAME] = nil session[:SHOPPING_CARD_SESSION_NAME] = nil
render :layout => "application_one_col" render :layout => "application_one_col"
......
...@@ -372,8 +372,25 @@ describe "CardPages" do ...@@ -372,8 +372,25 @@ describe "CardPages" do
end end
describe "step 4" do describe "step 4" do
before { visit url_for(controller: 'cards', action: 'thankyou') } describe "when not pass step 3" do
before { visit url_for(controller: 'cards', action: 'thankyou') }
it { should have_title('Thank you') } it { should have_selector('.alert.alert-error', text: 'Invalid') }
end
describe "when pass step 3" do
before do
# step 1
click_link "Check out"
# step 2
fill_in_order_form()
click_button "Continue"
# step 3
click_button "Correct, click here"
end
it { should have_title(full_title('Thank you')) }
it { should have_content('Thank you') }
end
end end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment