solidus_frontend 1.2.3 → 1.3.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_frontend might be problematic. Click here for more details.

Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/Rakefile +1 -1
  4. data/app/assets/javascripts/spree/frontend/checkout/address.js.coffee +0 -2
  5. data/app/assets/stylesheets/spree/frontend.css +1 -2
  6. data/app/assets/stylesheets/spree/frontend/_skeleton.scss +242 -0
  7. data/app/assets/stylesheets/spree/frontend/screen.css.scss +1 -0
  8. data/app/controllers/spree/checkout_controller.rb +93 -93
  9. data/app/controllers/spree/content_controller.rb +1 -1
  10. data/app/controllers/spree/orders_controller.rb +15 -16
  11. data/app/controllers/spree/products_controller.rb +19 -18
  12. data/app/controllers/spree/store_controller.rb +27 -27
  13. data/app/controllers/spree/taxons_controller.rb +1 -2
  14. data/app/models/spree/frontend_configuration.rb +1 -1
  15. data/app/views/spree/address/_form.html.erb +18 -12
  16. data/app/views/spree/orders/show.html.erb +2 -2
  17. data/app/views/spree/products/_cart_form.html.erb +5 -5
  18. data/app/views/spree/products/show.html.erb +1 -1
  19. data/app/views/spree/shared/_google_analytics.html.erb +1 -1
  20. data/app/views/spree/shared/_order_details.html.erb +12 -11
  21. data/app/views/spree/shared/_products.html.erb +2 -2
  22. data/config/initializers/assets.rb +8 -1
  23. data/config/initializers/canonical_rails.rb +1 -2
  24. data/config/routes.rb +17 -18
  25. data/lib/spree/frontend.rb +1 -0
  26. data/lib/spree/frontend/engine.rb +1 -9
  27. data/lib/spree/frontend/middleware/seo_assist.rb +3 -4
  28. data/lib/tasks/rake_util.rb +3 -6
  29. data/lib/tasks/taxon.rake +3 -3
  30. data/script/rails +0 -1
  31. data/solidus_frontend.gemspec +1 -0
  32. data/spec/controllers/controller_extension_spec.rb +15 -15
  33. data/spec/controllers/controller_helpers_spec.rb +1 -2
  34. data/spec/controllers/spree/checkout_controller_spec.rb +67 -115
  35. data/spec/controllers/spree/content_controller_spec.rb +1 -1
  36. data/spec/controllers/spree/current_order_tracking_spec.rb +7 -6
  37. data/spec/controllers/spree/home_controller_spec.rb +3 -3
  38. data/spec/controllers/spree/orders_controller_ability_spec.rb +17 -16
  39. data/spec/controllers/spree/orders_controller_spec.rb +9 -8
  40. data/spec/controllers/spree/orders_controller_transitions_spec.rb +5 -5
  41. data/spec/controllers/spree/products_controller_spec.rb +10 -11
  42. data/spec/controllers/spree/taxons_controller_spec.rb +5 -5
  43. data/spec/features/address_spec.rb +15 -15
  44. data/spec/features/automatic_promotion_adjustments_spec.rb +18 -18
  45. data/spec/features/caching/products_spec.rb +2 -2
  46. data/spec/features/caching/taxons_spec.rb +2 -2
  47. data/spec/features/cart_spec.rb +8 -6
  48. data/spec/features/checkout_spec.rb +49 -51
  49. data/spec/features/checkout_unshippable_spec.rb +4 -5
  50. data/spec/features/coupon_code_spec.rb +28 -30
  51. data/spec/features/currency_spec.rb +3 -3
  52. data/spec/features/free_shipping_promotions_spec.rb +17 -17
  53. data/spec/features/locale_spec.rb +33 -24
  54. data/spec/features/order_spec.rb +4 -4
  55. data/spec/features/products_spec.rb +12 -12
  56. data/spec/features/promotion_code_invalidation_spec.rb +1 -0
  57. data/spec/features/quantity_promotions_spec.rb +1 -1
  58. data/spec/features/taxons_spec.rb +16 -16
  59. data/spec/features/template_rendering_spec.rb +1 -2
  60. data/spec/helpers/base_helper_spec.rb +2 -2
  61. data/spec/spec_helper.rb +5 -5
  62. data/spec/support/shared_contexts/checkout_setup.rb +1 -0
  63. data/spec/support/shared_contexts/custom_products.rb +18 -17
  64. data/spec/support/shared_contexts/product_prototypes.rb +3 -5
  65. data/spec/views/spree/checkout/_summary_spec.rb +2 -2
  66. metadata +24 -9
