nimbleshop_core 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/app/assets/javascripts/admin.js +6 -4
  2. data/app/assets/javascripts/admin/payment_method.js.coffee +26 -0
  3. data/app/assets/javascripts/{product-group-condition.js.coffee → admin/product-group-condition.js.coffee} +0 -0
  4. data/app/assets/javascripts/admin/products/edit.js.coffee +26 -13
  5. data/app/assets/javascripts/admin/shipit.js.coffee +10 -0
  6. data/app/assets/javascripts/{fadeout_success.js.coffee → admin/utils/fadeout_success.js.coffee} +0 -0
  7. data/app/assets/stylesheets/admin_custom.css +4 -4
  8. data/app/controllers/admin_controller.rb +1 -5
  9. data/app/models/order.rb +11 -6
  10. data/app/{observers/order_observer.rb → models/order/payment_transitions.rb} +7 -4
  11. data/app/views/admin/shipping_zones/_form.html.erb +1 -1
  12. data/app/views/mailer/shipment_notification_to_buyer.text.erb +1 -1
  13. data/config/routes.rb +4 -1
  14. data/db/migrate/{20111107035350_create_creditcard_transactions.rb → 20111107035350_create_payment_transactions.rb} +1 -1
  15. data/lib/generators/nimbleshop/app/install_generator.rb +1 -0
  16. data/lib/generators/nimbleshop/app/templates/config/initializers/001_load_nimbleshop_config.rb +10 -0
  17. data/lib/generators/nimbleshop/app/templates/config/initializers/setup_email.rb +2 -2
  18. data/lib/generators/nimbleshop/app/templates/config/nimbleshop.yml +2 -1
  19. data/lib/nimbleshop/engine.rb +5 -4
  20. data/lib/nimbleshop/nimbleshop/util.rb +63 -0
  21. data/lib/nimbleshop/processor/base.rb +9 -2
  22. data/lib/nimbleshop/sampledata/data.rb +14 -12
  23. data/lib/nimbleshop/version.rb +2 -2
  24. data/lib/nimbleshop_core.rb +3 -0
  25. data/test/factories/address_factory.rb +10 -10
  26. data/test/fixtures/payment_methods.yml +5 -5
  27. data/{config/initializers/001_settings_application.rb → test/myshop/config/initializers/001_load_nimbleshop_config.rb} +1 -1
  28. data/test/myshop/config/initializers/carrierwave.rb +2 -3
  29. data/test/myshop/config/initializers/secret_token.rb +1 -1
  30. data/test/myshop/config/initializers/setup_email.rb +4 -13
  31. data/test/myshop/config/nimbleshop.yml +14 -17
  32. data/test/myshop/db/development.sqlite3 +0 -0
  33. data/test/myshop/db/migrate/{20120707041905_create_product_groups.nimbleshop_core.rb → 20120717095234_create_product_groups.nimbleshop_core.rb} +0 -0
  34. data/test/myshop/db/migrate/{20120707041906_create_products.nimbleshop_core.rb → 20120717095235_create_products.nimbleshop_core.rb} +0 -0
  35. data/test/myshop/db/migrate/{20120707041907_create_orders.nimbleshop_core.rb → 20120717095236_create_orders.nimbleshop_core.rb} +0 -0
  36. data/test/myshop/db/migrate/{20120707041908_create_line_items.nimbleshop_core.rb → 20120717095237_create_line_items.nimbleshop_core.rb} +0 -0
  37. data/test/myshop/db/migrate/{20120707041909_create_shops.nimbleshop_core.rb → 20120717095238_create_shops.nimbleshop_core.rb} +0 -0
  38. data/test/myshop/db/migrate/{20120707041910_create_link_groups.nimbleshop_core.rb → 20120717095239_create_link_groups.nimbleshop_core.rb} +0 -0
  39. data/test/myshop/db/migrate/{20120707041911_create_navigations.nimbleshop_core.rb → 20120717095240_create_navigations.nimbleshop_core.rb} +0 -0
  40. data/test/myshop/db/migrate/{20120707041912_create_links.nimbleshop_core.rb → 20120717095241_create_links.nimbleshop_core.rb} +0 -0
  41. data/test/myshop/db/migrate/{20120707041913_create_custom_fields.nimbleshop_core.rb → 20120717095242_create_custom_fields.nimbleshop_core.rb} +0 -0
  42. data/test/myshop/db/migrate/{20120707041914_create_custom_field_answers.nimbleshop_core.rb → 20120717095243_create_custom_field_answers.nimbleshop_core.rb} +0 -0
  43. data/test/myshop/db/migrate/{20120707041915_create_product_group_conditions.nimbleshop_core.rb → 20120717095244_create_product_group_conditions.nimbleshop_core.rb} +0 -0
  44. data/test/myshop/db/migrate/{20120707041916_create_creditcard_transactions.nimbleshop_core.rb → 20120717095245_create_creditcard_transactions.nimbleshop_core.rb} +0 -0
  45. data/test/myshop/db/migrate/{20120707041917_create_addresses.nimbleshop_core.rb → 20120717095246_create_addresses.nimbleshop_core.rb} +0 -0
  46. data/test/myshop/db/migrate/{20120707041918_create_pictures.nimbleshop_core.rb → 20120717095247_create_pictures.nimbleshop_core.rb} +0 -0
  47. data/test/myshop/db/migrate/{20120707041919_create_shipping_methods.nimbleshop_core.rb → 20120717095248_create_shipping_methods.nimbleshop_core.rb} +0 -0
  48. data/test/myshop/db/migrate/{20120707041920_create_shipping_zones.nimbleshop_core.rb → 20120717095249_create_shipping_zones.nimbleshop_core.rb} +0 -0
  49. data/test/myshop/db/migrate/{20120707041921_create_payment_methods.nimbleshop_core.rb → 20120717095250_create_payment_methods.nimbleshop_core.rb} +0 -0
  50. data/test/myshop/db/migrate/{20120707041922_create_preferences.nimbleshop_core.rb → 20120717095251_create_preferences.nimbleshop_core.rb} +0 -0
  51. data/test/myshop/db/migrate/{20120707041923_create_shipments.nimbleshop_core.rb → 20120717095252_create_shipments.nimbleshop_core.rb} +0 -0
  52. data/test/myshop/db/migrate/{20120707041924_create_shipment_carriers.nimbleshop_core.rb → 20120717095253_create_shipment_carriers.nimbleshop_core.rb} +0 -0
  53. data/test/myshop/db/migrate/{20120707041925_create_delayed_jobs.nimbleshop_core.rb → 20120717095254_create_delayed_jobs.nimbleshop_core.rb} +0 -0
  54. data/test/myshop/db/schema.rb +1 -1
  55. data/test/myshop/db/test.sqlite3 +0 -0
  56. data/test/myshop/log/development.log +3 -0
  57. data/test/support/shipping_method_test_helper.rb +1 -1
  58. data/test/test_helper.rb +1 -1
  59. metadata +85 -136
  60. data/app/assets/javascripts/payment_method.js.coffee +0 -19
  61. data/app/assets/javascripts/remove_deletion_of_product_pictures.js.coffee +0 -5
  62. data/app/assets/javascripts/shipit.js.coffee +0 -10
  63. data/app/mailers/mailer.rb +0 -31
  64. data/config/initializers/strip_and_nullify.rb +0 -13
  65. data/lib/nimbleshop/util.rb +0 -60
  66. data/test/integration/checkout/cart_acceptance_test.rb +0 -113
  67. data/test/integration/checkout/payment_confirmation_acceptance_test.rb +0 -24
  68. data/test/integration/checkout/paypal_acceptance_test.rb +0 -34
  69. data/test/integration/checkout/shipping_address_acceptance_test.rb +0 -91
  70. data/test/integration/checkout/shipping_method_acceptance_test.rb +0 -51
  71. data/test/integration/homepage_acceptance_test.rb +0 -24
  72. data/test/integration/products_acceptance_test.rb +0 -12
  73. data/test/integration/static_pages_acceptance_test.rb +0 -13
  74. data/test/mailers/mailer_test.rb +0 -25
  75. data/test/unit/payment_method/authorizedotnet_test.rb +0 -21
  76. data/test/unit/payment_method/paypalwp_test.rb +0 -17
  77. data/test/unit/payment_method/splitable_test.rb +0 -18
  78. data/test/unit/processor/authorize_net_test.rb +0 -236
  79. data/test/unit/processor/paypal_test.rb +0 -40
  80. data/test/unit/processor/splitable_test.rb +0 -123
  81. data/test/vcr_cassettes/authorize_net/authorize-failure.yml +0 -38
  82. data/test/vcr_cassettes/authorize_net/authorize-success.yml +0 -38
  83. data/test/vcr_cassettes/authorize_net/capture-failure.yml +0 -38
  84. data/test/vcr_cassettes/authorize_net/capture-success.yml +0 -38
  85. data/test/vcr_cassettes/authorize_net/purchase-failure.yml +0 -38
  86. data/test/vcr_cassettes/authorize_net/purchase-success.yml +0 -38
  87. data/test/vcr_cassettes/authorize_net/refund-failure.yml +0 -38
  88. data/test/vcr_cassettes/authorize_net/refund-success.yml +0 -38
  89. data/test/vcr_cassettes/authorize_net/void-authorize.yml +0 -38
  90. data/test/vcr_cassettes/authorize_net/void-failure.yml +0 -38
  91. data/test/vcr_cassettes/authorize_net/void-success.yml +0 -38
  92. data/test/vcr_cassettes/splitable/split-create-failure.yml +0 -48
  93. data/test/vcr_cassettes/splitable/split-create-success.yml +0 -50
  94. data/test/vcr_cassettes/splitable/split-draft-create-failure.yml +0 -50
  95. data/test/vcr_cassettes/splitable/split-draft-create-success.yml +0 -50
