spree_api 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/api/base_controller.rb +2 -2
  3. data/app/controllers/spree/api/option_types_controller.rb +2 -2
  4. data/app/controllers/spree/api/shipments_controller.rb +2 -2
  5. data/app/controllers/spree/api/taxons_controller.rb +1 -1
  6. data/app/helpers/spree/api/api_helpers.rb +0 -2
  7. data/app/views/spree/api/shipments/small.v1.rabl +4 -0
  8. data/app/views/spree/api/variants/small.v1.rabl +2 -0
  9. data/lib/spree/api/testing_support/helpers.rb +6 -6
  10. data/lib/spree/api/testing_support/setup.rb +2 -2
  11. data/spec/controllers/spree/api/addresses_controller_spec.rb +7 -7
  12. data/spec/controllers/spree/api/base_controller_spec.rb +20 -20
  13. data/spec/controllers/spree/api/checkouts_controller_spec.rb +53 -53
  14. data/spec/controllers/spree/api/classifications_controller_spec.rb +5 -5
  15. data/spec/controllers/spree/api/config_controller_spec.rb +9 -9
  16. data/spec/controllers/spree/api/countries_controller_spec.rb +11 -11
  17. data/spec/controllers/spree/api/credit_cards_controller_spec.rb +16 -16
  18. data/spec/controllers/spree/api/images_controller_spec.rb +11 -11
  19. data/spec/controllers/spree/api/inventory_units_controller_spec.rb +6 -6
  20. data/spec/controllers/spree/api/line_items_controller_spec.rb +33 -33
  21. data/spec/controllers/spree/api/option_types_controller_spec.rb +18 -18
  22. data/spec/controllers/spree/api/option_values_controller_spec.rb +21 -21
  23. data/spec/controllers/spree/api/orders_controller_spec.rb +170 -132
  24. data/spec/controllers/spree/api/payments_controller_spec.rb +46 -46
  25. data/spec/controllers/spree/api/product_properties_controller_spec.rb +21 -21
  26. data/spec/controllers/spree/api/products_controller_spec.rb +67 -67
  27. data/spec/controllers/spree/api/promotion_application_spec.rb +11 -11
  28. data/spec/controllers/spree/api/properties_controller_spec.rb +25 -25
  29. data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +40 -40
  30. data/spec/controllers/spree/api/shipments_controller_spec.rb +53 -30
  31. data/spec/controllers/spree/api/states_controller_spec.rb +18 -18
  32. data/spec/controllers/spree/api/stock_items_controller_spec.rb +26 -26
  33. data/spec/controllers/spree/api/stock_locations_controller_spec.rb +22 -22
  34. data/spec/controllers/spree/api/stock_movements_controller_spec.rb +16 -16
  35. data/spec/controllers/spree/api/taxonomies_controller_spec.rb +24 -24
  36. data/spec/controllers/spree/api/taxons_controller_spec.rb +39 -39
  37. data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +5 -5
  38. data/spec/controllers/spree/api/users_controller_spec.rb +25 -25
  39. data/spec/controllers/spree/api/variants_controller_spec.rb +36 -36
  40. data/spec/controllers/spree/api/zones_controller_spec.rb +20 -20
  41. data/spec/models/spree/legacy_user_spec.rb +5 -5
  42. data/spec/requests/rabl_cache_spec.rb +9 -9
  43. data/spec/spec_helper.rb +0 -1
  44. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67164eec95e8c7df0bd09088a07ccf352031bcf5
4
- data.tar.gz: fd296233701f4684bde99697a8e009b107e6d2e2
3
+ metadata.gz: bf48939c8d5c9e705d069f0e86a1cc25671797ac
4
+ data.tar.gz: 5bc9f3903e8d012c20f36469825b2bc24ab73742
5
5
  SHA512:
