workarea-usaepay 1.0.22 → 1.0.40

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd74aabd2817a36fc049cc39de11dccf99bc3c5f454e875bff188ba6f9b025e2
4
- data.tar.gz: 4884322299c4c860bdd41a15bdc7fde298c17a2491ba148b5a27ae5ae3400900
3
+ metadata.gz: f4de471500e7e2b9cf03f0f61327563f5c9be841d7518222e0f869135a8dd267
4
+ data.tar.gz: ddaf0fdfc9d06cf13433e0b9351f16217b16bd37e04691cb4ce0d62c44ae5aa6
5
5
  SHA512:
6
- metadata.gz: 331216b24e79bdf8c3c756e5452642e6701359c25324e30d35ff335ee57348fb9278502e89c1f5497055c9dec0a9538ddc20c3f5c6be8ae95ffb214612db0666
7
- data.tar.gz: d5d0f182935bd9f05f958818caf8437f8cfd4adcb6d2ef5883ab6be8394e69d37a0539652dce516a19a9eee6d5b59e02ec2a45105076a85dc78d26faf44fdda9
6
+ metadata.gz: 1daf19e12f6d9a92e8a82fd59ce6027fa8e439a0c9bb3b2674ca4a43dba0b39d475509241de0aee160ffd1699aa5a8c9a42bab274ecc9a4ed7a41b325e6ef74c
7
+ data.tar.gz: de0d2b17394bd57aa262a3cd85c0857f07afce18896efa1d515c0385d30d504e52e19bd468604e9901ef2548aa7ccc641554bcb32db53a0f48cefa42a7c4c99d
@@ -14,11 +14,6 @@ module ActiveMerchant
14
14
  if credit_card.is_a? String
15
15
  add_token(post, credit_card)
16
16
  else
17
- # Adding this override to avoid test script failures from wrokarea gems
18
- # TODO: This should be removed from here all those test cases sould be updated
19
- if credit_card.number == "1"
20
- credit_card.number = "4111111111111111"
21
- end
22
17
  add_payment(post, credit_card)
23
18
  add_address(post, credit_card, options)
24
19
  unless credit_card.track_data.present?
@@ -29,15 +29,13 @@ module Workarea
29
29
 
30
30
  def self.auto_initialize_gateway
31
31
  if credentials.present?
32
- # if ENV['HTTP_PROXY'].present?
33
- # uri = URI.parse(ENV['HTTP_PROXY'])
34
- # Workarea::UsaEpay::Gateway.proxy_address = uri.host
35
- # Workarea::UsaEpay::Gateway.proxy_port = uri.port
36
- # end
37
-
38
- self.gateway = ActiveMerchant::Billing::UsaEpayCustom.new credentials
32
+ if Rails.env.test?
33
+ self.gateway = ActiveMerchant::Billing::BogusGateway.new credentials
34
+ else
35
+ self.gateway = ActiveMerchant::Billing::UsaEpayCustom.new credentials
36
+ end
39
37
  else
40
- self.gateway = ActiveMerchant::Billing::BogusCreditCardGateway.new
38
+ self.gateway = ActiveMerchant::Billing::BogusGateway.new
41
39
  end
42
40
  end
43
41
  end
@@ -1,5 +1,5 @@
1
1
  module Workarea
2
2
  module Usaepay
3
- VERSION = "1.0.22".freeze
3
+ VERSION = "1.0.40".freeze
4
4
  end
5
5
  end
@@ -12,5 +12,104 @@ module Workarea
12
12
  )
13
13
  end
14
14
  end