@@ -3,6 +3,7 @@ require 'jquery-rails'
3
3
  require 'canonical-rails'
4
4
  require 'coffee-rails'
5
5
  require 'sass-rails'
6
+ require 'font-awesome-rails'
6
7
 
7
8
  require 'spree/core'
8
9
 
@@ -3,15 +3,7 @@ module Spree
3
3
  class Engine < ::Rails::Engine
4
4
  config.middleware.use "Spree::Frontend::Middleware::SeoAssist"
5
5
 
6
- # sets the manifests / assets to be precompiled, even when initialize_on_precompile is false
7
- initializer "spree.assets.precompile", :group => :all do |app|
8
- app.config.assets.precompile += %w[
9
- spree/frontend/all*
10
- jquery.validate/localization/messages_*
11
- ]
12
- end
13
-
14
- initializer "spree.frontend.environment", :before => :load_config_initializers do |app|
6
+ initializer "spree.frontend.environment", before: :load_config_initializers do |_app|
15
7
  Spree::Frontend::Config = Spree::FrontendConfiguration.new
16
8
  end
17
9
  end
@@ -13,13 +13,13 @@ module Spree
13
13
 
14
14
  taxon_id = params['taxon']
15
15
 
16
- #redirect requests using taxon id's to their permalinks
16
+ # redirect requests using taxon id's to their permalinks
17
17
  if !taxon_id.blank? && !taxon_id.is_a?(Hash) && taxon = Taxon.find(taxon_id)
18
18
  params.delete('taxon')
19
19
 
20
20
  return build_response(params, "#{request.script_name}t/#{taxon.permalink}" )
21
21
  elsif env["PATH_INFO"] =~ /^\/(t|products)(\/\S+)?\/$/
22
- #ensures no trailing / for taxon and product urls
22
+ # ensures no trailing / for taxon and product urls
23
23
 
24
24
  return build_response(params, env["PATH_INFO"][0...-1])
25
25
  end
@@ -32,7 +32,7 @@ module Spree
32
32
  def build_response(params, location)
33
33
  query = build_query(params)
34
34
  location += '?' + query unless query.blank?
35
- [301, { 'Location'=> location }, []]
35
+ [301, { 'Location' => location }, []]
36
36
  end
37
37
 
38
38
  def build_query(params)
@@ -44,7 +44,6 @@ module Spree
44
44
  end
45
45
  }.join("&")
46
46
  end
47
-
48
47
  end
49
48
  end
50
49
  end
@@ -1,19 +1,16 @@
1
1
  class RakeUtil
2
-
3
2
  def self.add_marker(msg)
4
- puts "#"*30 + " #{msg} " + '#'*30
3
+ puts "#" * 30 + " #{msg} " + '#' * 30
5
4
  end
6
5
 
7
6
  def self.warning(msg)
8
- puts "#"*50
7
+ puts "#" * 50
9
8
  puts msg
10
- puts "#"*50
9
+ puts "#" * 50
11
10
  end
12
11
 
13
12
  def self.execute(cmd)
14
13
  puts cmd
15
14
  system cmd
16
15
  end
17
-
18
16
  end
19
-
data/lib/tasks/taxon.rake CHANGED
@@ -1,7 +1,7 @@
1
1
  namespace :spree do
2
2
  desc "Resets all taxon permalinks"
