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,51 +1,53 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::UsersController
|
4
|
+
describe Api::UsersController do
|
5
5
|
render_views
|
6
6
|
|
7
|
-
let(:user) { create(:user
|
7
|
+
let(:user) { create(:user) }
|
8
8
|
let(:stranger) { create(:user, :email => 'stranger@example.com') }
|
9
9
|
let(:attributes) { [:id, :email, :created_at, :updated_at] }
|
10
10
|
|
11
|
+
before { stub_authentication! }
|
12
|
+
|
11
13
|
context "as a normal user" do
|
14
|
+
before do
|
15
|
+
controller.stub :try_spree_current_user => user
|
16
|
+
end
|
17
|
+
|
12
18
|
it "can get own details" do
|
13
|
-
api_get :show,
|
19
|
+
api_get :show, :id => user.id
|
14
20
|
|
15
|
-
|
21
|
+
json_response['email'].should eq user.email
|
16
22
|
end
|
17
23
|
|
18
24
|
it "cannot get other users details" do
|
19
|
-
api_get :show, id
|
25
|
+
api_get :show, :id => stranger.id
|
20
26
|
|
21
27
|
assert_not_found!
|
22
28
|
end
|
23
29
|
|
24
30
|
it "can learn how to create a new user" do
|
25
|
-
api_get :new
|
26
|
-
|
31
|
+
api_get :new
|
32
|
+
json_response["attributes"].should == attributes.map(&:to_s)
|
27
33
|
end
|
28
34
|
|
29
35
|
it "can create a new user" do
|
30
|
-
|
31
|
-
|
32
|
-
}
|
33
|
-
|
34
|
-
api_post :create, :user => user_params, token: user.spree_api_key
|
35
|
-
expect(json_response['email']).to eq 'new@example.com'
|
36
|
+
api_post :create, :user => { :email => 'new@example.com', :password => 'spree123', :password_confirmation => 'spree123' }
|
37
|
+
json_response['email'].should eq 'new@example.com'
|
36
38
|
end
|
37
39
|
|
38
40
|
# there's no validations on LegacyUser?
|
39
41
|
xit "cannot create a new user with invalid attributes" do
|
40
|
-
api_post :create, :user => {}
|
41
|
-
|
42
|
-
|
42
|
+
api_post :create, :user => {}
|
43
|
+
response.status.should == 422
|
44
|
+
json_response["error"].should == "Invalid resource. Please fix errors and try again."
|
43
45
|
errors = json_response["errors"]
|
44
46
|
end
|
45
47
|
|
46
48
|
it "can update own details" do
|
47
49
|
country = create(:country)
|
48
|
-
api_put :update, id: user.id,
|
50
|
+
api_put :update, id: user.id, user: {
|
49
51
|
email: "mine@example.com",
|
50
52
|
bill_address_attributes: {
|
51
53
|
first_name: 'First',
|
@@ -74,78 +76,76 @@ module Spree
|
|
74
76
|
end
|
75
77
|
|
76
78
|
it "cannot update other users details" do
|
77
|
-
api_put :update, id
|
79
|
+
api_put :update, :id => stranger.id, :user => { :email => "mine@example.com" }
|
78
80
|
assert_not_found!
|
79
81
|
end
|
80
82
|
|
81
83
|
it "can delete itself" do
|
82
|
-
api_delete :destroy,
|
83
|
-
|
84
|
+
api_delete :destroy, :id => user.id
|
85
|
+
response.status.should == 204
|
84
86
|
end
|
85
87
|
|
86
88
|
it "cannot delete other user" do
|
87
|
-
api_delete :destroy, id
|
89
|
+
api_delete :destroy, :id => stranger.id
|
88
90
|
assert_not_found!
|
89
91
|
end
|
90
92
|
|
91
93
|
it "should only get own details on index" do
|
92
94
|
2.times { create(:user) }
|
93
|
-
api_get :index
|
95
|
+
api_get :index
|
94
96
|
|
95
|
-
|
96
|
-
|
97
|
-
|
97
|
+
Spree.user_class.count.should eq 3
|
98
|
+
json_response['count'].should eq 1
|
99
|
+
json_response['users'].size.should eq 1
|
98
100
|
end
|
99
101
|
end
|
100
102
|
|
101
103
|
context "as an admin" do
|
102
|
-
before { stub_authentication! }
|
103
|
-
|
104
104
|
sign_in_as_admin!
|
105
105
|
|
106
106
|
it "gets all users" do
|
107
|
-
|
107
|
+
Spree::LegacyUser.stub(:find_by).with(hash_including(:spree_api_key)) { current_api_user }
|
108
108
|
|
109
109
|
2.times { create(:user) }
|
110
110
|
|
111
111
|
api_get :index
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
Spree.user_class.count.should eq 2
|
113
|
+
json_response['count'].should eq 2
|
114
|
+
json_response['users'].size.should eq 2
|
115
115
|
end
|
116
116
|
|
117
117
|
it 'can control the page size through a parameter' do
|
118
118
|
2.times { create(:user) }
|
119
119
|
api_get :index, :per_page => 1
|
120
|
-
|
121
|
-
|
122
|
-
|
120
|
+
json_response['count'].should == 1
|
121
|
+
json_response['current_page'].should == 1
|
122
|
+
json_response['pages'].should == 2
|
123
123
|
end
|
124
124
|
|
125
125
|
it 'can query the results through a paramter' do
|
126
126
|
expected_result = create(:user, :email => 'brian@spreecommerce.com')
|
127
127
|
api_get :index, :q => { :email_cont => 'brian' }
|
128
|
-
|
129
|
-
|
128
|
+
json_response['count'].should == 1
|
129
|
+
json_response['users'].first['email'].should eq expected_result.email
|
130
130
|
end
|
131
131
|
|
132
132
|
it "can create" do
|
133
133
|
api_post :create, :user => { :email => "new@example.com", :password => 'spree123', :password_confirmation => 'spree123' }
|
134
|
-
|
135
|
-
|
134
|
+
json_response.should have_attributes(attributes)
|
135
|
+
response.status.should == 201
|
136
136
|
end
|
137
137
|
|
138
138
|
it "can destroy user without orders" do
|
139
139
|
user.orders.destroy_all
|
140
140
|
api_delete :destroy, :id => user.id
|
141
|
-
|
141
|
+
response.status.should == 204
|
142
142
|
end
|
143
143
|
|
144
144
|
it "cannot destroy user with orders" do
|
145
145
|
create(:completed_order_with_totals, :user => user)
|
146
146
|
api_delete :destroy, :id => user.id
|
147
|
-
|
148
|
-
|
147
|
+
json_response["exception"].should eq "Spree::Core::DestroyWithOrdersError"
|
148
|
+
response.status.should == 422
|
149
149
|
end
|
150
150
|
|
151
151
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::VariantsController
|
4
|
+
describe Api::VariantsController do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
let!(:product) { create(:product) }
|
@@ -22,32 +22,32 @@ module Spree
|
|
22
22
|
it "can see a paginated list of variants" do
|
23
23
|
api_get :index
|
24
24
|
first_variant = json_response["variants"].first
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
first_variant.should have_attributes(show_attributes)
|
26
|
+
first_variant["stock_items"].should be_present
|
27
|
+
json_response["count"].should == 1
|
28
|
+
json_response["current_page"].should == 1
|
29
|
+
json_response["pages"].should == 1
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'can control the page size through a parameter' do
|
33
33
|
create(:variant)
|
34
34
|
api_get :index, :per_page => 1
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
json_response['count'].should == 1
|
36
|
+
json_response['current_page'].should == 1
|
37
|
+
json_response['pages'].should == 3
|
38
38
|
end
|
39
39
|
|
40
|
-
it 'can query the results through a
|
40
|
+
it 'can query the results through a parameter' do
|
41
41
|
expected_result = create(:variant, :sku => 'FOOBAR')
|
42
42
|
api_get :index, :q => { :sku_cont => 'FOO' }
|
43
|
-
|
44
|
-
|
43
|
+
json_response['count'].should == 1
|
44
|
+
json_response['variants'].first['sku'].should eq expected_result.sku
|
45
45
|
end
|
46
46
|
|
47
47
|
it "variants returned contain option values data" do
|
48
48
|
api_get :index
|
49
49
|
option_values = json_response["variants"].last["option_values"]
|
50
|
-
|
50
|
+
option_values.first.should have_attributes([:name,
|
51
51
|
:presentation,
|
52
52
|
:option_type_name,
|
53
53
|
:option_type_id])
|
@@ -58,8 +58,8 @@ module Spree
|
|
58
58
|
|
59
59
|
api_get :index
|
60
60
|
|
61
|
-
|
62
|
-
|
61
|
+
json_response["variants"].last.should have_attributes([:images])
|
62
|
+
json_response['variants'].first['images'].first.should have_attributes([:attachment_file_name,
|
63
63
|
:attachment_width,
|
64
64
|
:attachment_height,
|
65
65
|
:attachment_content_type,
|
@@ -70,6 +70,11 @@ module Spree
|
|
70
70
|
|
71
71
|
end
|
72
72
|
|
73
|
+
it 'variants returned do not contain cost price data' do
|
74
|
+
api_get :index
|
75
|
+
expect(json_response["variants"].first.has_key?(:cost_price)).to eq false
|
76
|
+
end
|
77
|
+
|
73
78
|
# Regression test for #2141
|
74
79
|
context "a deleted variant" do
|
75
80
|
before do
|
@@ -78,12 +83,12 @@ module Spree
|
|
78
83
|
|
79
84
|
it "is not returned in the results" do
|
80
85
|
api_get :index
|
81
|
-
|
86
|
+
json_response["variants"].count.should == 0
|
82
87
|
end
|
83
88
|
|
84
89
|
it "is not returned even when show_deleted is passed" do
|
85
90
|
api_get :index, :show_deleted => true
|
86
|
-
|
91
|
+
json_response["variants"].count.should == 0
|
87
92
|
end
|
88
93
|
end
|
89
94
|
|
@@ -91,19 +96,19 @@ module Spree
|
|
91
96
|
it "can select the next page of variants" do
|
92
97
|
second_variant = create(:variant)
|
93
98
|
api_get :index, :page => 2, :per_page => 1
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
99
|
+
json_response["variants"].first.should have_attributes(show_attributes)
|
100
|
+
json_response["total_count"].should == 3
|
101
|
+
json_response["current_page"].should == 2
|
102
|
+
json_response["pages"].should == 3
|
98
103
|
end
|
99
104
|
end
|
100
105
|
|
101
106
|
it "can see a single variant" do
|
102
107
|
api_get :show, :id => variant.to_param
|
103
|
-
|
104
|
-
|
108
|
+
json_response.should have_attributes(show_attributes)
|
109
|
+
json_response["stock_items"].should be_present
|
105
110
|
option_values = json_response["option_values"]
|
106
|
-
|
111
|
+
option_values.first.should have_attributes([:name,
|
107
112
|
:presentation,
|
108
113
|
:option_type_name,
|
109
114
|
:option_type_id])
|
@@ -114,9 +119,9 @@ module Spree
|
|
114
119
|
|
115
120
|
api_get :show, :id => variant.to_param
|
116
121
|
|
117
|
-
|
122
|
+
json_response.should have_attributes(show_attributes + [:images])
|
118
123
|
option_values = json_response["option_values"]
|
119
|
-
|
124
|
+
option_values.first.should have_attributes([:name,
|
120
125
|
:presentation,
|
121
126
|
:option_type_name,
|
122
127
|
:option_type_id])
|
@@ -124,8 +129,8 @@ module Spree
|
|
124
129
|
|
125
130
|
it "can learn how to create a new variant" do
|
126
131
|
api_get :new
|
127
|
-
|
128
|
-
|
132
|
+
json_response["attributes"].should == new_attributes.map(&:to_s)
|
133
|
+
json_response["required_attributes"].should be_empty
|
129
134
|
end
|
130
135
|
|
131
136
|
it "cannot create a new variant if not an admin" do
|
@@ -141,7 +146,7 @@ module Spree
|
|
141
146
|
it "cannot delete a variant" do
|
142
147
|
api_delete :destroy, :id => variant.to_param
|
143
148
|
assert_not_found!
|
144
|
-
|
149
|
+
lambda { variant.reload }.should_not raise_error
|
145
150
|
end
|
146
151
|
|
147
152
|
context "as an admin" do
|
@@ -156,28 +161,33 @@ module Spree
|
|
156
161
|
|
157
162
|
it "are visible by admin" do
|
158
163
|
api_get :index, :show_deleted => 1
|
159
|
-
|
164
|
+
json_response["variants"].count.should == 1
|
160
165
|
end
|
161
166
|
end
|
162
167
|
|
163
168
|
it "can create a new variant" do
|
164
169
|
api_post :create, :variant => { :sku => "12345" }
|
165
|
-
|
166
|
-
|
167
|
-
|
170
|
+
json_response.should have_attributes(new_attributes)
|
171
|
+
response.status.should == 201
|
172
|
+
json_response["sku"].should == "12345"
|
168
173
|
|
169
|
-
|
174
|
+
variant.product.variants.count.should == 1
|
170
175
|
end
|
171
176
|
|
172
177
|
it "can update a variant" do
|
173
178
|
api_put :update, :id => variant.to_param, :variant => { :sku => "12345" }
|
174
|
-
|
179
|
+
response.status.should == 200
|
175
180
|
end
|
176
181
|
|
177
182
|
it "can delete a variant" do
|
178
183
|
api_delete :destroy, :id => variant.to_param
|
179
|
-
|
180
|
-
|
184
|
+
response.status.should == 204
|
185
|
+
lambda { Spree::Variant.find(variant.id) }.should raise_error(ActiveRecord::RecordNotFound)
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'variants returned contain cost price data' do
|
189
|
+
api_get :index
|
190
|
+
expect(json_response["variants"].first.has_key?(:cost_price)).to eq true
|
181
191
|
end
|
182
192
|
end
|
183
193
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe Api::ZonesController
|
4
|
+
describe Api::ZonesController do
|
5
5
|
render_views
|
6
6
|
|
7
7
|
let!(:attributes) { [:id, :name, :zone_members] }
|
@@ -13,29 +13,51 @@ module Spree
|
|
13
13
|
|
14
14
|
it "gets list of zones" do
|
15
15
|
api_get :index
|
16
|
-
|
16
|
+
json_response['zones'].first.should have_attributes(attributes)
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'can control the page size through a parameter' do
|
20
20
|
create(:zone)
|
21
21
|
api_get :index, :per_page => 1
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
json_response['count'].should == 1
|
23
|
+
json_response['current_page'].should == 1
|
24
|
+
json_response['pages'].should == 2
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'can query the results through a paramter' do
|
28
28
|
expected_result = create(:zone, :name => 'South America')
|
29
29
|
api_get :index, :q => { :name_cont => 'south' }
|
30
|
-
|
31
|
-
|
30
|
+
json_response['count'].should == 1
|
31
|
+
json_response['zones'].first['name'].should eq expected_result.name
|
32
32
|
end
|
33
33
|
|
34
34
|
it "gets a zone" do
|
35
35
|
api_get :show, :id => @zone.id
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
json_response.should have_attributes(attributes)
|
37
|
+
json_response['name'].should eq @zone.name
|
38
|
+
json_response['zone_members'].size.should eq @zone.zone_members.count
|
39
|
+
end
|
40
|
+
|
41
|
+
context "specifying a rabl template to use" do
|
42
|
+
before do
|
43
|
+
Spree::Api::ZonesController.class_eval do
|
44
|
+
def custom_show
|
45
|
+
respond_with(zone)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "uses the specified template" do
|
51
|
+
request.headers['X-Spree-Template'] = 'show'
|
52
|
+
api_get :custom_show, :id => @zone.id
|
53
|
+
response.should render_template('spree/api/zones/show')
|
54
|
+
end
|
55
|
+
|
56
|
+
it "falls back to the default template if the specified template does not exist" do
|
57
|
+
request.headers['X-Spree-Template'] = 'invoice'
|
58
|
+
api_get :show, :id => @zone.id
|
59
|
+
response.should render_template('spree/api/zones/show')
|
60
|
+
end
|
39
61
|
end
|
40
62
|
|
41
63
|
context "as an admin" do
|
@@ -55,9 +77,9 @@ module Spree
|
|
55
77
|
}
|
56
78
|
|
57
79
|
api_post :create, params
|
58
|
-
|
59
|
-
|
60
|
-
|
80
|
+
response.status.should == 201
|
81
|
+
json_response.should have_attributes(attributes)
|
82
|
+
json_response["zone_members"].should_not be_empty
|
61
83
|
end
|
62
84
|
|
63
85
|
it "updates a zone" do
|
@@ -74,15 +96,15 @@ module Spree
|
|
74
96
|
}
|
75
97
|
|
76
98
|
api_put :update, params
|
77
|
-
|
78
|
-
|
79
|
-
|
99
|
+
response.status.should == 200
|
100
|
+
json_response['name'].should eq 'North Pole'
|
101
|
+
json_response['zone_members'].should_not be_blank
|
80
102
|
end
|
81
103
|
|
82
104
|
it "can delete a zone" do
|
83
105
|
api_delete :destroy, :id => @zone.id
|
84
|
-
|
85
|
-
|
106
|
+
response.status.should == 204
|
107
|
+
lambda { @zone.reload }.should raise_error(ActiveRecord::RecordNotFound)
|
86
108
|
end
|
87
109
|
end
|
88
110
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Spree
|
4
|
-
describe LegacyUser
|
4
|
+
describe LegacyUser do
|
5
5
|
let(:user) { LegacyUser.new }
|
6
6
|
|
7
7
|
it "can generate an API key" do
|
8
|
-
|
8
|
+
user.should_receive(:save!)
|
9
9
|
user.generate_spree_api_key!
|
10
|
-
|
10
|
+
user.spree_api_key.should_not be_blank
|
11
11
|
end
|
12
12
|
|
13
13
|
it "can clear an API key" do
|
14
|
-
|
14
|
+
user.should_receive(:save!)
|
15
15
|
user.clear_spree_api_key!
|
16
|
-
|
16
|
+
user.spree_api_key.should be_blank
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -1,32 +1,32 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "Rabl Cache", :
|
3
|
+
describe "Rabl Cache", :caching => true do
|
4
4
|
let!(:user) { create(:admin_user) }
|
5
5
|
|
6
6
|
before do
|
7
7
|
create(:variant)
|
8
8
|
user.generate_spree_api_key!
|
9
|
-
|
9
|
+
Spree::Product.count.should == 1
|
10
10
|
end
|
11
11
|
|
12
12
|
it "doesn't create a cache key collision for models with different rabl templates" do
|
13
13
|
get "/api/variants", :token => user.spree_api_key
|
14
|
-
|
14
|
+
response.status.should == 200
|
15
15
|
|
16
16
|
# Make sure we get a non master variant
|
17
17
|
variant_a = JSON.parse(response.body)['variants'].select do |v|
|
18
18
|
!v['is_master']
|
19
19
|
end.first
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
variant_a['is_master'].should be false
|
22
|
+
variant_a['stock_items'].should_not be_nil
|
23
23
|
|
24
24
|
get "/api/products/#{Spree::Product.first.id}", :token => user.spree_api_key
|
25
|
-
|
25
|
+
response.status.should == 200
|
26
26
|
variant_b = JSON.parse(response.body)['variants'].last
|
27
|
-
|
27
|
+
variant_b['is_master'].should be false
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
variant_a['id'].should == variant_b['id']
|
30
|
+
variant_b['stock_items'].should be_nil
|
31
31
|
end
|
32
32
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.4.0.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.4.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- app/controllers/spree/api/payments_controller.rb
|
81
81
|
- app/controllers/spree/api/product_properties_controller.rb
|
82
82
|
- app/controllers/spree/api/products_controller.rb
|
83
|
+
- app/controllers/spree/api/promotions_controller.rb
|
83
84
|
- app/controllers/spree/api/properties_controller.rb
|
84
85
|
- app/controllers/spree/api/return_authorizations_controller.rb
|
85
86
|
- app/controllers/spree/api/shipments_controller.rb
|
@@ -109,6 +110,7 @@ files:
|
|
109
110
|
- app/views/spree/api/errors/must_specify_api_key.v1.rabl
|
110
111
|
- app/views/spree/api/errors/not_found.v1.rabl
|
111
112
|
- app/views/spree/api/errors/unauthorized.v1.rabl
|
113
|
+
- app/views/spree/api/images/index.v1.rabl
|
112
114
|
- app/views/spree/api/images/show.v1.rabl
|
113
115
|
- app/views/spree/api/inventory_units/show.rabl
|
114
116
|
- app/views/spree/api/line_items/new.v1.rabl
|
@@ -142,6 +144,7 @@ files:
|
|
142
144
|
- app/views/spree/api/products/product.v1.rabl
|
143
145
|
- app/views/spree/api/products/show.v1.rabl
|
144
146
|
- app/views/spree/api/promotions/handler.v1.rabl
|
147
|
+
- app/views/spree/api/promotions/show.v1.rabl
|
145
148
|
- app/views/spree/api/properties/index.v1.rabl
|
146
149
|
- app/views/spree/api/properties/new.v1.rabl
|
147
150
|
- app/views/spree/api/properties/show.v1.rabl
|
@@ -149,7 +152,9 @@ files:
|
|
149
152
|
- app/views/spree/api/return_authorizations/new.v1.rabl
|
150
153
|
- app/views/spree/api/return_authorizations/show.v1.rabl
|
151
154
|
- app/views/spree/api/shared/stock_location_required.v1.rabl
|
155
|
+
- app/views/spree/api/shipments/big.v1.rabl
|
152
156
|
- app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl
|
157
|
+
- app/views/spree/api/shipments/mine.v1.rabl
|
153
158
|
- app/views/spree/api/shipments/show.v1.rabl
|
154
159
|
- app/views/spree/api/shipments/small.v1.rabl
|
155
160
|
- app/views/spree/api/shipping_rates/show.v1.rabl
|
@@ -215,6 +220,7 @@ files:
|
|
215
220
|
- spec/controllers/spree/api/product_properties_controller_spec.rb
|
216
221
|
- spec/controllers/spree/api/products_controller_spec.rb
|
217
222
|
- spec/controllers/spree/api/promotion_application_spec.rb
|
223
|
+
- spec/controllers/spree/api/promotions_controller_spec.rb
|
218
224
|
- spec/controllers/spree/api/properties_controller_spec.rb
|
219
225
|
- spec/controllers/spree/api/return_authorizations_controller_spec.rb
|
220
226
|
- spec/controllers/spree/api/shipments_controller_spec.rb
|
@@ -231,7 +237,6 @@ files:
|
|
231
237
|
- spec/fixtures/thinking-cat.jpg
|
232
238
|
- spec/models/spree/legacy_user_spec.rb
|
233
239
|
- spec/requests/rabl_cache_spec.rb
|
234
|
-
- spec/requests/ransackable_attributes_spec.rb
|
235
240
|
- spec/shared_examples/protect_product_actions.rb
|
236
241
|
- spec/spec_helper.rb
|
237
242
|
- spec/support/controller_hacks.rb
|
@@ -252,12 +257,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
252
257
|
version: '0'
|
253
258
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
254
259
|
requirements:
|
255
|
-
- - "
|
260
|
+
- - ">"
|
256
261
|
- !ruby/object:Gem::Version
|
257
|
-
version:
|
262
|
+
version: 1.3.1
|
258
263
|
requirements: []
|
259
264
|
rubyforge_project:
|
260
|
-
rubygems_version: 2.
|
265
|
+
rubygems_version: 2.2.2
|
261
266
|
signing_key:
|
262
267
|
specification_version: 4
|
263
268
|
summary: Spree's API
|
@@ -279,6 +284,7 @@ test_files:
|
|
279
284
|
- spec/controllers/spree/api/product_properties_controller_spec.rb
|
280
285
|
- spec/controllers/spree/api/products_controller_spec.rb
|
281
286
|
- spec/controllers/spree/api/promotion_application_spec.rb
|
287
|
+
- spec/controllers/spree/api/promotions_controller_spec.rb
|
282
288
|
- spec/controllers/spree/api/properties_controller_spec.rb
|
283
289
|
- spec/controllers/spree/api/return_authorizations_controller_spec.rb
|
284
290
|
- spec/controllers/spree/api/shipments_controller_spec.rb
|
@@ -295,7 +301,6 @@ test_files:
|
|
295
301
|
- spec/fixtures/thinking-cat.jpg
|
296
302
|
- spec/models/spree/legacy_user_spec.rb
|
297
303
|
- spec/requests/rabl_cache_spec.rb
|
298
|
-
- spec/requests/ransackable_attributes_spec.rb
|
299
304
|
- spec/shared_examples/protect_product_actions.rb
|
300
305
|
- spec/spec_helper.rb
|
301
306
|
- spec/support/controller_hacks.rb
|