15
+
16
+ def test_complete_sets_the_transaction_attributes_on_a_failure_response
17
+ VCR.use_cassette 'credit_card/store_error_auth' do
18
+ tender.token = 2
19
+ operation = Payment::Authorize::CreditCard.new(tender, transaction)
20
+ operation.complete!
21
+
22
+ refute(transaction.success?, "expected transaction.success? to be false")
23
+ assert_instance_of(
24
+ ActiveMerchant::Billing::Response,
25
+ transaction.response
26
+ )
27
+ end
28
+ end
29
+
30
+ def test_complete_sets_transaction_attributes_on_an_error_response
31
+ VCR.use_cassette 'credit_card/store_error_auth' do
32
+ tender.token = 3
33
+ operation = Payment::Authorize::CreditCard.new(tender, transaction)
34
+ operation.complete!
35
+
36
+ refute(transaction.success?, "expected transaction success? to be false")
37
+ assert_instance_of(
38
+ ActiveMerchant::Billing::Response,
39
+ transaction.response
40
+ )
41
+ end
42
+ end
43
+
44
+ def test_complete_does_nothing_if_gateway_storage_fails
45
+ VCR.use_cassette 'credit_card/store_auth' do
46
+ operation = Payment::Authorize::CreditCard.new(tender, transaction)
47
+
48
+ Payment::StoreCreditCard.any_instance.stubs(:save!).returns(false)
49
+
50
+ Workarea.config.gateways.credit_card.expects(:authorize).never
51
+
52
+ operation.complete!
53
+ end
54
+ end
55
+
56
+ def test_cancel_does_nothing_if_the_transaction_was_a_failure
57
+ VCR.use_cassette 'credit_card/store_auth' do
58
+ tender.number = 3
59
+ operation = Payment::Authorize::CreditCard.new(tender, transaction)
60
+
61
+ operation.gateway.expects(:void).never
62
+ operation.cancel!
63
+ end
64
+ end
65
+
66
+ def test_cancel_sets_cancellation_params_on_the_transaction
67
+ VCR.use_cassette 'credit_card/store_auth' do
68
+ transaction.response = ActiveMerchant::Billing::Response.new(
69
+ true,
70
+ 'Message',
71
+ {},
72
+ { authorization: authorization }
73
+ )
74
+
75
+ operation = Payment::Authorize::CreditCard.new(tender, transaction)
76
+ operation.cancel!
77
+
78
+ assert_instance_of(
79
+ ActiveMerchant::Billing::Response,
80
+ transaction.cancellation
81
+ )
82
+ end
83
+ end
84
+
85
+ private
86
+
87
+ def payment
88
+ @payment ||= create_payment
89
+ end
90
+
91
+ def authorization
92
+ @authorization ||= ActiveMerchant::Billing::BogusGateway::AUTHORIZATION
93
+ end
94
+
95
+ def tender
96
+ @tender ||=
97
+ begin
98
+ payment.set_address(first_name: 'Ben', last_name: 'Crouse')
99
+
100
+ payment.build_credit_card(
101
+ number: 4111111111111111,
102
+ month: 1,
103
+ year: Time.current.year + 1,
104
+ cvv: 999
105
+ )
106
+
107
+ payment.credit_card
108
+ end
109
+ end
110
+
111
+ def transaction
112
+ @transaction ||= tender.build_transaction(action: 'authorize', amount: 5.to_m)
113
+ end
15
114
  end
16
115
  end
