-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
63 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,27 @@ | ||
describe "PayPal", :js => true do | ||
let!(:product) { FactoryGirl.create(:product, :name => 'iPad') } | ||
describe "PayPal", js: true do | ||
let!(:product) { FactoryGirl.create(:product, name: 'iPad') } | ||
|
||
before do | ||
@gateway = Spree::Gateway::PayPalExpress.create!({ | ||
:preferred_login => "pp_api1.ryanbigg.com", | ||
:preferred_password => "1383066713", | ||
:preferred_signature => "An5ns1Kso7MWUdW4ErQKJJJ4qi4-Ar-LpzhMJL0cu8TjM8Z2e1ykVg5B", | ||
:name => "PayPal", | ||
:active => true | ||
preferred_login: "pp_api1.ryanbigg.com", | ||
preferred_password: "1383066713", | ||
preferred_signature: "An5ns1Kso7MWUdW4ErQKJJJ4qi4-Ar-LpzhMJL0cu8TjM8Z2e1ykVg5B", | ||
name: "PayPal", | ||
active: true | ||
}) | ||
FactoryGirl.create(:shipping_method) | ||
end | ||
|
||
def fill_in_billing | ||
within("#billing") do | ||
fill_in "First Name", :with => "Test" | ||
fill_in "Last Name", :with => "User" | ||
fill_in "Street Address", :with => "1 User Lane" | ||
# City, State and ZIP must all match for PayPal to be happy | ||
fill_in "City", :with => "Adamsville" | ||
select "United States of America", :from => "order_bill_address_attributes_country_id" | ||
select "Alabama", :from => "order_bill_address_attributes_state_id" | ||
fill_in "Zip", :with => "35005" | ||
fill_in "Phone", :with => "555-123-4567" | ||
end | ||
fill_in :order_bill_address_attributes_firstname, with: "Test" | ||
fill_in :order_bill_address_attributes_lastname, with: "User" | ||
fill_in :order_bill_address_attributes_address1, with: "1 User Lane" | ||
# City, State and ZIP must all match for PayPal to be happy | ||
fill_in :order_bill_address_attributes_city, with: "Adamsville" | ||
select "United States of America", from: :order_bill_address_attributes_country_id | ||
select "Alabama", from: :order_bill_address_attributes_state_id | ||
fill_in :order_bill_address_attributes_zipcode, with: "35005" | ||
fill_in :order_bill_address_attributes_phone, with: "555-123-4567" | ||
end | ||
|
||
def switch_to_paypal_login | ||
|
@@ -36,8 +34,8 @@ def switch_to_paypal_login | |
|
||
def login_to_paypal | ||
within("#loginForm") do | ||
fill_in "Email", :with => "[email protected]" | ||
fill_in "Password", :with => "thequickbrownfox" | ||
fill_in "Email", with: "[email protected]" | ||
fill_in "Password", with: "thequickbrownfox" | ||
click_button "Log in to PayPal" | ||
end | ||
end | ||
|
@@ -47,15 +45,23 @@ def within_transaction_cart(&block) | |
within(".transctionCartDetails") { block.call } | ||
end | ||
|
||
xit "pays for an order successfully" do | ||
def add_to_cart(product) | ||
visit spree.root_path | ||
click_link 'iPad' | ||
click_link product.name | ||
click_button 'Add To Cart' | ||
click_button 'Checkout' | ||
end | ||
|
||
def fill_in_guest | ||
within("#guest_checkout") do | ||
fill_in "Email", :with => "[email protected]" | ||
fill_in "Email", with: "[email protected]" | ||
click_button 'Continue' | ||
end | ||
end | ||
|
||
xit "pays for an order successfully" do | ||
add_to_cart(product) | ||
click_button 'Checkout' | ||
fill_in_guest | ||
fill_in_billing | ||
click_button "Save and Continue" | ||
# Delivery step doesn't require any action | ||
|
@@ -75,12 +81,10 @@ def within_transaction_cart(&block) | |
end | ||
|
||
xit "passes user details to PayPal" do | ||
visit spree.root_path | ||
click_link 'iPad' | ||
click_button 'Add To Cart' | ||
add_to_cart(product) | ||
click_button 'Checkout' | ||
within("#guest_checkout") do | ||
fill_in "Email", :with => "[email protected]" | ||
fill_in "Email", with: "[email protected]" | ||
click_button 'Continue' | ||
end | ||
fill_in_billing | ||
|
@@ -101,23 +105,18 @@ def within_transaction_cart(&block) | |
end | ||
|
||
xit "includes adjustments in PayPal summary" do | ||
visit spree.root_path | ||
click_link 'iPad' | ||
click_button 'Add To Cart' | ||
add_to_cart(product) | ||
# TODO: Is there a better way to find this current order? | ||
order = Spree::Order.last | ||
order.adjustments.create!(:amount => -5, :label => "$5 off") | ||
order.adjustments.create!(:amount => 10, :label => "$10 on") | ||
order.adjustments.create!(amount: -5, label: "$5 off") | ||
order.adjustments.create!(amount: 10, label: "$10 on") | ||
visit '/cart' | ||
within("#cart_adjustments") do | ||
page.should have_content("$5 off") | ||
page.should have_content("$10 on") | ||
end | ||
click_button 'Checkout' | ||
within("#guest_checkout") do | ||
fill_in "Email", :with => "[email protected]" | ||
click_button 'Continue' | ||
end | ||
fill_in_guest | ||
fill_in_billing | ||
click_button "Save and Continue" | ||
# Delivery step doesn't require any action | ||
|
@@ -148,14 +147,12 @@ def within_transaction_cart(&block) | |
let(:promotion) { Spree::Promotion.create(name: "10% off") } | ||
before do | ||
calculator = Spree::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) | ||
action = Spree::Promotion::Actions::CreateItemAdjustments.create(:calculator => calculator) | ||
action = Spree::Promotion::Actions::CreateItemAdjustments.create(calculator: calculator) | ||
promotion.actions << action | ||
end | ||
|
||
xit "includes line item adjustments in PayPal summary" do | ||
visit spree.root_path | ||
click_link 'iPad' | ||
click_button 'Add To Cart' | ||
add_to_cart(product) | ||
# TODO: Is there a better way to find this current order? | ||
order = Spree::Order.last | ||
order.line_item_adjustments.count.should == 1 | ||
|
@@ -166,7 +163,7 @@ def within_transaction_cart(&block) | |
end | ||
click_button 'Checkout' | ||
within("#guest_checkout") do | ||
fill_in "Email", :with => "[email protected]" | ||
fill_in "Email", with: "[email protected]" | ||
click_button 'Continue' | ||
end | ||
fill_in_billing | ||
|
@@ -190,23 +187,18 @@ def within_transaction_cart(&block) | |
|
||
# Regression test for #10 | ||
context "will skip $0 items" do | ||
let!(:product2) { FactoryGirl.create(:product, :name => 'iPod') } | ||
let!(:product2) { FactoryGirl.create(:product, name: 'iPod') } | ||
|
||
xit do | ||
visit spree.root_path | ||
click_link 'iPad' | ||
click_button 'Add To Cart' | ||
|
||
visit spree.root_path | ||
click_link 'iPod' | ||
click_button 'Add To Cart' | ||
add_to_cart(product) | ||
add_to_cart(product2) | ||
|
||
# TODO: Is there a better way to find this current order? | ||
order = Spree::Order.last | ||
order.line_items.last.update_attribute(:price, 0) | ||
click_button 'Checkout' | ||
within("#guest_checkout") do | ||
fill_in "Email", :with => "[email protected]" | ||
fill_in "Email", with: "[email protected]" | ||
click_button 'Continue' | ||
end | ||
fill_in_billing | ||
|
@@ -245,15 +237,13 @@ def within_transaction_cart(&block) | |
end | ||
|
||
xit do | ||
visit spree.root_path | ||
click_link 'iPad' | ||
click_button 'Add To Cart' | ||
add_to_cart(product) | ||
# TODO: Is there a better way to find this current order? | ||
order = Spree::Order.last | ||
order.adjustments.create!(:amount => -order.line_items.last.price, :label => "FREE iPad ZOMG!") | ||
order.adjustments.create!(amount: -order.line_items.last.price, label: "FREE iPad ZOMG!") | ||
click_button 'Checkout' | ||
within("#guest_checkout") do | ||
fill_in "Email", :with => "[email protected]" | ||
fill_in "Email", with: "[email protected]" | ||
click_button 'Continue' | ||
end | ||
fill_in_billing | ||
|
@@ -279,12 +269,10 @@ def within_transaction_cart(&block) | |
end | ||
|
||
specify do | ||
visit spree.root_path | ||
click_link 'iPad' | ||
click_button 'Add To Cart' | ||
add_to_cart(product) | ||
click_button 'Checkout' | ||
within("#guest_checkout") do | ||
fill_in "Email", :with => "[email protected]" | ||
fill_in "Email", with: "[email protected]" | ||
click_button 'Continue' | ||
end | ||
fill_in_billing | ||
|
@@ -306,7 +294,7 @@ def within_transaction_cart(&block) | |
click_button 'Add To Cart' | ||
click_button 'Checkout' | ||
within("#guest_checkout") do | ||
fill_in "Email", :with => "[email protected]" | ||
fill_in "Email", with: "[email protected]" | ||
click_button 'Continue' | ||
end | ||
fill_in_billing | ||
|
@@ -346,7 +334,7 @@ def within_transaction_cart(&block) | |
xit "can refund payments partially" do | ||
payment = Spree::Payment.last | ||
# Take a dollar off, which should cause refund type to be... | ||
fill_in "Amount", :with => payment.amount - 1 | ||
fill_in "Amount", with: payment.amount - 1 | ||
click_button "Refund" | ||
page.should have_content("PayPal refund successful") | ||
|
||
|
@@ -359,7 +347,7 @@ def within_transaction_cart(&block) | |
end | ||
|
||
xit "errors when given an invalid refund amount" do | ||
fill_in "Amount", :with => "lol" | ||
fill_in "Amount", with: "lol" | ||
click_button "Refund" | ||
page.should have_content("PayPal refund unsuccessful (The partial refund amount is not valid)") | ||
end | ||
|