spree_api 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/api/base_controller.rb +7 -4
  3. data/app/controllers/spree/api/checkouts_controller.rb +2 -2
  4. data/app/controllers/spree/api/countries_controller.rb +3 -3
  5. data/app/controllers/spree/api/images_controller.rb +2 -2
  6. data/app/controllers/spree/api/inventory_units_controller.rb +1 -1
  7. data/app/controllers/spree/api/orders_controller.rb +4 -4
  8. data/app/controllers/spree/api/payments_controller.rb +1 -1
  9. data/app/controllers/spree/api/product_properties_controller.rb +1 -1
  10. data/app/controllers/spree/api/products_controller.rb +4 -4
  11. data/app/controllers/spree/api/properties_controller.rb +1 -1
  12. data/app/controllers/spree/api/return_authorizations_controller.rb +4 -4
  13. data/app/controllers/spree/api/states_controller.rb +2 -2
  14. data/app/controllers/spree/api/stock_items_controller.rb +4 -4
  15. data/app/controllers/spree/api/stock_locations_controller.rb +5 -5
  16. data/app/controllers/spree/api/stock_movements_controller.rb +3 -3
  17. data/app/controllers/spree/api/stores_controller.rb +5 -5
  18. data/app/controllers/spree/api/taxonomies_controller.rb +4 -4
  19. data/app/controllers/spree/api/taxons_controller.rb +1 -1
  20. data/app/controllers/spree/api/variants_controller.rb +3 -3
  21. data/app/controllers/spree/api/zones_controller.rb +3 -3
  22. data/app/views/spree/api/variants/big.v1.rabl +0 -6
  23. data/lib/spree/api/testing_support/helpers.rb +1 -1
  24. data/lib/spree/api/testing_support/setup.rb +1 -1
  25. data/spec/controllers/spree/api/products_controller_spec.rb +7 -0
  26. data/spec/controllers/spree/api/users_controller_spec.rb +1 -1
  27. data/spec/controllers/spree/api/variants_controller_spec.rb +13 -2
  28. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab9505bfe7982709e648940a6685e64804a59525
4
- data.tar.gz: 33f82a1d56bca7c62d7992b90f7db61f37c1a853
3
+ metadata.gz: ef00fcd9a6f5ff3573c20c99509035edf9b49e66
4
+ data.tar.gz: 8b036132ce0f23d36d5cb58e283187ee17519066
5
5
  SHA512:
6
- metadata.gz: 078ed12604797d085834aebea70d5934c8af84c54aa61c05a1989c21f25d65520b37c331a4dd313dec0a121785aa9528b42fbab8ec9f55935319c689e68fe1e3
7
- data.tar.gz: b1a7ee95d0bc92cbbe1626a3732f074504f1589e1ea1d4bb1eda07b73d5417618ff4195b47ea55157ba248598d2bb7bd4afc63a18ecb7dd207b4d967a99fc7d3
6
+ metadata.gz: 70a31fa7caf0a0107ad2141582fa3ee166666789ff1202bf6082d72e7b8509af7a4f014cc1c7efc4985cf9e8bda1dbacaf93df443746b59b1ffca76d78865d5b
7
+ data.tar.gz: ce8f5e35409bb3593a2db354456761ab3dfdea846a454c94e1590039d8ef1a249f183f6ff48e0773112a2fd6cea7e5f8122f13285c7aa82690ee89e10f0e0514
@@ -42,15 +42,18 @@ module Spree
42
42
  end
43
43
  end
44
44
 
45
- private
46
-
47
- def set_content_type
48
- content_type = case params[:format]
45
+ def content_type
46
+ case params[:format]
49
47
  when "json"
50
48
  "application/json; charset=utf-8"
51
49
  when "xml"
52
50
  "text/xml; charset=utf-8"
53
51
  end
52
+ end
53
+
54
+ private
55
+
56
+ def set_content_type
54
57
  headers["Content-Type"] = content_type
55
58
  end
56
59
 
@@ -52,7 +52,7 @@ module Spree
52
52
  end
53
53
 
54
54
  def nested_params
55
- map_nested_attributes_keys Order, params[:order] || {}
55
+ map_nested_attributes_keys Spree::Order, params[:order] || {}
56
56
  end
57
57
 
58
58
  # Should be overriden if you have areas of your checkout that don't match