@@ -1,24 +0,0 @@
1
- require 'test_helper'
2
-
3
- class HomepageAcceptanceTest < ActionDispatch::IntegrationTest
4
-
5
- test 'home page with link groups' do
6
- assert_equal 1, Shop.count
7
- visit root_path
8
-
9
- assert_equal 1, Shop.count
10
-
11
- assert page.has_content?('powered by')
12
- assert page.has_content?('Shop by category')
13
- end
14
-
15
- test 'home page without link groups' do
16
- assert_equal 1, Shop.count
17
- LinkGroup.delete_all
18
-
19
- visit root_path
20
-
21
- assert page.has_content?('powered by')
22
- refute page.has_content?('Shop by category')
23
- end
24
- end
@@ -1,12 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ProductAcceptanceTest < ActionDispatch::IntegrationTest
4
- setup do
5
- @product = create(:product, name: 'ipad', description: 'awesome ipad from Apple')
6
- end
7
-
8
- test "show page" do
9
- visit nimbleshop_simply.product_path(@product)
10
- assert page.has_content?('awesome ipad from Apple')
11
- end
12
- end
@@ -1,13 +0,0 @@
1
- require 'test_helper'
2
-
3
- class StaticPagesAcceptanceTest < ActionDispatch::IntegrationTest
4
- test "static pages" do
5
- visit root_path
6
-
7
- click_link 'About us'
8
- assert page.has_content?('is a free and open source e-commerce framework based on Ruby on Rails')
9
-
10
- click_link 'Contact us'
11
- assert page.has_content?('hello.nimbleshop@gmail.com')
12
- end
13
- end
@@ -1,25 +0,0 @@
1
- require "test_helper"
2
-
3
- class MailerTest < ActiveSupport::TestCase
4
-
5
- test "sends out order notification" do
6
- order = create(:order_with_line_items)
7
-
8
- mail = Mailer.order_notification_to_buyer(order.number)
9
-
10
- assert_equal "Order confirmation for order ##{order.number}", mail.subject
11
- assert_equal ['john@nimbleshop.com'], mail.to
12
- assert_match /Here is receipt for your purchase/, mail.encoded
13
- end
14
-
15
- test "sends out shipment notification" do
16
- order = create(:order_paid_using_authorizedotnet)
17
-
18
- mail = Mailer.shipment_notification_to_buyer(order.number)
19
-
20
- assert_equal "Items for order ##{order.number} have been shipped", mail.subject
21
- assert_equal ['john@nimbleshop.com'], mail.to
22
- assert_match /Items have been shipped/, mail.encoded
23
- end
24
-
25
- end
@@ -1,21 +0,0 @@
1
- require "test_helper"
2
-
3
- class PaymentMethodAuthorizeNetTest < ActiveSupport::TestCase
4
-
5
- test "validations" do
6
- pm = NimbleshopAuthorizedotnet::Authorizedotnet.new(name: 'Authorize.net', description: 'this is description')
7
- refute pm.valid?
8
- expected = ["Company name on creditcard statement can't be blank", "Login can't be blank", "Transaction key can't be blank"]
9
- assert_equal expected, pm.errors.full_messages.sort
10
- end
11
-
12
- test "should save the record" do
13
- pm = NimbleshopAuthorizedotnet::Authorizedotnet.new(name: 'Authorize.net', description: 'this is description')
14
- pm.login_id = 'FWERSDEED093d'
15
- pm.transaction_key = 'SDFSDFSFSF423433SDFSFSSFSFSF334'
16
- pm.company_name_on_creditcard_statement = 'BigBinary LLC'
17
- assert pm.save
18
- assert_match /authorize-net/, pm.permalink
19
- end
20
-
21
- end
@@ -1,17 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PaymentMethodPaypalwpTest < ActiveSupport::TestCase
4
-
5
- test "validations" do
6
- pm = NimbleshopPaypalwp::Paypalwp.new(name: 'Paypalwp', description: 'this is description')
7
- refute pm.valid?
8
- assert_equal ["Merchant email can't be blank", "Merchant email is invalid"], pm.errors.full_messages.sort
9
- end
10
-
11
- test "should save the record" do
12
- pm = NimbleshopPaypalwp::Paypalwp.new(name: 'Paypalwp', merchant_email: 'merchant@example.com', description: 'this is description')
13
- assert pm.save
14
- assert_match /paypalwp/, pm.permalink
15
- end
16
-
17
- end
@@ -1,18 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PaymentMethodSplitableTest < ActiveSupport::TestCase
4
-
5
- test "validations" do
6
- pm = NimbleshopSplitable::Splitable.new(name: 'Splitable', description: 'this is description')
7
- refute pm.valid?
8
- assert_equal ["Api key can't be blank"], pm.errors.full_messages.sort
9
- end
10
-
11
- test "should save the record" do
12
- pm = NimbleshopSplitable::Splitable.new(name: 'Splitable', description: 'this is description')
13
- pm.api_key = 'FWERSDEED093d'
14
- assert pm.save
15
- assert_match /splitable/, pm.permalink
16
- end
17
-
18
- end
@@ -1,236 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Processor
4
- class NimbleshopAuthorizeNetAuthorizeTest < ActiveRecord::TestCase
5
- setup do
6
- @order = create(:order)
7
- @order.stubs(:total_amount).returns(100.48)
8
- @processor = NimbleshopAuthorizedotnet::Processor.new(@order)
9
- end
10
-
11
- test 'when authorization succeeds' do
12
- creditcard = build(:creditcard)
13
-
14
- playcasette('authorize.net/authorize-success') do
15
- assert_equal true, @processor.authorize(creditcard: creditcard)
16
- end
17
-
18
- @order.reload
19
-
20
- transaction = @order.payment_transactions.last
21
- assert_equal 'authorized', transaction.operation
22
- assert_equal true, transaction.success
23
- assert_equal NimbleshopAuthorizedotnet::Authorizedotnet.first, @order.payment_method
24
- assert @order.authorized?
25
- end
26
-
27
- test 'authorization fails when credit card number is not entered' do
28
- creditcard = build(:creditcard, number: nil)
29
- assert_equal false, @processor.authorize(creditcard: creditcard)
30
- assert_equal 'Please enter credit card number', @processor.errors.first
31
-
32
- @order.reload
33
-
34
- assert_nil @order.payment_method
35
- assert @order.abandoned?
36
- end
37
-
38
- test 'authorization fails with invalid credit card number' do
39
- creditcard = build(:creditcard, number: 2)
40
-
41
- playcasette('authorize.net/authorize-failure') do
42
- assert_equal false, @processor.authorize(creditcard: creditcard)
43
- assert_equal 'Credit card was declined. Please try again!', @processor.errors.first
44
- end
45
-
46
- @order.reload
47
-
48
- assert_nil @order.payment_method
49
- assert @order.abandoned?
50
- end
51
- end
52
-
53
- class AuthorizeNetCaptureTest < ActiveRecord::TestCase
54
- setup do
55
- @order = create(:order, payment_method: NimbleshopAuthorizedotnet::Authorizedotnet.first)
56
- @order.stubs(:total_amount).returns(100.48)
57
- @processor = NimbleshopAuthorizedotnet::Processor.new(@order)
58
- creditcard = build(:creditcard)
59
-
60
- playcasette('authorize.net/authorize-success') do
61
- @processor.authorize(creditcard: creditcard)
62
- end
63
-
64
- @tsx_id = @order.payment_transactions.last.transaction_gid
65
- end
66
-
67
- test 'when capture succeeds' do
68
- creditcard = build(:creditcard)
69
-
70
- playcasette('authorize.net/capture-success') do
71
- assert_equal true, @processor.kapture(transaction_gid: @tsx_id)
72
- end
73
-
74
- @order.reload
75
- transaction = @order.payment_transactions.last
76
- assert_equal 'captured', transaction.operation
77
- assert_equal true, transaction.success
78
- assert @order.purchased?
79
- end
80
-
81
- test 'when capture fails' do
82
- creditcard = build(:creditcard, number: 2)
83
-
84
- playcasette('authorize.net/capture-failure') do
85
- assert_equal false, @processor.kapture(transaction_gid: @tsx_id)
86
- assert_equal 'Capture failed', @processor.errors.first
87
- end
88
-
89
- @order.reload
90
-
91
- transaction = @order.payment_transactions.last
92
-
93
- assert_equal false, transaction.success
94
- assert_equal 'captured', transaction.operation
95
- assert @order.authorized?
96
- end
97
- end
98
-
99
- class AuthorizeNetRefundTest < ActiveRecord::TestCase
100
- setup do
101
- @order = create(:order)
102
- @order.stubs(:total_amount).returns(100.48)
103
- @processor = NimbleshopAuthorizedotnet::Processor.new(@order)
104
- creditcard = build(:creditcard)
105
-
106
- playcasette('authorize.net/purchase-success') do
107
- assert_equal true, @processor.purchase(creditcard: creditcard)
108
- end
109
-
110
- assert @order.reload.purchased?
111
-
112
- @transaction = @order.payment_transactions.last
113
- end
114
-
115
- test 'when refund succeeds' do
116
-
117
- playcasette('authorize.net/refund-success') do
118
- assert_equal true, @processor.refund(transaction_gid: @transaction.transaction_gid,
119
- card_number: @transaction.metadata[:card_number])
120
- end
121
-
122
- @order.reload
123
- transaction = @order.payment_transactions.last
124
-
125
- assert_equal 'refunded', transaction.operation
126
- assert_equal true, transaction.success
127
- assert_equal NimbleshopAuthorizedotnet::Authorizedotnet.first, @order.payment_method
128
- assert @order.refunded?
129
- end
130
-
131
- test 'when refund fails' do
132
-
133
- playcasette('authorize.net/refund-failure') do
134
- assert_equal false, @processor.refund(transaction_gid: @transaction.transaction_gid, card_number: '1234')
135
- end
136
-
137
- @order.reload
138
-
139
- transaction = @order.payment_transactions.last
140
-
141
- assert_equal 'refunded', transaction.operation
142
- assert_equal false, transaction.success
143
- end
144
- end
145
-
146
- class AuthorizeNetVoidTest < ActiveRecord::TestCase
147
- setup do
148
- @order = create(:order)
149
- @order.stubs(:total_amount).returns(100.48)
150
- @processor = NimbleshopAuthorizedotnet::Processor.new(@order)
151
- creditcard = build(:creditcard)
152
-
153
- playcasette('authorize.net/authorize-success') do
154
- assert_equal true, @processor.authorize(creditcard: creditcard)
155
- end
156
-
157
- @tsx_id = @order.payment_transactions.last.transaction_gid
158
- end
159
-
160
- test 'when capture succeeds' do
161
- playcasette('authorize.net/void-success') do
162
- assert_equal true, @processor.void(transaction_gid: @tsx_id)
163
- end
164
-
165
- @order.reload
166
- transaction = @order.payment_transactions.last
167
-
168
- assert_equal 'voided', transaction.operation
169
- assert_equal true, transaction.success
170
- assert_equal NimbleshopAuthorizedotnet::Authorizedotnet.first, @order.payment_method
171
- assert @order.voided?
172
- end
173
-
174
- test 'when capture fails' do
175
- playcasette('authorize.net/void-failure') do
176
- assert_equal false, @processor.void(transaction_gid: @tsx_id)
177
- end
178
-
179
- @order.reload
180
-
181
- transaction = @order.payment_transactions.last
182
-
183
- assert_equal 'voided', transaction.operation
184
- assert_equal false, transaction.success
185
- end
186
- end
187
-
188
- class AuthorizeNetPurchaseTest < ActiveRecord::TestCase
189
- setup do
190
- @order = create(:order)
191
- @order.stubs(:total_amount).returns(100.48)
192
- @processor = NimbleshopAuthorizedotnet::Processor.new(@order)
193
- end
194
-
195
- test 'when purchase succeeds' do
196
- creditcard = build(:creditcard)
197
-
198
- playcasette('authorize.net/purchase-success') do
199
- assert_equal true, @processor.purchase(creditcard: creditcard)
200
- end
201
-
202
- @order.reload
203
-
204
- transaction = @order.payment_transactions.last
205
- assert_equal 'purchased', transaction.operation
206
- assert_equal true, transaction.success
207
- assert @order.purchased?
208
- end
209
-
210
- test 'purchase fails when credit card number is not entered ' do
211
- creditcard = build(:creditcard, number: nil)
212
-
213
- playcasette('authorize.net/purchase-failure') do
214
- assert_equal false, @processor.purchase(creditcard: creditcard)
215
- assert_equal 'Please enter credit card number', @processor.errors.first
216
- end
217
-
218
- assert @order.abandoned?
219
- end
220
-
221
- test 'purchase fails when invalid credit card number is entered' do
222
- creditcard = build(:creditcard, number: 2)
223
-
224
- playcasette('authorize.net/purchase-failure') do
225
- assert_equal false, @processor.purchase(creditcard: creditcard)
226
- assert_equal 'Credit card was declined. Please try again!', @processor.errors.first
227
- end
228
-
229
- transaction = @order.payment_transactions.last
230
-
231
- assert_equal false, transaction.success
232
- assert_equal 'purchased', transaction.operation
233
- assert @order.abandoned?
234
- end
235
- end
236
- end
@@ -1,40 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Processor
4
- class PaypalAuthorizeTest < ActiveRecord::TestCase
5
- def raw1
6
- "mc_gross=152.73&invoice=54145619&protection_eligibility=Ineligible&item_number1=&payer_id=Q96HQCW3NMN8A&tax=1.73&payment_date=19%3A48%3A59+Apr+22%2C+2012+PDT&payment_status=Completed&charset=windows-1252&mc_shipping=0.00&mc_handling=10.00&first_name=buyer&mc_fee=4.73&notify_version=3.4&custom=&payer_status=verified&business=seller_1323037155_biz%40bigbinary.com&num_cart_items=1&mc_handling1=0.00&verify_sign=AAmQuqWvZCTtQW5vSunjl6MYb9xfACAPVvn0EpIPnon.Cyn5sYgI-bZB&payer_email=nimble_1333550340_per%40hotmail.com&mc_shipping1=0.00&tax1=0.00&txn_id=2LY704674J0179216&payment_type=instant&last_name=again&item_name1=Colorful+shoes&receiver_email=seller_1323037155_biz%40bigbinary.com&payment_fee=4.73&quantity1=1&receiver_id=EULE94DW3YTH4&txn_type=cart&mc_gross_1=141.00&mc_currency=USD&residence_country=US&test_ipn=1&transaction_subject=Shopping+CartColorful+shoes&payment_gross=152.73&ipn_track_id=72a7efbc940b7"
7
- end
8
-
9
- def raw_post(order_id, total)
10
- "mc_gross=#{total}&invoice=#{order_id}&protection_eligibility=Ineligible&item_number1=&payer_id=UU9QTKRET6CCA&tax=0.23&payment_date=13%3A46%3A50+Apr+01%2C+2012+PDT&payment_status=Completed&charset=windows-1252&mc_shipping=0.00&mc_handling=0.00&first_name=venkata&mc_fee=0.63&notify_version=3.4&custom=&payer_status=verified&business=pvdsub_1332777111_biz%40hotmail.com&num_cart_items=1&mc_handling1=0.00&verify_sign=A97HaEBl1Z9n6y3FnK2ES7ntmCFAA42qVBV1tGxSqeM5XnO3fijruk.r&payer_email=pvdsub_1332813592_per%40hotmail.com&mc_shipping1=0.00&tax1=0.00&txn_id=48D08257JB6543456&payment_type=instant&last_name=pasupuleti&item_name1=Handmade+vibrant+bangles&receiver_email=pvdsub_1332777111_biz%40hotmail.com&payment_fee=0.63&quantity1=1&receiver_id=DT54LCN8WQM8S&txn_type=cart&mc_gross_1=11.00&mc_currency=USD&residence_country=US&test_ipn=1&transaction_subject=Shopping+CartHandmade+vibrant+bangles&payment_gross=11.23&ipn_track_id=b1f9dd1a56ae8"
11
- end
12
-
13
- setup do
14
- @order = create(:order)
15
- end
16
-
17
- test "when authorization succeeds" do
18
- processor = NimbleshopPaypalwp::Processor.new(raw_post: raw_post(@order.number, @order.total_amount))
19
- playcasette('paypal/authorize-success') do
20
- assert_equal true, processor.authorize
21
- end
22
-
23
- @order.reload
24
-
25
- transaction = @order.payment_transactions.last
26
- assert_equal 'authorized', transaction.operation
27
- assert_equal true, transaction.success
28
- assert_equal true, @order.authorized?
29
- assert_equal "April 01, 2012 at 08:46 pm", @order.purchased_at.to_s(:long)
30
- assert_equal NimbleshopPaypalwp::Paypalwp.first, @order.payment_method
31
- assert_equal transaction.amount, @order.total_amount_in_cents
32
- end
33
-
34
- test "when authorization fails" do
35
- processor = NimbleshopPaypalwp::Processor.new(raw_post: raw_post(@order.number, 10.48))
36
- assert_equal false, processor.authorize
37
- assert_nil @order.payment_method
38
- end
39
- end
40
- end
@@ -1,123 +0,0 @@
1
- require 'test_helper'
2
-
3
- module Processor
4
- class SpllitableCreateTest < ActiveRecord::TestCase
5
- setup do
6
- @product = create(:product, price: 10)
7
- @order = create(:order)
8
- @request = stub(protocol: 'https', host_with_port: 'localhost:3000' )
9
- end
10
-
11
- test "when successful" do
12
- @order.add(@product)
13
- processor = NimbleshopSplitable::Processor.new(order: @order)
14
-
15
- expected = "https://nimbleshop.splitable-draft.com/cws/0a0722b80ce3b662039884060ca49aaa7a1bb4135ea92fa47dc8"
16
-
17
- playcasette('splitable/split-draft-create-success') do
18
- error, split_url = processor.create_split(request: @request)
19
- assert_nil error, "must be have no errors"
20
- assert_equal expected, split_url
21
- assert_equal NimbleshopSplitable::Splitable.first, @order.payment_method
22
- assert @order.pending?
23
- end
24
- end
25
-
26
- test "when failed" do
27
- processor = NimbleshopSplitable::Processor.new(order: @order)
28
-
29
- playcasette('splitable/split-draft-create-failure') do
30
- error, split_url = processor.create_split(request: @request)
31
- assert_nil split_url, "must not create split url"
32
- assert_equal "Order must have atleast one line item", error
33
- end
34
- end
35
- end
36
-
37
- class SpllitablePaidTest < ActiveRecord::TestCase
38
- def callback_params(order)
39
- {
40
- invoice: order.number,
41
- payment_status: "paid",
42
- api_secret: "82746e2d66cb8993",
43
- transaction_id: "852973493383974"
44
- }
45
- end
46
-
47
- setup do
48
- @product = create(:product, price: 10)
49
- @order = create(:order)
50
- end
51
-
52
- test "when transaction is paid" do
53
- processor = NimbleshopSplitable::Processor.new(order: @order)
54
- playcasette('splitable/split-draft-create-success') do
55
- processor.create_split(request: @request)
56
- end
57
-
58
- assert @order.pending?
59
-
60
- options = callback_params(@order)
61
- processor = NimbleshopSplitable::Processor.new(invoice: options[:invoice])
62
-
63
-
64
- processor.acknowledge(options)
65
- transaction = @order.payment_transactions.last
66
-
67
- assert_equal 'purchased', transaction.operation
68
- assert_equal '852973493383974', transaction.transaction_gid
69
- @order.reload
70
- assert @order.purchased?
71
- end
72
- end
73
-
74
- class SpllitableVoidTest < ActiveRecord::TestCase
75
- def callback_params(order)
76
- {
77
- invoice: order.number,
78
- payment_status: "cancelled",
79
- api_secret: "82746e2d66cb8993",
80
- transaction_id: "852973493383974"
81
- }
82
- end
83
-
84
- setup do
85
- @order = create(:order)
86
- end
87
-
88
- test "when transaction is cancelled" do
89
- processor = NimbleshopSplitable::Processor.new(order: @order)
90
- playcasette('splitable/split-draft-create-success') do
91
- processor.create_split(request: @request)
92
- end
93
-
94
- assert @order.pending?
95
-
96
- options = callback_params(@order)
97
- processor = NimbleshopSplitable::Processor.new(invoice: options[:invoice])
98
- assert processor.acknowledge(options)
99
- transaction = @order.payment_transactions.last
100
-
101
- assert_equal 'voided', transaction.operation
102
- assert_equal '852973493383974', transaction.transaction_gid
103
- @order.reload
104
- assert @order.voided?
105
- end
106
-
107
- test "when an invalid order number is used" do
108
- options = callback_params(@order)
109
- processor = NimbleshopSplitable::Processor.new(invoice: '123')
110
-
111
- assert_equal false, processor.acknowledge(options)
112
- assert_equal ["Unknown invoice number"], processor.errors
113
- end
114
-
115
- test "when payment_status is blank" do
116
- options = callback_params(@order).merge(payment_status: nil)
117
- processor = NimbleshopSplitable::Processor.new(invoice: options[:invoice])
118
-
119
- assert_equal false, processor.acknowledge(options)
120
- assert_equal ["Parameter payment_status is blank"], processor.errors
121
- end
122
- end
123
- end