spree_api 4.0.0.rc3 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6064574ff2f1083d6d90789c4d2c9560fd52aac40545b5117bfadb7f5bb2f14b
4
- data.tar.gz: b0f41b268234fe9fc1951f26751ec79536275bb6afc8aa562d7ef8851c1d7aa8
3
+ metadata.gz: fc158319298bbbcc29f0137370d6785232e6e9a03f1335a6759a1604daffd9d0
4
+ data.tar.gz: e4295163450d6523e8480f960fc239b72051b0ec8f5ad958ec95f6ea898334a4
5
5
  SHA512:
6
- metadata.gz: 3f213b7b87c542d60c7c65726bd40564e2d93ae2235f65838e2f4bbd08f5e171f8efc4d56a96f22f3a3563f73dbf305bc2ef35a5f93bb97f362971837fa1ac51
7
- data.tar.gz: 1dd02adbf07965baddab2baccb5aabe4a100025d13cf3b8b6225b0bd5f96b371eee75ba01eb28ec885b6276ce6ae1900bd630b16c1c464e0e7f539d8ed8fe1a2
6
+ metadata.gz: 32baa584cd58b7e51784162c1b6f630013cb4af832465fb4cfb313e9c914684d0898cbacab9e7237b57b78fea2ed5244e7b2c6c8499287260f542361bab3d9b8
7
+ data.tar.gz: 6194748bc05257b57003d98f751c5729815171fce592027b3858f40e600ac252284d34fd26b2676075bfe64d6019a55cda9265806aa94cb18741d2cce5d684f0
@@ -7,13 +7,17 @@ module Spree
7
7
  def index
8
8
  @users = Spree.user_class.accessible_by(current_ability, :show)
9
9
 
10
- @users = if params[:ids]
11
- @users.ransack(id_in: params[:ids].split(','))
12
- else
13
- @users.ransack(params[:q])
14
- end
10
+ if params[:ids]
11
+ @users = @users.where(id: params[:ids])
12
+ elsif params[:q]
13
+ users_with_ship_address = @users.with_address(params[:q][:ship_address_firstname_start])
14
+ users_with_bill_address = @users.with_address(params[:q][:ship_address_firstname_start], :bill_address)
15
15
 
16
- @users = @users.result.page(params[:page]).per(params[:per_page])
16
+ users_with_addresses_ids = (users_with_ship_address.ids + users_with_bill_address.ids).compact.uniq
17
+ @users = @users.with_email_or_addresses_ids(params[:q][:email_start], users_with_addresses_ids)
18
+ end
19
+
20
+ @users = @users.page(params[:page]).per(params[:per_page])
17
21
  expires_in 15.minutes, public: true
18
22
  headers['Surrogate-Control'] = "max-age=#{15.minutes}"
19
23
  respond_with(@users)
@@ -55,7 +55,12 @@ module Spree
55
55
  end
56
56
 
57
57
  def spree_current_user
58
- @spree_current_user ||= Spree.user_class.find_by(id: doorkeeper_token.resource_owner_id) if doorkeeper_token
58
+ return nil unless doorkeeper_token
59
+ return @spree_current_user if @spree_current_user
60
+
61
+ doorkeeper_authorize!
62
+
63
+ @spree_current_user ||= Spree.user_class.find_by(id: doorkeeper_token.resource_owner_id)
59
64
  end
60
65
 
61
66
  def spree_authorize!(action, subject, *args)
@@ -5,6 +5,8 @@ module Spree
5
5
  class OrderStatusController < ::Spree::Api::V2::BaseController
6
6
  include Spree::Api::V2::Storefront::OrderConcern
7
7
 
8
+ before_action :ensure_order_token
9
+
8
10
  def show
9
11
  render_serialized_payload { serialize_resource(resource) }
10
12
  end
@@ -25,6 +27,10 @@ module Spree
25
27
  def resource_serializer
26
28
  Spree::Api::Dependencies.storefront_cart_serializer.constantize
27
29
  end
30
+
31
+ def ensure_order_token
32
+ raise ActiveRecord::RecordNotFound unless order_token
33
+ end
28
34
  end
29
35
  end
30
36
  end
@@ -12,15 +12,7 @@ module Spree
12
12
 
13
13
  has_many :line_items
14
14
  has_many :variants
15
- has_many :promotions, id_method_name: :promotion_id do |cart|
16
- # we only want to display applied and valid promotions
17
- # sometimes Order can have multiple promotions but the promo engine
18
- # will only apply those that are more beneficial for the customer
19
- # TODO: we should probably move this code out of the serializer
20
- promotion_ids = cart.all_adjustments.eligible.nonzero.promotion.map { |a| a.source.promotion_id }.uniq
21
-
22
- cart.order_promotions.where(promotion_id: promotion_ids).uniq(&:promotion_id)
23
- end
15
+ has_many :promotions, object_method_name: :valid_promotions, id_method_name: :valid_promotion_ids
24
16
  has_many :payments do |cart|
25
17
  cart.payments.valid
26
18
  end
@@ -162,6 +162,8 @@ paths:
162
162
  - $ref: '#/components/parameters/OrderParam'
163
163
  - $ref: '#/components/parameters/CartIncludeParam'
164
164
  - $ref: '#/components/parameters/SparseFieldsParam'
165
+ security:
166
+ - orderToken: []
165
167
  '/cart':
166
168
  post:
167
169
  description: >-
@@ -4,7 +4,7 @@ shared_context 'API v2 tokens' do
4
4
  let(:headers_order_token) { { 'X-Spree-Order-Token' => order.token } }
5
5
  end
6
6
 
7
- [200, 201, 400, 404, 403, 422].each do |status_code|
7
+ [200, 201, 400, 401, 404, 403, 422].each do |status_code|
8
8
  shared_examples "returns #{status_code} HTTP status" do
9
9
  it "returns #{status_code}" do
10
10
  expect(response.status).to eq(status_code)
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: 4.0.0.rc3
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-27 00:00:00.000000000 Z
11
+ date: 2020-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-rspec
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 4.0.0.rc3
33
+ version: 4.0.4
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: 4.0.0.rc3
40
+ version: 4.0.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rabl
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -301,7 +301,7 @@ homepage: http://spreecommerce.org
301
301
  licenses:
302
302
  - BSD-3-Clause
303
303
  metadata: {}
304
- post_install_message:
304
+ post_install_message:
305
305
  rdoc_options: []
306
306
  require_paths:
307
307
  - lib
@@ -312,12 +312,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
312
312
  version: 2.5.0
313
313
  required_rubygems_version: !ruby/object:Gem::Requirement
314
314
  requirements:
315
- - - ">"
315
+ - - ">="
316
316
  - !ruby/object:Gem::Version
317
- version: 1.3.1
317
+ version: '0'
318
318
  requirements: []
319
- rubygems_version: 3.0.2
320
- signing_key:
319
+ rubygems_version: 3.1.4
320
+ signing_key:
321
321
  specification_version: 4
322
322
  summary: Spree's API
323
323
  test_files: []