@@ -79,7 +79,7 @@ module Spree
79
79
 
80
80
  def after_update_attributes
81
81
  if nested_params && nested_params[:coupon_code].present?
82
- handler = PromotionHandler::Coupon.new(@order).apply
82
+ handler = Spree::PromotionHandler::Coupon.new(@order).apply
83
83
 
84
84
  if handler.error.present?
85
85
  @coupon_message = handler.error
@@ -5,17 +5,17 @@ module Spree
5
5
  skip_before_action :authenticate_user
6
6
 
7
7
  def index
8
- @countries = Country.accessible_by(current_ability, :read).ransack(params[:q]).result.
8
+ @countries = Spree::Country.accessible_by(current_ability, :read).ransack(params[:q]).result.
9
9
  includes(:states).order('name ASC').
10
10
  page(params[:page]).per(params[:per_page])
11
- country = Country.order("updated_at ASC").last
11
+ country = Spree::Country.order("updated_at ASC").last
12
12
  if stale?(country)
13
13
  respond_with(@countries)
14
14
  end
15
15
  end
16
16
 
17
17
  def show
18
- @country = Country.accessible_by(current_ability, :read).find(params[:id])
18
+ @country = Spree::Country.accessible_by(current_ability, :read).find(params[:id])
19
19
  respond_with(@country)
20
20
  end
21
21
  end
@@ -8,12 +8,12 @@ module Spree
8
8
  end
9
9
 
10
10
  def show
11
- @image = Image.accessible_by(current_ability, :read).find(params[:id])
11
+ @image = Spree::Image.accessible_by(current_ability, :read).find(params[:id])
12
12
  respond_with(@image)
13
13
  end
14
14
 
15
15
  def create
16
- authorize! :create, Image
16
+ authorize! :create, Spree::Image
17
17
  @image = scope.images.create(image_params)
18
18
  respond_with(@image, :status => 201, :default_template => :show)
19
19
  end
@@ -24,7 +24,7 @@ module Spree
24
24
  private
25
25
 
26
26
  def inventory_unit
27
- @inventory_unit ||= InventoryUnit.accessible_by(current_ability, :read).find(params[:id])
27
+ @inventory_unit ||= Spree::InventoryUnit.accessible_by(current_ability, :read).find(params[:id])
28
28
  end
29
29
 
30
30
  def prepare_event
@@ -7,7 +7,7 @@ module Spree
7
7
  before_action :find_order, except: [:create, :mine, :current, :index, :update]
8
8
 
9
9
  # Dynamically defines our stores checkout steps to ensure we check authorization on each step.
10
- Order.checkout_steps.keys.each do |step|
10
+ Spree::Order.checkout_steps.keys.each do |step|
11
11
  define_method step do
12
12
  find_order
13
13
  authorize! :update, @order, params[:token]
@@ -21,7 +21,7 @@ module Spree
21
21
  end
22
22
 
23
23
  def create
24
- authorize! :create, Order
24
+ authorize! :create, Spree::Order
25
25
  order_user = if @current_user_roles.include?('admin') && order_params[:user_id]
26
26
  Spree.user_class.find(order_params[:user_id])
27
27
  else
@@ -46,7 +46,7 @@ module Spree
46
46
 
47
47
  def index
48
48
  authorize! :index, Order
49
- @orders = Order.ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
49
+ @orders = Spree::Order.ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
50
50
  respond_with(@orders)
51
51
  end
52
52
 
@@ -91,7 +91,7 @@ module Spree
91
91
  find_order
92
92
  authorize! :update, @order, order_token
93
93
  @order.coupon_code = params[:coupon_code]
94
- @handler = PromotionHandler::Coupon.new(@order).apply
94
+ @handler = Spree::PromotionHandler::Coupon.new(@order).apply
95
95
  status = @handler.successful? ? 200 : 422
96
96
  render "spree/api/promotions/handler", :status => status
97
97
  end
@@ -67,7 +67,7 @@ module Spree
67
67
  end
68
68
 
69
69
  def perform_payment_action(action, *args)
70
- authorize! action, Payment
70
+ authorize! action, Spree::Payment
71
71
  @payment.send("#{action}!", *args)
72
72
  respond_with(@payment, default_template: :show)
73
73
  end
@@ -20,7 +20,7 @@ module Spree
20
20
  end