6
- metadata.gz: e6a47aa15c09115f6b8aeb8677c5bc3cac9dd035ac799cd2b3454102b8ec5f2dcaf1a9deadad156dd7ee33168a0e88154e6f7f816af87e5831d5790f4fd12c62
7
- data.tar.gz: 01f1be77baf5bd64995358b732ef6003e20cedf4d951fc799a51505bb3d1fe42a5503f2cdb64c457e666e9a1cf69f82d0f3f646d83cc2ad4e6fa653b52cded7f
6
+ metadata.gz: 173933e3f5cfdc718056035c232401e48cde88491280b912dd173378021a4bf304f1d5dd83c9bcd2e7951a87359a4ad24b3c64e0ac35e701f5fdfb70f733197f
7
+ data.tar.gz: faddf7e2c60e3d8eef60620f8ba971708ca81d12c783ce2d67d20dc6d03513d577847f6fc04b1ee762fbf0c23ab9930033309e1217f7c3aae0404ff4a9720b15
@@ -97,8 +97,8 @@ module Spree
97
97
  Rails.logger.error exception.message
98
98
  Rails.logger.error exception.backtrace.join("\n")
99
99
 
100
- render :text => { :exception => exception.message }.to_json,
101
- :status => 422 and return
100
+ render text: { exception: exception.message }.to_json,
101
+ status: 422 and return
102
102
  end
103
103
 
104
104
  def gateway_error(exception)
@@ -3,9 +3,9 @@ module Spree
3
3
  class OptionTypesController < Spree::Api::BaseController
4
4
  def index
5
5
  if params[:ids]
6
- @option_types = Spree::OptionType.accessible_by(current_ability, :read).where(:id => params[:ids].split(','))
6
+ @option_types = Spree::OptionType.includes(:option_values).accessible_by(current_ability, :read).where(id: params[:ids].split(','))
7
7
  else
8
- @option_types = Spree::OptionType.accessible_by(current_ability, :read).load.ransack(params[:q]).result
8
+ @option_types = Spree::OptionType.includes(:option_values).accessible_by(current_ability, :read).load.ransack(params[:q]).result
9
9
  end
10
10
  respond_with(@option_types)
11
11
  end
@@ -5,11 +5,11 @@ module Spree
5
5
  before_filter :find_and_update_shipment, only: [:ship, :ready, :add, :remove]
6
6
 
7
7
  def create
8
- @order = Spree::Order.find_by!(number: params[:shipment][:order_id])
8
+ @order = Spree::Order.find_by!(number: params.fetch(:shipment).fetch(:order_id))
9
9
  authorize! :read, @order
10
10
  authorize! :create, Shipment
11
11
  quantity = params[:quantity].to_i
12
- @shipment = @order.shipments.create(stock_location_id: params[:stock_location_id])
12
+ @shipment = @order.shipments.create(stock_location_id: params.fetch(:stock_location_id))
13
13
  @order.contents.add(variant, quantity, nil, @shipment)
14
14
 
15
15
  @shipment.save!
@@ -65,7 +65,7 @@ module Spree
65
65
  # Products#index does not do the sorting.
66
66
  taxon = Spree::Taxon.find(params[:id])
67
67
  @products = taxon.products.ransack(params[:q]).result
68
- @products = @products.page(params[:page]).per(500 || params[:per_page])
68
+ @products = @products.page(params[:page]).per(params[:per_page] || 500)
69
69
  render "spree/api/products/index"
70
70
  end
71
71
 
@@ -21,8 +21,6 @@ module Spree
21
21
  :country_attributes,
22
22
  :state_attributes,
23
23
  :adjustment_attributes,
24
- :inventory_unit_attributes,
25
- :return_authorization_attributes,
26
24
  :creditcard_attributes,
27
25
  :payment_source_attributes,
28
26
  :user_attributes,
@@ -31,3 +31,7 @@ child :manifest => :manifest do
31
31
  node(:quantity) { |m| m.quantity }
32
32
  node(:states) { |m| m.states }
33
33
  end
34
+
35
+ child :adjustments => :adjustments do
36
+ extends "spree/api/adjustments/show"
37
+ end
@@ -4,6 +4,8 @@ cache [I18n.locale, 'small_variant', root_object]
4
4
  node(:display_price) { |p| p.display_price.to_s }
5
5
  node(:options_text) { |v| v.options_text }
6
6
  node(:in_stock) { |v| v.in_stock? }
7
+ node(:is_backorderable) { |v| v.is_backorderable? }
8
+ node(:total_on_hand) { |v| v.total_on_hand }
7
9
 
8
10
  child :option_values => :option_values do
