spree_api 2.0.8 → 2.0.9
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 -14
- data/app/controllers/spree/api/base_controller.rb +1 -1
- data/app/controllers/spree/api/checkouts_controller.rb +6 -13
- data/app/controllers/spree/api/orders_controller.rb +17 -16
- data/app/controllers/spree/api/products_controller.rb +24 -0
- data/app/models/spree/order_decorator.rb +7 -7
- data/app/views/spree/api/images/show.v1.rabl +3 -0
- data/app/views/spree/api/products/index.v1.rabl +1 -1
- data/app/views/spree/api/variants/index.v1.rabl +1 -1
- data/config/routes.rb +1 -1
- data/spec/controllers/spree/api/orders_controller_spec.rb +4 -1
- data/spec/controllers/spree/api/products_controller_spec.rb +59 -92
- data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +1 -1
- data/spec/controllers/spree/api/variants_controller_spec.rb +33 -18
- data/spree_api.gemspec +2 -2
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4f74781ea0934c3fecc2b6bfabf934360efce72
|
4
|
+
data.tar.gz: fa04ae4fd788014ba5a0f23abf4ab5120fb04e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 016441c31d86a96ebc8a362c8c254bcf682aa164a1fb418d961884ad7e92351ae863deca84299ba88b52c5c78f08aad9bfdb66d8b92bb58da82168ad1296c6c3
|
7
|
+
data.tar.gz: 0f3762b3c07a6089b7055a68d2114234724ab2c0ab450702e40d0a77d66e953ac1596143b02e8d3bd7cd0c5619815df4d8c4b7f7e43af7140dc1ee7deda40a08
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1 @@
|
|
1
|
-
## Spree 2.0.
|
2
|
-
|
3
|
-
* When line items are added after the delivery state, the shipments are now recreated. #3914
|
4
|
-
|
5
|
-
Washington Luiz
|
6
|
-
|
7
|
-
* State names are now persisted on addresses when using `ensure_state_from_api`, even if the state does not exist as a `Spree::State`. e976a3bbd603ea981499f440fa69f2e6d0d930d7
|
8
|
-
|
9
|
-
Washington Luiz
|
10
|
-
|
11
|
-
* Times are now returned with millisecond precision. (Note: this patch is not in the 2-1-stable or master branches because Rails 4 does this by default.)
|
12
|
-
|
13
|
-
Washington Luiz
|
14
|
-
|
1
|
+
## Spree 2.0.9 (unreleased) ##
|
@@ -28,7 +28,7 @@ module Spree
|
|
28
28
|
|
29
29
|
def set_jsonp_format
|
30
30
|
if params[:callback] && request.get?
|
31
|
-
self.response_body = "#{params[:callback]}(#{
|
31
|
+
self.response_body = "#{params[:callback]}(#{response.body})"
|
32
32
|
headers["Content-Type"] = 'application/javascript'
|
33
33
|
end
|
34
34
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Spree
|
2
2
|
module Api
|
3
3
|
class CheckoutsController < Spree::Api::BaseController
|
4
|
-
|
5
|
-
before_filter :load_order, only: [:show, :update, :next, :advance]
|
6
4
|
before_filter :associate_user, only: :update
|
7
5
|
|
8
6
|
include Spree::Core::ControllerHelpers::Auth
|
@@ -18,6 +16,7 @@ module Spree
|
|
18
16
|
end
|
19
17
|
|
20
18
|
def next
|
19
|
+
load_order(true)
|
21
20
|
authorize! :update, @order, params[:order_token]
|
22
21
|
@order.next!
|
23
22
|
respond_with(@order, default_template: 'spree/api/orders/show', status: 200)
|
@@ -26,16 +25,19 @@ module Spree
|
|
26
25
|
end
|
27
26
|
|
28
27
|
def advance
|
28
|
+
load_order(true)
|
29
29
|
authorize! :update, @order, params[:order_token]
|
30
30
|
while @order.next; end
|
31
31
|
respond_with(@order, default_template: 'spree/api/orders/show', status: 200)
|
32
32
|
end
|
33
33
|
|
34
34
|
def show
|
35
|
+
load_order
|
35
36
|
respond_with(@order, default_template: 'spree/api/orders/show', status: 200)
|
36
37
|
end
|
37
38
|
|
38
39
|
def update
|
40
|
+
load_order(true)
|
39
41
|
authorize! :update, @order, params[:order_token]
|
40
42
|
order_params = object_params
|
41
43
|
user_id = order_params.delete(:user_id)
|
@@ -53,14 +55,6 @@ module Spree
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
|
-
def next
|
57
|
-
@order.next!
|
58
|
-
authorize! :update, @order, params[:order_token]
|
59
|
-
respond_with(@order, :default_template => 'spree/api/orders/show', :status => 200)
|
60
|
-
rescue StateMachine::InvalidTransition
|
61
|
-
respond_with(@order, :default_template => 'spree/api/orders/could_not_transition', :status => 422)
|
62
|
-
end
|
63
|
-
|
64
58
|
private
|
65
59
|
|
66
60
|
def object_params
|
@@ -88,9 +82,8 @@ module Spree
|
|
88
82
|
false
|
89
83
|
end
|
90
84
|
|
91
|
-
def load_order
|
92
|
-
@order = Spree::Order.find_by_number!(params[:id])
|
93
|
-
authorize! :read, @order, params[:order_token]
|
85
|
+
def load_order(lock = false)
|
86
|
+
@order = Spree::Order.lock(lock).find_by_number!(params[:id])
|
94
87
|
raise_insufficient_quantity and return if @order.insufficient_stock_lines.present?
|
95
88
|
@order.state = params[:state] if params[:state]
|
96
89
|
state_callback(:before)
|
@@ -3,7 +3,7 @@ module Spree
|
|
3
3
|
class OrdersController < Spree::Api::BaseController
|
4
4
|
respond_to :json
|
5
5
|
|
6
|
-
before_filter :
|
6
|
+
before_filter :find_and_authorize!, :except => [:index, :search, :create]
|
7
7
|
|
8
8
|
def index
|
9
9
|
# should probably look at turning this into a CanCan step
|
@@ -19,33 +19,32 @@ module Spree
|
|
19
19
|
def create
|
20
20
|
nested_params[:line_items_attributes] = sanitize_line_items(nested_params[:line_items_attributes])
|
21
21
|
@order = Order.build_from_api(current_api_user, nested_params)
|
22
|
-
respond_with(order, :default_template => :show, :status => 201)
|
22
|
+
respond_with(@order, :default_template => :show, :status => 201)
|
23
23
|
end
|
24
24
|
|
25
25
|
def update
|
26
|
-
authorize! :update, Order
|
27
26
|
# Parsing line items through as an update_attributes call in the API will result in
|
28
27
|
# many line items for the same variant_id being created. We must be smarter about this,
|
29
28
|
# hence the use of the update_line_items method, defined within order_decorator.rb.
|
30
29
|
line_items_params = sanitize_line_items(nested_params.delete("line_items_attributes"))
|
31
|
-
if order.update_attributes(nested_params)
|
32
|
-
order.update_line_items(line_items_params)
|
33
|
-
order.line_items.reload
|
34
|
-
order.update!
|
35
|
-
respond_with(order, :default_template => :show)
|
30
|
+
if @order.update_attributes(nested_params)
|
31
|
+
@order.update_line_items(line_items_params)
|
32
|
+
@order.line_items.reload
|
33
|
+
@order.update!
|
34
|
+
respond_with(@order, :default_template => :show)
|
36
35
|
else
|
37
|
-
invalid_resource!(order)
|
36
|
+
invalid_resource!(@order)
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
40
|
def cancel
|
42
|
-
order.cancel!
|
41
|
+
@order.cancel!
|
43
42
|
render :show
|
44
43
|
end
|
45
44
|
|
46
45
|
def empty
|
47
|
-
order.empty!
|
48
|
-
order.update!
|
46
|
+
@order.empty!
|
47
|
+
@order.update!
|
49
48
|
render :text => nil, :status => 200
|
50
49
|
end
|
51
50
|
|
@@ -70,8 +69,9 @@ module Spree
|
|
70
69
|
line_item_attributes = Hash[line_item_attributes].delete_if { |k,v| v.empty? }
|
71
70
|
end
|
72
71
|
|
73
|
-
def
|
74
|
-
@order
|
72
|
+
def find_order(lock = false)
|
73
|
+
@order = Spree::Order.lock(lock).find_by_number!(params[:id])
|
74
|
+
authorize! :update, @order, params[:order_token]
|
75
75
|
end
|
76
76
|
|
77
77
|
def next!(options={})
|
@@ -82,8 +82,9 @@ module Spree
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
def
|
86
|
-
|
85
|
+
def find_and_authorize!
|
86
|
+
find_order(true)
|
87
|
+
authorize! :read, @order
|
87
88
|
end
|
88
89
|
end
|
89
90
|
end
|
@@ -60,8 +60,32 @@ module Spree
|
|
60
60
|
|
61
61
|
def update
|
62
62
|
authorize! :update, Product
|
63
|
+
|
64
|
+
variants_attributes = params[:product].delete(:variants_attributes) || []
|
65
|
+
option_type_attributes = params[:product].delete(:option_types) || []
|
66
|
+
set_up_shipping_category
|
67
|
+
|
63
68
|
@product = find_product(params[:id])
|
64
69
|
if @product.update_attributes(params[:product])
|
70
|
+
variants_attributes.each do |variant_attribute|
|
71
|
+
# update the variant if the id is present in the payload
|
72
|
+
if variant_attribute['id'].present?
|
73
|
+
@product.variants.find(variant_attribute['id'].to_i).update_attributes(variant_attribute)
|
74
|
+
else
|
75
|
+
variant = @product.variants.new
|
76
|
+
variant.update_attributes(variant_attribute)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
option_type_attributes.each do |name|
|
81
|
+
option_type = OptionType.where(name: name).first_or_initialize do |option_type|
|
82
|
+
option_type.presentation = name
|
83
|
+
option_type.save!
|
84
|
+
end
|
85
|
+
|
86
|
+
@product.option_types << option_type unless @product.option_types.include?(option_type)
|
87
|
+
end
|
88
|
+
|
65
89
|
respond_with(@product, :status => 200, :default_template => :show)
|
66
90
|
else
|
67
91
|
invalid_resource!(@product)
|
@@ -67,7 +67,7 @@ Spree::Order.class_eval do
|
|
67
67
|
shipment.shipping_rates.create!(:shipping_method => shipping_method,
|
68
68
|
:cost => s[:cost])
|
69
69
|
rescue Exception => e
|
70
|
-
raise "#{e.message} #{s}"
|
70
|
+
raise "Order import shipments: #{e.message} #{s}"
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -81,7 +81,7 @@ Spree::Order.class_eval do
|
|
81
81
|
payment.payment_method = Spree::PaymentMethod.find_by_name!(p[:payment_method])
|
82
82
|
payment.save!
|
83
83
|
rescue Exception => e
|
84
|
-
raise "#{e.message} #{p}"
|
84
|
+
raise "Order import payments: #{e.message} #{p}"
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -96,7 +96,7 @@ Spree::Order.class_eval do
|
|
96
96
|
line_item = self.contents.add(Spree::Variant.find(line_item[:variant_id]), line_item[:quantity])
|
97
97
|
line_item.update_attributes(extra_params, as: :api) unless extra_params.empty?
|
98
98
|
rescue Exception => e
|
99
|
-
raise "#{e.message} #{line_item}"
|
99
|
+
raise "Order import line items: #{e.message} #{line_item}"
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
@@ -109,7 +109,7 @@ Spree::Order.class_eval do
|
|
109
109
|
adjustment.save!
|
110
110
|
adjustment.finalize!
|
111
111
|
rescue Exception => e
|
112
|
-
raise "#{e.message} #{a}"
|
112
|
+
raise "Order import adjustments: #{e.message} #{a}"
|
113
113
|
end
|
114
114
|
end
|
115
115
|
end
|
@@ -121,7 +121,7 @@ Spree::Order.class_eval do
|
|
121
121
|
hash.delete(:sku)
|
122
122
|
end
|
123
123
|
rescue Exception => e
|
124
|
-
raise "#{e.message} #{hash}"
|
124
|
+
raise "Ensure order import variant: #{e.message} #{hash}"
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -144,7 +144,7 @@ Spree::Order.class_eval do
|
|
144
144
|
address[:country_id] = Spree::Country.where(search).first!.id
|
145
145
|
|
146
146
|
rescue Exception => e
|
147
|
-
raise "#{e.message} #{search}"
|
147
|
+
raise "Ensure order import address country: #{e.message} #{search}"
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
@@ -168,7 +168,7 @@ Spree::Order.class_eval do
|
|
168
168
|
address[:state_name] = search[:name] || search[:abbr]
|
169
169
|
end
|
170
170
|
rescue Exception => e
|
171
|
-
raise "#{e.message} #{search}"
|
171
|
+
raise "Ensure order import address state: #{e.message} #{search}"
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
@@ -4,6 +4,6 @@ node(:total_count) { @products.total_count }
|
|
4
4
|
node(:current_page) { params[:page] ? params[:page].to_i : 1 }
|
5
5
|
node(:pages) { @products.num_pages }
|
6
6
|
node(:per_page) { params[:per_page] || Kaminari.config.default_per_page }
|
7
|
-
child(@products) do
|
7
|
+
child(@products => :products) do
|
8
8
|
extends "spree/api/products/show"
|
9
9
|
end
|
data/config/routes.rb
CHANGED
@@ -296,10 +296,13 @@ module Spree
|
|
296
296
|
end
|
297
297
|
|
298
298
|
it "responds with orders updated_at with miliseconds precision" do
|
299
|
+
if ActiveRecord::Base.connection.adapter_name == "Mysql2"
|
300
|
+
pending "MySQL does not support millisecond timestamps."
|
301
|
+
end
|
302
|
+
|
299
303
|
api_get :index
|
300
304
|
milisecond = order.updated_at.strftime("%L")
|
301
305
|
updated_at = json_response["orders"].first["updated_at"]
|
302
|
-
|
303
306
|
expect(updated_at.split("T").last).to have_content(milisecond)
|
304
307
|
end
|
305
308
|
|
@@ -13,6 +13,16 @@ module Spree
|
|
13
13
|
:price => 19.99,
|
14
14
|
:shipping_category_id => create(:shipping_category).id }
|
15
15
|
end
|
16
|
+
let(:attributes_for_variant) do
|
17
|
+
h = attributes_for(:variant).except(:is_master, :product)
|
18
|
+
h.delete(:option_values)
|
19
|
+
h.merge({
|
20
|
+
options: [
|
21
|
+
{ name: "size", value: "small" },
|
22
|
+
{ name: "color", value: "black" }
|
23
|
+
]
|
24
|
+
})
|
25
|
+
end
|
16
26
|
|
17
27
|
before do
|
18
28
|
stub_authentication!
|
@@ -82,6 +92,13 @@ module Spree
|
|
82
92
|
response.body.should =~ /^callback\(.*\)$/
|
83
93
|
response.header['Content-Type'].should include('application/javascript')
|
84
94
|
end
|
95
|
+
|
96
|
+
# Regression test for #4332
|
97
|
+
it "does not escape quotes" do
|
98
|
+
api_get :index, {:callback => 'callback'}
|
99
|
+
response.body.should =~ /^callback\({"count":1,"total_count":1/
|
100
|
+
response.header['Content-Type'].should include('application/javascript')
|
101
|
+
end
|
85
102
|
end
|
86
103
|
|
87
104
|
it "can search for products" do
|
@@ -192,97 +209,6 @@ module Spree
|
|
192
209
|
|
193
210
|
describe "creating products with" do
|
194
211
|
it "embedded variants" do
|
195
|
-
def attributes_for_variant
|
196
|
-
h = attributes_for(:variant).except(:is_master, :product)
|
197
|
-
h.delete(:option_values)
|
198
|
-
h.merge({
|
199
|
-
options: [
|
200
|
-
{ name: "size", value: "small" },
|
201
|
-
{ name: "color", value: "black" }
|
202
|
-
]
|
203
|
-
})
|
204
|
-
end
|
205
|
-
|
206
|
-
attributes = product_hash
|
207
|
-
|
208
|
-
attributes.merge!({
|
209
|
-
shipping_category_id: 1,
|
210
|
-
|
211
|
-
option_types: ['size', 'color'],
|
212
|
-
|
213
|
-
variants_attributes: [
|
214
|
-
attributes_for_variant,
|
215
|
-
attributes_for_variant
|
216
|
-
]
|
217
|
-
})
|
218
|
-
|
219
|
-
api_post :create, :product => attributes
|
220
|
-
|
221
|
-
expect(json_response['variants'].count).to eq(3) # 1 master + 2 variants
|
222
|
-
expect(json_response['variants'][1]['option_values'][0]['name']).to eq('small')
|
223
|
-
expect(json_response['variants'][1]['option_values'][0]['option_type_name']).to eq('size')
|
224
|
-
|
225
|
-
expect(json_response['option_types'].count).to eq(2) # size, color
|
226
|
-
end
|
227
|
-
|
228
|
-
it "embedded product_properties" do
|
229
|
-
attributes = product_hash
|
230
|
-
|
231
|
-
attributes.merge!({
|
232
|
-
shipping_category_id: 1,
|
233
|
-
|
234
|
-
product_properties_attributes: [{
|
235
|
-
property_name: "fabric",
|
236
|
-
value: "cotton"
|
237
|
-
}]
|
238
|
-
})
|
239
|
-
|
240
|
-
api_post :create, :product => attributes
|
241
|
-
|
242
|
-
expect(json_response['product_properties'][0]['property_name']).to eq('fabric')
|
243
|
-
expect(json_response['product_properties'][0]['value']).to eq('cotton')
|
244
|
-
end
|
245
|
-
|
246
|
-
it "option_types even if without variants" do
|
247
|
-
attributes = product_hash
|
248
|
-
|
249
|
-
attributes.merge!({
|
250
|
-
shipping_category_id: 1,
|
251
|
-
|
252
|
-
option_types: ['size', 'color']
|
253
|
-
})
|
254
|
-
|
255
|
-
api_post :create, :product => attributes
|
256
|
-
|
257
|
-
expect(json_response['option_types'].count).to eq(2)
|
258
|
-
end
|
259
|
-
|
260
|
-
it "creates with shipping categories" do
|
261
|
-
hash = { :name => "The Other Product",
|
262
|
-
:price => 19.99,
|
263
|
-
:shipping_category => "Free Ships" }
|
264
|
-
|
265
|
-
api_post :create, :product => hash
|
266
|
-
expect(response.status).to eq 201
|
267
|
-
|
268
|
-
shipping_id = ShippingCategory.find_by_name("Free Ships").id
|
269
|
-
expect(json_response['shipping_category_id']).to eq shipping_id
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
describe "creating products with" do
|
274
|
-
it "embedded variants" do
|
275
|
-
def attributes_for_variant
|
276
|
-
h = attributes_for(:variant).except(:is_master, :product)
|
277
|
-
h.delete(:option_values)
|
278
|
-
h.merge({
|
279
|
-
options: [
|
280
|
-
{ name: "size", value: "small" },
|
281
|
-
{ name: "color", value: "black" }
|
282
|
-
]
|
283
|
-
})
|
284
|
-
end
|
285
|
-
|
286
212
|
product_hash.merge!({
|
287
213
|
variants_attributes: [
|
288
214
|
attributes_for_variant,
|
@@ -292,7 +218,6 @@ module Spree
|
|
292
218
|
|
293
219
|
api_post :create, :product => product_hash
|
294
220
|
expect(response.status).to eq 201
|
295
|
-
expect(json_response['variants'].count).to eq(3) # 1 master + 2 variants
|
296
221
|
|
297
222
|
variants = json_response['variants'].select { |v| !v['is_master'] }
|
298
223
|
expect(variants.first['option_values'][0]['name']).to eq('small')
|
@@ -376,6 +301,13 @@ module Spree
|
|
376
301
|
response.status.should == 200
|
377
302
|
end
|
378
303
|
|
304
|
+
it "updates shipping category properly if provided" do
|
305
|
+
api_put :update, :id => product.to_param, :product => { :shipping_category => "New Ships" }
|
306
|
+
expect(response.status).to eq 200
|
307
|
+
shipping_id = ShippingCategory.find_by_name("New Ships").id
|
308
|
+
expect(json_response['shipping_category_id']).to eq shipping_id
|
309
|
+
end
|
310
|
+
|
379
311
|
it "cannot update a product with an invalid attribute" do
|
380
312
|
api_put :update, :id => product.to_param, :product => { :name => "" }
|
381
313
|
response.status.should == 422
|
@@ -389,6 +321,41 @@ module Spree
|
|
389
321
|
response.status.should == 204
|
390
322
|
product.reload.deleted_at.should_not be_nil
|
391
323
|
end
|
324
|
+
|
325
|
+
describe "updating products with" do
|
326
|
+
it "embedded option types" do
|
327
|
+
api_put :update, :id => product.to_param, :product => { :option_types => ['shape', 'color'] }
|
328
|
+
json_response['option_types'].count.should eq(2)
|
329
|
+
end
|
330
|
+
|
331
|
+
it "new variants" do
|
332
|
+
api_put :update, :id => product.to_param, :product => { :variants_attributes => [attributes_for_variant, attributes_for_variant] }
|
333
|
+
response.status.should == 200
|
334
|
+
json_response['variants'].count.should == 3 # 1 master + 2 variants
|
335
|
+
|
336
|
+
variants = json_response['variants'].select { |v| !v['is_master'] }
|
337
|
+
variants.last['option_values'][0]['name'].should == 'small'
|
338
|
+
variants.last['option_values'][0]['option_type_name'].should == 'size'
|
339
|
+
|
340
|
+
json_response['option_types'].count.should == 2 # size, color
|
341
|
+
end
|
342
|
+
|
343
|
+
it "updating an existing variant" do
|
344
|
+
variant_hash = {
|
345
|
+
:sku => '123', :price => 19.99, :options => [{:name => "size", :value => "small"}]
|
346
|
+
}
|
347
|
+
variant = product.variants.new
|
348
|
+
variant.update_attributes(variant_hash)
|
349
|
+
|
350
|
+
api_put :update, :id => product.to_param, :product => { :variants_attributes => [variant_hash.merge(:id => variant.id.to_s, :sku => '456', :options => [{:name => "size", :value => "large" }])] }
|
351
|
+
|
352
|
+
json_response['variants'].count.should == 2 # 1 master + 2 variants
|
353
|
+
variants = json_response['variants'].select { |v| !v['is_master'] }
|
354
|
+
variants.last['option_values'][0]['name'].should == 'large'
|
355
|
+
variants.last['sku'].should == '456'
|
356
|
+
variants.count.should == 1
|
357
|
+
end
|
358
|
+
end
|
392
359
|
end
|
393
360
|
end
|
394
361
|
end
|
@@ -133,7 +133,7 @@ module Spree
|
|
133
133
|
end
|
134
134
|
|
135
135
|
it "can mark a return authorization as received on the order with an inventory unit" do
|
136
|
-
FactoryGirl.create(:new_return_authorization, :order => order)
|
136
|
+
FactoryGirl.create(:new_return_authorization, :order => order, :stock_location_id => order.shipments.first.stock_location.id)
|
137
137
|
return_authorization = order.return_authorizations.first
|
138
138
|
return_authorization.state.should == "authorized"
|
139
139
|
|
@@ -87,27 +87,42 @@ module Spree
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
|
91
|
-
api_get :show, :id => variant.to_param
|
92
|
-
json_response.should have_attributes(attributes)
|
93
|
-
option_values = json_response["option_values"]
|
94
|
-
option_values.first.should have_attributes([:name,
|
95
|
-
:presentation,
|
96
|
-
:option_type_name,
|
97
|
-
:option_type_id])
|
98
|
-
end
|
90
|
+
context "single variant" do
|
99
91
|
|
100
|
-
|
101
|
-
|
92
|
+
it "can see a single variant" do
|
93
|
+
api_get :show, :id => variant.to_param
|
94
|
+
json_response.should have_attributes(attributes)
|
95
|
+
option_values = json_response["option_values"]
|
96
|
+
option_values.first.should have_attributes([:name,
|
97
|
+
:presentation,
|
98
|
+
:option_type_name,
|
99
|
+
:option_type_id])
|
100
|
+
end
|
102
101
|
|
103
|
-
|
102
|
+
it "can see a single variant with images" do
|
103
|
+
variant.images.create!(:attachment => image("thinking-cat.jpg"))
|
104
|
+
|
105
|
+
api_get :show, :id => variant.to_param
|
106
|
+
|
107
|
+
json_response.should have_attributes(attributes + [:images])
|
108
|
+
option_values = json_response["option_values"]
|
109
|
+
option_values.first.should have_attributes([:name,
|
110
|
+
:presentation,
|
111
|
+
:option_type_name,
|
112
|
+
:option_type_id])
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'shows variant image urls' do
|
116
|
+
variant.images.create!(:attachment => image("thinking-cat.jpg"))
|
117
|
+
|
118
|
+
api_get :show, :id => variant.to_param
|
119
|
+
|
120
|
+
images = json_response["images"]
|
121
|
+
image = images.first
|
122
|
+
|
123
|
+
expect(image).to have_attributes [:mini_url, :small_url, :product_url, :large_url]
|
124
|
+
end
|
104
125
|
|
105
|
-
json_response.should have_attributes(attributes + [:images])
|
106
|
-
option_values = json_response["option_values"]
|
107
|
-
option_values.first.should have_attributes([:name,
|
108
|
-
:presentation,
|
109
|
-
:option_type_name,
|
110
|
-
:option_type_id])
|
111
126
|
end
|
112
127
|
|
113
128
|
it "can learn how to create a new variant" do
|
data/spree_api.gemspec
CHANGED
@@ -16,6 +16,6 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = version
|
17
17
|
|
18
18
|
gem.add_dependency 'spree_core', version
|
19
|
-
gem.add_dependency 'rabl', '0.
|
20
|
-
gem.add_dependency 'versioncake', '1.
|
19
|
+
gem.add_dependency 'rabl', '0.9.3'
|
20
|
+
gem.add_dependency 'versioncake', '~> 1.2.0'
|
21
21
|
end
|
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.0.
|
4
|
+
version: 2.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.
|
19
|
+
version: 2.0.9
|
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.0.
|
26
|
+
version: 2.0.9
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.9.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.9.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: versioncake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: 1.2.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: 1.2.0
|
55
55
|
description: Spree's API
|
56
56
|
email:
|
57
57
|
- ryan@spreecommerce.com
|