21
21
 
22
22
  def create
23
- authorize! :create, ProductProperty
23
+ authorize! :create, Spree::ProductProperty
24
24
  @product_property = @product.product_properties.new(product_property_params)
25
25
  if @product_property.save
26
26
  respond_with(@product_property, status: 201, default_template: :show)
@@ -57,12 +57,12 @@ module Spree
57
57
  # }
58
58
  #
59
59
  def create
60
- authorize! :create, Product
60
+ authorize! :create, Spree::Product
61
61
  params[:product][:available_on] ||= Time.now
62
62
  set_up_shipping_category
63
63
 
64
64
  options = { variants_attrs: variants_params, options_attrs: option_types_params }
65
- @product = Core::Importer::Product.new(nil, product_params, options).create
65
+ @product = Spree::Core::Importer::Product.new(nil, product_params, options).create
66
66
 
67
67
  if @product.persisted?
68
68
  respond_with(@product, :status => 201, :default_template => :show)
@@ -76,7 +76,7 @@ module Spree
76
76
  authorize! :update, @product
77
77
 
78
78
  options = { variants_attrs: variants_params, options_attrs: option_types_params }
79
- @product = Core::Importer::Product.new(@product, product_params, options).update
79
+ @product = Spree::Core::Importer::Product.new(@product, product_params, options).update
80
80
 
81
81
  if @product.errors.empty?
82
82
  respond_with(@product.reload, :status => 200, :default_template => :show)
@@ -119,7 +119,7 @@ module Spree
119
119
 
120
120
  def set_up_shipping_category
121
121
  if shipping_category = params[:product].delete(:shipping_category)
122
- id = ShippingCategory.find_or_create_by(name: shipping_category).id
122
+ id = Spree::ShippingCategory.find_or_create_by(name: shipping_category).id
123
123
  params[:product][:shipping_category_id] = id
124
124
  end
125
125
  end
@@ -25,7 +25,7 @@ module Spree
25
25
  end
26
26
 
27
27
  def create
28
- authorize! :create, Property
28
+ authorize! :create, Spree::Property
29
29
  @property = Spree::Property.new(property_params)
30
30
  if @property.save
31
31
  respond_with(@property, status: 201, default_template: :show)
@@ -3,7 +3,7 @@ module Spree
3
3
  class ReturnAuthorizationsController < Spree::Api::BaseController
4
4
 
5
5
  def create
6
- authorize! :create, ReturnAuthorization
6
+ authorize! :create, Spree::ReturnAuthorization
7
7
  @return_authorization = order.return_authorizations.build(return_authorization_params)
8
8
  if @return_authorization.save
9
9
  respond_with(@return_authorization, status: 201, default_template: :show)
@@ -19,7 +19,7 @@ module Spree
19
19
  end
20
20
 
21
21
  def index
22
- authorize! :admin, ReturnAuthorization
22
+ authorize! :admin, Spree::ReturnAuthorization
23
23
  @return_authorizations = order.return_authorizations.accessible_by(current_ability, :read).
24
24
  ransack(params[:q]).result.
25
25
  page(params[:page]).per(params[:per_page])
@@ -27,11 +27,11 @@ module Spree
27
27
  end
28
28
 
29
29
  def new
30
- authorize! :admin, ReturnAuthorization
30
+ authorize! :admin, Spree::ReturnAuthorization
31
31
  end
32
32
 
33
33
  def show
34
- authorize! :admin, ReturnAuthorization
34
+ authorize! :admin, Spree::ReturnAuthorization
35
35
  @return_authorization = order.return_authorizations.accessible_by(current_ability, :read).find(params[:id])
36
36
  respond_with(@return_authorization)
37
37
  end
@@ -27,10 +27,10 @@ module Spree
27
27
  private
28
28
  def scope
29
29
  if params[:country_id]
30
- @country = Country.accessible_by(current_ability, :read).find(params[:country_id])
30
+ @country = Spree::Country.accessible_by(current_ability, :read).find(params[:country_id])
31
31
  return @country.states.accessible_by(current_ability, :read)
32
32
  else
33
- return State.accessible_by(current_ability, :read)
33
+ return Spree::State.accessible_by(current_ability, :read)
34
34
  end
35
35
  end
36
36
  end
@@ -14,7 +14,7 @@ module Spree
14
14
  end