9
11
  attributes *option_value_attributes
@@ -12,23 +12,23 @@ module Spree
12
12
  end
13
13
 
14
14
  def assert_not_found!
15
- json_response.should == { "error" => "The resource you were looking for could not be found." }
16
- response.status.should == 404
15
+ expect(json_response).to eq({ "error" => "The resource you were looking for could not be found." })
16
+ expect(response.status).to eq 404
17
17
  end
18
18
 
19
19
  def assert_unauthorized!
20
- json_response.should == { "error" => "You are not authorized to perform that action." }
21
- response.status.should == 401
20
+ expect(json_response).to eq({ "error" => "You are not authorized to perform that action." })
21
+ expect(response.status).to eq 401
22
22
  end
23
23
 
24
24
  def stub_authentication!
25
- Spree::LegacyUser.stub(:find_by).with(hash_including(:spree_api_key)) { current_api_user }
25
+ allow(Spree::LegacyUser).to receive(:find_by).with(hash_including(:spree_api_key)) { current_api_user }
26
26
  end
27
27
 
28
28
  # This method can be overriden (with a let block) inside a context
29
29
  # For instance, if you wanted to have an admin user instead.
30
30
  def current_api_user
31
- @current_api_user ||= stub_model(Spree::LegacyUser, :email => "spree@example.com")
31
+ @current_api_user ||= stub_model(Spree::LegacyUser, email: "spree@example.com")
32
32
  end
33
33
 
34
34
  def image(filename)
@@ -5,8 +5,8 @@ module Spree
5
5
  def sign_in_as_admin!
6
6
  let!(:current_api_user) do
7
7
  user = stub_model(Spree::LegacyUser)
8
- user.stub_chain(:spree_roles, :pluck).and_return(["admin"])
9
- user.stub(:has_spree_role?).with("admin").and_return(true)
8
+ allow(user).to receive_message_chain(:spree_roles, :pluck).and_return(["admin"])
9
+ allow(user).to receive(:has_spree_role?).with("admin").and_return(true)
10
10
  user
11
11
  end
12
12
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::AddressesController do
4
+ describe Api::AddressesController, :type => :controller do
5
5
  render_views
6
6
 
7
7
  before do
@@ -12,27 +12,27 @@ module Spree
12
12
 
13
13
  context "with their own address" do
14
14
  before do
15
- Order.any_instance.stub :user => current_api_user
15
+ allow_any_instance_of(Order).to receive_messages :user => current_api_user
16
16
  end
17
17
 
18
18
  it "gets an address" do
19
19
  api_get :show, :id => @address.id, :order_id => @order.number
20
- json_response['address1'].should eq @address.address1
20
+ expect(json_response['address1']).to eq @address.address1
21
21
  end
22
22
 
23
23
  it "updates an address" do
24
24
  api_put :update, :id => @address.id, :order_id => @order.number,
25
25
  :address => { :address1 => "123 Test Lane" }
26
- json_response['address1'].should eq '123 Test Lane'
26
+ expect(json_response['address1']).to eq '123 Test Lane'
27
27
  end
28
28
 
29
29
  it "receives the errors object if address is invalid" do
30
30
  api_put :update, :id => @address.id, :order_id => @order.number,
31
31
  :address => { :address1 => "" }
32
32
 
33
- json_response['error'].should_not be_nil
34
- json_response['errors'].should_not be_nil
35
- json_response['errors']['address1'].first.should eq "can't be blank"
33
+ expect(json_response['error']).not_to be_nil
34
+ expect(json_response['errors']).not_to be_nil
35
+ expect(json_response['errors']['address1'].first).to eq "can't be blank"
36
36
  end
37
37
  end
38
38
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Spree::Api::BaseController do
3
+ describe Spree::Api::BaseController, :type => :controller do
4
4
  render_views
5
5
  controller(Spree::Api::BaseController) do
6
6
  def index
@@ -11,14 +11,14 @@ describe Spree::Api::BaseController do
11
11
  context "signed in as a user using an authentication extension" do
12
12
  before do
13
13
  user = double(:email => "spree@example.com")
14
- user.stub_chain :spree_roles, pluck: []
15
- controller.stub :try_spree_current_user => user
14
+ allow(user).to receive_message_chain :spree_roles, pluck: []
15
+ allow(controller).to receive_messages :try_spree_current_user => user
16
16
  end