3
- task :reset_taxon_permalinks => :environment do
4
- Spree::Taxon.where(:parent_id => nil).each {|taxon| redo_permalinks(taxon) }
3
+ task reset_taxon_permalinks: :environment do
4
+ Spree::Taxon.where(parent_id: nil).each { |taxon| redo_permalinks(taxon) }
5
5
  end
6
6
 
7
7
  def redo_permalinks(taxon)
@@ -11,4 +11,4 @@ namespace :spree do
11
11
 
12
12
  taxon.children.each { |t| redo_permalinks(t) }
13
13
  end
14
- end
14
+ end
data/script/rails CHANGED
@@ -6,4 +6,3 @@ ENGINE_PATH = File.expand_path('../../lib/spree/frontend/engine', __FILE__)
6
6
 
7
7
  require 'rails/all'
8
8
  require 'rails/engine/commands'
9
-
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  s.add_dependency 'jquery-rails'
26
26
  s.add_dependency 'sass-rails'
27
27
  s.add_dependency 'coffee-rails'
28
+ s.add_dependency 'font-awesome-rails', '~> 4.0'
28
29
 
29
30
  s.add_development_dependency 'capybara-accessible'
30
31
  end
@@ -6,7 +6,7 @@ require 'spec_helper'
6
6
  class Spree::CustomController < Spree::BaseController
7
7
  def index
8
8
  respond_with(Spree::Address.new) do |format|
9
- format.html { render :text => "neutral" }
9
+ format.html { render text: "neutral" }
10
10
  end
11
11
  end
12
12
 
@@ -18,7 +18,7 @@ class Spree::CustomController < Spree::BaseController
18
18
  end
19
19
  end
20
20
 
21
- describe Spree::CustomController, :type => :controller do
21
+ describe Spree::CustomController, type: :controller do
22
22
  after do
23
23
  Spree::CustomController.clear_overrides!
24
24
  end
@@ -37,12 +37,12 @@ describe Spree::CustomController, :type => :controller do
37
37
  context "specify symbol for handler instead of Proc" do
38
38
  before do
39
39
  Spree::CustomController.class_eval do
40
- respond_override({:index => {:html => {:success => :success_method}}})
40
+ respond_override({ index: { html: { success: :success_method } } })
41
41
 
42
42
  private
43
43
 
44
44
  def success_method
45
- render :text => 'success!!!'
45
+ render text: 'success!!!'
46
46
  end
47
47
  end
48
48
  end
@@ -51,7 +51,7 @@ describe Spree::CustomController, :type => :controller do
51
51
  it "has value success" do
52
52
  spree_get :index
53
53
  expect(response).to be_success
54
- assert (response.body =~ /success!!!/)
54
+ expect(response.body).to match(/success!!!/)
55
55
  end
56
56
  end
57
57
  end
@@ -59,8 +59,8 @@ describe Spree::CustomController, :type => :controller do
59
59
  context "render" do
60
60
  before do
61
61
  Spree::CustomController.instance_eval do
62
- respond_override({:index => {:html => {:success => lambda { render(:text => 'success!!!') }}}})
63
- respond_override({:index => {:html => {:failure => lambda { render(:text => 'failure!!!') }}}})
62
+ respond_override({ index: { html: { success: lambda { render(text: 'success!!!') } } } })
63
+ respond_override({ index: { html: { failure: lambda { render(text: 'failure!!!') } } } })
64
64
  end
65
65
  end
66
66
 
@@ -68,7 +68,7 @@ describe Spree::CustomController, :type => :controller do
68
68
  it "has value success" do
69
69
  spree_get :index
70
70
  expect(response).to be_success
71
- assert (response.body =~ /success!!!/)
71
+ expect(response.body).to match(/success!!!/)
72
72
  end
73
73
  end
74
74
  end
@@ -76,8 +76,8 @@ describe Spree::CustomController, :type => :controller do
76
76
  context "redirect" do
77
77
  before do
78
78
  Spree::CustomController.instance_eval do