15
15
 
16
16
  def create
17
- authorize! :create, StockItem
17
+ authorize! :create, Spree::StockItem
18
18
 
19
19
  count_on_hand = 0
20
20
  if params[:stock_item].has_key?(:count_on_hand)
@@ -31,7 +31,7 @@ module Spree
31
31
  end
32
32
 
33
33
  def update
34
- @stock_item = StockItem.accessible_by(current_ability, :update).find(params[:id])
34
+ @stock_item = Spree::StockItem.accessible_by(current_ability, :update).find(params[:id])
35
35
 
36
36
  count_on_hand = 0
37
37
  if params[:stock_item].has_key?(:count_on_hand)
@@ -50,7 +50,7 @@ module Spree
50
50
  end
51
51
 
52
52
  def destroy
53
- @stock_item = StockItem.accessible_by(current_ability, :destroy).find(params[:id])
53
+ @stock_item = Spree::StockItem.accessible_by(current_ability, :destroy).find(params[:id])
54
54
  @stock_item.destroy
55
55
  respond_with(@stock_item, status: 204)
56
56
  end
@@ -59,7 +59,7 @@ module Spree
59
59
 
60
60
  def stock_location
61
61
  render 'spree/api/shared/stock_location_required', status: 422 and return unless params[:stock_location_id]
62
- @stock_location ||= StockLocation.accessible_by(current_ability, :read).find(params[:stock_location_id])
62
+ @stock_location ||= Spree::StockLocation.accessible_by(current_ability, :read).find(params[:stock_location_id])
63
63
  end
64
64
 
65
65
  def scope
@@ -2,8 +2,8 @@ module Spree
2
2
  module Api
3
3
  class StockLocationsController < Spree::Api::BaseController
4
4
  def index
5
- authorize! :read, StockLocation
6
- @stock_locations = StockLocation.accessible_by(current_ability, :read).order('name ASC').ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
5
+ authorize! :read, Spree::StockLocation
6
+ @stock_locations = Spree::StockLocation.accessible_by(current_ability, :read).order('name ASC').ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
7
7
  respond_with(@stock_locations)
8
8
  end
9
9
 
@@ -12,8 +12,8 @@ module Spree
12
12
  end
13
13
 
14
14
  def create
15
- authorize! :create, StockLocation
16
- @stock_location = StockLocation.new(stock_location_params)
15
+ authorize! :create, Spree::StockLocation
16
+ @stock_location = Spree::StockLocation.new(stock_location_params)
17
17
  if @stock_location.save
18
18
  respond_with(@stock_location, status: 201, default_template: :show)
19
19
  else
@@ -39,7 +39,7 @@ module Spree
39
39
  private
40
40
 
41
41
  def stock_location
42
- @stock_location ||= StockLocation.accessible_by(current_ability, :read).find(params[:id])
42
+ @stock_location ||= Spree::StockLocation.accessible_by(current_ability, :read).find(params[:id])
43
43
  end
44
44
 
45
45
  def stock_location_params
@@ -4,7 +4,7 @@ module Spree
4
4
  before_action :stock_location, except: [:update, :destroy]
5
5
 
6
6
  def index
7
- authorize! :read, StockMovement
7
+ authorize! :read, Spree::StockMovement
8
8
  @stock_movements = scope.ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
9
9
  respond_with(@stock_movements)
10
10
  end
@@ -15,7 +15,7 @@ module Spree
15
15
  end
16
16
 
17
17
  def create
18
- authorize! :create, StockMovement
18
+ authorize! :create, Spree::StockMovement
19
19
  @stock_movement = scope.new(stock_movement_params)
20
20
  if @stock_movement.save
21
21
  respond_with(@stock_movement, status: 201, default_template: :show)
@@ -28,7 +28,7 @@ module Spree
28
28
 
29
29
  def stock_location
30
30
  render 'spree/api/shared/stock_location_required', status: 422 and return unless params[:stock_location_id]
31
- @stock_location ||= StockLocation.accessible_by(current_ability, :read).find(params[:stock_location_id])
31
+ @stock_location ||= Spree::StockLocation.accessible_by(current_ability, :read).find(params[:stock_location_id])
32
32
  end
33
33
 
34
34
  def scope
@@ -5,14 +5,14 @@ module Spree
5
5
  before_filter :get_store, except: [:index, :create]