17
17
 
18
18
  it "can make a request" do
19
19
  api_get :index
20
- json_response.should == { "products" => [] }
21
- response.status.should == 200
20
+ expect(json_response).to eq({ "products" => [] })
21
+ expect(response.status).to eq(200)
22
22
  end
23
23
  end
24
24
 
@@ -28,19 +28,19 @@ describe Spree::Api::BaseController do
28
28
  context "with a correct order token" do
29
29
  it "succeeds" do
30
30
  api_get :index, order_token: order.guest_token, order_id: order.number
31
- response.status.should == 200
31
+ expect(response.status).to eq(200)
32
32
  end
33
33
 
34
34
  it "succeeds with an order_number parameter" do
35
35
  api_get :index, order_token: order.guest_token, order_number: order.number
36
- response.status.should == 200
36
+ expect(response.status).to eq(200)
37
37
  end
38
38
  end
39
39
 
40
40
  context "with an incorrect order token" do
41
41
  it "returns unauthorized" do
42
42
  api_get :index, order_token: "NOT_A_TOKEN", order_id: order.number
43
- response.status.should == 401
43
+ expect(response.status).to eq(401)
44
44
  end
45
45
  end
46
46
  end
@@ -48,29 +48,29 @@ describe Spree::Api::BaseController do
48
48
  context "cannot make a request to the API" do
49
49
  it "without an API key" do
50
50
  api_get :index
51
- json_response.should == { "error" => "You must specify an API key." }
52
- response.status.should == 401
51
+ expect(json_response).to eq({ "error" => "You must specify an API key." })
52
+ expect(response.status).to eq(401)
53
53
  end
54
54
 
55
55
  it "with an invalid API key" do
56
56
  request.headers["X-Spree-Token"] = "fake_key"
57
57
  get :index, {}
58
- json_response.should == { "error" => "Invalid API key (fake_key) specified." }
59
- response.status.should == 401
58
+ expect(json_response).to eq({ "error" => "Invalid API key (fake_key) specified." })
59
+ expect(response.status).to eq(401)
60
60
  end
61
61
 
62
62
  it "using an invalid token param" do
63
63
  get :index, :token => "fake_key"
64
- json_response.should == { "error" => "Invalid API key (fake_key) specified." }
64
+ expect(json_response).to eq({ "error" => "Invalid API key (fake_key) specified." })
65
65
  end
66
66
  end
67
67
 
68
68
  it 'handles exceptions' do
69
- subject.should_receive(:authenticate_user).and_return(true)
70
- subject.should_receive(:load_user_roles).and_return(true)
71
- subject.should_receive(:index).and_raise(Exception.new("no joy"))
69
+ expect(subject).to receive(:authenticate_user).and_return(true)
70
+ expect(subject).to receive(:load_user_roles).and_return(true)
71
+ expect(subject).to receive(:index).and_raise(Exception.new("no joy"))
72
72
  get :index, :token => "fake_key"
73
- json_response.should == { "exception" => "no joy" }
73
+ expect(json_response).to eq({ "exception" => "no joy" })
74
74
  end
75
75
 
76
76
  it "maps semantic keys to nested_attributes keys" do
@@ -81,11 +81,11 @@ describe Spree::Api::BaseController do
81
81
  'name' => 'test order' }
82
82
 
83
83
  mapped = subject.map_nested_attributes_keys(klass, attributes)
84
- mapped.has_key?('line_items_attributes').should be true
85
- mapped.has_key?('name').should be true
84
+ expect(mapped.has_key?('line_items_attributes')).to be true
85
+ expect(mapped.has_key?('name')).to be true
86
86
  end
87
87
 
88
88
  it "lets a subclass override the product associations that are eager-loaded" do
89
- controller.respond_to?(:product_includes, true).should be
89
+ expect(controller.respond_to?(:product_includes, true)).to be
90
90
  end
91
91
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::CheckoutsController do
4
+ describe Api::CheckoutsController, :type => :controller do
5
5
  render_views
6
6
 
7
7
  before(:each) do
@@ -31,39 +31,39 @@ module Spree
31
31
  end
32
32
 
33
33
  before(:each) do
34
- Order.any_instance.stub(:confirmation_required? => true)
35
- Order.any_instance.stub(:payment_required? => true)
34
+ allow_any_instance_of(Order).to receive_messages(:confirmation_required? => true)
35
+ allow_any_instance_of(Order).to receive_messages(:payment_required? => true)
36
36
  end
37
37
 
38
38
  it "should transition a recently created order from cart to address" do
39
- order.state.should eq "cart"
40
- order.email.should_not be_nil
39
+ expect(order.state).to eq "cart"
40
+ expect(order.email).not_to be_nil
41
41
  api_put :update, :id => order.to_param, :order_token => order.guest_token
42
- order.reload.state.should eq "address"
42
+ expect(order.reload.state).to eq "address"
43
43
  end
44
44
 
45
45
  it "should transition a recently created order from cart to address with order token in header" do
46
- order.state.should eq "cart"
47
- order.email.should_not be_nil
46
+ expect(order.state).to eq "cart"
47
+ expect(order.email).not_to be_nil
48
48
  request.headers["X-Spree-Order-Token"] = order.guest_token
49
49
  api_put :update, :id => order.to_param
50
- order.reload.state.should eq "address"
50
+ expect(order.reload.state).to eq "address"
51
51
  end
52
52
 
53
53
  it "can take line_items_attributes as a parameter" do
54
54
  line_item = order.line_items.first
55
55
  api_put :update, :id => order.to_param, :order_token => order.guest_token,
56
56
  :order => { :line_items_attributes => { 0 => { :id => line_item.id, :quantity => 1 } } }
57
- response.status.should == 200
58
- order.reload.state.should eq "address"
57
+ expect(response.status).to eq(200)
58
+ expect(order.reload.state).to eq "address"
59
59
  end
60
60
 
61
61
  it "can take line_items as a parameter" do
62
62
  line_item = order.line_items.first
63
63
  api_put :update, :id => order.to_param, :order_token => order.guest_token,
64
64
  :order => { :line_items => { 0 => { :id => line_item.id, :quantity => 1 } } }
65
- response.status.should == 200
66
- order.reload.state.should eq "address"
65
+ expect(response.status).to eq(200)
66
+ expect(order.reload.state).to eq "address"
67
67
  end
68
68
 
69
69
  it "will return an error if the order cannot transition" do
@@ -73,7 +73,7 @@ module Spree
73
73
  order.update_column(:state, "address")
74
74
  api_put :update, :id => order.to_param, :order_token => order.guest_token
75
75
  # Order has not transitioned
76
- response.status.should == 422
76
+ expect(response.status).to eq(422)
77
77
  end
78
78
 
79
79
  context "transitioning to delivery" do
@@ -101,10 +101,10 @@ module Spree
101
101
  :bill_address_attributes => address,
102
102
  :ship_address_attributes => address
103
103
  }
104
- json_response['state'].should == 'delivery'
105
- json_response['bill_address']['firstname'].should == 'John'
106
- json_response['ship_address']['firstname'].should == 'John'
107
- response.status.should == 200
104
+ expect(json_response['state']).to eq('delivery')
105
+ expect(json_response['bill_address']['firstname']).to eq('John')
106
+ expect(json_response['ship_address']['firstname']).to eq('John')
107
+ expect(response.status).to eq(200)
108
108
  end
109
109
 
110
110
  # Regression test for #4498
@@ -129,25 +129,25 @@ module Spree
129
129
  shipping_rate = shipment.shipping_rates.where(:selected => false).first
130
130
  api_put :update, :id => order.to_param, :order_token => order.guest_token,
131
131
  :order => { :shipments_attributes => { "0" => { :selected_shipping_rate_id => shipping_rate.id, :id => shipment.id } } }
132
- response.status.should == 200
132
+ expect(response.status).to eq(200)
133
133
  # Find the correct shipment...
134
134
  json_shipment = json_response['shipments'].detect { |s| s["id"] == shipment.id }
135
135
  # Find the correct shipping rate for that shipment...
136
136
  json_shipping_rate = json_shipment['shipping_rates'].detect { |sr| sr["id"] == shipping_rate.id }
137
137
  # ... And finally ensure that it's selected
138
- json_shipping_rate['selected'].should be true
138
+ expect(json_shipping_rate['selected']).to be true
139
139
  # Order should automatically transfer to payment because all criteria are met
140
- json_response['state'].should == 'payment'
140
+ expect(json_response['state']).to eq('payment')
141
141
  end
142
142
 
143
143
  it "can update payment method and transition from payment to confirm" do
144
144
  order.update_column(:state, "payment")
145
145
  api_put :update, :id => order.to_param, :order_token => order.guest_token,
146
146
  :order => { :payments_attributes => [{ :payment_method_id => @payment_method.id }] }
147
- json_response['state'].should == 'confirm'
148
- json_response['payments'][0]['payment_method']['name'].should == @payment_method.name
149
- json_response['payments'][0]['amount'].should == order.total.to_s
150
- response.status.should == 200
147
+ expect(json_response['state']).to eq('confirm')
148
+ expect(json_response['payments'][0]['payment_method']['name']).to eq(@payment_method.name)
149
+ expect(json_response['payments'][0]['amount']).to eq(order.total.to_s)
150
+ expect(response.status).to eq(200)
151
151
  end
152
152
 
153
153
  it "can update payment method with source and transition from payment to confirm" do
@@ -163,9 +163,9 @@ module Spree
163
163
  api_put :update, :id => order.to_param, :order_token => order.guest_token,
164
164
  :order => { :payments_attributes => [{ :payment_method_id => @payment_method.id.to_s }],
165
165
  :payment_source => { @payment_method.id.to_s => source_attributes } }
166
- json_response['payments'][0]['payment_method']['name'].should == @payment_method.name
167
- json_response['payments'][0]['amount'].should == order.total.to_s
168
- response.status.should == 200
166
+ expect(json_response['payments'][0]['payment_method']['name']).to eq(@payment_method.name)
167
+ expect(json_response['payments'][0]['amount']).to eq(order.total.to_s)
168
+ expect(response.status).to eq(200)
169
169
  end
170
170
 
171
171
  it "returns errors when source is missing attributes" do
@@ -178,12 +178,12 @@ module Spree
178
178
  @payment_method.id.to_s => { name: "Spree" }
179
179
  }
180
180
 
181
- response.status.should == 422
181
+ expect(response.status).to eq(422)
182
182
  cc_errors = json_response['errors']['payments.Credit Card']
183
- cc_errors.should include("Number can't be blank")
184
- cc_errors.should include("Month is not a number")
185
- cc_errors.should include("Year is not a number")
186
- cc_errors.should include("Verification Value can't be blank")
183
+ expect(cc_errors).to include("Number can't be blank")
184
+ expect(cc_errors).to include("Month is not a number")
185
+ expect(cc_errors).to include("Year is not a number")
186
+ expect(cc_errors).to include("Verification Value can't be blank")
187
187
  end
188
188
 
189
189
  it "allow users to reuse a credit card" do
@@ -199,17 +199,17 @@ module Spree
199
199
 
200
200
  it "can transition from confirm to complete" do
201
201
  order.update_column(:state, "confirm")
202
- Spree::Order.any_instance.stub(:payment_required? => false)
202
+ allow_any_instance_of(Spree::Order).to receive_messages(:payment_required? => false)
203
203
  api_put :update, :id => order.to_param, :order_token => order.guest_token
204
- json_response['state'].should == 'complete'
205
- response.status.should == 200
204
+ expect(json_response['state']).to eq('complete')
205
+ expect(response.status).to eq(200)
206
206
  end
207
207
 
208
208
  it "returns the order if the order is already complete" do
209
209
  order.update_column(:state, "complete")
210
210
  api_put :update, :id => order.to_param, :order_token => order.guest_token
211
- json_response['number'].should == order.number
212
- response.status.should == 200
211
+ expect(json_response['number']).to eq(order.number)
212
+ expect(response.status).to eq(200)
213
213
  end
214
214
 
215
215
  # Regression test for #3784
@@ -227,24 +227,24 @@ module Spree
227
227
  # Need to pass email as well so that validations succeed
228
228
  api_put :update, :id => order.to_param, :order_token => order.guest_token,
229
229
  :order => { :user_id => user.id, :email => "guest@spreecommerce.com" }
230
- response.status.should == 200
231
- json_response['user_id'].should == user.id
230
+ expect(response.status).to eq(200)
231
+ expect(json_response['user_id']).to eq(user.id)
232
232
  end
233
233
  end
234
234
 
235
235
  it "can assign an email to the order" do
236
236
  api_put :update, :id => order.to_param, :order_token => order.guest_token,
237
237
  :order => { :email => "guest@spreecommerce.com" }
238
- json_response['email'].should == "guest@spreecommerce.com"
239
- response.status.should == 200
238
+ expect(json_response['email']).to eq("guest@spreecommerce.com")
239
+ expect(response.status).to eq(200)
240
240
  end
241
241
 
242
242
  it "can apply a coupon code to an order" do
243
243
  skip "ensure that the order totals are properly updated, see frontend orders_controller or checkout_controller as example"
244
244
 
245
245
  order.update_column(:state, "payment")
246
- PromotionHandler::Coupon.should_receive(:new).with(order).and_call_original
247
- PromotionHandler::Coupon.any_instance.should_receive(:apply).and_return({:coupon_applied? => true})
246
+ expect(PromotionHandler::Coupon).to receive(:new).with(order).and_call_original
247
+ expect_any_instance_of(PromotionHandler::Coupon).to receive(:apply).and_return({:coupon_applied? => true})
248
248
  api_put :update, :id => order.to_param, :order_token => order.guest_token, :order => { :coupon_code => "foobar" }
249
249
  end
250
250
  end
@@ -255,16 +255,16 @@ module Spree
255
255
  order.line_items.delete_all
256
256
  order.update_column(:email, "spree@example.com")
257
257
  api_put :next, :id => order.to_param, :order_token => order.guest_token
258
- response.status.should == 422
259
- json_response["errors"]["base"].should include(Spree.t(:there_are_no_items_for_this_order))
258
+ expect(response.status).to eq(422)
259
+ expect(json_response["errors"]["base"]).to include(Spree.t(:there_are_no_items_for_this_order))
260
260
  end
261
261
 
262
262
  it "can transition an order to the next state" do
263
263
  order.update_column(:email, "spree@example.com")
264
264
 
265
265
  api_put :next, :id => order.to_param, :order_token => order.guest_token
266
- response.status.should == 200
267
- json_response['state'].should == 'address'
266
+ expect(response.status).to eq(200)
267
+ expect(json_response['state']).to eq('address')
268
268
  end
269
269
 
270
270
  it "cannot transition if order email is blank" do
@@ -274,14 +274,14 @@ module Spree
274
274
  )
275
275
 
276
276
  api_put :next, :id => order.to_param, :order_token => order.guest_token
277
- response.status.should == 422
278
- json_response['error'].should =~ /could not be transitioned/
277
+ expect(response.status).to eq(422)
278
+ expect(json_response['error']).to match(/could not be transitioned/)
279
279
  end
280
280
 
281
281
  it "doesnt advance payment state if order has no payment" do
282
282
  order.update_column(:state, "payment")
283
283
  api_put :next, :id => order.to_param, :order_token => order.guest_token, :order => {}
284
- json_response["errors"]["base"].should include(Spree.t(:no_payment_found))
284
+ expect(json_response["errors"]["base"]).to include(Spree.t(:no_payment_found))
285
285
  end
286
286
  end
287
287
 
@@ -289,13 +289,13 @@ module Spree
289
289
  let!(:order) { create(:order_with_line_items) }
290
290
 
291
291
  it 'continues to advance advances an order while it can move forward' do
292
- Spree::Order.any_instance.should_receive(:next).exactly(3).times.and_return(true, true, false)
292
+ expect_any_instance_of(Spree::Order).to receive(:next).exactly(3).times.and_return(true, true, false)
293
293
  api_put :advance, :id => order.to_param, :order_token => order.guest_token
294
294
  end
295
295
 
296
296
  it 'returns the order' do
297
297
  api_put :advance, :id => order.to_param, :order_token => order.guest_token
298
- json_response['id'].should == order.id
298
+ expect(json_response['id']).to eq(order.id)
299
299
  end
300
300
  end
301
301
  end