79
- respond_override({:index => {:html => {:success => lambda { redirect_to('/cart') }}}})
80
- respond_override({:index => {:html => {:failure => lambda { render(:text => 'failure!!!') }}}})
79
+ respond_override({ index: { html: { success: lambda { redirect_to('/cart') } } } })
80
+ respond_override({ index: { html: { failure: lambda { render(text: 'failure!!!') } } } })
81
81
  end
82
82
  end
83
83
 
@@ -93,8 +93,8 @@ describe Spree::CustomController, :type => :controller do
93
93
  before do
94
94
  Spree::CustomController.instance_eval do
95
95
  respond_to :html
96
- respond_override({:create => {:html => {:success => lambda { render(:text => 'success!!!') }}}})
97
- respond_override({:create => {:html => {:failure => lambda { render(:text => 'failure!!!') }}}})
96
+ respond_override({ create: { html: { success: lambda { render(text: 'success!!!') } } } })
97
+ respond_override({ create: { html: { failure: lambda { render(text: 'failure!!!') } } } })
98
98
  end
99
99
  end
100
100
 
@@ -102,7 +102,7 @@ describe Spree::CustomController, :type => :controller do
102
102
  it "has value success" do
103
103
  spree_post :create
104
104
  expect(response).to be_success
105
- assert (response.body =~ /success!/)
105
+ expect(response.body).to match(/success!/)
106
106
  end
107
107
  end
108
108
  end
@@ -110,14 +110,14 @@ describe Spree::CustomController, :type => :controller do
110
110
  context 'A different controllers respond_override. Regression test for #1301' do
111
111
  before do
112
112
  Spree::CheckoutController.instance_eval do
113
- respond_override({:index => {:html => {:success => lambda { render(:text => 'success!!!') }}}})
113
+ respond_override({ index: { html: { success: lambda { render(text: 'success!!!') } } } })
114
114
  end
115
115
  end
116
116
 
117
117
  describe "POST" do
118
118
  it "should not effect the wrong controller" do
119
119
  spree_get :index
120
- assert (response.body =~ /neutral/)
120
+ expect(response.body).to match(/neutral/)
121
121
  end
122
122
  end
123
123
  end
@@ -3,8 +3,7 @@ require 'spec_helper'
3
3
  # In this file, we want to test that the controller helpers function correctly
4
4
  # So we need to use one of the controllers inside Spree.
5
5
  # ProductsController is good.
6
- describe Spree::ProductsController, :type => :controller do
7
-
6
+ describe Spree::ProductsController, type: :controller do
8
7
  before do
9
8
  I18n.enforce_available_locales = false
10
9
  Spree::Frontend::Config[:locale] = :de
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Spree::CheckoutController, :type => :controller do
3
+ describe Spree::CheckoutController, type: :controller do
4
4
  let(:token) { 'some_token' }
5
5
  let(:user) { stub_model(Spree::LegacyUser) }
6
6
  let(:order) { FactoryGirl.create(:order_with_totals) }
@@ -24,27 +24,27 @@ describe Spree::CheckoutController, :type => :controller do
24
24
  end
25
25
 
26
26
  it "should redirect to the cart path unless checkout_allowed?" do
27
- allow(order).to receive_messages :checkout_allowed? => false
28
- spree_get :edit, { :state => "delivery" }
27
+ allow(order).to receive_messages checkout_allowed?: false
28
+ spree_get :edit, { state: "delivery" }
29
29
  expect(response).to redirect_to(spree.cart_path)
30
30
  end
31
31
 
32
32
  it "should redirect to the cart path if current_order is nil" do
33
33
  allow(controller).to receive(:current_order).and_return(nil)
34
- spree_get :edit, { :state => "delivery" }
34
+ spree_get :edit, { state: "delivery" }
35
35
  expect(response).to redirect_to(spree.cart_path)
36
36
  end
37
37
 
38
38
  it "should redirect to cart if order is completed" do
39
- allow(order).to receive_messages(:completed? => true)
40
- spree_get :edit, { :state => "address" }
39
+ allow(order).to receive_messages(completed?: true)
40
+ spree_get :edit, { state: "address" }
41
41
  expect(response).to redirect_to(spree.cart_path)
42
42
  end
43
43
 
44
44
  # Regression test for https://github.com/spree/spree/issues/2280
45
45
  it "should redirect to current step trying to access a future step" do
46
46
  order.update_column(:state, "address")
47
- spree_get :edit, { :state => "delivery" }
47
+ spree_get :edit, { state: "delivery" }
48
48
  expect(response).to redirect_to spree.checkout_state_path("address")
49
49
  end
50
50
 
@@ -73,17 +73,18 @@ describe Spree::CheckoutController, :type => :controller do
73
73
  context "save successful" do
74
74
  def spree_post_address
75
75
  spree_post :update, {
76
- :state => "address",
77
- :order => {
78
- :bill_address_attributes => address_params,
79
- :use_billing => true
76
+ state: "address",
77
+ order: {
78
+ bill_address_attributes: address_params,
79
+ use_billing: true
80
80
  }
81
81
  }
82
82
  end
83
83
 
84
- let!(:payment_method) { create(:payment_method) }
85
84
  before do
86
85
  # Must have *a* shipping method and a payment method so updating from address works
86
+ allow(order).to receive_messages available_shipping_methods: [stub_model(Spree::ShippingMethod)]
87
+ allow(order).to receive_messages available_payment_methods: [stub_model(Spree::PaymentMethod)]
87
88
  allow(order).to receive_messages ensure_available_shipping_rates: true
88
89
  order.line_items << FactoryGirl.create(:line_item)
89
90
  end
@@ -95,7 +96,7 @@ describe Spree::CheckoutController, :type => :controller do
95
96
  end
96
97
 
97
98
  it "should assign order" do
98
- spree_post :update, {:state => "address"}
99
+ spree_post :update, { state: "address" }
99
100
  expect(assigns[:order]).not_to be_nil
100
101
  end
101
102
 
@@ -113,12 +114,12 @@ describe Spree::CheckoutController, :type => :controller do
113
114
  it "calls persist order address on user" do
114
115
  expect(user).to receive(:persist_order_address)
115
116
  spree_post :update, {
116
- :state => "address",
117
- :order => {
118
- :bill_address_attributes => address_params,
119
- :use_billing => true
117
+ state: "address",
118
+ order: {
119
+ bill_address_attributes: address_params,
120
+ use_billing: true
120
121
  },
121
- :save_user_address => "1"
122
+ save_user_address: "1"
122
123
  }
123
124
  end
124
125
  end
@@ -126,12 +127,12 @@ describe Spree::CheckoutController, :type => :controller do
126
127
  context "current_user doesnt respond to persist_order_address" do
127
128
  it "doesnt raise any error" do
128
129
  spree_post :update, {
129
- :state => "address",
130
- :order => {
131
- :bill_address_attributes => address_params,
132
- :use_billing => true
130
+ state: "address",
131
+ order: {
132
+ bill_address_attributes: address_params,
133
+ use_billing: true
133
134
  },
134
- :save_user_address => "1"
135
+ save_user_address: "1"
135
136
  }
136
137
  end
137
138
  end
@@ -149,11 +150,11 @@ describe Spree::CheckoutController, :type => :controller do
149
150
  @expected_ship_address_id = order.ship_address.id
150
151
 
151
152
  spree_post :update, {
152
- :state => "address",
153
- :order => {
154
- :bill_address_attributes => order.bill_address.attributes.except("created_at", "updated_at"),
155
- :ship_address_attributes => order.ship_address.attributes.except("created_at", "updated_at"),
156
- :use_billing => false
153
+ state: "address",
154
+ order: {
155
+ bill_address_attributes: order.bill_address.attributes.except("created_at", "updated_at"),
156
+ ship_address_attributes: order.ship_address.attributes.except("created_at", "updated_at"),
157
+ use_billing: false
157
158
  }
158
159
  }
159
160
 
@@ -195,10 +196,10 @@ describe Spree::CheckoutController, :type => :controller do
195
196
  payments_attributes: [
196
197
  {
197
198
  payment_method_id: payment_method.id.to_s,
198
- source_attributes: attributes_for(:credit_card),
199
- },
200
- ],
201
- },
199
+ source_attributes: attributes_for(:credit_card)
200
+ }
201
+ ]
202
+ }
202
203
  }
203
204
  end
204
205
 
@@ -216,77 +217,30 @@ describe Spree::CheckoutController, :type => :controller do
216
217
  end
217
218
  end
218
219
 
219
- context "when in the payment state" do
220
- let(:order) { create(:order_with_line_items) }
221
- let(:payment_method) { create(:credit_card_payment_method) }
222
-
223
- let(:params) do
224
- {
225
- state: 'payment',
226
- order: {
227
- payments_attributes: [
228
- {
229
- payment_method_id: payment_method.id.to_s,
230
- source_attributes: attributes_for(:credit_card)
231
- }
232
- ]
233
- }
234
- }
235
- end
236
-
237
- before do
238
- order.update_attributes! user: user
239
- 3.times { order.next! } # should put us in the payment state
240
- end
241
-
242
- context 'with a permitted payment method' do
243
- it 'sets the payment amount' do
244
- post :update, params
245
- order.reload
246
- expect(order.state).to eq('confirm')
247
- expect(order.payments.size).to eq(1)
248
- expect(order.payments.first.amount).to eq(order.total)
249
- end
250
- end
251
-
252
- context 'with an unpermitted payment method' do
253
- before { payment_method.update!(display_on: "back_end") }
254
-
255
- it 'sets the payment amount' do
256
- expect {
257
- post :update, params
258
- }.to raise_error(ActiveRecord::RecordNotFound)
259
-
260
- expect(order.state).to eq('payment')
261
- expect(order.payments).to be_empty
262
- end
263
- end
264
- end
265
-
266
220
  context "when in the confirm state" do
267
221
  before do
268
222
  order.update_attributes! user: user
269
223
  order.update_column(:state, "confirm")
270
224
  # An order requires a payment to reach the complete state
271
225
  # This is because payment_required? is true on the order
272
- create(:payment, :amount => order.total, :order => order)
226
+ create(:payment, amount: order.total, order: order)
273
227
  order.create_proposed_shipments
274
228
  order.payments.reload
275
229
  end
276
230
 
277
231
  # This inadvertently is a regression test for https://github.com/spree/spree/issues/2694
278
232
  it "should redirect to the order view" do
279
- spree_post :update, {:state => "confirm"}
233
+ spree_post :update, { state: "confirm" }
280
234
  expect(response).to redirect_to spree.order_path(order)
281
235
  end
282
236
 
283
237
  it "should populate the flash message" do
284
- spree_post :update, {:state => "confirm"}
238
+ spree_post :update, { state: "confirm" }
285
239
  expect(flash.notice).to eq(Spree.t(:order_processed_successfully))
286
240
  end
287
241
 
288
242
  it "should remove completed order from current_order" do
289
- spree_post :update, {:state => "confirm"}, {:order_id => "foofah"}
243
+ spree_post :update, { state: "confirm" }, { order_id: "foofah" }
290
244
  expect(assigns(:current_order)).to be_nil
291
245
  expect(assigns(:order)).to eql controller.current_order
292
246
  end
@@ -300,30 +254,30 @@ describe Spree::CheckoutController, :type => :controller do
300
254
  end
301
255
 
302
256
  it "should not assign order" do
303
- spree_post :update, {:state => "address", email: ''}
257
+ spree_post :update, { state: "address", email: '' }
304
258
  expect(assigns[:order]).not_to be_nil
305
259
  end
306
260
 
307
261
  it "should not change the order state" do
308
- spree_post :update, { :state => 'address' }
262
+ spree_post :update, { state: 'address' }
309
263
  end
310
264
 
311
265
  it "should render the edit template" do
312
- spree_post :update, { :state => 'address' }
266
+ spree_post :update, { state: 'address' }
313
267
  expect(response).to render_template :edit
314
268
  end
315
269
  end
316
270
 
317
271
  context "when current_order is nil" do
318
- before { allow(controller).to receive_messages :current_order => nil }
272
+ before { allow(controller).to receive_messages current_order: nil }
319
273
 
320
274
  it "should not change the state if order is completed" do
321
275
  expect(order).not_to receive(:update_attribute)
322
- spree_post :update, {:state => "confirm"}
276
+ spree_post :update, { state: "confirm" }
323
277
  end
324
278
 
325
279
  it "should redirect to the cart_path" do
326
- spree_post :update, {:state => "confirm"}
280
+ spree_post :update, { state: "confirm" }
327
281
  expect(response).to redirect_to spree.cart_path
328
282
  end
329
283
  end
@@ -332,7 +286,7 @@ describe Spree::CheckoutController, :type => :controller do
332
286
  before do
333
287
  order.update_attributes! user: user
334
288
  allow(order).to receive(:next).and_raise(Spree::Core::GatewayError.new("Invalid something or other."))
335
- spree_post :update, {:state => "address"}
289
+ spree_post :update, { state: "address" }
336
290
  end
337
291
 
338
292
  it "should render the edit template and display exception message" do
@@ -351,19 +305,19 @@ describe Spree::CheckoutController, :type => :controller do
351
305
  end
352
306
 
353
307
  before do
354
- allow(controller).to receive_messages :current_order => order
355
- allow(controller).to receive_messages :check_authorization => true
308
+ allow(controller).to receive_messages current_order: order
309
+ allow(controller).to receive_messages check_authorization: true
356
310
  end
357
311
 
358
312
  context "when the order is invalid" do
359
313
  before do
360
- allow(order).to receive_messages :valid? => true, :next => nil
314
+ allow(order).to receive_messages valid?: true, next: nil
361
315
  order.errors.add :base, 'Base error'
362
316
  order.errors.add :adjustments, 'error'
363
317
  end
364
318
 
365
319
  it "due to the order having errors" do
366
- spree_put :update, :state => order.state, :order => {}
320
+ spree_put :update, state: order.state, order: {}
367
321
  expect(flash[:error]).to eq("Base error\nAdjustments error")
368
322
  expect(response).to redirect_to(spree.checkout_state_path('address'))
369
323
  end
@@ -372,14 +326,12 @@ describe Spree::CheckoutController, :type => :controller do
372
326
 
373
327
  context "fails to transition to complete from confirm" do
374
328
  let(:order) do
375
- FactoryGirl.create(:order_with_line_items).tap do |order|
376
- order.next!
377
- end
329
+ FactoryGirl.create(:order_with_line_items).tap(&:next!)
378
330
  end
379
331
 
380
332
  before do
381
- allow(controller).to receive_messages :current_order => order
382
- allow(controller).to receive_messages :check_authorization => true
333
+ allow(controller).to receive_messages current_order: order
334
+ allow(controller).to receive_messages check_authorization: true
383
335
  end
384
336
 
385
337
  context "when the country is not a shippable country" do
@@ -392,7 +344,7 @@ describe Spree::CheckoutController, :type => :controller do
392
344
  end
393
345
 
394
346
  payment_method = FactoryGirl.create(:simple_credit_card_payment_method)
395
- payment = FactoryGirl.create(:payment, :payment_method => payment_method)
347
+ payment = FactoryGirl.create(:payment, payment_method: payment_method)
396
348
  order.payments << payment
397
349
  end
398
350
 
@@ -400,7 +352,7 @@ describe Spree::CheckoutController, :type => :controller do
400
352
  expect(order.shipments.count).to eq(1)
401
353
  order.shipments.first.shipping_rates.delete_all
402
354
  order.update_attributes(state: 'confirm')
403
- spree_put :update, state: order.state, :order => {}
355
+ spree_put :update, state: order.state, order: {}
404
356
  expect(flash[:error]).to eq(Spree.t(:items_cannot_be_shipped))
405
357
  expect(response).to redirect_to(spree.checkout_state_path('confirm'))
406
358
  end
@@ -422,26 +374,26 @@ describe Spree::CheckoutController, :type => :controller do
422
374
  end
