forked from spree-contrib/better_spree_paypal_express
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into no-shipping-preference
- Loading branch information
Showing
6 changed files
with
83 additions
and
31 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 |
---|---|---|
|
@@ -8,5 +8,6 @@ Gemfile.lock | |
tmp | ||
pkg | ||
spec/dummy | ||
rspec.failures | ||
.rvmrc | ||
.idea |
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
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
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 |
---|---|---|
|
@@ -30,11 +30,24 @@ def fill_in_billing | |
def switch_to_paypal_login | ||
# If you go through a payment once in the sandbox, it remembers your preferred setting. | ||
# It defaults to the *wrong* setting for the first time, so we need to have this method. | ||
unless page.has_selector?("#login_email") | ||
unless page.has_selector?("#login #email") | ||
find("#loadLogin").click | ||
end | ||
end | ||
|
||
def login_to_paypal | ||
within("#loginForm") do | ||
fill_in "Email", :with => "[email protected]" | ||
fill_in "Password", :with => "thequickbrownfox" | ||
click_button "Log in to PayPal" | ||
end | ||
end | ||
|
||
def within_transaction_cart(&block) | ||
find(".transactionDetails").click | ||
within(".transctionCartDetails") { block.call } | ||
end | ||
|
||
it "pays for an order successfully" do | ||
visit spree.root_path | ||
click_link 'iPad' | ||
|
@@ -50,10 +63,8 @@ def switch_to_paypal_login | |
click_button "Save and Continue" | ||
find("#paypal_button").click | ||
switch_to_paypal_login | ||
fill_in "login_email", :with => "[email protected]" | ||
fill_in "login_password", :with => "thequickbrownfox" | ||
click_button "Log In" | ||
find("#continue_abovefold").click # Because there's TWO continue buttons. | ||
login_to_paypal | ||
click_button "Pay Now" | ||
page.should have_content("Your order has been processed successfully") | ||
|
||
Spree::Payment.last.source.transaction_id.should_not be_blank | ||
|
@@ -79,16 +90,14 @@ def switch_to_paypal_login | |
click_button "Save and Continue" | ||
find("#paypal_button").click | ||
|
||
page.should have_selector '#billingInfo', text: 'Test User' | ||
page.should have_selector '#billingInfo', text: '1 User Lane' | ||
page.should have_selector '#billingInfo', text: 'Adamsville, AL 35005' | ||
page.should have_selector '#billingInfo', text: 'United States' | ||
page.should have_field 'email', with: '[email protected]' | ||
login_to_paypal | ||
click_button "Pay Now" | ||
|
||
# PayPal arbitrarily removes or does not remove the hypenation in phone numbers, | ||
# so our test needs to accept both cases | ||
page.should have_field 'H_PhoneNumberUS' | ||
page.find('#H_PhoneNumberUS').value.gsub('-', '').should == '5551234567' | ||
page.should have_selector '[data-hook=order-bill-address] .fn', text: 'Test User' | ||
page.should have_selector '[data-hook=order-bill-address] .adr', text: '1 User Lane' | ||
page.should have_selector '[data-hook=order-bill-address] .adr', text: 'Adamsville AL 35005' | ||
page.should have_selector '[data-hook=order-bill-address] .adr', text: 'United States' | ||
page.should have_selector '[data-hook=order-bill-address] .tel', text: '555-123-4567' | ||
end | ||
end | ||
|
||
|
@@ -115,7 +124,22 @@ def switch_to_paypal_login | |
# Delivery step doesn't require any action | ||
click_button "Save and Continue" | ||
find("#paypal_button").click | ||
within("#miniCart") do | ||
|
||
within_transaction_cart do | ||
page.should have_content("$5 off") | ||
page.should have_content("$10 on") | ||
end | ||
|
||
login_to_paypal | ||
|
||
within_transaction_cart do | ||
page.should have_content("$5 off") | ||
page.should have_content("$10 on") | ||
end | ||
|
||
click_button "Pay Now" | ||
|
||
within("[data-hook=order_details_adjustments]") do | ||
page.should have_content("$5 off") | ||
page.should have_content("$10 on") | ||
end | ||
|
@@ -127,7 +151,7 @@ def switch_to_paypal_login | |
calculator = Spree::Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10) | ||
action = Spree::Promotion::Actions::CreateItemAdjustments.create(:calculator => calculator) | ||
promotion.actions << action | ||
end | ||
end | ||
|
||
it "includes line item adjustments in PayPal summary" do | ||
|
||
|
@@ -152,7 +176,15 @@ def switch_to_paypal_login | |
# Delivery step doesn't require any action | ||
click_button "Save and Continue" | ||
find("#paypal_button").click | ||
within("#miniCart") do | ||
|
||
within_transaction_cart do | ||
page.should have_content("10% off") | ||
end | ||
|
||
login_to_paypal | ||
click_button "Pay Now" | ||
|
||
within("[data-hook=order_details_price_adjustments]") do | ||
page.should have_content("10% off") | ||
end | ||
end | ||
|
@@ -184,10 +216,25 @@ def switch_to_paypal_login | |
# Delivery step doesn't require any action | ||
click_button "Save and Continue" | ||
find("#paypal_button").click | ||
within("#miniCart") do | ||
|
||
within_transaction_cart do | ||
page.should have_content('iPad') | ||
page.should_not have_content('iPod') | ||
end | ||
|
||
login_to_paypal | ||
|
||
within_transaction_cart do | ||
page.should have_content('iPad') | ||
page.should_not have_content('iPod') | ||
end | ||
|
||
click_button "Pay Now" | ||
|
||
within("#line-items") do | ||
page.should have_content('iPad') | ||
page.should have_content('iPod') | ||
end | ||
end | ||
end | ||
|
||
|
@@ -216,8 +263,13 @@ def switch_to_paypal_login | |
# Delivery step doesn't require any action | ||
click_button "Save and Continue" | ||
find("#paypal_button").click | ||
within("#miniCart") do | ||
page.should have_content('Current purchase') | ||
|
||
login_to_paypal | ||
|
||
click_button "Pay Now" | ||
|
||
within("[data-hook=order_details_adjustments]") do | ||
page.should have_content('FREE iPad ZOMG!') | ||
end | ||
end | ||
end | ||
|
@@ -265,10 +317,8 @@ def switch_to_paypal_login | |
click_button "Save and Continue" | ||
find("#paypal_button").click | ||
switch_to_paypal_login | ||
fill_in "login_email", :with => "[email protected]" | ||
fill_in "login_password", :with => "thequickbrownfox" | ||
click_button "Log In" | ||
find("#continue_abovefold").click # Because there's TWO continue buttons. | ||
login_to_paypal | ||
click_button("Pay Now") | ||
page.should have_content("Your order has been processed successfully") | ||
|
||
visit '/admin' | ||
|
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
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