6
6
 
7
7
  def index
8
- authorize! :read, Store
9
- @stores = Store.accessible_by(current_ability, :read).all
8
+ authorize! :read, Spree::Store
9
+ @stores = Spree::Store.accessible_by(current_ability, :read).all
10
10
  respond_with(@stores)
11
11
  end
12
12
 
13
13
  def create
14
- authorize! :create, Store
15
- @store = Store.new(store_params)
14
+ authorize! :create, Spree::Store
15
+ @store = Spree::Store.new(store_params)
16
16
  @store.code = params[:store][:code]
17
17
  if @store.save
18
18
  respond_with(@store, status: 201, default_template: :show)
@@ -44,7 +44,7 @@ module Spree
44
44
  private
45
45
 
46
46
  def get_store
47
- @store = Store.find(params[:id])
47
+ @store = Spree::Store.find(params[:id])
48
48
  end
49
49
 
50
50
  def store_params
@@ -16,8 +16,8 @@ module Spree
16
16
  end
17
17
 
18
18
  def create
19
- authorize! :create, Taxonomy
20
- @taxonomy = Taxonomy.new(taxonomy_params)
19
+ authorize! :create, Spree::Taxonomy
20
+ @taxonomy = Spree::Taxonomy.new(taxonomy_params)
21
21
  if @taxonomy.save
22
22
  respond_with(@taxonomy, :status => 201, :default_template => :show)
23
23
  else
@@ -43,13 +43,13 @@ module Spree
43
43
  private
44
44
 
45
45
  def taxonomies
46
- @taxonomies = Taxonomy.accessible_by(current_ability, :read).order('name').includes(:root => :children).
46
+ @taxonomies = Spree::Taxonomy.accessible_by(current_ability, :read).order('name').includes(:root => :children).
47
47
  ransack(params[:q]).result.
48
48
  page(params[:page]).per(params[:per_page])
49
49
  end
50
50
 
51
51
  def taxonomy
52
- @taxonomy ||= Taxonomy.accessible_by(current_ability, :read).find(params[:id])
52
+ @taxonomy ||= Spree::Taxonomy.accessible_by(current_ability, :read).find(params[:id])
53
53
  end
54
54
 
55
55
  def taxonomy_params
@@ -26,7 +26,7 @@ module Spree
26
26
  end
27
27
 
28
28
  def create
29
- authorize! :create, Taxon
29
+ authorize! :create, Spree::Taxon
30
30
  @taxon = Spree::Taxon.new(taxon_params)
31
31
  @taxon.taxonomy_id = params[:taxonomy_id]
32
32
  taxonomy = Spree::Taxonomy.find_by(id: params[:taxonomy_id])
@@ -4,7 +4,7 @@ module Spree
4
4
  before_action :product
5
5
 
6
6
  def create
7
- authorize! :create, Variant
7
+ authorize! :create, Spree::Variant
8
8
  @variant = scope.new(variant_params)
9
9
  if @variant.save
10
10
  respond_with(@variant, status: 201, default_template: :show)
@@ -55,10 +55,10 @@ module Spree
55
55
  if @product
56
56
  variants = @product.variants_including_master
57
57
  else
58
- variants = Variant
58
+ variants = Spree::Variant
59
59
  end
60
60
 
61
- if current_ability.can?(:manage, Variant) && params[:show_deleted]
61
+ if current_ability.can?(:manage, Spree::Variant) && params[:show_deleted]
62
62
  variants = variants.with_deleted
63
63
  end
64
64
 
@@ -3,8 +3,8 @@ module Spree
3
3
  class ZonesController < Spree::Api::BaseController
4
4
 
5
5
  def create
6
- authorize! :create, Zone
7
- @zone = Zone.new(map_nested_attributes_keys(Spree::Zone, zone_params))
6
+ authorize! :create, Spree::Zone
7
+ @zone = Spree::Zone.new(map_nested_attributes_keys(Spree::Zone, zone_params))
8
8
  if @zone.save
9
9
  respond_with(@zone, :status => 201, :default_template => :show)
10
10
  else
@@ -19,7 +19,7 @@ module Spree
19
19
  end
20
20
 
21
21
  def index
22
- @zones = Zone.accessible_by(current_ability, :read).order('name ASC').ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
22
+ @zones = Spree::Zone.accessible_by(current_ability, :read).order('name ASC').ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
23
23
  respond_with(@zones)
