spree_api 2.4.0.rc2 → 2.4.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/api/base_controller.rb +4 -6
- data/app/controllers/spree/api/option_types_controller.rb +2 -2
- data/app/controllers/spree/api/orders_controller.rb +9 -1
- data/app/controllers/spree/api/return_authorizations_controller.rb +0 -9
- data/app/controllers/spree/api/taxons_controller.rb +3 -3
- data/app/helpers/spree/api/api_helpers.rb +0 -2
- data/app/views/spree/api/orders/show.v1.rabl +4 -0
- data/app/views/spree/api/products/show.v1.rabl +4 -0
- data/app/views/spree/api/shipments/small.v1.rabl +4 -0
- data/lib/spree/api/testing_support/helpers.rb +6 -6
- data/lib/spree/api/testing_support/setup.rb +2 -2
- data/spec/controllers/spree/api/addresses_controller_spec.rb +8 -8
- data/spec/controllers/spree/api/base_controller_spec.rb +22 -22
- data/spec/controllers/spree/api/checkouts_controller_spec.rb +53 -53
- data/spec/controllers/spree/api/classifications_controller_spec.rb +5 -5
- data/spec/controllers/spree/api/config_controller_spec.rb +9 -9
- data/spec/controllers/spree/api/countries_controller_spec.rb +11 -11
- data/spec/controllers/spree/api/credit_cards_controller_spec.rb +16 -16
- data/spec/controllers/spree/api/images_controller_spec.rb +21 -21
- data/spec/controllers/spree/api/inventory_units_controller_spec.rb +6 -6
- data/spec/controllers/spree/api/line_items_controller_spec.rb +33 -33
- data/spec/controllers/spree/api/option_types_controller_spec.rb +19 -19
- data/spec/controllers/spree/api/option_values_controller_spec.rb +23 -23
- data/spec/controllers/spree/api/orders_controller_spec.rb +186 -143
- data/spec/controllers/spree/api/payments_controller_spec.rb +39 -39
- data/spec/controllers/spree/api/product_properties_controller_spec.rb +21 -21
- data/spec/controllers/spree/api/products_controller_spec.rb +71 -66
- data/spec/controllers/spree/api/promotion_application_spec.rb +13 -13
- data/spec/controllers/spree/api/promotions_controller_spec.rb +1 -1
- data/spec/controllers/spree/api/properties_controller_spec.rb +25 -25
- data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +27 -36
- data/spec/controllers/spree/api/shipments_controller_spec.rb +22 -22
- data/spec/controllers/spree/api/states_controller_spec.rb +18 -18
- data/spec/controllers/spree/api/stock_items_controller_spec.rb +26 -26
- data/spec/controllers/spree/api/stock_locations_controller_spec.rb +22 -22
- data/spec/controllers/spree/api/stock_movements_controller_spec.rb +16 -16
- data/spec/controllers/spree/api/taxonomies_controller_spec.rb +24 -24
- data/spec/controllers/spree/api/taxons_controller_spec.rb +39 -39
- data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +6 -6
- data/spec/controllers/spree/api/users_controller_spec.rb +25 -25
- data/spec/controllers/spree/api/variants_controller_spec.rb +36 -36
- data/spec/controllers/spree/api/zones_controller_spec.rb +20 -20
- data/spec/models/spree/legacy_user_spec.rb +5 -5
- data/spec/requests/rabl_cache_spec.rb +9 -9
- data/spec/spec_helper.rb +0 -1
- data/spec/support/controller_hacks.rb +4 -0
- metadata +4 -4
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::ClassificationsController do
|
4
|
+
describe Api::ClassificationsController, :type => :controller do
|
5
5
|
let(:taxon) do
|
6
6
|
taxon = create(:taxon)
|
7
7
|
3.times do
|
@@ -18,7 +18,7 @@ module Spree
|
|
18
18
|
context "as a user" do
|
19
19
|
it "cannot change the order of a product" do
|
20
20
|
api_put :update, :taxon_id => taxon, :product_id => taxon.products.first, :position => 1
|
21
|
-
response.status.
|
21
|
+
expect(response.status).to eq(401)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -28,10 +28,10 @@ module Spree
|
|
28
28
|
it "can change the order a product" do
|
29
29
|
last_product = taxon.products.last
|
30
30
|
classification = taxon.classifications.find_by(:product_id => last_product.id)
|
31
|
-
classification.position.
|
31
|
+
expect(classification.position).to eq(3)
|
32
32
|
api_put :update, :taxon_id => taxon, :product_id => last_product, :position => 0
|
33
|
-
response.status.
|
34
|
-
classification.reload.position.
|
33
|
+
expect(response.status).to eq(200)
|
34
|
+
expect(classification.reload.position).to eq(1)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::ConfigController do
|
4
|
+
describe Api::ConfigController, :type => :controller do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
before do
|
@@ -10,18 +10,18 @@ module Spree
|
|
10
10
|
|
11
11
|
it "returns Spree::Money settings" do
|
12
12
|
api_get :money
|
13
|
-
response.
|
14
|
-
json_response["symbol"].
|
15
|
-
json_response["symbol_position"].
|
16
|
-
json_response["no_cents"].
|
17
|
-
json_response["decimal_mark"].
|
18
|
-
json_response["thousands_separator"].
|
13
|
+
expect(response).to be_success
|
14
|
+
expect(json_response["symbol"]).to eq("$")
|
15
|
+
expect(json_response["symbol_position"]).to eq("before")
|
16
|
+
expect(json_response["no_cents"]).to eq(false)
|
17
|
+
expect(json_response["decimal_mark"]).to eq(".")
|
18
|
+
expect(json_response["thousands_separator"]).to eq(",")
|
19
19
|
end
|
20
20
|
|
21
21
|
it "returns some configuration settings" do
|
22
22
|
api_get :show
|
23
|
-
response.
|
24
|
-
json_response["default_country_id"].
|
23
|
+
expect(response).to be_success
|
24
|
+
expect(json_response["default_country_id"]).to eq(Spree::Config[:default_country_id])
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::CountriesController do
|
4
|
+
describe Api::CountriesController, :type => :controller do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
before do
|
@@ -12,7 +12,7 @@ module Spree
|
|
12
12
|
|
13
13
|
it "gets all countries" do
|
14
14
|
api_get :index
|
15
|
-
json_response['countries'].first['iso3'].
|
15
|
+
expect(json_response['countries'].first['iso3']).to eq @country.iso3
|
16
16
|
end
|
17
17
|
|
18
18
|
context "with two countries" do
|
@@ -20,29 +20,29 @@ module Spree
|
|
20
20
|
|
21
21
|
it "can view all countries" do
|
22
22
|
api_get :index
|
23
|
-
json_response['count'].
|
24
|
-
json_response['current_page'].
|
25
|
-
json_response['pages'].
|
23
|
+
expect(json_response['count']).to eq(2)
|
24
|
+
expect(json_response['current_page']).to eq(1)
|
25
|
+
expect(json_response['pages']).to eq(1)
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'can query the results through a paramter' do
|
29
29
|
api_get :index, :q => { :name_cont => 'zam' }
|
30
|
-
json_response['count'].
|
31
|
-
json_response['countries'].first['name'].
|
30
|
+
expect(json_response['count']).to eq(1)
|
31
|
+
expect(json_response['countries'].first['name']).to eq @zambia.name
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'can control the page size through a parameter' do
|
35
35
|
api_get :index, :per_page => 1
|
36
|
-
json_response['count'].
|
37
|
-
json_response['current_page'].
|
38
|
-
json_response['pages'].
|
36
|
+
expect(json_response['count']).to eq(1)
|
37
|
+
expect(json_response['current_page']).to eq(1)
|
38
|
+
expect(json_response['pages']).to eq(2)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
it "includes states" do
|
43
43
|
api_get :show, :id => @country.id
|
44
44
|
states = json_response['states']
|
45
|
-
states.first['name'].
|
45
|
+
expect(states.first['name']).to eq @state.name
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::CreditCardsController do
|
4
|
+
describe Api::CreditCardsController, :type => :controller do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
let!(:admin_user) do
|
8
8
|
user = Spree.user_class.new(:email => "spree@example.com", :id => 1)
|
9
9
|
user.generate_spree_api_key!
|
10
|
-
user.
|
10
|
+
allow(user).to receive(:has_spree_role?).with('admin').and_return(true)
|
11
11
|
user
|
12
12
|
end
|
13
13
|
|
@@ -25,7 +25,7 @@ module Spree
|
|
25
25
|
|
26
26
|
it "the user id doesn't exist" do
|
27
27
|
api_get :index, user_id: 1000
|
28
|
-
response.status.
|
28
|
+
expect(response.status).to eq(404)
|
29
29
|
end
|
30
30
|
|
31
31
|
context "calling user is in admin role" do
|
@@ -37,18 +37,18 @@ module Spree
|
|
37
37
|
it "no credit cards exist for user" do
|
38
38
|
api_get :index, user_id: normal_user.id
|
39
39
|
|
40
|
-
response.status.
|
41
|
-
json_response["pages"].
|
40
|
+
expect(response.status).to eq(200)
|
41
|
+
expect(json_response["pages"]).to eq(0)
|
42
42
|
end
|
43
43
|
|
44
44
|
it "can view all credit cards for user" do
|
45
45
|
api_get :index, user_id: current_api_user.id
|
46
46
|
|
47
|
-
response.status.
|
48
|
-
json_response["pages"].
|
49
|
-
json_response["current_page"].
|
50
|
-
json_response["credit_cards"].length.
|
51
|
-
json_response["credit_cards"].first["id"].
|
47
|
+
expect(response.status).to eq(200)
|
48
|
+
expect(json_response["pages"]).to eq(1)
|
49
|
+
expect(json_response["current_page"]).to eq(1)
|
50
|
+
expect(json_response["credit_cards"].length).to eq(1)
|
51
|
+
expect(json_response["credit_cards"].first["id"]).to eq(card.id)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -63,17 +63,17 @@ module Spree
|
|
63
63
|
it "can not view user" do
|
64
64
|
api_get :index, user_id: admin_user.id
|
65
65
|
|
66
|
-
response.status.
|
66
|
+
expect(response.status).to eq(404)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "can view own credit cards" do
|
70
70
|
api_get :index, user_id: normal_user.id
|
71
71
|
|
72
|
-
response.status.
|
73
|
-
json_response["pages"].
|
74
|
-
json_response["current_page"].
|
75
|
-
json_response["credit_cards"].length.
|
76
|
-
json_response["credit_cards"].first["id"].
|
72
|
+
expect(response.status).to eq(200)
|
73
|
+
expect(json_response["pages"]).to eq(1)
|
74
|
+
expect(json_response["current_page"]).to eq(1)
|
75
|
+
expect(json_response["credit_cards"].length).to eq(1)
|
76
|
+
expect(json_response["credit_cards"].first["id"]).to eq(card.id)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Spree::Api::ImagesController do
|
4
|
+
describe Spree::Api::ImagesController, :type => :controller do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
let!(:product) { create(:product) }
|
@@ -17,15 +17,15 @@ module Spree
|
|
17
17
|
sign_in_as_admin!
|
18
18
|
|
19
19
|
it "can upload a new image for a variant" do
|
20
|
-
|
20
|
+
expect do
|
21
21
|
api_post :create,
|
22
22
|
:image => { :attachment => upload_image('thinking-cat.jpg'),
|
23
23
|
:viewable_type => 'Spree::Variant',
|
24
24
|
:viewable_id => product.master.to_param },
|
25
25
|
:product_id => product.id
|
26
|
-
response.status.
|
27
|
-
json_response.
|
28
|
-
end.
|
26
|
+
expect(response.status).to eq(201)
|
27
|
+
expect(json_response).to have_attributes(attributes)
|
28
|
+
end.to change(Image, :count).by(1)
|
29
29
|
end
|
30
30
|
|
31
31
|
context "working with an existing image" do
|
@@ -33,42 +33,42 @@ module Spree
|
|
33
33
|
|
34
34
|
it "can get a single product image" do
|
35
35
|
api_get :show, :id => product_image.id, :product_id => product.id
|
36
|
-
response.status.
|
37
|
-
json_response.
|
36
|
+
expect(response.status).to eq(200)
|
37
|
+
expect(json_response).to have_attributes(attributes)
|
38
38
|
end
|
39
39
|
|
40
40
|
it "can get a single variant image" do
|
41
41
|
api_get :show, :id => product_image.id, :variant_id => product.master.id
|
42
|
-
response.status.
|
43
|
-
json_response.
|
42
|
+
expect(response.status).to eq(200)
|
43
|
+
expect(json_response).to have_attributes(attributes)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "can get a list of product images" do
|
47
47
|
api_get :index, :product_id => product.id
|
48
|
-
response.status.
|
49
|
-
json_response.
|
50
|
-
json_response["images"].first.
|
48
|
+
expect(response.status).to eq(200)
|
49
|
+
expect(json_response).to have_key("images")
|
50
|
+
expect(json_response["images"].first).to have_attributes(attributes)
|
51
51
|
end
|
52
52
|
|
53
53
|
it "can get a list of variant images" do
|
54
54
|
api_get :index, :variant_id => product.master.id
|
55
|
-
response.status.
|
56
|
-
json_response.
|
57
|
-
json_response["images"].first.
|
55
|
+
expect(response.status).to eq(200)
|
56
|
+
expect(json_response).to have_key("images")
|
57
|
+
expect(json_response["images"].first).to have_attributes(attributes)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "can update image data" do
|
61
|
-
product_image.position.
|
61
|
+
expect(product_image.position).to eq(1)
|
62
62
|
api_post :update, :image => { :position => 2 }, :id => product_image.id, :product_id => product.id
|
63
|
-
response.status.
|
64
|
-
json_response.
|
65
|
-
product_image.reload.position.
|
63
|
+
expect(response.status).to eq(200)
|
64
|
+
expect(json_response).to have_attributes(attributes)
|
65
|
+
expect(product_image.reload.position).to eq(2)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "can delete an image" do
|
69
69
|
api_delete :destroy, :id => product_image.id, :product_id => product.id
|
70
|
-
response.status.
|
71
|
-
|
70
|
+
expect(response.status).to eq(204)
|
71
|
+
expect { product_image.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
72
72
|
end
|
73
73
|
end
|
74
74
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::InventoryUnitsController do
|
4
|
+
describe Api::InventoryUnitsController, :type => :controller do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
before do
|
@@ -14,13 +14,13 @@ module Spree
|
|
14
14
|
|
15
15
|
it "gets an inventory unit" do
|
16
16
|
api_get :show, :id => @inventory_unit.id
|
17
|
-
json_response['state'].
|
17
|
+
expect(json_response['state']).to eq @inventory_unit.state
|
18
18
|
end
|
19
19
|
|
20
20
|
it "updates an inventory unit (only shipment is accessable by default)" do
|
21
21
|
api_put :update, :id => @inventory_unit.id,
|
22
22
|
:inventory_unit => { :shipment => nil }
|
23
|
-
json_response['shipment_id'].
|
23
|
+
expect(json_response['shipment_id']).to be_nil
|
24
24
|
end
|
25
25
|
|
26
26
|
context 'fires state event' do
|
@@ -29,19 +29,19 @@ module Spree
|
|
29
29
|
:fire => 'ship',
|
30
30
|
:inventory_unit => { :shipment => nil }
|
31
31
|
|
32
|
-
json_response['state'].
|
32
|
+
expect(json_response['state']).to eq 'shipped'
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'and returns exception if cannot fire' do
|
36
36
|
api_put :update, :id => @inventory_unit.id,
|
37
37
|
:fire => 'return'
|
38
|
-
json_response['exception'].
|
38
|
+
expect(json_response['exception']).to match /cannot transition to return/
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'and returns exception bad state' do
|
42
42
|
api_put :update, :id => @inventory_unit.id,
|
43
43
|
:fire => 'bad'
|
44
|
-
json_response['exception'].
|
44
|
+
expect(json_response['exception']).to match /cannot transition to bad/
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::LineItemsController do
|
4
|
+
describe Api::LineItemsController, :type => :controller do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
let!(:order) { create(:order_with_line_items, line_items_count: 1) }
|
@@ -11,77 +11,77 @@ module Spree
|
|
11
11
|
let(:resource_scoping) { { :order_id => order.to_param } }
|
12
12
|
|
13
13
|
it "can learn how to create a new line item" do
|
14
|
-
controller.
|
14
|
+
allow(controller).to receive_messages :try_spree_current_user => current_api_user
|
15
15
|
api_get :new
|
16
|
-
json_response["attributes"].
|
16
|
+
expect(json_response["attributes"]).to eq(["quantity", "price", "variant_id"])
|
17
17
|
required_attributes = json_response["required_attributes"]
|
18
|
-
required_attributes.
|
18
|
+
expect(required_attributes).to include("quantity", "variant_id")
|
19
19
|
end
|
20
20
|
|
21
21
|
context "authenticating with a token" do
|
22
22
|
it "can add a new line item to an existing order" do
|
23
23
|
api_post :create, :line_item => { :variant_id => product.master.to_param, :quantity => 1 }, :order_token => order.guest_token
|
24
|
-
response.status.
|
25
|
-
json_response.
|
26
|
-
json_response["variant"]["name"].
|
24
|
+
expect(response.status).to eq(201)
|
25
|
+
expect(json_response).to have_attributes(attributes)
|
26
|
+
expect(json_response["variant"]["name"]).not_to be_blank
|
27
27
|
end
|
28
28
|
|
29
29
|
it "can add a new line item to an existing order with token in header" do
|
30
30
|
request.headers["X-Spree-Order-Token"] = order.guest_token
|
31
31
|
api_post :create, :line_item => { :variant_id => product.master.to_param, :quantity => 1 }
|
32
|
-
response.status.
|
33
|
-
json_response.
|
34
|
-
json_response["variant"]["name"].
|
32
|
+
expect(response.status).to eq(201)
|
33
|
+
expect(json_response).to have_attributes(attributes)
|
34
|
+
expect(json_response["variant"]["name"]).not_to be_blank
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
context "as the order owner" do
|
39
39
|
before do
|
40
|
-
controller.
|
41
|
-
Order.
|
40
|
+
allow(controller).to receive_messages :try_spree_current_user => current_api_user
|
41
|
+
allow_any_instance_of(Order).to receive_messages :user => current_api_user
|
42
42
|
end
|
43
43
|
|
44
44
|
it "can add a new line item to an existing order" do
|
45
45
|
api_post :create, :line_item => { :variant_id => product.master.to_param, :quantity => 1 }
|
46
|
-
response.status.
|
47
|
-
json_response.
|
48
|
-
json_response["variant"]["name"].
|
46
|
+
expect(response.status).to eq(201)
|
47
|
+
expect(json_response).to have_attributes(attributes)
|
48
|
+
expect(json_response["variant"]["name"]).not_to be_blank
|
49
49
|
end
|
50
50
|
|
51
51
|
it "default quantity to 1 if none is given" do
|
52
52
|
api_post :create, :line_item => { :variant_id => product.master.to_param }
|
53
|
-
response.status.
|
54
|
-
json_response.
|
53
|
+
expect(response.status).to eq(201)
|
54
|
+
expect(json_response).to have_attributes(attributes)
|
55
55
|
expect(json_response[:quantity]).to eq 1
|
56
56
|
end
|
57
57
|
|
58
58
|
it "increases a line item's quantity if it exists already" do
|
59
59
|
order.line_items.create(:variant_id => product.master.id, :quantity => 10)
|
60
60
|
api_post :create, :line_item => { :variant_id => product.master.to_param, :quantity => 1 }
|
61
|
-
response.status.
|
61
|
+
expect(response.status).to eq(201)
|
62
62
|
order.reload
|
63
|
-
order.line_items.count.
|
64
|
-
json_response.
|
65
|
-
json_response["quantity"].
|
63
|
+
expect(order.line_items.count).to eq(2) # 1 original due to factory, + 1 in this test
|
64
|
+
expect(json_response).to have_attributes(attributes)
|
65
|
+
expect(json_response["quantity"]).to eq(11)
|
66
66
|
end
|
67
67
|
|
68
68
|
it "can update a line item on the order" do
|
69
69
|
line_item = order.line_items.first
|
70
70
|
api_put :update, :id => line_item.id, :line_item => { :quantity => 101 }
|
71
|
-
response.status.
|
71
|
+
expect(response.status).to eq(200)
|
72
72
|
order.reload
|
73
|
-
order.total.
|
74
|
-
json_response.
|
75
|
-
json_response["quantity"].
|
73
|
+
expect(order.total).to eq(1010) # 10 original due to factory, + 1000 in this test
|
74
|
+
expect(json_response).to have_attributes(attributes)
|
75
|
+
expect(json_response["quantity"]).to eq(101)
|
76
76
|
end
|
77
77
|
|
78
78
|
it "can delete a line item on the order" do
|
79
79
|
line_item = order.line_items.first
|
80
80
|
api_delete :destroy, :id => line_item.id
|
81
|
-
response.status.
|
81
|
+
expect(response.status).to eq(204)
|
82
82
|
order.reload
|
83
|
-
order.line_items.count.
|
84
|
-
|
83
|
+
expect(order.line_items.count).to eq(0) # 1 original due to factory, - 1 in this test
|
84
|
+
expect { line_item.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
85
85
|
end
|
86
86
|
|
87
87
|
context "order contents changed after shipments were created" do
|
@@ -110,8 +110,8 @@ module Spree
|
|
110
110
|
|
111
111
|
context "order is completed" do
|
112
112
|
before do
|
113
|
-
order.
|
114
|
-
Order.
|
113
|
+
allow(order).to receive_messages completed?: true
|
114
|
+
allow(Order).to receive_message_chain :includes, find_by!: order
|
115
115
|
end
|
116
116
|
|
117
117
|
it "doesn't destroy shipments or restart checkout flow" do
|
@@ -126,7 +126,7 @@ module Spree
|
|
126
126
|
context "as just another user" do
|
127
127
|
before do
|
128
128
|
user = create(:user)
|
129
|
-
controller.
|
129
|
+
allow(controller).to receive_messages :try_spree_current_user => user
|
130
130
|
end
|
131
131
|
|
132
132
|
it "cannot add a new line item to the order" do
|
@@ -138,14 +138,14 @@ module Spree
|
|
138
138
|
line_item = order.line_items.first
|
139
139
|
api_put :update, :id => line_item.id, :line_item => { :quantity => 1000 }
|
140
140
|
assert_unauthorized!
|
141
|
-
line_item.reload.quantity.
|
141
|
+
expect(line_item.reload.quantity).not_to eq(1000)
|
142
142
|
end
|
143
143
|
|
144
144
|
it "cannot delete a line item on the order" do
|
145
145
|
line_item = order.line_items.first
|
146
146
|
api_delete :destroy, :id => line_item.id
|
147
147
|
assert_unauthorized!
|
148
|
-
|
148
|
+
expect { line_item.reload }.not_to raise_error
|
149
149
|
end
|
150
150
|
end
|
151
151
|
end
|