spree_api 2.3.13 → 2.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -43
- data/Gemfile +1 -1
- data/app/controllers/spree/api/addresses_controller.rb +1 -1
- data/app/controllers/spree/api/base_controller.rb +22 -9
- data/app/controllers/spree/api/checkouts_controller.rb +2 -2
- data/app/controllers/spree/api/countries_controller.rb +2 -2
- data/app/controllers/spree/api/credit_cards_controller.rb +1 -1
- data/app/controllers/spree/api/images_controller.rb +5 -0
- data/app/controllers/spree/api/inventory_units_controller.rb +1 -1
- data/app/controllers/spree/api/line_items_controller.rb +7 -7
- data/app/controllers/spree/api/option_types_controller.rb +2 -2
- data/app/controllers/spree/api/orders_controller.rb +17 -6
- data/app/controllers/spree/api/payments_controller.rb +3 -11
- data/app/controllers/spree/api/product_properties_controller.rb +2 -2
- data/app/controllers/spree/api/promotions_controller.rb +26 -0
- data/app/controllers/spree/api/properties_controller.rb +1 -1
- data/app/controllers/spree/api/return_authorizations_controller.rb +0 -10
- data/app/controllers/spree/api/shipments_controller.rb +71 -4
- data/app/controllers/spree/api/states_controller.rb +3 -3
- data/app/controllers/spree/api/stock_items_controller.rb +1 -1
- data/app/controllers/spree/api/stock_movements_controller.rb +1 -1
- data/app/controllers/spree/api/taxons_controller.rb +1 -1
- data/app/controllers/spree/api/variants_controller.rb +1 -2
- data/app/helpers/spree/api/api_helpers.rb +19 -5
- data/app/views/spree/api/images/index.v1.rabl +4 -0
- data/app/views/spree/api/products/show.v1.rabl +4 -1
- data/app/views/spree/api/promotions/handler.v1.rabl +2 -1
- data/app/views/spree/api/promotions/show.v1.rabl +2 -0
- data/app/views/spree/api/shipments/big.v1.rabl +48 -0
- data/app/views/spree/api/shipments/mine.v1.rabl +9 -0
- data/app/views/spree/api/shipments/small.v1.rabl +1 -5
- data/app/views/spree/api/shipping_rates/show.v1.rabl +2 -2
- data/app/views/spree/api/taxonomies/show.v1.rabl +2 -2
- data/app/views/spree/api/variants/big.v1.rabl +6 -1
- data/app/views/spree/api/variants/show.v1.rabl +1 -1
- data/app/views/spree/api/variants/small.v1.rabl +2 -3
- data/config/routes.rb +9 -0
- data/lib/spree/api/responders/rabl_template.rb +1 -1
- 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 +7 -7
- data/spec/controllers/spree/api/base_controller_spec.rb +66 -19
- data/spec/controllers/spree/api/checkouts_controller_spec.rb +54 -54
- 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 +37 -11
- data/spec/controllers/spree/api/inventory_units_controller_spec.rb +6 -6
- data/spec/controllers/spree/api/line_items_controller_spec.rb +34 -35
- data/spec/controllers/spree/api/option_types_controller_spec.rb +18 -18
- data/spec/controllers/spree/api/option_values_controller_spec.rb +21 -21
- data/spec/controllers/spree/api/orders_controller_spec.rb +177 -161
- data/spec/controllers/spree/api/payments_controller_spec.rb +52 -89
- data/spec/controllers/spree/api/product_properties_controller_spec.rb +21 -21
- data/spec/controllers/spree/api/products_controller_spec.rb +103 -60
- data/spec/controllers/spree/api/promotion_application_spec.rb +14 -12
- data/spec/controllers/spree/api/promotions_controller_spec.rb +64 -0
- data/spec/controllers/spree/api/properties_controller_spec.rb +25 -25
- data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +42 -66
- data/spec/controllers/spree/api/shipments_controller_spec.rb +69 -21
- 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 +5 -5
- data/spec/controllers/spree/api/users_controller_spec.rb +41 -41
- data/spec/controllers/spree/api/variants_controller_spec.rb +47 -37
- data/spec/controllers/spree/api/zones_controller_spec.rb +40 -18
- data/spec/models/spree/legacy_user_spec.rb +5 -5
- data/spec/requests/rabl_cache_spec.rb +9 -9
- data/spec/spec_helper.rb +1 -0
- metadata +14 -9
- data/spec/requests/ransackable_attributes_spec.rb +0 -79
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::StockLocationsController
|
4
|
+
describe Api::StockLocationsController do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
let!(:stock_location) { create(:stock_location) }
|
@@ -14,12 +14,12 @@ module Spree
|
|
14
14
|
context "as a user" do
|
15
15
|
it "cannot see stock locations" do
|
16
16
|
api_get :index
|
17
|
-
|
17
|
+
response.status.should == 401
|
18
18
|
end
|
19
19
|
|
20
20
|
it "cannot see a single stock location" do
|
21
21
|
api_get :show, :id => stock_location.id
|
22
|
-
|
22
|
+
response.status.should == 404
|
23
23
|
end
|
24
24
|
|
25
25
|
it "cannot create a new stock location" do
|
@@ -31,17 +31,17 @@ module Spree
|
|
31
31
|
}
|
32
32
|
|
33
33
|
api_post :create, params
|
34
|
-
|
34
|
+
response.status.should == 401
|
35
35
|
end
|
36
36
|
|
37
37
|
it "cannot update a stock location" do
|
38
38
|
api_put :update, :stock_location => { :name => "South Pole" }, :id => stock_location.to_param
|
39
|
-
|
39
|
+
response.status.should == 404
|
40
40
|
end
|
41
41
|
|
42
42
|
it "cannot delete a stock location" do
|
43
43
|
api_put :destroy, :id => stock_location.to_param
|
44
|
-
|
44
|
+
response.status.should == 404
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -51,30 +51,30 @@ module Spree
|
|
51
51
|
|
52
52
|
it "gets list of stock locations" do
|
53
53
|
api_get :index
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
json_response['stock_locations'].first.should have_attributes(attributes)
|
55
|
+
json_response['stock_locations'].first['country'].should_not be_nil
|
56
|
+
json_response['stock_locations'].first['state'].should_not be_nil
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'can control the page size through a parameter' do
|
60
60
|
create(:stock_location)
|
61
61
|
api_get :index, per_page: 1
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
json_response['count'].should == 1
|
63
|
+
json_response['current_page'].should == 1
|
64
|
+
json_response['pages'].should == 2
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'can query the results through a paramter' do
|
68
68
|
expected_result = create(:stock_location, name: 'South America')
|
69
69
|
api_get :index, q: { name_cont: 'south' }
|
70
|
-
|
71
|
-
|
70
|
+
json_response['count'].should == 1
|
71
|
+
json_response['stock_locations'].first['name'].should eq expected_result.name
|
72
72
|
end
|
73
73
|
|
74
74
|
it "gets a stock location" do
|
75
75
|
api_get :show, id: stock_location.to_param
|
76
|
-
|
77
|
-
|
76
|
+
json_response.should have_attributes(attributes)
|
77
|
+
json_response['name'].should eq stock_location.name
|
78
78
|
end
|
79
79
|
|
80
80
|
it "can create a new stock location" do
|
@@ -86,8 +86,8 @@ module Spree
|
|
86
86
|
}
|
87
87
|
|
88
88
|
api_post :create, params
|
89
|
-
|
90
|
-
|
89
|
+
response.status.should == 201
|
90
|
+
json_response.should have_attributes(attributes)
|
91
91
|
end
|
92
92
|
|
93
93
|
it "can update a stock location" do
|
@@ -99,14 +99,14 @@ module Spree
|
|
99
99
|
}
|
100
100
|
|
101
101
|
api_put :update, params
|
102
|
-
|
103
|
-
|
102
|
+
response.status.should == 200
|
103
|
+
json_response['name'].should eq 'South Pole'
|
104
104
|
end
|
105
105
|
|
106
106
|
it "can delete a stock location" do
|
107
107
|
api_delete :destroy, id: stock_location.to_param
|
108
|
-
|
109
|
-
|
108
|
+
response.status.should == 204
|
109
|
+
lambda { stock_location.reload }.should raise_error(ActiveRecord::RecordNotFound)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::StockMovementsController
|
4
|
+
describe Api::StockMovementsController do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
let!(:stock_location) { create(:stock_location_with_items) }
|
@@ -16,12 +16,12 @@ module Spree
|
|
16
16
|
context 'as a user' do
|
17
17
|
it 'cannot see a list of stock movements' do
|
18
18
|
api_get :index, stock_location_id: stock_location.to_param
|
19
|
-
|
19
|
+
response.status.should == 404
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'cannot see a stock movement' do
|
23
23
|
api_get :show, stock_location_id: stock_location.to_param, id: stock_movement.id
|
24
|
-
|
24
|
+
response.status.should == 404
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'cannot create a stock movement' do
|
@@ -33,7 +33,7 @@ module Spree
|
|
33
33
|
}
|
34
34
|
|
35
35
|
api_post :create, params
|
36
|
-
|
36
|
+
response.status.should == 404
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -42,34 +42,34 @@ module Spree
|
|
42
42
|
|
43
43
|
it 'gets list of stock movements' do
|
44
44
|
api_get :index, stock_location_id: stock_location.to_param
|
45
|
-
|
46
|
-
|
45
|
+
json_response['stock_movements'].first.should have_attributes(attributes)
|
46
|
+
json_response['stock_movements'].first['stock_item']['count_on_hand'].should eq 11
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'requires a stock_location_id to be passed as a parameter' do
|
50
50
|
api_get :index
|
51
|
-
|
52
|
-
|
51
|
+
json_response['error'].should =~ /stock_location_id parameter must be provided/
|
52
|
+
response.status.should == 422
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'can control the page size through a parameter' do
|
56
56
|
create(:stock_movement, stock_item: stock_item)
|
57
57
|
api_get :index, stock_location_id: stock_location.to_param, per_page: 1
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
json_response['count'].should == 1
|
59
|
+
json_response['current_page'].should == 1
|
60
|
+
json_response['pages'].should == 2
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'can query the results through a paramter' do
|
64
64
|
expected_result = create(:stock_movement, :received, quantity: 10, stock_item: stock_item)
|
65
65
|
api_get :index, stock_location_id: stock_location.to_param, q: { quantity_eq: '10' }
|
66
|
-
|
66
|
+
json_response['count'].should == 1
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'gets a stock movement' do
|
70
70
|
api_get :show, stock_location_id: stock_location.to_param, id: stock_movement.to_param
|
71
|
-
|
72
|
-
|
71
|
+
json_response.should have_attributes(attributes)
|
72
|
+
json_response['stock_item_id'].should eq stock_movement.stock_item_id
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'can create a new stock movement' do
|
@@ -81,8 +81,8 @@ module Spree
|
|
81
81
|
}
|
82
82
|
|
83
83
|
api_post :create, params
|
84
|
-
|
85
|
-
|
84
|
+
response.status.should == 201
|
85
|
+
json_response.should have_attributes(attributes)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::TaxonomiesController
|
4
|
+
describe Api::TaxonomiesController do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
let(:taxonomy) { create(:taxonomy) }
|
@@ -20,57 +20,57 @@ module Spree
|
|
20
20
|
it "gets all taxonomies" do
|
21
21
|
api_get :index
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
json_response["taxonomies"].first['name'].should eq taxonomy.name
|
24
|
+
json_response["taxonomies"].first['root']['taxons'].count.should eq 1
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'can control the page size through a parameter' do
|
28
28
|
create(:taxonomy)
|
29
29
|
api_get :index, :per_page => 1
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
json_response['count'].should == 1
|
31
|
+
json_response['current_page'].should == 1
|
32
|
+
json_response['pages'].should == 2
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'can query the results through a paramter' do
|
36
36
|
expected_result = create(:taxonomy, :name => 'Style')
|
37
37
|
api_get :index, :q => { :name_cont => 'style' }
|
38
|
-
|
39
|
-
|
38
|
+
json_response['count'].should == 1
|
39
|
+
json_response['taxonomies'].first['name'].should eq expected_result.name
|
40
40
|
end
|
41
41
|
|
42
42
|
it "gets a single taxonomy" do
|
43
43
|
api_get :show, :id => taxonomy.id
|
44
44
|
|
45
|
-
|
45
|
+
json_response['name'].should eq taxonomy.name
|
46
46
|
|
47
47
|
children = json_response['root']['taxons']
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
children.count.should eq 1
|
49
|
+
children.first['name'].should eq taxon.name
|
50
|
+
children.first.key?('taxons').should be false
|
51
51
|
end
|
52
52
|
|
53
53
|
it "gets a single taxonomy with set=nested" do
|
54
54
|
api_get :show, :id => taxonomy.id, :set => 'nested'
|
55
55
|
|
56
|
-
|
56
|
+
json_response['name'].should eq taxonomy.name
|
57
57
|
|
58
58
|
children = json_response['root']['taxons']
|
59
|
-
|
59
|
+
children.first.key?('taxons').should be true
|
60
60
|
end
|
61
61
|
|
62
62
|
it "gets the jstree-friendly version of a taxonomy" do
|
63
63
|
api_get :jstree, :id => taxonomy.id
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
json_response["data"].should eq(taxonomy.root.name)
|
65
|
+
json_response["attr"].should eq({ "id" => taxonomy.root.id, "name" => taxonomy.root.name})
|
66
|
+
json_response["state"].should eq("closed")
|
67
67
|
end
|
68
68
|
|
69
69
|
it "can learn how to create a new taxonomy" do
|
70
70
|
api_get :new
|
71
|
-
|
71
|
+
json_response["attributes"].should == attributes.map(&:to_s)
|
72
72
|
required_attributes = json_response["required_attributes"]
|
73
|
-
|
73
|
+
required_attributes.should include("name")
|
74
74
|
end
|
75
75
|
|
76
76
|
it "cannot create a new taxonomy if not an admin" do
|
@@ -94,20 +94,20 @@ module Spree
|
|
94
94
|
|
95
95
|
it "can create" do
|
96
96
|
api_post :create, :taxonomy => { :name => "Colors"}
|
97
|
-
|
98
|
-
|
97
|
+
json_response.should have_attributes(attributes)
|
98
|
+
response.status.should == 201
|
99
99
|
end
|
100
100
|
|
101
101
|
it "cannot create a new taxonomy with invalid attributes" do
|
102
102
|
api_post :create, :taxonomy => {}
|
103
|
-
|
104
|
-
|
103
|
+
response.status.should == 422
|
104
|
+
json_response["error"].should == "Invalid resource. Please fix errors and try again."
|
105
105
|
errors = json_response["errors"]
|
106
106
|
end
|
107
107
|
|
108
108
|
it "can destroy" do
|
109
109
|
api_delete :destroy, :id => taxonomy.id
|
110
|
-
|
110
|
+
response.status.should == 204
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::TaxonsController
|
4
|
+
describe Api::TaxonsController do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
let(:taxonomy) { create(:taxonomy) }
|
@@ -20,19 +20,19 @@ module Spree
|
|
20
20
|
it "gets all taxons for a taxonomy" do
|
21
21
|
api_get :index, :taxonomy_id => taxonomy.id
|
22
22
|
|
23
|
-
|
23
|
+
json_response['taxons'].first['name'].should eq taxon.name
|
24
24
|
children = json_response['taxons'].first['taxons']
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
children.count.should eq 1
|
26
|
+
children.first['name'].should eq taxon2.name
|
27
|
+
children.first['taxons'].count.should eq 1
|
28
28
|
end
|
29
29
|
|
30
30
|
# Regression test for #4112
|
31
31
|
it "does not include children when asked not to" do
|
32
32
|
api_get :index, :taxonomy_id => taxonomy.id, :without_children => 1
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
json_response['taxons'].first['name'].should eq(taxon.name)
|
35
|
+
json_response['taxons'].first['taxons'].should be_nil
|
36
36
|
end
|
37
37
|
|
38
38
|
it "paginates through taxons" do
|
@@ -57,8 +57,8 @@ module Spree
|
|
57
57
|
let(:name) { "Ruby" }
|
58
58
|
|
59
59
|
it "returns an array including the matching taxon" do
|
60
|
-
|
61
|
-
|
60
|
+
json_response['taxons'].count.should == 1
|
61
|
+
json_response['taxons'].first['name'].should eq "Ruby"
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
@@ -66,8 +66,8 @@ module Spree
|
|
66
66
|
let(:name) { "Imaginary" }
|
67
67
|
|
68
68
|
it 'returns an empty array of taxons' do
|
69
|
-
|
70
|
-
|
69
|
+
json_response.keys.should include('taxons')
|
70
|
+
json_response['taxons'].count.should == 0
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -76,11 +76,11 @@ module Spree
|
|
76
76
|
it "gets all taxons" do
|
77
77
|
api_get :index
|
78
78
|
|
79
|
-
|
79
|
+
json_response['taxons'].first['name'].should eq taxonomy.root.name
|
80
80
|
children = json_response['taxons'].first['taxons']
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
children.count.should eq 1
|
82
|
+
children.first['name'].should eq taxon.name
|
83
|
+
children.first['taxons'].count.should eq 1
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
@@ -88,23 +88,23 @@ module Spree
|
|
88
88
|
it "gets a single taxon" do
|
89
89
|
api_get :show, :id => taxon.id, :taxonomy_id => taxonomy.id
|
90
90
|
|
91
|
-
|
92
|
-
|
91
|
+
json_response['name'].should eq taxon.name
|
92
|
+
json_response['taxons'].count.should eq 1
|
93
93
|
end
|
94
94
|
|
95
95
|
it "gets all taxons in JSTree form" do
|
96
96
|
api_get :jstree, :taxonomy_id => taxonomy.id, :id => taxon.id
|
97
97
|
response = json_response.first
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
response["data"].should eq(taxon2.name)
|
99
|
+
response["attr"].should eq({ "name" => taxon2.name, "id" => taxon2.id})
|
100
|
+
response["state"].should eq("closed")
|
101
101
|
end
|
102
102
|
|
103
103
|
it "can learn how to create a new taxon" do
|
104
104
|
api_get :new, :taxonomy_id => taxonomy.id
|
105
|
-
|
105
|
+
json_response["attributes"].should == attributes.map(&:to_s)
|
106
106
|
required_attributes = json_response["required_attributes"]
|
107
|
-
|
107
|
+
required_attributes.should include("name")
|
108
108
|
end
|
109
109
|
|
110
110
|
it "cannot create a new taxon if not an admin" do
|
@@ -128,48 +128,48 @@ module Spree
|
|
128
128
|
|
129
129
|
it "can create" do
|
130
130
|
api_post :create, :taxonomy_id => taxonomy.id, :taxon => { :name => "Colors" }
|
131
|
-
|
132
|
-
|
131
|
+
json_response.should have_attributes(attributes)
|
132
|
+
response.status.should == 201
|
133
133
|
|
134
|
-
|
134
|
+
taxonomy.reload.root.children.count.should eq 2
|
135
135
|
taxon = Spree::Taxon.where(:name => 'Colors').first
|
136
136
|
|
137
|
-
|
138
|
-
|
137
|
+
taxon.parent_id.should eq taxonomy.root.id
|
138
|
+
taxon.taxonomy_id.should eq taxonomy.id
|
139
139
|
end
|
140
140
|
|
141
141
|
it "can update the position in the list" do
|
142
142
|
taxonomy.root.children << taxon2
|
143
143
|
api_put :update, :taxonomy_id => taxonomy.id, :id => taxon.id, :taxon => {:parent_id => taxon.parent_id, :child_index => 2 }
|
144
|
-
|
145
|
-
|
146
|
-
|
144
|
+
response.status.should == 200
|
145
|
+
taxonomy.reload.root.children[0].should eql taxon2
|
146
|
+
taxonomy.reload.root.children[1].should eql taxon
|
147
147
|
end
|
148
148
|
|
149
149
|
it "cannot create a new taxon with invalid attributes" do
|
150
150
|
api_post :create, :taxonomy_id => taxonomy.id, :taxon => {}
|
151
|
-
|
152
|
-
|
151
|
+
response.status.should == 422
|
152
|
+
json_response["error"].should == "Invalid resource. Please fix errors and try again."
|
153
153
|
errors = json_response["errors"]
|
154
154
|
|
155
|
-
|
155
|
+
taxonomy.reload.root.children.count.should eq 1
|
156
156
|
end
|
157
157
|
|
158
158
|
it "cannot create a new taxon with invalid taxonomy_id" do
|
159
159
|
api_post :create, :taxonomy_id => 1000, :taxon => { :name => "Colors" }
|
160
|
-
|
161
|
-
|
160
|
+
response.status.should == 422
|
161
|
+
json_response["error"].should == "Invalid resource. Please fix errors and try again."
|
162
162
|
|
163
163
|
errors = json_response["errors"]
|
164
|
-
|
165
|
-
|
164
|
+
errors["taxonomy_id"].should_not be_nil
|
165
|
+
errors["taxonomy_id"].first.should eq "Invalid taxonomy id."
|
166
166
|
|
167
|
-
|
167
|
+
taxonomy.reload.root.children.count.should eq 1
|
168
168
|
end
|
169
169
|
|
170
170
|
it "can destroy" do
|
171
171
|
api_delete :destroy, :taxonomy_id => taxonomy.id, :id => taxon.id
|
172
|
-
|
172
|
+
response.status.should == 204
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
@@ -2,7 +2,7 @@ require 'shared_examples/protect_product_actions'
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
module Spree
|
5
|
-
describe Spree::Api::ProductsController
|
5
|
+
describe Spree::Api::ProductsController do
|
6
6
|
render_views
|
7
7
|
|
8
8
|
let!(:product) { create(:product) }
|
@@ -13,10 +13,10 @@ module Spree
|
|
13
13
|
|
14
14
|
it "retreives a list of products" do
|
15
15
|
api_get :index
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
json_response["products"].first.should have_attributes(attributes)
|
17
|
+
json_response["count"].should == 1
|
18
|
+
json_response["current_page"].should == 1
|
19
|
+
json_response["pages"].should == 1
|
20
20
|
end
|
21
21
|
|
22
22
|
it_behaves_like "modifying product actions are restricted"
|