24
24
  end
25
25
 
@@ -1,15 +1,9 @@
1
1
  object @variant
2
- attributes *variant_attributes
3
2
 
4
3
  cache [I18n.locale, @current_user_roles.include?('admin'), 'big_variant', root_object]
5
4
 
6
5
  extends "spree/api/variants/small"
7
6
 
8
- node :total_on_hand do
9
- root_object.total_on_hand
10
- end
11
-
12
-
13
7
  child(:stock_items => :stock_items) do
14
8
  attributes :id, :count_on_hand, :stock_location_id, :backorderable
15
9
  attribute :available? => :available
@@ -28,7 +28,7 @@ module Spree
28
28
  # This method can be overriden (with a let block) inside a context
29
29
  # For instance, if you wanted to have an admin user instead.
30
30
  def current_api_user
31
- @current_api_user ||= stub_model(Spree::LegacyUser, email: "spree@example.com")
31
+ @current_api_user ||= stub_model(Spree.user_class, email: "spree@example.com")
32
32
  end
33
33
 
34
34
  def image(filename)
@@ -4,7 +4,7 @@ module Spree
4
4
  module Setup
5
5
  def sign_in_as_admin!
6
6
  let!(:current_api_user) do
7
- user = stub_model(Spree::LegacyUser)
7
+ user = stub_model(Spree.user_class)
8
8
  allow(user).to receive_message_chain(:spree_roles, :pluck).and_return(["admin"])
9
9
  allow(user).to receive(:has_spree_role?).with("admin").and_return(true)
10
10
  user
@@ -326,6 +326,13 @@ module Spree
326
326
  expect(json_response['option_types'].count).to eq(2)
327
327
  end
328
328
 
329
+ it "creates product with option_types ids" do
330
+ option_type = create(:option_type)
331
+ product_data.merge!(option_type_ids: [option_type.id])
332
+ api_post :create, product: product_data
333
+ expect(json_response['option_types'].first['id']).to eq option_type.id
334
+ end
335
+
329
336
  it "creates with shipping categories" do
330
337
  hash = { :name => "The Other Product",
331
338
  :price => 19.99,
@@ -4,7 +4,7 @@ module Spree
4
4
  describe Api::UsersController, :type => :controller do
5
5
  render_views
6
6
 
7
- let(:user) { create(:user, spree_api_key: rand) }
7
+ let(:user) { create(:user, spree_api_key: rand.to_s) }
8
8
  let(:stranger) { create(:user, :email => 'stranger@example.com') }
9
9
  let(:attributes) { [:id, :email, :created_at, :updated_at] }
10
10
 
@@ -4,10 +4,11 @@ module Spree
4
4
  describe Api::VariantsController, :type => :controller do
5
5
  render_views
6
6
 
7
+ let(:option_value) { create(:option_value) }
7
8
  let!(:product) { create(:product) }
8
9
  let!(:variant) do
9
10
  variant = product.master
10
- variant.option_values << create(:option_value)
11
+ variant.option_values << option_value
11
12
  variant
12
13
  end
13
14
 
@@ -166,10 +167,20 @@ module Spree
166
167
  end
167
168
 
168
169
  it "can create a new variant" do
169
- api_post :create, :variant => { :sku => "12345" }
170
+ other_value = create(:option_value)
171
+ api_post :create, variant: {
172
+ sku: "12345",
173
+ price: "20",
174
+ option_value_ids: [option_value.id, other_value.id]
175
+ }
176
+
170
177
  expect(json_response).to have_attributes(new_attributes)
171
178
  expect(response.status).to eq(201)
172
179
  expect(json_response["sku"]).to eq("12345")
180
+ expect(json_response["price"]).to match "20"
181
+
182
+ option_value_ids = json_response["option_values"].map { |o| o['id'] }
183
+ expect(option_value_ids).to match_array [option_value.id, other_value.id]
173
184
 
174
185
  expect(variant.product.variants.count).to eq(1)
175
186
  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: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-10 00:00:00.000000000 Z
11
+ date: 2015-05-05 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: 3.0.0
19
+ version: 3.0.1
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: 3.0.0
26
+ version: 3.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rabl
29
29
  requirement: !ruby/object:Gem::Requirement