Created
October 20, 2011 13:45
-
-
Save zefer/1301183 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe OrdersController do | |
describe "GET express (/order/new/express)" do | |
context "with an empty basket" do | |
let(:current_basket) do | |
basket = mock(Basket, sub_total: 0.to_money) | |
controller.stub(:current_basket).and_return(basket) | |
basket | |
end | |
it "should redirect to basket" do | |
get :express | |
response.should redirect_to basket_items_path | |
end | |
end | |
context "with items in basket" do | |
let!(:current_basket) do | |
basket = mock(Basket, sub_total: 1234.56.to_money) | |
controller.stub(:current_basket).and_return(basket) | |
basket | |
end | |
let(:paypal_redirect_url) { "banana" } | |
let(:response) { mock(ActiveMerchant::Billing::PaypalExpressResponse, token: "stub_token") } | |
before(:each) do | |
EXPRESS_GATEWAY.stub!(:setup_purchase).and_return(response) | |
EXPRESS_GATEWAY.stub!(:redirect_url_for).and_return(paypal_redirect_url) | |
end | |
it "should init the paypal purchase" do | |
EXPRESS_GATEWAY.should_receive(:setup_purchase).with(123456, { | |
ip: request.remote_ip, | |
return_url: new_order_url, | |
cancel_return_url: basket_items_url | |
}).and_return(response) | |
get :express | |
end | |
it "should ask for the redirect url" do | |
EXPRESS_GATEWAY.should_receive(:paypal_redirect_url_for).with("stub_token").and_return(paypal_redirect_url) | |
get :express | |
end | |
it "should redirect to the paypal gateway" do | |
get :express | |
response.should redirect_to(paypal_redirect_url) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment