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
@@ -1,5 +1,5 @@
1
1
  require 'spec_helper'
2
- describe Spree::ContentController, :type => :controller do
2
+ describe Spree::ContentController, type: :controller do
3
3
  it "should display CVV page" do
4
4
  spree_get :cvv
5
5
  expect(response.response_code).to eq(200)
@@ -1,25 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe 'current order tracking', :type => :controller do
3
+ describe 'current order tracking', type: :controller do
4
+ let!(:store) { create(:store) }
4
5
  let(:user) { create(:user) }
5
6
 
6
7
  controller(Spree::StoreController) do
7
8
  def index
8
- render :nothing => true
9
+ render nothing: true
9
10
  end
10
11
  end
11
12
 
12
13
  let(:order) { FactoryGirl.create(:order) }
13
14
 
14
15
  it 'automatically tracks who the order was created by & IP address' do
15
- allow(controller).to receive_messages(:try_spree_current_user => user)
16
+ allow(controller).to receive_messages(try_spree_current_user: user)
16
17
  get :index
17
18
  expect(controller.current_order(create_order_if_necessary: true).created_by).to eq controller.try_spree_current_user
18
19
  expect(controller.current_order.last_ip_address).to eq "0.0.0.0"
19
20
  end
20
21
 
21
22
  context "current order creation" do
22
- before { allow(controller).to receive_messages(:try_spree_current_user => user) }
23
+ before { allow(controller).to receive_messages(try_spree_current_user: user) }
23
24
 
24
25
  it "doesn't create a new order out of the blue" do
25
26
  expect {
@@ -29,10 +30,10 @@ describe 'current order tracking', :type => :controller do
29
30
  end
30
31
  end
31
32
 
32
- describe Spree::OrdersController, :type => :controller do
33
+ describe Spree::OrdersController, type: :controller do
33
34
  let(:user) { create(:user) }
34
35
 
35
- before { allow(controller).to receive_messages(:try_spree_current_user => user) }
36
+ before { allow(controller).to receive_messages(try_spree_current_user: user) }
36
37
 
37
38
  describe Spree::OrdersController do
38
39
  it "doesn't create a new order out of the blue" do
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Spree::HomeController, :type => :controller do
3
+ describe Spree::HomeController, type: :controller do
4
4
  it "provides current user to the searcher class" do
5
- user = mock_model(Spree.user_class, :last_incomplete_spree_order => nil, :spree_api_key => 'fake')
6
- allow(controller).to receive_messages :try_spree_current_user => user
5
+ user = mock_model(Spree.user_class, last_incomplete_spree_order: nil, spree_api_key: 'fake')
6
+ allow(controller).to receive_messages try_spree_current_user: user
7
7
  expect_any_instance_of(Spree::Config.searcher_class).to receive(:current_user=).with(user)
8
8
  spree_get :index
9
9
  expect(response.status).to eq(200)
@@ -1,9 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe OrdersController, :type => :controller do
4
+ describe OrdersController, type: :controller do
5
5
  ORDER_TOKEN = 'ORDER_TOKEN'
6
6
 
7
+ let!(:store) { create(:store) }
7
8
  let(:user) { create(:user) }
8
9
  let(:guest_user) { create(:user) }
9
10
  let(:order) { Spree::Order.create }
@@ -17,29 +18,29 @@ module Spree
17
18
  let(:specified_order) { create(:order) }
18
19
 
19
20
  before do
20
- allow(controller).to receive_messages :current_order => order
21
- allow(controller).to receive_messages :spree_current_user => user
21
+ allow(controller).to receive_messages current_order: order
22
+ allow(controller).to receive_messages spree_current_user: user
22
23
  end
23
24
 
24
25
  context '#populate' do
25
26
  it 'should check if user is authorized for :edit' do
26
27
  expect(controller).to receive(:authorize!).with(:edit, order, token)
27
- spree_post :populate, :token => token
28
+ spree_post :populate, token: token
28
29
  end
29
30
  it "should check against the specified order" do
30
31
  expect(controller).to receive(:authorize!).with(:edit, specified_order, token)
31
- spree_post :populate, :id => specified_order.number, :token => token
32
+ spree_post :populate, id: specified_order.number, token: token
32
33
  end
33
34
  end
34
35
 
35
36
  context '#edit' do
36
37
  it 'should check if user is authorized for :edit' do
37
38
  expect(controller).to receive(:authorize!).with(:edit, order, token)
38
- spree_get :edit, :token => token
39
+ spree_get :edit, token: token
39
40
  end
40
41
  it "should check against the specified order" do
41
42
  expect(controller).to receive(:authorize!).with(:edit, specified_order, token)
42
- spree_get :edit, :id => specified_order.number, :token => token
43
+ spree_get :edit, id: specified_order.number, token: token
43
44
  end
44
45
  end
45
46
 
@@ -47,54 +48,54 @@ module Spree
47
48
  it 'should check if user is authorized for :edit' do
48
49
  allow(order).to receive :update_attributes
49
50
  expect(controller).to receive(:authorize!).with(:edit, order, token)
50
- spree_post :update, :order => { :email => "foo@bar.com" }, :token => token
51
+ spree_post :update, order: { email: "foo@bar.com" }, token: token
51
52
  end
52
53
  it "should check against the specified order" do
53
54
  allow(order).to receive :update_attributes
54
55
  expect(controller).to receive(:authorize!).with(:edit, specified_order, token)
55
- spree_post :update, :order => { :email => "foo@bar.com" }, :id => specified_order.number, :token => token
56
+ spree_post :update, order: { email: "foo@bar.com" }, id: specified_order.number, token: token
56
57
  end
57
58
  end
58
59
 
59
60
  context '#empty' do
60
61
  it 'should check if user is authorized for :edit' do
61
62
  expect(controller).to receive(:authorize!).with(:edit, order, token)
62
- spree_post :empty, :token => token
63
+ spree_post :empty, token: token
63
64
  end
64
65
  it "should check against the specified order" do
65
66
  expect(controller).to receive(:authorize!).with(:edit, specified_order, token)
66
- spree_post :empty, :id => specified_order.number, :token => token
67
+ spree_post :empty, id: specified_order.number, token: token
67
68
  end
68
69
  end
69
70
 
70
71
  context "#show" do
71
72
  it "should check against the specified order" do
72
73
  expect(controller).to receive(:authorize!).with(:edit, specified_order, token)
73
- spree_get :show, :id => specified_order.number, :token => token
74
+ spree_get :show, id: specified_order.number, token: token
74
75
  end
75
76
  end
76
77
  end
77
78
 
78
79
  context 'when no authenticated user' do
79
- let(:order) { create(:order, :number => 'R123') }
80
+ let(:order) { create(:order, number: 'R123') }
80
81
 
81
82
  context '#show' do
82
83
  context 'when token parameter present' do
83
84
  it 'always ooverride existing token when passing a new one' do
84
85
  cookies.signed[:guest_token] = "soo wrong"
85
- spree_get :show, { :id => 'R123', :token => order.guest_token }
86
+ spree_get :show, { id: 'R123', token: order.guest_token }
86
87
  expect(cookies.signed[:guest_token]).to eq(order.guest_token)
87
88
  end
88
89
 
89
90
  it 'should store as guest_token in session' do
90
- spree_get :show, {:id => 'R123', :token => order.guest_token }
91
+ spree_get :show, { id: 'R123', token: order.guest_token }
91
92
  expect(cookies.signed[:guest_token]).to eq(order.guest_token)
92
93
  end
93
94
  end
94
95
 
95
96
  context 'when no token present' do
96
97
  it 'should respond with 404' do
97
- spree_get :show, {:id => 'R123'}
98
+ spree_get :show, { id: 'R123' }
98
99
  expect(response.code).to eq('404')
99
100
  end
100
101
  end
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Spree::OrdersController, :type => :controller do
3
+ describe Spree::OrdersController, type: :controller do
4
+ let!(:store) { create(:store) }
4
5
  let(:user) { create(:user) }
5
6
 
6
7
  context "Order model mock" do
@@ -10,7 +11,7 @@ describe Spree::OrdersController, :type => :controller do
10
11
  let(:variant) { create(:variant) }
11
12
 
12
13
  before do
13
- allow(controller).to receive_messages(:try_spree_current_user => user)
14
+ allow(controller).to receive_messages(try_spree_current_user: user)
14
15
  end
15
16
 
16
17
  context "#populate" do
@@ -75,13 +76,13 @@ describe Spree::OrdersController, :type => :controller do
75
76
  it "should render the edit view (on failure)" do
76
77
  # email validation is only after address state
77
78
  order.update_column(:state, "delivery")
78
- spree_put :update, { :order => { :email => "" } }, { :order_id => order.id }
79
+ spree_put :update, { order: { email: "" } }, { order_id: order.id }
79
80
  expect(response).to render_template :edit
80
81
  end
81
82
 
82
83
  it "should redirect to cart path (on success)" do
83
84
  allow(order).to receive(:update_attributes).and_return true
84
- spree_put :update, {}, {:order_id => 1}
85
+ spree_put :update, {}, { order_id: 1 }
85
86
  expect(response).to redirect_to(spree.cart_path)
86
87
  end
87
88
  end
@@ -108,7 +109,7 @@ describe Spree::OrdersController, :type => :controller do
108
109
  end
109
110
 
110
111
  it "cannot update a blank order" do
111
- spree_put :update, :order => { :email => "foo" }
112
+ spree_put :update, order: { email: "foo" }
112
113
  expect(flash[:error]).to eq(Spree.t(:order_not_found))
113
114
  expect(response).to redirect_to(spree.root_path)
114
115
  end
@@ -116,18 +117,18 @@ describe Spree::OrdersController, :type => :controller do
116
117
  end
117
118
 
118
119
  context "line items quantity is 0" do
119
- let(:order) { Spree::Order.create }
120
+ let(:order) { Spree::Order.create(store: store) }
120
121
  let(:variant) { create(:variant) }
121
122
  let!(:line_item) { order.contents.add(variant, 1) }
122
123
 
123
124
  before do
124
125
  allow(controller).to receive(:check_authorization)
125
- allow(controller).to receive_messages(:current_order => order)
126
+ allow(controller).to receive_messages(current_order: order)
126
127
  end
127
128
 
128
129
  it "removes line items on update" do
129
130
  expect(order.line_items.count).to eq 1
130
- spree_put :update, :order => { line_items_attributes: { "0" => { id: line_item.id, quantity: 0 } } }
131
+ spree_put :update, order: { line_items_attributes: { "0" => { id: line_item.id, quantity: 0 } } }
131
132
  expect(order.reload.line_items.count).to eq 0
132
133
  end
133
134
  end
@@ -5,17 +5,17 @@ Spree::Order.class_eval do
5
5
  end
6
6
 
7
7
  module Spree
8
- describe OrdersController, :type => :controller do
8
+ describe OrdersController, type: :controller do
9
9
  # Regression test for https://github.com/spree/spree/issues/2004
10
10
  context "with a transition callback on first state" do
11
11
  let(:order) { Spree::Order.new }
12
12
 
13
13
  before do
14
- allow(controller).to receive_messages :current_order => order
14
+ allow(controller).to receive_messages current_order: order
15
15
  expect(controller).to receive(:authorize!).at_least(:once).and_return(true)
16
16
 
17
- first_state, _ = Spree::Order.checkout_steps.first
18
- Spree::Order.state_machine.after_transition :to => first_state do |order|
17
+ first_state, = Spree::Order.checkout_steps.first
18
+ Spree::Order.state_machine.after_transition to: first_state do |order|
19
19
  order.did_transition = true
20
20
  end
21
21
  end
@@ -23,7 +23,7 @@ module Spree
23
23
  it "correctly calls the transition callback" do
24
24
  expect(order.did_transition).to be_nil
25
25
  order.line_items << FactoryGirl.create(:line_item)
26
- spree_put :update, { :checkout => "checkout" }, { :order_id => 1}
26
+ spree_put :update, { checkout: "checkout" }, { order_id: 1 }
27
27
  expect(order.did_transition).to be true
28
28
  end
29
29
  end
@@ -1,23 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Spree::ProductsController, :type => :controller do
4
- let!(:product) { create(:product, :available_on => 1.year.from_now) }
3
+ describe Spree::ProductsController, type: :controller do
4
+ let!(:product) { create(:product, available_on: 1.year.from_now) }
5
5
 
6
6
  # Regression test for https://github.com/spree/spree/issues/1390
7
7
  it "allows admins to view non-active products" do
8
- allow(controller).to receive_messages :spree_current_user => mock_model(Spree.user_class, :has_spree_role? => true, :last_incomplete_spree_order => nil, :spree_api_key => 'fake')
9
- spree_get :show, :id => product.to_param
8
+ allow(controller).to receive_messages spree_current_user: mock_model(Spree.user_class, has_spree_role?: true, last_incomplete_spree_order: nil, spree_api_key: 'fake')
9
+ spree_get :show, id: product.to_param
10
10
  expect(response.status).to eq(200)
11
11
  end
12
12
 
13
13
  it "cannot view non-active products" do
14
- spree_get :show, :id => product.to_param
14
+ spree_get :show, id: product.to_param
15
15
  expect(response.status).to eq(404)
16
16
  end
17
17
 
18
18
  it "should provide the current user to the searcher class" do
19
- user = mock_model(Spree.user_class, :last_incomplete_spree_order => nil, :spree_api_key => 'fake')
20
- allow(controller).to receive_messages :spree_current_user => user
19
+ user = mock_model(Spree.user_class, last_incomplete_spree_order: nil, spree_api_key: 'fake')
20
+ allow(controller).to receive_messages spree_current_user: user
21
21
  expect_any_instance_of(Spree::Config.searcher_class).to receive(:current_user=).with(user)
22
22
  spree_get :index
23
23
  expect(response.status).to eq(200)
@@ -25,12 +25,11 @@ describe Spree::ProductsController, :type => :controller do
25
25
 
26
26
  # Regression test for https://github.com/spree/spree/issues/2249
27
27
  it "doesn't error when given an invalid referer" do
28
- current_user = mock_model(Spree.user_class, :has_spree_role? => true, :last_incomplete_spree_order => nil, :generate_spree_api_key! => nil)
29
- allow(controller).to receive_messages :spree_current_user => current_user
28
+ current_user = mock_model(Spree.user_class, has_spree_role?: true, last_incomplete_spree_order: nil, generate_spree_api_key!: nil)
29
+ allow(controller).to receive_messages spree_current_user: current_user
30
30
  request.env['HTTP_REFERER'] = "not|a$url"
31
31
 
32
32
  # Previously a URI::InvalidURIError exception was being thrown
33
- spree_get :show, :id => product.to_param
33
+ spree_get :show, id: product.to_param
34
34
  end
35
-
36
35
  end
@@ -1,12 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Spree::TaxonsController, :type => :controller do
3
+ describe Spree::TaxonsController, type: :controller do
4
4
  it "should provide the current user to the searcher class" do
5
- taxon = create(:taxon, :permalink => "test")
6
- user = mock_model(Spree.user_class, :last_incomplete_spree_order => nil, :spree_api_key => 'fake')
7
- allow(controller).to receive_messages :spree_current_user => user
5
+ taxon = create(:taxon, permalink: "test")
6
+ user = mock_model(Spree.user_class, last_incomplete_spree_order: nil, spree_api_key: 'fake')
7
+ allow(controller).to receive_messages spree_current_user: user
8
8
  expect_any_instance_of(Spree::Config.searcher_class).to receive(:current_user=).with(user)
9
- spree_get :show, :id => taxon.permalink
9
+ spree_get :show, id: taxon.permalink
10
10
  expect(response.status).to eq(200)
11
11
  end
12
12
  end
@@ -1,8 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Address", type: :feature, inaccessible: true do
4
- let!(:product) { create(:product, :name => "RoR Mug") }
5
- let!(:order) { create(:order_with_totals, :state => 'cart') }
4
+ let!(:product) { create(:product, name: "RoR Mug") }
5
+ let!(:order) { create(:order_with_totals, state: 'cart') }
6
6
 
7
7
  stub_authorization!
8
8
 
@@ -18,43 +18,43 @@ describe "Address", type: :feature, inaccessible: true do
18
18
  @state_name_css = "##{address}_state_name"
19
19
  end
20
20
 
21
- context "country requires state", :js => true, :focus => true do
22
- let!(:canada) { create(:country, :name => "Canada", :states_required => true, :iso => "CA") }
23
- let!(:uk) { create(:country, :name => "United Kingdom", :states_required => true, :iso => "GB") }
21
+ context "country requires state", js: true, focus: true do
22
+ let!(:canada) { create(:country, name: "Canada", states_required: true, iso: "CA") }
23
+ let!(:uk) { create(:country, name: "United Kingdom", states_required: true, iso: "GB") }
24
24
 
25
- before { Spree::Config[:default_country_id] = uk.id }
25
+ before { Spree::Config[:default_country_iso] = uk.iso }
26
26
 
27
27
  context "but has no state" do
28
28
  it "shows the state input field" do
29
29
  click_button "Checkout"
30
30
 
31
- select canada.name, :from => @country_css
31
+ select canada.name, from: @country_css
32
32
  expect(page).to have_no_css(@state_select_css)
33
33
  expect(page).to have_css("#{@state_name_css}.required")
34
34
  end
35
35
  end
36
36
 
37
37
  context "and has state" do
38
- before { create(:state, :name => "Ontario", :country => canada) }
38
+ before { create(:state, name: "Ontario", country: canada) }
39
39
 
40
40
  it "shows the state collection selection" do
41
41
  click_button "Checkout"
42
42
 
43
- select canada.name, :from => @country_css
43
+ select canada.name, from: @country_css
44
44
  expect(page).to have_no_css(@state_name_css)
45
45
  expect(page).to have_css("#{@state_select_css}.required")
46
46
  end
47
47
  end
48
48
 
49
49
  context "user changes to country without states required" do
50
- let!(:france) { create(:country, :name => "France", :states_required => false, :iso => "FRA") }
50
+ let!(:france) { create(:country, name: "France", states_required: false, iso: "FR") }
51
51
 
52
52
  it "clears the state name" do
53
53
  click_button "Checkout"
54
- select canada.name, :from => @country_css
54
+ select canada.name, from: @country_css
55
55
  page.find(@state_name_css).set("Toscana")
56
56
 
57
- select france.name, :from => @country_css
57
+ select france.name, from: @country_css
58
58
 
59
59
  expect(page).to have_no_css(@state_name_css)
60
60
  expect(page).to have_no_css(@state_select_css)
@@ -62,13 +62,13 @@ describe "Address", type: :feature, inaccessible: true do
62
62
  end
63
63
  end
64
64
 
65
- context "country does not require state", :js => true do
66
- let!(:france) { create(:country, :name => "France", :states_required => false, :iso => "FRA") }
65
+ context "country does not require state", js: true do
66
+ let!(:france) { create(:country, name: "France", states_required: false, iso: "FR") }
67
67
 
68
68
  it "shows a disabled state input field" do
69
69
  click_button "Checkout"
70
70
 
71
- select france.name, :from => @country_css
71
+ select france.name, from: @country_css
72
72
  expect(page).to have_no_css(@state_name_css)
73
73
  expect(page).to have_css("#{@state_select_css}[disabled]", visible: false)
74
74
  end
@@ -1,34 +1,34 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Automatic promotions", :type => :feature, :js => true do
4
- let!(:country) { create(:country, :name => "United States of America", :states_required => true) }
5
- let!(:state) { create(:state, :name => "Alabama", :country => country) }
3
+ describe "Automatic promotions", type: :feature, js: true do
4
+ let!(:store) { create(:store) }
5
+ let!(:country) { create(:country, name: "United States of America", states_required: true) }
6
+ let!(:state) { create(:state, name: "Alabama", country: country) }
6
7
  let!(:zone) { create(:zone) }
7
8
  let!(:shipping_method) { create(:shipping_method) }
8
9
  let!(:payment_method) { create(:check_payment_method) }
9
- let!(:product) { create(:product, :name => "RoR Mug", :price => 20) }
10
+ let!(:product) { create(:product, name: "RoR Mug", price: 20) }
10
11
 
11
12
  let!(:promotion) do
12
13
  promotion = Spree::Promotion.create!(name: "$10 off when you spend more than $100", apply_automatically: true)
13
14
 
14
- calculator = Spree::Calculator::FlatRate.new
15
- calculator.preferred_amount = 10
15
+ calculator = Spree::Calculator::FlatRate.new
16
+ calculator.preferred_amount = 10
16
17
 
17
- rule = Spree::Promotion::Rules::ItemTotal.create
18
- rule.preferred_amount = 100
19
- rule.save
18
+ rule = Spree::Promotion::Rules::ItemTotal.create
19
+ rule.preferred_amount = 100
20
+ rule.save
20
21
 
21
- promotion.rules << rule
22
+ promotion.rules << rule
22
23
 
23
- action = Spree::Promotion::Actions::CreateAdjustment.create
24
- action.calculator = calculator
25
- action.save
24
+ action = Spree::Promotion::Actions::CreateAdjustment.create
25
+ action.calculator = calculator
26
+ action.save
26
27
 
27
- promotion.actions << action
28
+ promotion.actions << action
28
29
  end
29
30
 
30
31
  context "on the cart page" do
31
-
32
32
  before do
33
33
  visit spree.root_path
34
34
  click_link product.name
@@ -36,12 +36,12 @@ describe "Automatic promotions", :type => :feature, :js => true do
36
36
  end
37
37
 
38
38
  it "automatically applies the promotion once the order crosses the threshold" do
39
- fill_in "order_line_items_attributes_0_quantity", :with => 10
39
+ fill_in "order_line_items_attributes_0_quantity", with: 10
40
40
  click_button "Update"
41
41
  expect(page).to have_content("Promotion ($10 off when you spend more than $100) -$10.00")
42
- fill_in "order_line_items_attributes_0_quantity", :with => 1
42
+ fill_in "order_line_items_attributes_0_quantity", with: 1
43
43
  click_button "Update"
44
44
  expect(page).not_to have_content("Promotion ($10 off when you spend more than $100) -$10.00")
45
45
  end
46
46
  end
47
- end
47
+ end