@@ -0,0 +1,57 @@
1
+ module Workarea
2
+ decorate Payment::Authorize::StoreCreditTest, with: :usaepay_transaction do #[8]
3
+ decorated { include UsaepayTransactionVcrGateway } #[9]
4
+ def test_complete!
5
+ VCR.use_cassette 'credit_card/store_auth' do
6
+ transaction = tender.build_transaction(amount: 5.to_m)
7
+ operation = Payment::Authorize::StoreCredit.new(tender, transaction)
8
+
9
+ operation.complete!
10
+ profile.reload
11
+
12
+ assert_equal(10.to_m, profile.store_credit)
13
+ assert(transaction.success?)
14
+ assert_equal(
15
+ ActiveMerchant::Billing::Response,
16
+ transaction.response.class
17
+ )
18
+ assert_equal('purchase', transaction.action)
19
+
20
+ transaction = tender.build_transaction(amount: 100.to_m)
21
+ operation = Payment::Authorize::StoreCredit.new(tender, transaction)
22
+
23
+ operation.complete!
24
+ refute(transaction.success?)
25
+ assert(transaction.response)
26
+ assert_equal(
27
+ ActiveMerchant::Billing::Response,
28
+ transaction.response.class
29
+ )
30
+ end
31
+ end
32
+
33
+ def test_cancel!
34
+ VCR.use_cassette 'credit_card/store_auth' do
35
+ transaction = tender.build_transaction(amount: 5.to_m, success: false)
36
+ operation = Payment::Authorize::StoreCredit.new(tender, transaction)
37
+
38
+ operation.cancel!
39
+ profile.reload
40
+
41
+ assert_equal(15.to_m, profile.store_credit)
42
+
43
+ transaction = tender.build_transaction(amount: 5.to_m, success: true)
44
+ operation = Payment::Authorize::StoreCredit.new(tender, transaction)
45
+
46
+ operation.cancel!
47
+ profile.reload
48
+
49
+ assert_equal(20.to_m, profile.store_credit)
50
+ assert_equal(
51
+ ActiveMerchant::Billing::Response,
52
+ transaction.cancellation.class
53
+ )
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ decorate Storefront::CreditCardsSystemTest, with: :murals_your_way do
5
+ def test_managing_credit_cards
6
+ visit storefront.login_path
7
+
8
+ within '#login_form' do
9
+ fill_in 'email', with: 'bcrouse@workarea.com'
10
+ fill_in 'password', with: 'W3bl1nc!'
11
+ click_button t('workarea.storefront.users.login')
12
+ end
13
+
14
+ visit storefront.new_users_credit_card_path
15
+
16
+ within '#credit_card_form' do
17
+ fill_in 'credit_card[number]', with: '4111111111111111'
18
+ fill_in 'credit_card[first_name]', with: 'Ben'
19
+ fill_in 'credit_card[last_name]', with: 'Crouse'
20
+ select '1', from: 'credit_card[month]'
21
+ select @year, from: 'credit_card[year]'
22
+ fill_in 'credit_card[cvv]', with: '999'
23
+ click_button t('workarea.storefront.forms.save')
24
+ end
25
+
26
+ assert(page.has_content?('Success'))
27
+ assert(page.has_content?('ending in 1111'))
28
+ assert(page.has_content?('1'))
29
+ assert(page.has_content?(@year))
30
+
31
+ click_link t('workarea.storefront.forms.edit')
32
+
33
+ within '#credit_card_form' do
34
+ select '2', from: 'credit_card[month]'
35
+ fill_in 'credit_card[cvv]', with: '999'
36
+ click_button t('workarea.storefront.forms.save')
37
+ end
38
+
39
+ assert(page.has_content?('Success'))
40
+ assert(page.has_content?('ending in 1111'))
41
+ assert(page.has_content?('2'))
42
+ assert(page.has_content?(@year))
43
+
44
+ click_button t('workarea.storefront.forms.delete')
45
+
46
+ assert(page.has_no_content?('ending in 1111'))
47
+
48
+ visit storefront.new_users_credit_card_path
49
+
50
+ within '#credit_card_form' do
51
+ fill_in 'credit_card[number]', with: '40120000333304'
52
+ fill_in 'credit_card[first_name]', with: 'Ben'
53
+ fill_in 'credit_card[last_name]', with: 'Crouse'
54
+ select '1', from: 'credit_card[month]'
55
+ select @year, from: 'credit_card[year]'
56
+ fill_in 'credit_card[cvv]', with: '999'
57
+ click_button t('workarea.storefront.forms.save')
58
+ end
59
+
60
+ refute(page.has_content?('Success'))
61
+ assert(page.has_content?(I18n.t('workarea.payment.store_credit_card_failure')))
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,64 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ decorate Storefront::DownloadSystemTest, with: :murals_your_way do
5
+ def test_checking_out_with_downloadable_product
6
+ setup_checkout_specs
7
+
8
+ Order.first.items.delete_all
9
+
10
+ product = create_product(
11
+ name: 'Digital Product',
12
+ variants: [
13
+ { sku: 'SKU1', regular: 10.to_m, tax_code: '001' },
14
+ { sku: 'SKU2', regular: 15.to_m, tax_code: '001' }
15
+ ]
16
+ )
17
+
18
+ create_fulfillment_sku(id: 'SKU1', policy: :download, file: product_image_file)
19
+ create_fulfillment_sku(id: 'SKU2', policy: :download, file: product_image_file)
20
+
21
+ visit storefront.product_path(product)
22
+
23
+ within '.product-details__add-to-cart-form' do
24
+ select product.skus.first, from: 'sku'
25
+ click_button t('workarea.storefront.products.add_to_cart')
26
+ end
27
+
28
+ assert(page.has_content?('Success'))
29
+
30
+ start_guest_checkout
31
+
32
+ assert_current_path(storefront.checkout_addresses_path)
33
+
34
+ fill_in_email
35
+ fill_in_billing_address
36
+ click_button t('workarea.storefront.checkouts.continue_to_payment')
37
+
38
+ assert_current_path(storefront.checkout_payment_path)
39
+ assert(page.has_content?('Success'))
40
+
41
+ fill_in_credit_card
42
+ click_button t('workarea.storefront.checkouts.place_order')
43
+
44
+ assert_current_path(storefront.checkout_confirmation_path)
45
+ assert(page.has_content?('Success'))
46
+ assert(page.has_content?(t('workarea.storefront.flash_messages.order_placed')))
47
+ assert(page.has_content?(Order.first.id))
48
+
49
+ assert(page.has_content?('1019 S. 47th St.'))
50
+ assert(page.has_content?('Philadelphia'))
51
+ assert(page.has_content?('PA'))
52
+ assert(page.has_content?('19143'))
53
+
54
+ assert(page.has_content?('Visa'))
55
+ assert(page.has_content?('1111'))
56
+
57
+ assert(page.has_content?('Digital Product'))
58
+ assert(page.has_content?('10.00'))
59
+ assert(page.has_content?('0.70'))
60
+ assert(page.has_content?('10.70'))
61
+ assert(page.has_content?(t('workarea.storefront.orders.download')))
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,38 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ decorate Storefront::GuestCheckoutSystemTest, with: :murals_your_way do
5
+ def test_creating_an_account
6
+ assert_current_path(storefront.checkout_addresses_path)
7
+ fill_in_email
8
+ fill_in_shipping_address
9
+ uncheck 'same_as_shipping'
10
+ fill_in_billing_address
11
+ click_button t('workarea.storefront.checkouts.continue_to_shipping')
12
+
13
+ assert_current_path(storefront.checkout_shipping_path)
14
+ assert(page.has_content?('Success'))
15
+ click_button t('workarea.storefront.checkouts.continue_to_payment')
16
+
17
+ assert_current_path(storefront.checkout_payment_path)
18
+ assert(page.has_content?('Success'))
19
+ fill_in_credit_card
20
+ click_button t('workarea.storefront.checkouts.place_order')
21
+
22
+ assert_current_path(storefront.checkout_confirmation_path)
23
+ fill_in 'password', with: 'W3bl1nc!'
24
+ check 'email_signup'
25
+ click_button t('workarea.storefront.users.create_account')
26
+
27
+ assert_current_path(storefront.users_account_path)
28
+
29
+ assert(page.has_content?('Success'))
30
+ assert(page.has_content?('Ben'))
31
+ assert(page.has_content?('Crouse'))
32
+ assert(page.has_content?(Order.first.id))
33
+ assert(page.has_content?('22 S. 3rd St.'))
34
+ assert(page.has_content?('1019 S. 47th St.'))
35
+ assert(page.has_content?('1111'))
36
+ end
37
+ end
38
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-usaepay
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.22
4
+ version: 1.0.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gunasekaran.Raja
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-16 00:00:00.000000000 Z
11
+ date: 2020-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea
@@ -101,10 +101,14 @@ files:
101
101
  - test/dummy/lib/assets/.keep
102
102
  - test/dummy/log/.keep
103
103
  - test/models/workarea/payment/authorize/credit_card_test.decorator
104
+ - test/models/workarea/payment/authorize/store_credit_test.decorator
104
105
  - test/models/workarea/payment/credit_card_integration_test.decorator
105
106
  - test/support/workarea/usaepay_transaction_vcr_gateway.rb
106
107
  - test/system/workarea/admin/payment_transactions_system_test.decorator
107
- - test/system/workarea/storefront/account/credit_cards_system_test.decorator
108
+ - test/system/workarea/storefront/accounts/credit_cards_system_test.decorator
109
+ - test/system/workarea/storefront/credit_cards_system_test.decorator
110
+ - test/system/workarea/storefront/download_system_test.decorator
111
+ - test/system/workarea/storefront/guest_checkout_system_test.decorator
108
112
  - test/teaspoon_env.rb
109
113
  - test/test_helper.rb
110
114
  - workarea-usaepay.gemspec