spree_api 3.3.6 → 3.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/app/controllers/spree/api/base_controller.rb +17 -21
- data/app/controllers/spree/api/v1/countries_controller.rb +2 -4
- data/app/controllers/spree/api/v1/credit_cards_controller.rb +9 -10
- data/app/controllers/spree/api/v1/images_controller.rb +1 -2
- data/app/controllers/spree/api/v1/inventory_units_controller.rb +2 -2
- data/app/controllers/spree/api/v1/line_items_controller.rb +24 -28
- data/app/controllers/spree/api/v1/option_types_controller.rb +5 -5
- data/app/controllers/spree/api/v1/option_values_controller.rb +16 -17
- data/app/controllers/spree/api/v1/orders_controller.rb +39 -49
- data/app/controllers/spree/api/v1/payments_controller.rb +15 -17
- data/app/controllers/spree/api/v1/product_properties_controller.rb +2 -3
- data/app/controllers/spree/api/v1/products_controller.rb +24 -25
- data/app/controllers/spree/api/v1/promotions_controller.rb +9 -8
- data/app/controllers/spree/api/v1/properties_controller.rb +14 -16
- data/app/controllers/spree/api/v1/return_authorizations_controller.rb +0 -1
- data/app/controllers/spree/api/v1/shipments_controller.rb +17 -26
- data/app/controllers/spree/api/v1/states_controller.rb +9 -10
- data/app/controllers/spree/api/v1/stock_items_controller.rb +2 -2
- data/app/controllers/spree/api/v1/stores_controller.rb +0 -1
- data/app/controllers/spree/api/v1/tags_controller.rb +1 -1
- data/app/controllers/spree/api/v1/taxonomies_controller.rb +1 -3
- data/app/controllers/spree/api/v1/taxons_controller.rb +15 -16
- data/app/controllers/spree/api/v1/users_controller.rb +1 -4
- data/app/controllers/spree/api/v1/variants_controller.rb +22 -22
- data/app/controllers/spree/api/v1/zones_controller.rb +0 -1
- data/app/helpers/spree/api/api_helpers.rb +5 -5
- data/app/views/spree/api/errors/gateway_error.v1.rabl +1 -1
- data/app/views/spree/api/errors/invalid_api_key.v1.rabl +1 -1
- data/app/views/spree/api/errors/invalid_resource.v1.rabl +1 -1
- data/app/views/spree/api/errors/must_specify_api_key.v1.rabl +1 -1
- data/app/views/spree/api/errors/not_found.v1.rabl +1 -1
- data/app/views/spree/api/errors/unauthorized.v1.rabl +1 -1
- data/app/views/spree/api/v1/addresses/show.v1.rabl +2 -2
- data/app/views/spree/api/v1/credit_cards/index.v1.rabl +1 -1
- data/app/views/spree/api/v1/images/index.v1.rabl +1 -1
- data/app/views/spree/api/v1/images/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/line_items/show.v1.rabl +3 -3
- data/app/views/spree/api/v1/option_types/index.v1.rabl +1 -1
- data/app/views/spree/api/v1/option_types/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/option_values/index.v1.rabl +1 -1
- data/app/views/spree/api/v1/option_values/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/orders/could_not_transition.v1.rabl +1 -1
- data/app/views/spree/api/v1/orders/index.v1.rabl +1 -1
- data/app/views/spree/api/v1/orders/invalid_shipping_method.v1.rabl +1 -1
- data/app/views/spree/api/v1/orders/mine.v1.rabl +1 -1
- data/app/views/spree/api/v1/orders/order.v1.rabl +5 -5
- data/app/views/spree/api/v1/orders/show.v1.rabl +7 -7
- data/app/views/spree/api/v1/product_properties/index.v1.rabl +1 -1
- data/app/views/spree/api/v1/product_properties/new.v1.rabl +1 -1
- data/app/views/spree/api/v1/products/index.v1.rabl +1 -1
- data/app/views/spree/api/v1/products/show.v1.rabl +5 -5
- data/app/views/spree/api/v1/return_authorizations/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/shared/stock_location_required.v1.rabl +1 -1
- data/app/views/spree/api/v1/shipments/big.v1.rabl +8 -8
- data/app/views/spree/api/v1/shipments/cannot_ready_shipment.v1.rabl +1 -1
- data/app/views/spree/api/v1/shipments/mine.v1.rabl +1 -1
- data/app/views/spree/api/v1/shipments/show.v1.rabl +5 -5
- data/app/views/spree/api/v1/shipments/small.v1.rabl +5 -5
- data/app/views/spree/api/v1/shipping_rates/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/states/index.v1.rabl +1 -3
- data/app/views/spree/api/v1/stock_items/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/stock_locations/show.v1.rabl +2 -2
- data/app/views/spree/api/v1/stock_movements/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/taxonomies/index.v1.rabl +1 -1
- data/app/views/spree/api/v1/taxonomies/jstree.rabl +2 -3
- data/app/views/spree/api/v1/taxonomies/nested.v1.rabl +1 -1
- data/app/views/spree/api/v1/taxonomies/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/taxons/index.v1.rabl +1 -3
- data/app/views/spree/api/v1/taxons/jstree.rabl +3 -4
- data/app/views/spree/api/v1/taxons/taxons.v1.rabl +1 -1
- data/app/views/spree/api/v1/users/index.v1.rabl +1 -1
- data/app/views/spree/api/v1/users/show.v1.rabl +3 -3
- data/app/views/spree/api/v1/variants/big.v1.rabl +1 -1
- data/app/views/spree/api/v1/variants/index.v1.rabl +1 -1
- data/app/views/spree/api/v1/variants/show.v1.rabl +1 -1
- data/app/views/spree/api/v1/variants/small.v1.rabl +7 -7
- data/config/routes.rb +3 -3
- data/lib/spree/api/controller_setup.rb +2 -2
- data/lib/spree/api/engine.rb +3 -3
- data/lib/spree/api/responders/rabl_template.rb +1 -3
- data/lib/spree/api/testing_support/caching.rb +3 -3
- data/lib/spree/api/testing_support/helpers.rb +4 -4
- data/lib/spree/api/testing_support/setup.rb +2 -2
- metadata +7 -7
@@ -1,2 +1,2 @@
|
|
1
1
|
object false
|
2
|
-
node(:error) { I18n.t(:cannot_ready, scope:
|
2
|
+
node(:error) { I18n.t(:cannot_ready, scope: 'spree.api.shipment') }
|
@@ -5,11 +5,11 @@ node(:order_id) { |shipment| shipment.order.number }
|
|
5
5
|
node(:stock_location_name) { |shipment| shipment.stock_location.name }
|
6
6
|
|
7
7
|
child shipping_rates: :shipping_rates do
|
8
|
-
extends
|
8
|
+
extends 'spree/api/v1/shipping_rates/show'
|
9
9
|
end
|
10
10
|
|
11
11
|
child selected_shipping_rate: :selected_shipping_rate do
|
12
|
-
extends
|
12
|
+
extends 'spree/api/v1/shipping_rates/show'
|
13
13
|
end
|
14
14
|
|
15
15
|
child shipping_methods: :shipping_methods do
|
@@ -25,8 +25,8 @@ end
|
|
25
25
|
|
26
26
|
child manifest: :manifest do
|
27
27
|
child variant: :variant do
|
28
|
-
extends
|
28
|
+
extends 'spree/api/v1/variants/small'
|
29
29
|
end
|
30
|
-
node(:quantity
|
31
|
-
node(:states
|
30
|
+
node(:quantity, &:quantity)
|
31
|
+
node(:states, &:states)
|
32
32
|
end
|
@@ -6,11 +6,11 @@ node(:order_id) { |shipment| shipment.order.number }
|
|
6
6
|
node(:stock_location_name) { |shipment| shipment.stock_location.name }
|
7
7
|
|
8
8
|
child shipping_rates: :shipping_rates do
|
9
|
-
extends
|
9
|
+
extends 'spree/api/v1/shipping_rates/show'
|
10
10
|
end
|
11
11
|
|
12
12
|
child selected_shipping_rate: :selected_shipping_rate do
|
13
|
-
extends
|
13
|
+
extends 'spree/api/v1/shipping_rates/show'
|
14
14
|
end
|
15
15
|
|
16
16
|
child shipping_methods: :shipping_methods do
|
@@ -28,10 +28,10 @@ child manifest: :manifest do
|
|
28
28
|
glue(:variant) do
|
29
29
|
attribute id: :variant_id
|
30
30
|
end
|
31
|
-
node(:quantity
|
32
|
-
node(:states
|
31
|
+
node(:quantity, &:quantity)
|
32
|
+
node(:states, &:states)
|
33
33
|
end
|
34
34
|
|
35
35
|
child adjustments: :adjustments do
|
36
|
-
extends
|
36
|
+
extends 'spree/api/v1/adjustments/show'
|
37
37
|
end
|
@@ -1,2 +1,2 @@
|
|
1
|
-
attributes
|
1
|
+
attributes :id, :name, :cost, :selected, :shipping_method_id, :shipping_method_code
|
2
2
|
node(:display_cost) { |sr| sr.display_cost.to_s }
|
@@ -6,7 +6,5 @@ node(:per_page) { params[:per_page].try(:to_i) || Kaminari.config.default_per_pa
|
|
6
6
|
node(:pages) { @taxons.total_pages }
|
7
7
|
child @taxons => :taxons do
|
8
8
|
attributes *taxon_attributes
|
9
|
-
unless params[:without_children]
|
10
|
-
extends "spree/api/v1/taxons/taxons"
|
11
|
-
end
|
9
|
+
extends 'spree/api/v1/taxons/taxons' unless params[:without_children]
|
12
10
|
end
|
@@ -3,9 +3,9 @@ cache [I18n.locale, root_object]
|
|
3
3
|
|
4
4
|
attributes *user_attributes
|
5
5
|
child(bill_address: :bill_address) do
|
6
|
-
extends
|
6
|
+
extends 'spree/api/v1/addresses/show'
|
7
7
|
end
|
8
8
|
|
9
9
|
child(ship_address: :ship_address) do
|
10
|
-
extends
|
11
|
-
end
|
10
|
+
extends 'spree/api/v1/addresses/show'
|
11
|
+
end
|
@@ -2,7 +2,7 @@ object @variant
|
|
2
2
|
|
3
3
|
cache [I18n.locale, @current_user_roles.include?('admin'), 'big_variant', root_object]
|
4
4
|
|
5
|
-
extends
|
5
|
+
extends 'spree/api/v1/variants/small'
|
6
6
|
|
7
7
|
child(stock_items: :stock_items) do
|
8
8
|
attributes :id, :count_on_hand, :stock_location_id, :backorderable
|
@@ -3,16 +3,16 @@ cache [I18n.locale, @current_user_roles.include?('admin'), 'small_variant', root
|
|
3
3
|
attributes *variant_attributes
|
4
4
|
|
5
5
|
node(:display_price) { |p| p.display_price.to_s }
|
6
|
-
node(:options_text
|
7
|
-
node(:track_inventory
|
8
|
-
node(:in_stock
|
9
|
-
node(:is_backorderable
|
6
|
+
node(:options_text, &:options_text)
|
7
|
+
node(:track_inventory, &:should_track_inventory?)
|
8
|
+
node(:in_stock, &:in_stock?)
|
9
|
+
node(:is_backorderable, &:is_backorderable?)
|
10
10
|
node(:is_orderable) { |v| v.is_backorderable? || v.in_stock? }
|
11
|
-
node(:total_on_hand
|
12
|
-
node(:is_destroyed
|
11
|
+
node(:total_on_hand, &:total_on_hand)
|
12
|
+
node(:is_destroyed, &:destroyed?)
|
13
13
|
|
14
14
|
child option_values: :option_values do
|
15
15
|
attributes *option_value_attributes
|
16
16
|
end
|
17
17
|
|
18
|
-
child(images: :images) { extends
|
18
|
+
child(images: :images) { extends 'spree/api/v1/images/show' }
|
data/config/routes.rb
CHANGED
@@ -61,7 +61,7 @@ Spree::Core::Engine.add_routes do
|
|
61
61
|
resources :option_values, only: :index
|
62
62
|
|
63
63
|
get '/orders/mine', to: 'orders#mine', as: 'my_orders'
|
64
|
-
get
|
64
|
+
get '/orders/current', to: 'orders#current', as: 'current_order'
|
65
65
|
|
66
66
|
resources :orders, concerns: :order_routes
|
67
67
|
|
@@ -122,14 +122,14 @@ Spree::Core::Engine.add_routes do
|
|
122
122
|
|
123
123
|
spree_path = Rails.application.routes.url_helpers.try(:spree_path, trailing_slash: true) || '/'
|
124
124
|
|
125
|
-
match 'v:api/*path', to: redirect{ |params, request|
|
125
|
+
match 'v:api/*path', to: redirect { |params, request|
|
126
126
|
format = ".#{params[:format]}" unless params[:format].blank?
|
127
127
|
query = "?#{request.query_string}" unless request.query_string.blank?
|
128
128
|
|
129
129
|
"#{spree_path}api/v1/#{params[:path]}#{format}#{query}"
|
130
130
|
}, via: [:get, :post, :put, :patch, :delete]
|
131
131
|
|
132
|
-
match '*path', to: redirect{ |params, request|
|
132
|
+
match '*path', to: redirect { |params, request|
|
133
133
|
format = ".#{params[:format]}" unless params[:format].blank?
|
134
134
|
query = "?#{request.query_string}" unless request.query_string.blank?
|
135
135
|
|
@@ -8,8 +8,8 @@ module Spree
|
|
8
8
|
include CanCan::ControllerAdditions
|
9
9
|
include Spree::Core::ControllerHelpers::Auth
|
10
10
|
|
11
|
-
prepend_view_path Rails.root +
|
12
|
-
append_view_path File.expand_path(
|
11
|
+
prepend_view_path Rails.root + 'app/views'
|
12
|
+
append_view_path File.expand_path('../../../app/views', File.dirname(__FILE__))
|
13
13
|
|
14
14
|
self.responder = Spree::Api::Responders::AppResponder
|
15
15
|
respond_to :json
|
data/lib/spree/api/engine.rb
CHANGED
@@ -17,7 +17,7 @@ module Spree
|
|
17
17
|
config.json_engine = ActiveSupport::JSON
|
18
18
|
end
|
19
19
|
|
20
|
-
initializer
|
20
|
+
initializer 'spree.api.versioncake' do |_app|
|
21
21
|
VersionCake.setup do |config|
|
22
22
|
config.resources do |r|
|
23
23
|
r.resource %r{.*}, [], [], [1]
|
@@ -28,12 +28,12 @@ module Spree
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
initializer
|
31
|
+
initializer 'spree.api.environment', before: :load_config_initializers do |_app|
|
32
32
|
Spree::Api::Config = Spree::ApiConfiguration.new
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.activate
|
36
|
-
Dir.glob(File.join(File.dirname(__FILE__),
|
36
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../../app/**/*_decorator*.rb')) do |c|
|
37
37
|
Rails.configuration.cache_classes ? require(c) : load(c)
|
38
38
|
end
|
39
39
|
end
|
@@ -17,11 +17,9 @@ module Spree
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def api_behavior
|
20
|
-
if controller.params[:action] ==
|
20
|
+
if controller.params[:action] == 'destroy'
|
21
21
|
# Render a blank template
|
22
22
|
super
|
23
|
-
else
|
24
|
-
# Do nothing and fallback to the default template
|
25
23
|
end
|
26
24
|
end
|
27
25
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
RSpec.configure do |config|
|
2
|
-
config.before(:each, caching: true) do
|
2
|
+
config.before(:each, caching: true) do
|
3
3
|
ActionController::Base.perform_caching = true
|
4
4
|
end
|
5
|
-
|
5
|
+
|
6
6
|
config.after(:each, caching: true) do
|
7
7
|
ActionController::Base.perform_caching = false
|
8
8
|
Rails.cache.clear
|
9
9
|
end
|
10
|
-
end
|
10
|
+
end
|
@@ -12,12 +12,12 @@ module Spree
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def assert_not_found!
|
15
|
-
expect(json_response).to eq(
|
15
|
+
expect(json_response).to eq('error' => 'The resource you were looking for could not be found.')
|
16
16
|
expect(response.status).to eq 404
|
17
17
|
end
|
18
18
|
|
19
19
|
def assert_unauthorized!
|
20
|
-
expect(json_response).to eq(
|
20
|
+
expect(json_response).to eq('error' => 'You are not authorized to perform that action.')
|
21
21
|
expect(response.status).to eq 401
|
22
22
|
end
|
23
23
|
|
@@ -28,11 +28,11 @@ 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.user_class, email:
|
31
|
+
@current_api_user ||= stub_model(Spree.user_class, email: 'spree@example.com')
|
32
32
|
end
|
33
33
|
|
34
34
|
def image(filename)
|
35
|
-
File.open(Spree::Api::Engine.root +
|
35
|
+
File.open(Spree::Api::Engine.root + 'spec/fixtures' + filename)
|
36
36
|
end
|
37
37
|
|
38
38
|
def upload_image(filename)
|
@@ -5,8 +5,8 @@ module Spree
|
|
5
5
|
def sign_in_as_admin!
|
6
6
|
let!(:current_api_user) do
|
7
7
|
user = stub_model(Spree.user_class)
|
8
|
-
allow(user).to receive_message_chain(:spree_roles, :pluck).and_return([
|
9
|
-
allow(user).to receive(:has_spree_role?).with(
|
8
|
+
allow(user).to receive_message_chain(:spree_roles, :pluck).and_return(['admin'])
|
9
|
+
allow(user).to receive(:has_spree_role?).with('admin').and_return(true)
|
10
10
|
user
|
11
11
|
end
|
12
12
|
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.
|
4
|
+
version: 3.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: 2017-09-22 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.
|
19
|
+
version: 3.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: 3.
|
26
|
+
version: 3.4.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,12 +230,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
230
230
|
version: 2.2.7
|
231
231
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
232
232
|
requirements:
|
233
|
-
- - "
|
233
|
+
- - ">"
|
234
234
|
- !ruby/object:Gem::Version
|
235
|
-
version:
|
235
|
+
version: 1.3.1
|
236
236
|
requirements: []
|
237
237
|
rubyforge_project:
|
238
|
-
rubygems_version: 2.6.
|
238
|
+
rubygems_version: 2.6.12
|
239
239
|
signing_key:
|
240
240
|
specification_version: 4
|
241
241
|
summary: Spree's API
|