effective_orders 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/effective_orders/version.rb +1 -1
- metadata +10 -258
- data/spec/controllers/admin/orders_controller_spec.rb +0 -243
- data/spec/controllers/carts_controller_spec.rb +0 -143
- data/spec/controllers/ccbill_orders_controller_spec.rb +0 -103
- data/spec/controllers/moneris_orders_controller_spec.rb +0 -133
- data/spec/controllers/orders_controller_spec.rb +0 -500
- data/spec/controllers/stripe_orders_controller_spec.rb +0 -128
- data/spec/controllers/webhooks_controller_spec.rb +0 -170
- data/spec/dummy/README.rdoc +0 -8
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/models/product.rb +0 -9
- data/spec/dummy/app/models/product_with_float_price.rb +0 -9
- data/spec/dummy/app/models/user.rb +0 -11
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/config/application.rb +0 -32
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -37
- data/spec/dummy/config/environments/production.rb +0 -80
- data/spec/dummy/config/environments/test.rb +0 -36
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/devise.rb +0 -254
- data/spec/dummy/config/initializers/effective_addresses.rb +0 -15
- data/spec/dummy/config/initializers/effective_orders.rb +0 -269
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/simple_form.rb +0 -189
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/db/schema.rb +0 -158
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -164
- data/spec/dummy/log/test.log +0 -60
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/fixtures/stripe_webhooks/invoice.payment_succeeded.without_renewals.json +0 -76
- data/spec/helpers/effective_orders_helper_spec.rb +0 -21
- data/spec/models/acts_as_purchasable_spec.rb +0 -75
- data/spec/models/customer_spec.rb +0 -72
- data/spec/models/factories_spec.rb +0 -35
- data/spec/models/order_item_spec.rb +0 -35
- data/spec/models/order_spec.rb +0 -445
- data/spec/models/stripe_charge_spec.rb +0 -39
- data/spec/models/subscription_spec.rb +0 -103
- data/spec/spec_helper.rb +0 -46
- data/spec/support/factories.rb +0 -139
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 087ee5d1dd1c2882afcbe2f455c21b9c9a88fb84
|
4
|
+
data.tar.gz: c51480679d42773312d8fd384515f3ca302dfaf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae149e37f2810d9dea9cb2c2177e2349f7addd84cc53d3350836f2605c84ec958e8d5691750785aa7a3f3e247e3302756663e73bd205712d86f6d8cd01c641b5
|
7
|
+
data.tar.gz: f52633ba98f00efe3c71740f7385106a9e557fbc3773d0f2c372a677ad1ff668585022ad3d7da952a2172e290bb9109e7295cb0a908146215dfbff248fb4aac0
|
data/README.md
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -86,154 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: effective_datatables
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 3.0
|
103
|
+
version: '3.0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 3.0.0
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: stripe-ruby-mock
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 2.0.4
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 2.0.4
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: factory_girl_rails
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: rspec-rails
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: shoulda-matchers
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - ">="
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '0'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '0'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: sqlite3
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: effective_obfuscation
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: 1.0.2
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: 1.0.2
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: pry
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - ">="
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
202
|
-
type: :development
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - ">="
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
209
|
-
- !ruby/object:Gem::Dependency
|
210
|
-
name: pry-stack_explorer
|
211
|
-
requirement: !ruby/object:Gem::Requirement
|
212
|
-
requirements:
|
213
|
-
- - ">="
|
214
|
-
- !ruby/object:Gem::Version
|
215
|
-
version: '0'
|
216
|
-
type: :development
|
217
|
-
prerelease: false
|
218
|
-
version_requirements: !ruby/object:Gem::Requirement
|
219
|
-
requirements:
|
220
|
-
- - ">="
|
108
|
+
- - "~>"
|
221
109
|
- !ruby/object:Gem::Version
|
222
|
-
version: '0'
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: pry-byebug
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - ">="
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: '0'
|
230
|
-
type: :development
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - ">="
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: '0'
|
110
|
+
version: '3.0'
|
237
111
|
description: Quickly build an online store with carts, orders, automatic email receipts
|
238
112
|
and payment collection via Stripe, StripeConnect, PayPal and Moneris.
|
239
113
|
email:
|
@@ -376,67 +250,6 @@ files:
|
|
376
250
|
- lib/generators/effective_orders/install_generator.rb
|
377
251
|
- lib/generators/templates/effective_orders_mailer_preview.rb
|
378
252
|
- lib/tasks/effective_orders_tasks.rake
|
379
|
-
- spec/controllers/admin/orders_controller_spec.rb
|
380
|
-
- spec/controllers/carts_controller_spec.rb
|
381
|
-
- spec/controllers/ccbill_orders_controller_spec.rb
|
382
|
-
- spec/controllers/moneris_orders_controller_spec.rb
|
383
|
-
- spec/controllers/orders_controller_spec.rb
|
384
|
-
- spec/controllers/stripe_orders_controller_spec.rb
|
385
|
-
- spec/controllers/webhooks_controller_spec.rb
|
386
|
-
- spec/dummy/README.rdoc
|
387
|
-
- spec/dummy/Rakefile
|
388
|
-
- spec/dummy/app/assets/javascripts/application.js
|
389
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
390
|
-
- spec/dummy/app/controllers/application_controller.rb
|
391
|
-
- spec/dummy/app/helpers/application_helper.rb
|
392
|
-
- spec/dummy/app/models/product.rb
|
393
|
-
- spec/dummy/app/models/product_with_float_price.rb
|
394
|
-
- spec/dummy/app/models/user.rb
|
395
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
396
|
-
- spec/dummy/bin/bundle
|
397
|
-
- spec/dummy/bin/rails
|
398
|
-
- spec/dummy/bin/rake
|
399
|
-
- spec/dummy/config.ru
|
400
|
-
- spec/dummy/config/application.rb
|
401
|
-
- spec/dummy/config/boot.rb
|
402
|
-
- spec/dummy/config/database.yml
|
403
|
-
- spec/dummy/config/environment.rb
|
404
|
-
- spec/dummy/config/environments/development.rb
|
405
|
-
- spec/dummy/config/environments/production.rb
|
406
|
-
- spec/dummy/config/environments/test.rb
|
407
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
408
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
409
|
-
- spec/dummy/config/initializers/devise.rb
|
410
|
-
- spec/dummy/config/initializers/effective_addresses.rb
|
411
|
-
- spec/dummy/config/initializers/effective_orders.rb
|
412
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
413
|
-
- spec/dummy/config/initializers/inflections.rb
|
414
|
-
- spec/dummy/config/initializers/mime_types.rb
|
415
|
-
- spec/dummy/config/initializers/session_store.rb
|
416
|
-
- spec/dummy/config/initializers/simple_form.rb
|
417
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
418
|
-
- spec/dummy/config/locales/en.yml
|
419
|
-
- spec/dummy/config/routes.rb
|
420
|
-
- spec/dummy/config/secrets.yml
|
421
|
-
- spec/dummy/db/schema.rb
|
422
|
-
- spec/dummy/db/test.sqlite3
|
423
|
-
- spec/dummy/log/development.log
|
424
|
-
- spec/dummy/log/test.log
|
425
|
-
- spec/dummy/public/404.html
|
426
|
-
- spec/dummy/public/422.html
|
427
|
-
- spec/dummy/public/500.html
|
428
|
-
- spec/dummy/public/favicon.ico
|
429
|
-
- spec/fixtures/stripe_webhooks/invoice.payment_succeeded.without_renewals.json
|
430
|
-
- spec/helpers/effective_orders_helper_spec.rb
|
431
|
-
- spec/models/acts_as_purchasable_spec.rb
|
432
|
-
- spec/models/customer_spec.rb
|
433
|
-
- spec/models/factories_spec.rb
|
434
|
-
- spec/models/order_item_spec.rb
|
435
|
-
- spec/models/order_spec.rb
|
436
|
-
- spec/models/stripe_charge_spec.rb
|
437
|
-
- spec/models/subscription_spec.rb
|
438
|
-
- spec/spec_helper.rb
|
439
|
-
- spec/support/factories.rb
|
440
253
|
homepage: https://github.com/code-and-effect/effective_orders
|
441
254
|
licenses:
|
442
255
|
- MIT
|
@@ -457,70 +270,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
457
270
|
version: '0'
|
458
271
|
requirements: []
|
459
272
|
rubyforge_project:
|
460
|
-
rubygems_version: 2.4.
|
273
|
+
rubygems_version: 2.4.5.1
|
461
274
|
signing_key:
|
462
275
|
specification_version: 4
|
463
276
|
summary: Quickly build an online store with carts, orders, automatic email receipts
|
464
277
|
and payment collection via Stripe, StripeConnect, PayPal and Moneris.
|
465
|
-
test_files:
|
466
|
-
- spec/controllers/admin/orders_controller_spec.rb
|
467
|
-
- spec/controllers/carts_controller_spec.rb
|
468
|
-
- spec/controllers/ccbill_orders_controller_spec.rb
|
469
|
-
- spec/controllers/moneris_orders_controller_spec.rb
|
470
|
-
- spec/controllers/orders_controller_spec.rb
|
471
|
-
- spec/controllers/stripe_orders_controller_spec.rb
|
472
|
-
- spec/controllers/webhooks_controller_spec.rb
|
473
|
-
- spec/dummy/app/assets/javascripts/application.js
|
474
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
475
|
-
- spec/dummy/app/controllers/application_controller.rb
|
476
|
-
- spec/dummy/app/helpers/application_helper.rb
|
477
|
-
- spec/dummy/app/models/product.rb
|
478
|
-
- spec/dummy/app/models/product_with_float_price.rb
|
479
|
-
- spec/dummy/app/models/user.rb
|
480
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
481
|
-
- spec/dummy/bin/bundle
|
482
|
-
- spec/dummy/bin/rails
|
483
|
-
- spec/dummy/bin/rake
|
484
|
-
- spec/dummy/config/application.rb
|
485
|
-
- spec/dummy/config/boot.rb
|
486
|
-
- spec/dummy/config/database.yml
|
487
|
-
- spec/dummy/config/environment.rb
|
488
|
-
- spec/dummy/config/environments/development.rb
|
489
|
-
- spec/dummy/config/environments/production.rb
|
490
|
-
- spec/dummy/config/environments/test.rb
|
491
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
492
|
-
- spec/dummy/config/initializers/cookies_serializer.rb
|
493
|
-
- spec/dummy/config/initializers/devise.rb
|
494
|
-
- spec/dummy/config/initializers/effective_addresses.rb
|
495
|
-
- spec/dummy/config/initializers/effective_orders.rb
|
496
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
497
|
-
- spec/dummy/config/initializers/inflections.rb
|
498
|
-
- spec/dummy/config/initializers/mime_types.rb
|
499
|
-
- spec/dummy/config/initializers/session_store.rb
|
500
|
-
- spec/dummy/config/initializers/simple_form.rb
|
501
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
502
|
-
- spec/dummy/config/locales/en.yml
|
503
|
-
- spec/dummy/config/routes.rb
|
504
|
-
- spec/dummy/config/secrets.yml
|
505
|
-
- spec/dummy/config.ru
|
506
|
-
- spec/dummy/db/schema.rb
|
507
|
-
- spec/dummy/db/test.sqlite3
|
508
|
-
- spec/dummy/log/development.log
|
509
|
-
- spec/dummy/log/test.log
|
510
|
-
- spec/dummy/public/404.html
|
511
|
-
- spec/dummy/public/422.html
|
512
|
-
- spec/dummy/public/500.html
|
513
|
-
- spec/dummy/public/favicon.ico
|
514
|
-
- spec/dummy/Rakefile
|
515
|
-
- spec/dummy/README.rdoc
|
516
|
-
- spec/fixtures/stripe_webhooks/invoice.payment_succeeded.without_renewals.json
|
517
|
-
- spec/helpers/effective_orders_helper_spec.rb
|
518
|
-
- spec/models/acts_as_purchasable_spec.rb
|
519
|
-
- spec/models/customer_spec.rb
|
520
|
-
- spec/models/factories_spec.rb
|
521
|
-
- spec/models/order_item_spec.rb
|
522
|
-
- spec/models/order_spec.rb
|
523
|
-
- spec/models/stripe_charge_spec.rb
|
524
|
-
- spec/models/subscription_spec.rb
|
525
|
-
- spec/spec_helper.rb
|
526
|
-
- spec/support/factories.rb
|
278
|
+
test_files: []
|
@@ -1,243 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Admin::OrdersController, type: :controller do
|
4
|
-
routes { EffectiveOrders::Engine.routes }
|
5
|
-
|
6
|
-
let!(:user1) { FactoryGirl.create(:user, email: 'bbb@example.com') }
|
7
|
-
let!(:user2) { FactoryGirl.create(:user, email: 'ccc@example.com') }
|
8
|
-
let!(:user3) { FactoryGirl.create(:user, email: 'aaa@example.com') }
|
9
|
-
let(:cart) { FactoryGirl.create(:cart, user: user1) }
|
10
|
-
|
11
|
-
before { sign_in cart.user }
|
12
|
-
|
13
|
-
describe 'GET #new' do
|
14
|
-
it 'should render admin new order page successfully' do
|
15
|
-
get :new
|
16
|
-
|
17
|
-
expect(response).to be_successful
|
18
|
-
expect(response).to render_template :new
|
19
|
-
expect(assigns(:order)).to be_an Effective::Order
|
20
|
-
expect(assigns(:order)).to be_new_record
|
21
|
-
expect(assigns(:page_title)).to eq 'New Order'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'POST #create' do
|
26
|
-
let(:user1) { FactoryGirl.create(:user, email: 'bbb@example.com', billing_address: FactoryGirl.create(:address), shipping_address: FactoryGirl.create(:address)) }
|
27
|
-
|
28
|
-
context 'when success' do
|
29
|
-
let(:order_params) { { effective_order: { user_id: user1.id, order_items_attributes: { '0' => { purchasable_attributes: { title: 'test product 1', price: '10000', tax_exempt: '1' }, quantity: '2', '_destroy' => 'false' }, '1' => { purchasable_attributes: { title: 'test product 2', price: '30000', tax_exempt: '0' }, quantity: '3', '_destroy' => 'false' } }, send_payment_request_to_buyer: '1' } } }
|
30
|
-
|
31
|
-
shared_context 'creates objects in db correctly' do
|
32
|
-
it 'should create new custom order with pending state' do
|
33
|
-
expect { post :create, order_params.merge(commit: button_pressed) }.to change { Effective::Order.count }.from(0).to(1)
|
34
|
-
|
35
|
-
expect(assigns(:order)).to be_persisted
|
36
|
-
expect(assigns(:order).pending?).to be_truthy
|
37
|
-
expect(assigns(:order).user).to eq user1
|
38
|
-
expect(assigns(:order).billing_address).to eq user1.billing_address
|
39
|
-
expect(assigns(:order).shipping_address).to eq user1.shipping_address
|
40
|
-
|
41
|
-
expect(assigns(:order).order_items.count).to eq 2
|
42
|
-
|
43
|
-
first_item = assigns(:order).order_items.sort.first
|
44
|
-
expect(first_item).to be_persisted
|
45
|
-
expect(first_item.title).to eq 'test product 1'
|
46
|
-
expect(first_item.quantity).to eq 2
|
47
|
-
expect(first_item.price).to eq 10000
|
48
|
-
expect(first_item.tax_exempt).to be_truthy
|
49
|
-
|
50
|
-
second_item = assigns(:order).order_items.sort.last
|
51
|
-
expect(second_item).to be_persisted
|
52
|
-
expect(second_item.title).to eq 'test product 2'
|
53
|
-
expect(second_item.quantity).to eq 3
|
54
|
-
expect(second_item.price).to eq 30000
|
55
|
-
expect(second_item.tax_exempt).to be_falsey
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should create new effective products' do
|
59
|
-
expect { post :create, order_params.merge(commit: button_pressed) }.to change { Effective::Product.count }.from(0).to(2)
|
60
|
-
|
61
|
-
first_product = Effective::Product.all.sort.first
|
62
|
-
expect(first_product.title).to eq 'test product 1'
|
63
|
-
expect(first_product.price).to eq 10000
|
64
|
-
|
65
|
-
second_product = Effective::Product.all.sort.last
|
66
|
-
expect(second_product.title).to eq 'test product 2'
|
67
|
-
expect(second_product.price).to eq 30000
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
context 'when "Save" button is pressed' do
|
72
|
-
let(:button_pressed) { 'Save' }
|
73
|
-
|
74
|
-
it_should_behave_like 'creates objects in db correctly'
|
75
|
-
|
76
|
-
it 'should redirect to admin orders index page with success message' do
|
77
|
-
post :create, order_params.merge(commit: button_pressed)
|
78
|
-
|
79
|
-
expect(response).to be_redirect
|
80
|
-
expect(response).to redirect_to EffectiveOrders::Engine.routes.url_helpers.admin_order_path(assigns(:order))
|
81
|
-
expect(flash[:success]).to eq "Successfully created order. #{assigns(:order).user.email} has been sent a request for payment."
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'when "Save and Add New" button is pressed' do
|
86
|
-
let(:button_pressed) { 'Save and Add New' }
|
87
|
-
|
88
|
-
it_should_behave_like 'creates objects in db correctly'
|
89
|
-
|
90
|
-
it 'should redirect to admin new order page with success message' do
|
91
|
-
post :create, order_params.merge(commit: button_pressed)
|
92
|
-
|
93
|
-
expect(response).to be_redirect
|
94
|
-
expect(response).to redirect_to EffectiveOrders::Engine.routes.url_helpers.new_admin_order_path(user_id: 1)
|
95
|
-
expect(flash[:success]).to eq "Successfully created order. #{assigns(:order).user.email} has been sent a request for payment."
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context 'when failed' do
|
101
|
-
let(:order_params) { { effective_order: { user_id: user1.id, order_items_attributes: { '0' => { purchasable_attributes: { title: 'test product 1', price: '0', tax_exempt: '1' }, quantity: '2', '_destroy' => 'false' } } } } }
|
102
|
-
|
103
|
-
shared_context 'does not create objects in db and redirects to admin new order page with danger message' do
|
104
|
-
it 'should not create order' do
|
105
|
-
expect { post :create, order_params.merge(commit: button_pressed) }.not_to change { Effective::Order.count }
|
106
|
-
|
107
|
-
expect(assigns(:order)).to be_new_record
|
108
|
-
expect(assigns(:order).valid?).to be_falsey
|
109
|
-
expect(assigns(:order).pending?).to be_truthy
|
110
|
-
expect(assigns(:order).user).to eq user1
|
111
|
-
expect(assigns(:order).billing_address).to eq user1.billing_address
|
112
|
-
expect(assigns(:order).shipping_address).to eq user1.shipping_address
|
113
|
-
|
114
|
-
expect(assigns(:order).order_items.to_a.count).to eq 1
|
115
|
-
|
116
|
-
item = assigns(:order).order_items.first
|
117
|
-
expect(item).to be_new_record
|
118
|
-
expect(item.valid?).to be_falsey
|
119
|
-
expect(item.title).to eq 'test product 1'
|
120
|
-
expect(item.quantity).to eq 2
|
121
|
-
expect(item.price).to eq 0
|
122
|
-
expect(item.tax_exempt).to be_truthy
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'should not create product' do
|
126
|
-
expect { post :create, order_params.merge(commit: button_pressed) }.not_to change { Effective::Product.count }
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'should render admin new order page with danger message' do
|
130
|
-
post :create, order_params.merge(commit: button_pressed)
|
131
|
-
|
132
|
-
expect(response).to be_successful
|
133
|
-
expect(response).to render_template :new
|
134
|
-
expect(assigns(:page_title)).to eq 'New Order'
|
135
|
-
expect(flash[:danger].to_s.include?('Unable to create order')).to eq true
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
context 'when "Save" button is pressed' do
|
140
|
-
let(:button_pressed) { 'Save' }
|
141
|
-
|
142
|
-
it_should_behave_like 'does not create objects in db and redirects to admin new order page with danger message'
|
143
|
-
end
|
144
|
-
|
145
|
-
context 'when "Save and Add New" button is pressed' do
|
146
|
-
let(:button_pressed) { 'Save and Add New' }
|
147
|
-
|
148
|
-
it_should_behave_like 'does not create objects in db and redirects to admin new order page with danger message'
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
# This was changed to be a GET -> POST form, but it hasn't been updated in the test yet
|
154
|
-
# describe 'POST #mark_as_paid' do
|
155
|
-
# let(:order) { FactoryGirl.create(:pending_order) }
|
156
|
-
|
157
|
-
# before { request.env['HTTP_REFERER'] = 'where_i_came_from' }
|
158
|
-
|
159
|
-
# context 'when success' do
|
160
|
-
# it 'should update order state and redirect to orders admin index page with success message' do
|
161
|
-
# post :mark_as_paid, id: order.to_param
|
162
|
-
|
163
|
-
# expect(response).to be_redirect
|
164
|
-
# expect(response).to redirect_to EffectiveOrders::Engine.routes.url_helpers.admin_order_path(assigns(:order))
|
165
|
-
# expect(assigns(:order)).to eq order
|
166
|
-
# expect(assigns(:order).purchased?).to be_truthy
|
167
|
-
# expect(assigns(:order).payment).to eq(details: 'Marked as paid by admin')
|
168
|
-
# expect(flash[:success]).to eq 'Order marked as paid successfully'
|
169
|
-
# end
|
170
|
-
# end
|
171
|
-
|
172
|
-
# context 'when failed' do
|
173
|
-
# before { Effective::Order.any_instance.stub(:purchase!).and_return(false) }
|
174
|
-
|
175
|
-
# it 'should redirect back with danger message' do
|
176
|
-
# post :mark_as_paid, id: order.to_param
|
177
|
-
|
178
|
-
# expect(response).to be_redirect
|
179
|
-
# expect(response).to redirect_to 'where_i_came_from'
|
180
|
-
# expect(assigns(:order)).to eq order
|
181
|
-
# expect(assigns(:order).purchased?).to be_falsey
|
182
|
-
# expect(flash[:danger]).to eq 'Unable to mark order as paid'
|
183
|
-
# end
|
184
|
-
# end
|
185
|
-
# end
|
186
|
-
|
187
|
-
describe 'POST #send_payment_request' do
|
188
|
-
let(:user) { FactoryGirl.create(:user, email: 'user@example.com') }
|
189
|
-
let(:order) { FactoryGirl.create(:order, user: user) }
|
190
|
-
|
191
|
-
context 'when success' do
|
192
|
-
before { Effective::Order.any_instance.should_receive(:send_payment_request_to_buyer!).once.and_return(true) }
|
193
|
-
|
194
|
-
context 'when referrer page is present' do
|
195
|
-
before { request.env['HTTP_REFERER'] = 'where_i_came_from' }
|
196
|
-
|
197
|
-
it 'should redirect to previous page with success message' do
|
198
|
-
post :send_payment_request, id: order.to_param
|
199
|
-
|
200
|
-
expect(response).to be_redirect
|
201
|
-
expect(response).to redirect_to 'where_i_came_from'
|
202
|
-
expect(flash[:success]).to eq 'Successfully sent payment request to user@example.com'
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
context 'when referrer page is not present' do
|
207
|
-
it 'should redirect to admin order show page with success message' do
|
208
|
-
post :send_payment_request, id: order.to_param
|
209
|
-
|
210
|
-
expect(response).to be_redirect
|
211
|
-
expect(response).to redirect_to EffectiveOrders::Engine.routes.url_helpers.admin_order_path(order)
|
212
|
-
expect(flash[:success]).to eq 'Successfully sent payment request to user@example.com'
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
context 'when failed' do
|
218
|
-
before { Effective::Order.any_instance.should_receive(:send_payment_request_to_buyer!).once.and_return(false) }
|
219
|
-
|
220
|
-
context 'when referrer page is present' do
|
221
|
-
before { request.env['HTTP_REFERER'] = 'where_i_came_from' }
|
222
|
-
|
223
|
-
it 'should redirect to previous page with danger message' do
|
224
|
-
post :send_payment_request, id: order.to_param
|
225
|
-
|
226
|
-
expect(response).to be_redirect
|
227
|
-
expect(response).to redirect_to 'where_i_came_from'
|
228
|
-
expect(flash[:danger]).to eq 'Unable to send payment request'
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
context 'when referrer page is not present' do
|
233
|
-
it 'should redirect to admin order show page with danger message' do
|
234
|
-
post :send_payment_request, id: order.to_param
|
235
|
-
|
236
|
-
expect(response).to be_redirect
|
237
|
-
expect(response).to redirect_to EffectiveOrders::Engine.routes.url_helpers.admin_order_path(order)
|
238
|
-
expect(flash[:danger]).to eq 'Unable to send payment request'
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|