solidus_paypal_commerce_platform 0.0.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/stale.yml +4 -4
- data/.github_changelog_generator +2 -0
- data/.rubocop.yml +18 -5
- data/CHANGELOG.md +181 -0
- data/README.md +49 -28
- data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/button_actions.js +14 -4
- data/app/assets/javascripts/spree/frontend/solidus_paypal_commerce_platform/buttons.js +6 -3
- data/app/controllers/solidus_paypal_commerce_platform/orders_controller.rb +8 -5
- data/app/controllers/solidus_paypal_commerce_platform/paypal_orders_controller.rb +3 -1
- data/app/decorators/models/solidus_paypal_commerce_platform/spree/address_decorator.rb +17 -0
- data/app/jobs/solidus_paypal_commerce_platform/webhook_job.rb +3 -3
- data/app/models/solidus_paypal_commerce_platform/gateway.rb +1 -2
- data/app/models/solidus_paypal_commerce_platform/payment_method.rb +4 -1
- data/app/models/solidus_paypal_commerce_platform/paypal_address.rb +27 -23
- data/app/models/solidus_paypal_commerce_platform/paypal_order.rb +3 -3
- data/app/models/solidus_paypal_commerce_platform/pricing_options.rb +1 -1
- data/app/models/solidus_paypal_commerce_platform/state_guesser.rb +28 -0
- data/bin/rails-sandbox +1 -3
- data/bin/sandbox +2 -2
- data/lib/generators/solidus_paypal_commerce_platform/install/install_generator.rb +14 -5
- data/lib/generators/solidus_paypal_commerce_platform/install/templates/initializer.rb +6 -0
- data/lib/solidus_paypal_commerce_platform.rb +7 -5
- data/lib/solidus_paypal_commerce_platform/client.rb +5 -4
- data/lib/solidus_paypal_commerce_platform/configuration.rb +14 -4
- data/lib/solidus_paypal_commerce_platform/{factories.rb → testing_support/factories.rb} +0 -0
- data/lib/solidus_paypal_commerce_platform/version.rb +1 -1
- data/lib/views/frontend/solidus_paypal_commerce_platform/shared/_javascript_sdk_tag.html.erb +6 -0
- data/lib/views/frontend/spree/checkout/payment/_paypal_commerce_platform.html.erb +6 -1
- data/lib/views/frontend/spree/orders/payment/_paypal_commerce_platform.html.erb +3 -2
- data/lib/views/frontend/spree/products/payment/_paypal_commerce_platform.html.erb +3 -2
- data/solidus_paypal_commerce_platform.gemspec +7 -6
- data/spec/features/frontend/cart_spec.rb +21 -13
- data/spec/features/frontend/checkout_spec.rb +21 -13
- data/spec/features/frontend/product_spec.rb +27 -15
- data/spec/lib/solidus_paypal_commerce_platform/client_spec.rb +1 -1
- data/spec/lib/solidus_paypal_commerce_platform/configuration_spec.rb +28 -4
- data/spec/models/solidus_paypal_commerce_platform/payment_method_spec.rb +19 -0
- data/spec/models/solidus_paypal_commerce_platform/paypal_address_spec.rb +17 -5
- data/spec/models/solidus_paypal_commerce_platform/state_guesser_spec.rb +38 -0
- data/spec/requests/solidus_paypal_commerce_platform/orders_controller_spec.rb +2 -2
- data/spec/requests/solidus_paypal_commerce_platform/shipping_rates_controller_spec.rb +3 -3
- data/spec/requests/solidus_paypal_commerce_platform/wizard_controller_spec.rb +1 -1
- data/spec/spec_helper.rb +10 -8
- data/spec/support/capybara.rb +11 -0
- data/spec/support/paypal_sdk_script_tag_helper.rb +13 -0
- metadata +46 -15
- data/app/decorators/solidus_paypal_commerce_platform/remove_required_phone_from_address.rb +0 -13
@@ -0,0 +1,6 @@
|
|
1
|
+
<% currency = @order ? @order.currency : current_pricing_options.currency %>
|
2
|
+
|
3
|
+
<script
|
4
|
+
src="<%= payment_method.javascript_sdk_url(order: @order, currency: currency) %>"
|
5
|
+
data-partner-attribution-id="<%= SolidusPaypalCommercePlatform.config.partner_code %>">
|
6
|
+
</script>
|
@@ -1,10 +1,15 @@
|
|
1
|
-
|
1
|
+
<%= render partial: "solidus_paypal_commerce_platform/shared/javascript_sdk_tag", locals: {payment_method: payment_method} %>
|
2
2
|
|
3
3
|
<div id="paypal-button-container"></div>
|
4
|
+
|
5
|
+
<div data-pp-message data-pp-placement="payment" data-pp-amount="<%= @order.total %>"></div>
|
6
|
+
|
4
7
|
<input type="hidden" name="payment_source[<%= payment_method.id %>][paypal_order_id]" id="payments_source_paypal_order_id">
|
5
8
|
<input type="hidden" name="payment_source[<%= payment_method.id %>][paypal_email]" id="payments_source_paypal_email">
|
6
9
|
|
7
10
|
<script>
|
11
|
+
Spree.current_order_id = "<%= @order.number %>"
|
12
|
+
Spree.current_order_token = "<%= @order.guest_token %>"
|
8
13
|
$( document ).ready(function() {
|
9
14
|
SolidusPaypalCommercePlatform.renderButton("<%= payment_method.id %>",<%= raw payment_method.button_style.to_json %>)
|
10
15
|
})
|
@@ -1,9 +1,10 @@
|
|
1
1
|
<div style="margin-left:auto;margin-right:auto;width:50%;margin-top:20px;">
|
2
|
-
|
3
|
-
</script>
|
2
|
+
<%= render partial: "solidus_paypal_commerce_platform/shared/javascript_sdk_tag", locals: {payment_method: payment_method} %>
|
4
3
|
|
5
4
|
<div id="paypal-button-container"></div>
|
6
5
|
|
6
|
+
<div data-pp-message data-pp-placement="cart" data-pp-amount="<%= @order.total %>"></div>
|
7
|
+
|
7
8
|
<script>
|
8
9
|
Spree.current_order_id = "<%= @order.number %>"
|
9
10
|
Spree.current_order_token = "<%= @order.guest_token %>"
|
@@ -1,9 +1,10 @@
|
|
1
1
|
<div style="margin-top:20px;">
|
2
|
-
|
3
|
-
</script>
|
2
|
+
<%= render partial: "solidus_paypal_commerce_platform/shared/javascript_sdk_tag", locals: {payment_method: payment_method} %>
|
4
3
|
|
5
4
|
<div id="paypal-button-container"></div>
|
6
5
|
|
6
|
+
<div data-pp-message data-pp-placement="product" data-pp-amount="<%= @product.price %>"></div>
|
7
|
+
|
7
8
|
<script>
|
8
9
|
SolidusPaypalCommercePlatform.checkout_url = "<%= checkout_url %>"
|
9
10
|
$( document ).ready(function() {
|
@@ -9,12 +9,12 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.email = 'contact@solidus.io'
|
10
10
|
|
11
11
|
spec.summary = 'Integrate Solidus with Paypal Commerce Platform'
|
12
|
-
spec.homepage = 'https://github.com/
|
12
|
+
spec.homepage = 'https://github.com/solidusio-contrib/solidus_paypal_commerce_platform'
|
13
13
|
spec.license = 'BSD-3-Clause'
|
14
14
|
|
15
15
|
spec.metadata['homepage_uri'] = spec.homepage
|
16
|
-
spec.metadata['source_code_uri'] = 'https://github.com/
|
17
|
-
spec.metadata['changelog_uri'] = 'https://github.com/
|
16
|
+
spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_paypal_commerce_platform'
|
17
|
+
spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_paypal_commerce_platform/releases'
|
18
18
|
|
19
19
|
spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
|
20
20
|
|
@@ -30,10 +30,11 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency 'deface', '~> 1.5'
|
32
32
|
spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 3']
|
33
|
-
spec.add_dependency 'solidus_support',
|
34
|
-
spec.add_dependency 'solidus_webhooks', '~> 0.2
|
33
|
+
spec.add_dependency 'solidus_support', [">= 0.8.0", "< 1"]
|
34
|
+
spec.add_dependency 'solidus_webhooks', '~> 0.2'
|
35
35
|
|
36
36
|
spec.add_dependency 'paypal-checkout-sdk'
|
37
37
|
|
38
|
-
spec.add_development_dependency '
|
38
|
+
spec.add_development_dependency 'cuprite'
|
39
|
+
spec.add_development_dependency 'solidus_dev_support', '~> 2.1'
|
39
40
|
end
|
@@ -16,22 +16,30 @@ RSpec.describe "Cart page" do
|
|
16
16
|
)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
context "when generating a script tag" do
|
20
|
+
it "generates a url with the correct credentials attached" do
|
21
|
+
visit '/cart'
|
22
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
it "generates a partner_id attribute with the correct partner code attached" do
|
26
|
+
visit '/cart'
|
27
|
+
expect(js_sdk_script_partner_id).to eq("Solidus_PCP_SP")
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
paypal_payment_method.update(auto_capture: true)
|
30
|
+
it "generates a URL with the correct currency" do
|
31
|
+
allow(order).to receive(:currency).and_return "EUR"
|
32
32
|
visit '/cart'
|
33
|
-
expect(
|
34
|
-
|
33
|
+
expect(js_sdk_script_query).to include("currency=EUR")
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when auto-capture is set to true" do
|
37
|
+
it "generates a url with intent capture" do
|
38
|
+
paypal_payment_method.update(auto_capture: true)
|
39
|
+
visit '/cart'
|
40
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
41
|
+
expect(js_sdk_script_query).to include("intent=capture")
|
42
|
+
end
|
35
43
|
end
|
36
44
|
end
|
37
45
|
end
|
@@ -17,22 +17,30 @@ RSpec.describe "Checkout" do
|
|
17
17
|
)
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
context "when generating a script tag" do
|
21
|
+
it "generates a url with the correct credentials attached" do
|
22
|
+
visit '/checkout/payment'
|
23
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
it "generates a partner_id attribute with the correct partner code attached" do
|
27
|
+
visit '/checkout/payment'
|
28
|
+
expect(js_sdk_script_partner_id).to eq("Solidus_PCP_SP")
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
paypal_payment_method.update(auto_capture: true)
|
31
|
+
it "generates a URL with the correct currency" do
|
32
|
+
allow(order).to receive(:currency).and_return "EUR"
|
33
33
|
visit '/checkout/payment'
|
34
|
-
expect(
|
35
|
-
|
34
|
+
expect(js_sdk_script_query).to include("currency=EUR")
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when auto-capture is set to true" do
|
38
|
+
it "generates a url with intent capture" do
|
39
|
+
paypal_payment_method.update(auto_capture: true)
|
40
|
+
visit '/checkout/payment'
|
41
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
42
|
+
expect(js_sdk_script_query).to include("intent=capture")
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
38
46
|
|
@@ -12,29 +12,37 @@ RSpec.describe "Product page", js: true do
|
|
12
12
|
paypal_payment_method
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
context "when generating a script tag" do
|
16
|
+
it "generates a url with the correct credentials attached" do
|
17
|
+
visit "/products/#{product.slug}"
|
18
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
it "generates a partner_id attribute with the correct partner code attached" do
|
22
|
+
visit "/products/#{product.slug}"
|
23
|
+
expect(js_sdk_script_partner_id).to eq("Solidus_PCP_SP")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "generates a URL with the correct currency" do
|
27
|
+
allow_any_instance_of(SolidusPaypalCommercePlatform::PricingOptions).to receive(:currency).and_return "EUR"
|
28
|
+
visit "/products/#{product.slug}"
|
29
|
+
expect(js_sdk_script_query).to include("currency=EUR")
|
30
|
+
end
|
24
31
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
context "when auto-capture is set to true" do
|
33
|
+
it "generates a url with intent capture" do
|
34
|
+
paypal_payment_method.update(auto_capture: true)
|
35
|
+
visit "/products/#{product.slug}"
|
36
|
+
expect(js_sdk_script_query).to include("client-id=#{paypal_payment_method.preferences[:client_id]}")
|
37
|
+
expect(js_sdk_script_query).to include("intent=capture")
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
33
41
|
|
34
42
|
describe "order creation" do
|
35
43
|
before do
|
36
44
|
allow_any_instance_of(Spree::Core::ControllerHelpers::Store).to receive(:current_store) { store }
|
37
|
-
visit
|
45
|
+
visit "/products/#{product.slug}"
|
38
46
|
|
39
47
|
# Stubbing out paypal methods since their JS doesn't load in correctly on tests
|
40
48
|
page.execute_script("paypal = {}")
|
@@ -48,12 +56,14 @@ RSpec.describe "Product page", js: true do
|
|
48
56
|
|
49
57
|
it "creates an order successfully" do
|
50
58
|
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
59
|
+
page.driver.wait_for_network_idle
|
51
60
|
|
52
61
|
expect(Spree::Order.last).not_to be nil
|
53
62
|
end
|
54
63
|
|
55
64
|
it "sets the Spree number and token variables" do
|
56
65
|
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
66
|
+
page.driver.wait_for_network_idle
|
57
67
|
|
58
68
|
expect(page.evaluate_script("Spree.current_order_id")).to eq Spree::Order.last.number
|
59
69
|
expect(page.evaluate_script("Spree.current_order_token")).to eq Spree::Order.last.guest_token
|
@@ -64,6 +74,7 @@ RSpec.describe "Product page", js: true do
|
|
64
74
|
fill_in('quantity', with: quantity)
|
65
75
|
|
66
76
|
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
77
|
+
page.driver.wait_for_network_idle
|
67
78
|
|
68
79
|
expect(Spree::Order.last.line_items.first.quantity).to eq quantity
|
69
80
|
end
|
@@ -71,6 +82,7 @@ RSpec.describe "Product page", js: true do
|
|
71
82
|
it "uses the selected variant" do
|
72
83
|
page.choose("variant_id_#{variant_two.id}")
|
73
84
|
page.evaluate_script("SolidusPaypalCommercePlatform.createOrder()")
|
85
|
+
page.driver.wait_for_network_idle
|
74
86
|
|
75
87
|
expect(Spree::Order.last.line_items.first.variant_id).to eq variant_two.id
|
76
88
|
end
|
@@ -10,7 +10,7 @@ RSpec.describe SolidusPaypalCommercePlatform::Client do
|
|
10
10
|
let(:status_code) { 201 }
|
11
11
|
|
12
12
|
it 'forwards to the upstream client adding i18n response messages' do
|
13
|
-
|
13
|
+
allow_any_instance_of(PayPal::PayPalHttpClient)
|
14
14
|
.to receive(:execute).with(paypal_request).and_return(paypal_response)
|
15
15
|
|
16
16
|
response = subject.execute_with_response(paypal_request)
|
@@ -12,16 +12,16 @@ RSpec.describe SolidusPaypalCommercePlatform::Configuration do
|
|
12
12
|
it "falls back to Rails.env if ENV['PAYPAL_ENV'] is not set" do
|
13
13
|
expect(ENV).to receive(:[]).with("PAYPAL_ENV").and_return(nil).at_least(:once)
|
14
14
|
|
15
|
-
|
15
|
+
allow(Rails).to receive(:env).and_return("development".inquiry)
|
16
16
|
expect(subject.default_env).to eq("sandbox")
|
17
17
|
|
18
|
-
|
18
|
+
allow(Rails).to receive(:env).and_return("test".inquiry)
|
19
19
|
expect(subject.default_env).to eq("sandbox")
|
20
20
|
|
21
|
-
|
21
|
+
allow(Rails).to receive(:env).and_return("production".inquiry)
|
22
22
|
expect(subject.default_env).to eq("live")
|
23
23
|
|
24
|
-
|
24
|
+
allow(Rails).to receive(:env).and_return("staging".inquiry)
|
25
25
|
expect{ subject.default_env }.to raise_error(described_class::InvalidEnvironment)
|
26
26
|
end
|
27
27
|
end
|
@@ -64,4 +64,28 @@ RSpec.describe SolidusPaypalCommercePlatform::Configuration do
|
|
64
64
|
expect(subject.env_domain).to eq("www.sandbox.paypal.com")
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
describe "#state_guesser_class" do
|
69
|
+
before do
|
70
|
+
stub_const('SolidusPaypalCommercePlatform::BetterStateGuesser', Class.new)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "returns a class" do
|
74
|
+
expect(subject.state_guesser_class).to be_kind_of(Class)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "is settable" do
|
78
|
+
expect(subject.state_guesser_class).to eq(SolidusPaypalCommercePlatform::StateGuesser)
|
79
|
+
|
80
|
+
subject.state_guesser_class = "SolidusPaypalCommercePlatform::BetterStateGuesser"
|
81
|
+
|
82
|
+
expect(subject.state_guesser_class).to eq(SolidusPaypalCommercePlatform::BetterStateGuesser)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "#partner_code" do
|
87
|
+
it "returns the correct code" do
|
88
|
+
expect(subject.partner_code).to eq("Solidus_PCP_SP")
|
89
|
+
end
|
90
|
+
end
|
67
91
|
end
|
@@ -92,6 +92,25 @@ RSpec.describe SolidusPaypalCommercePlatform::PaymentMethod, type: :model do
|
|
92
92
|
expect(url.query.split("&")).to include("commit=true")
|
93
93
|
end
|
94
94
|
end
|
95
|
+
|
96
|
+
context 'when messaging is turned on' do
|
97
|
+
let(:order) { instance_double(Spree::Order, checkout_steps: { "foo" => "bar" }) }
|
98
|
+
|
99
|
+
it 'includes messaging component' do
|
100
|
+
paypal_payment_method.preferences.update(display_credit_messaging: true)
|
101
|
+
expect(url.query.split("&")).to include("components=buttons%2Cmessages")
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context 'when messaging is turned off' do
|
106
|
+
let(:order) { instance_double(Spree::Order, checkout_steps: { "foo" => "bar" }) }
|
107
|
+
|
108
|
+
it 'only includes buttons components' do
|
109
|
+
paypal_payment_method.preferences.update(display_credit_messaging: false)
|
110
|
+
expect(url.query.split("&")).not_to include("messages")
|
111
|
+
expect(url.query.split("&")).to include("components=buttons")
|
112
|
+
end
|
113
|
+
end
|
95
114
|
end
|
96
115
|
|
97
116
|
private
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe SolidusPaypalCommercePlatform::PaypalAddress, type: :model do
|
4
4
|
let(:order) { create(:order) }
|
5
5
|
let(:original_address) { create(:address) }
|
6
|
-
let(:address) { create(:address) }
|
6
|
+
let(:address) { create(:address, name_attributes) }
|
7
7
|
let(:params) {
|
8
8
|
{
|
9
9
|
updated_address: {
|
@@ -16,8 +16,8 @@ RSpec.describe SolidusPaypalCommercePlatform::PaypalAddress, type: :model do
|
|
16
16
|
},
|
17
17
|
recipient: {
|
18
18
|
name: {
|
19
|
-
given_name:
|
20
|
-
surname:
|
19
|
+
given_name: "Alexander",
|
20
|
+
surname: "Hamilton"
|
21
21
|
}
|
22
22
|
}
|
23
23
|
}
|
@@ -37,8 +37,12 @@ RSpec.describe SolidusPaypalCommercePlatform::PaypalAddress, type: :model do
|
|
37
37
|
expect(subject.address2).to eq address.address2
|
38
38
|
expect(subject.zipcode).to eq address.zipcode
|
39
39
|
expect(subject.country).to eq address.country
|
40
|
-
|
41
|
-
|
40
|
+
if SolidusSupport.combined_first_and_last_name_in_address?
|
41
|
+
expect(subject.name).to eq address.name
|
42
|
+
else
|
43
|
+
expect(subject.firstname).to eq address.firstname
|
44
|
+
expect(subject.lastname).to eq address.lastname
|
45
|
+
end
|
42
46
|
expect(subject.phone).to eq original_address.phone
|
43
47
|
end
|
44
48
|
|
@@ -52,4 +56,12 @@ RSpec.describe SolidusPaypalCommercePlatform::PaypalAddress, type: :model do
|
|
52
56
|
end
|
53
57
|
end
|
54
58
|
end
|
59
|
+
|
60
|
+
def name_attributes
|
61
|
+
if SolidusSupport.combined_first_and_last_name_in_address?
|
62
|
+
{ name: "Alexander Hamilton" }
|
63
|
+
else
|
64
|
+
{ firstname: "Alexander", lastname: "Hamilton" }
|
65
|
+
end
|
66
|
+
end
|
55
67
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe SolidusPaypalCommercePlatform::StateGuesser, type: :model do
|
4
|
+
let(:country) { create(:country, iso: "IT") }
|
5
|
+
let!(:state) { create(:state, country: country, name: "Abruzzo") }
|
6
|
+
|
7
|
+
describe "#guess" do
|
8
|
+
context "with a guessable state error" do
|
9
|
+
it "correctly guesses the state" do
|
10
|
+
expect(
|
11
|
+
described_class.new("Pescara", country).guess
|
12
|
+
).to eq state
|
13
|
+
end
|
14
|
+
|
15
|
+
it "guesses the state using an abbreviation" do
|
16
|
+
expect(
|
17
|
+
described_class.new("PE", country).guess
|
18
|
+
).to eq state
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with an unsolvable state error" do
|
23
|
+
it "returns nil" do
|
24
|
+
expect(
|
25
|
+
described_class.new("Gondor", country).guess
|
26
|
+
).to eq nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with an already correct state" do
|
31
|
+
it "returns the correct state" do
|
32
|
+
expect(
|
33
|
+
described_class.new("Abruzzo", country).guess
|
34
|
+
).to eq state
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -15,7 +15,7 @@ RSpec.describe SolidusPaypalCommercePlatform::OrdersController, type: :request d
|
|
15
15
|
|
16
16
|
get solidus_paypal_commerce_platform.verify_total_path, params: params
|
17
17
|
|
18
|
-
expect(response).to have_http_status(
|
18
|
+
expect(response).to have_http_status(:ok)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -29,7 +29,7 @@ RSpec.describe SolidusPaypalCommercePlatform::OrdersController, type: :request d
|
|
29
29
|
|
30
30
|
get solidus_paypal_commerce_platform.verify_total_path, params: params
|
31
31
|
|
32
|
-
expect(response).to have_http_status(
|
32
|
+
expect(response).to have_http_status(:bad_request)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|