solidus_afterpay 0.2.0 → 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/.rubocop.yml +9 -0
- data/Gemfile +6 -3
- data/README.md +3 -0
- data/app/controllers/solidus_afterpay/callbacks_controller.rb +5 -1
- data/app/controllers/solidus_afterpay/express_callbacks_controller.rb +5 -1
- data/app/models/solidus_afterpay/order_component_builder.rb +1 -1
- data/bin/sandbox +1 -1
- data/lib/solidus_afterpay/configuration.rb +9 -2
- data/lib/solidus_afterpay/engine.rb +1 -1
- data/lib/solidus_afterpay/testing_support/factories.rb +1 -1
- data/lib/solidus_afterpay/version.rb +1 -1
- data/solidus_afterpay.gemspec +4 -4
- metadata +11 -99
- data/spec/fixtures/vcr_casettes/create_checkout/invalid.yml +0 -65
- data/spec/fixtures/vcr_casettes/create_checkout/valid.yml +0 -64
- data/spec/fixtures/vcr_casettes/credit/invalid.yml +0 -61
- data/spec/fixtures/vcr_casettes/credit/valid.yml +0 -63
- data/spec/fixtures/vcr_casettes/deferred/authorize/declined_payment.yml +0 -120
- data/spec/fixtures/vcr_casettes/deferred/authorize/invalid.yml +0 -61
- data/spec/fixtures/vcr_casettes/deferred/authorize/valid.yml +0 -120
- data/spec/fixtures/vcr_casettes/deferred/capture/invalid.yml +0 -61
- data/spec/fixtures/vcr_casettes/deferred/capture/valid.yml +0 -140
- data/spec/fixtures/vcr_casettes/deferred/void/invalid.yml +0 -61
- data/spec/fixtures/vcr_casettes/deferred/void/valid.yml +0 -137
- data/spec/fixtures/vcr_casettes/find_order/invalid.yml +0 -64
- data/spec/fixtures/vcr_casettes/find_order/valid.yml +0 -120
- data/spec/fixtures/vcr_casettes/find_payment/invalid.yml +0 -61
- data/spec/fixtures/vcr_casettes/find_payment/valid.yml +0 -140
- data/spec/fixtures/vcr_casettes/immediate/capture/declined_payment.yml +0 -120
- data/spec/fixtures/vcr_casettes/immediate/capture/invalid.yml +0 -61
- data/spec/fixtures/vcr_casettes/immediate/capture/valid.yml +0 -134
- data/spec/fixtures/vcr_casettes/retrieve_configuration/valid.yml +0 -67
- data/spec/helpers/solidus_afterpay/afterpay_helper_spec.rb +0 -39
- data/spec/models/solidus_afterpay/gateway_spec.rb +0 -492
- data/spec/models/solidus_afterpay/order_component_builder_spec.rb +0 -198
- data/spec/models/solidus_afterpay/payment_method_spec.rb +0 -207
- data/spec/models/solidus_afterpay/payment_source_spec.rb +0 -61
- data/spec/models/solidus_afterpay/user_agent_generator_spec.rb +0 -22
- data/spec/models/spree/order_spec.rb +0 -158
- data/spec/presenters/solidus_afterpay/order_presenter_spec.rb +0 -34
- data/spec/presenters/solidus_afterpay/shipping_rate_presenter_spec.rb +0 -28
- data/spec/requests/solidus_afterpay/callbacks_controller_spec.rb +0 -127
- data/spec/requests/solidus_afterpay/checkouts_controller_spec.rb +0 -258
- data/spec/requests/solidus_afterpay/express_callbacks_controller_spec.rb +0 -167
- data/spec/services/solidus_afterpay/base_service_spec.rb +0 -13
- data/spec/services/solidus_afterpay/shipping_rate_builder_service_spec.rb +0 -34
- data/spec/services/solidus_afterpay/update_order_addresses_service_spec.rb +0 -82
- data/spec/services/solidus_afterpay/update_order_attributes_service_spec.rb +0 -58
- data/spec/spec_helper.rb +0 -31
- data/spec/support/auth.rb +0 -15
- data/spec/support/cache.rb +0 -5
- data/spec/support/preferences.rb +0 -33
- data/spec/support/solidus.rb +0 -1
- data/spec/support/vcr.rb +0 -18
- data/spec/views/solidus_afterpay/express_checkout_button_spec.rb +0 -33
- data/spec/views/spree/shared/afterpay_messaging_spec.rb +0 -44
data/spec/support/preferences.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.configure do |config|
|
4
|
-
def described_class_source_location
|
5
|
-
described_class.instance_methods(false).map do |method|
|
6
|
-
described_class.instance_method(method).source_location.first
|
7
|
-
end.uniq.first
|
8
|
-
end
|
9
|
-
|
10
|
-
config.before(:each, use_solidus_api: true) do
|
11
|
-
SolidusAfterpay.configure do |c|
|
12
|
-
c.use_solidus_api = true
|
13
|
-
end
|
14
|
-
|
15
|
-
class_name = described_class.to_s.split('::').last
|
16
|
-
source_location = described_class_source_location
|
17
|
-
|
18
|
-
SolidusAfterpay.send(:remove_const, class_name)
|
19
|
-
load source_location
|
20
|
-
end
|
21
|
-
|
22
|
-
config.after(:each, use_solidus_api: true) do
|
23
|
-
SolidusAfterpay.configure do |c|
|
24
|
-
c.use_solidus_api = false
|
25
|
-
end
|
26
|
-
|
27
|
-
class_name = described_class.to_s.split('::').last
|
28
|
-
source_location = described_class_source_location
|
29
|
-
|
30
|
-
SolidusAfterpay.send(:remove_const, class_name)
|
31
|
-
load source_location
|
32
|
-
end
|
33
|
-
end
|
data/spec/support/solidus.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'spree/testing_support/order_walkthrough'
|
data/spec/support/vcr.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'vcr'
|
4
|
-
|
5
|
-
VCR.configure do |config|
|
6
|
-
config.ignore_localhost = true
|
7
|
-
config.cassette_library_dir = "spec/fixtures/vcr_casettes"
|
8
|
-
config.hook_into :webmock
|
9
|
-
config.configure_rspec_metadata!
|
10
|
-
config.allow_http_connections_when_no_cassette = false
|
11
|
-
|
12
|
-
config.filter_sensitive_data('<ENCODED_AUTH_HEADER>') do
|
13
|
-
Base64.strict_encode64(
|
14
|
-
"#{ENV.fetch('AFTERPAY_MERCHANT_ID',
|
15
|
-
'dummy_merchant_id')}:#{ENV.fetch('AFTERPAY_SECRET_KEY', 'dummy_secret_key')}"
|
16
|
-
)
|
17
|
-
end
|
18
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "rendering afterpay express checkout button", type: :view do
|
4
|
-
subject(:rendered) { render "solidus_afterpay/afterpay_checkout_button", payment_method: payment_method }
|
5
|
-
|
6
|
-
let(:payment_method) { SolidusAfterpay::PaymentMethod.active.first }
|
7
|
-
let(:order) { create(:order) }
|
8
|
-
|
9
|
-
before do
|
10
|
-
create(:afterpay_payment_method)
|
11
|
-
assign(:order, order)
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when order is available for order" do
|
15
|
-
before do
|
16
|
-
allow(payment_method).to receive(:available_for_order?).with(order).and_return(true)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'displays the afterpay express checkout button' do
|
20
|
-
expect(rendered).to match("Checkout with Afterpay")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "when order is not available for order" do
|
25
|
-
before do
|
26
|
-
allow(payment_method).to receive(:available_for_order?).with(order).and_return(false)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'does not display the afterpay express checkout button' do
|
30
|
-
expect(rendered).not_to match("Checkout with Afterpay")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
RSpec.describe "rendering afterpay messaging", type: :view do
|
4
|
-
let(:product) { create(:base_product) }
|
5
|
-
let(:second_product) { create(:base_product) }
|
6
|
-
let(:excluded_product) { create(:base_product) }
|
7
|
-
let(:product_array) { [product] }
|
8
|
-
let(:payment_method) { SolidusAfterpay::PaymentMethod.active.first }
|
9
|
-
let(:amount) { product.price }
|
10
|
-
|
11
|
-
before do
|
12
|
-
create(:afterpay_payment_method, preferred_excluded_products: excluded_product.id.to_s)
|
13
|
-
render partial: "spree/shared/afterpay_messaging", locals: { min: nil, max: nil, products: product_array,
|
14
|
-
data:
|
15
|
-
{ amount: amount, locale: "en_US", currency: "USD" } }
|
16
|
-
end
|
17
|
-
|
18
|
-
context "without excluded products" do
|
19
|
-
context "when rendering afterpay messaging for a single product" do
|
20
|
-
it 'displays afterpay messaging' do
|
21
|
-
expect(rendered).to match("19.99" && "afterpay-placement")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context "when rendering afterpay messaging for multiple products" do
|
26
|
-
let(:product_array) { [product, second_product] }
|
27
|
-
let(:amount) { (product.price + second_product.price) }
|
28
|
-
|
29
|
-
it 'displays afterpay messaging' do
|
30
|
-
expect(rendered).to match("39.98" && "afterpay-placement")
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "with excluded products" do
|
36
|
-
context "when one of the products is excluded" do
|
37
|
-
let(:product_array) { [product, second_product, excluded_product] }
|
38
|
-
|
39
|
-
it "does not render the afterpay messaging partial" do
|
40
|
-
expect(rendered).not_to match("afterpay-placement")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|