423
375
 
424
376
  before do
425
- allow(controller).to receive_messages :current_order => order
426
- allow(controller).to receive_messages :check_authorization => true
377
+ allow(controller).to receive_messages current_order: order
378
+ allow(controller).to receive_messages check_authorization: true
427
379
  end
428
380
 
429
381
  it "fails to transition from payment to complete" do
430
382
  allow_any_instance_of(Spree::Payment).to receive(:process!).and_raise(Spree::Core::GatewayError.new(Spree.t(:payment_processing_failed)))
431
- spree_put :update, state: order.state, :order => {}
383
+ spree_put :update, state: order.state, order: {}
432
384
  expect(flash[:error]).to eq(Spree.t(:payment_processing_failed))
433
385
  end
434
386
  end
435
387
  end
436
388
 
437
389
  context "When last inventory item has been purchased" do
438
- let(:product) { mock_model(Spree::Product, :name => "Amazing Object") }
390
+ let(:product) { mock_model(Spree::Product, name: "Amazing Object") }
439
391
  let(:variant) { mock_model(Spree::Variant) }
440
- let(:line_item) { mock_model Spree::LineItem, :insufficient_stock? => true, :amount => 0 }
392
+ let(:line_item) { mock_model Spree::LineItem, insufficient_stock?: true, amount: 0 }
441
393
  let(:order) { create(:order) }
442
394
 
443
395
  before do
444
- allow(order).to receive_messages(:line_items => [line_item], :state => "payment")
396
+ allow(order).to receive_messages(line_items: [line_item], state: "payment")
445
397
 
446
398
  configure_spree_preferences do |config|
447
399
  config.track_inventory_levels = true
@@ -450,7 +402,7 @@ describe Spree::CheckoutController, :type => :controller do
450
402
 
451
403
  context "and back orders are not allowed" do
452
404
  before do
453
- spree_post :update, { :state => "payment" }
405
+ spree_post :update, { state: "payment" }
454
406
  end
455
407
 
456
408
  it "should redirect to cart" do
@@ -458,16 +410,16 @@ describe Spree::CheckoutController, :type => :controller do
458
410
  end
459
411
 
460
412
  it "should set flash message for no inventory" do
461
- expect(flash[:error]).to eq(Spree.t(:inventory_error_flash_for_insufficient_quantity , :names => "'#{product.name}'" ))
413
+ expect(flash[:error]).to eq(Spree.t(:inventory_error_flash_for_insufficient_quantity, names: "'#{product.name}'" ))
462
414
  end
463
415
  end
464
416
  end
465
417
 
466
418
  context "order doesn't have a delivery step" do
467
419
  before do
468
- allow(order).to receive_messages(:checkout_steps => ["cart", "address", "payment"])
420
+ allow(order).to receive_messages(checkout_steps: ["cart", "address", "payment"])
469
421
  allow(order).to receive_messages state: "address"
470
- allow(controller).to receive_messages :check_authorization => true
422
+ allow(controller).to receive_messages check_authorization: true
471
423
  end
472
424
 
473
425
  it "doesn't set shipping address on the order" do
@@ -477,17 +429,17 @@ describe Spree::CheckoutController, :type => :controller do
477
429
 
478
430
  it "doesn't remove unshippable items before payment" do
479
431
  expect {
480
- spree_post :update, { :state => "payment" }
432
+ spree_post :update, { state: "payment" }
481
433
  }.to_not change { order.line_items }
482
434
  end
483
435
  end
484
436
 
485
437
  it "does remove unshippable items before payment" do
486
- allow(order).to receive_messages :payment_required? => true
487
- allow(controller).to receive_messages :check_authorization => true
438
+ allow(order).to receive_messages payment_required?: true
439
+ allow(controller).to receive_messages check_authorization: true
488
440
 
489
441
  expect {
490
- spree_post :update, { :state => "payment" }
442
+ spree_post :update, { state: "payment" }
491
443
  }.to change { order.line_items }
492
444
  end
493
445
  end