solidus_api 1.2.3 → 1.3.0.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_api might be problematic. Click here for more details.

Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/Rakefile +1 -1
  4. data/app/controllers/spree/api/addresses_controller.rb +3 -2
  5. data/app/controllers/spree/api/base_controller.rb +10 -15
  6. data/app/controllers/spree/api/checkouts_controller.rb +56 -55
  7. data/app/controllers/spree/api/classifications_controller.rb +4 -4
  8. data/app/controllers/spree/api/config_controller.rb +6 -1
  9. data/app/controllers/spree/api/credit_cards_controller.rb +11 -11
  10. data/app/controllers/spree/api/images_controller.rb +13 -13
  11. data/app/controllers/spree/api/inventory_units_controller.rb +4 -4
  12. data/app/controllers/spree/api/line_items_controller.rb +27 -23
  13. data/app/controllers/spree/api/option_types_controller.rb +6 -5
  14. data/app/controllers/spree/api/option_values_controller.rb +12 -12
  15. data/app/controllers/spree/api/orders_controller.rb +6 -17
  16. data/app/controllers/spree/api/payments_controller.rb +15 -17
  17. data/app/controllers/spree/api/product_properties_controller.rb +13 -14
  18. data/app/controllers/spree/api/products_controller.rb +31 -28
  19. data/app/controllers/spree/api/promotions_controller.rb +9 -8
  20. data/app/controllers/spree/api/properties_controller.rb +9 -10
  21. data/app/controllers/spree/api/resource_controller.rb +9 -1
  22. data/app/controllers/spree/api/shipments_controller.rb +18 -18
  23. data/app/controllers/spree/api/states_controller.rb +8 -7
  24. data/app/controllers/spree/api/stock_items_controller.rb +2 -1
  25. data/app/controllers/spree/api/stock_locations_controller.rb +1 -1
  26. data/app/controllers/spree/api/stores_controller.rb +0 -1
  27. data/app/controllers/spree/api/taxonomies_controller.rb +7 -5
  28. data/app/controllers/spree/api/taxons_controller.rb +20 -19
  29. data/app/controllers/spree/api/users_controller.rb +1 -4
  30. data/app/controllers/spree/api/variants_controller.rb +19 -18
  31. data/app/controllers/spree/api/zones_controller.rb +3 -4
  32. data/app/helpers/spree/api/api_helpers.rb +7 -6
  33. data/app/models/spree/api_configuration.rb +1 -1
  34. data/app/views/spree/api/config/show.v1.rabl +2 -1
  35. data/app/views/spree/api/products/show.v1.rabl +1 -1
  36. data/db/migrate/20100107141738_add_api_key_to_spree_users.rb +1 -1
  37. data/db/migrate/20120411123334_resize_api_key_field.rb +1 -1
  38. data/lib/spree/api/engine.rb +8 -8
  39. data/lib/spree/api/responders/rabl_template.rb +1 -1
  40. data/lib/spree/api/testing_support/caching.rb +4 -4
  41. data/script/rails +0 -1
  42. data/solidus_api.gemspec +3 -3
  43. data/spec/controllers/spree/api/addresses_controller_spec.rb +12 -13
  44. data/spec/controllers/spree/api/base_controller_spec.rb +10 -11
  45. data/spec/controllers/spree/api/checkouts_controller_spec.rb +38 -59
  46. data/spec/controllers/spree/api/config_controller_spec.rb +4 -2
  47. data/spec/controllers/spree/api/countries_controller_spec.rb +5 -5
  48. data/spec/controllers/spree/api/credit_cards_controller_spec.rb +5 -5
  49. data/spec/controllers/spree/api/images_controller_spec.rb +20 -18
  50. data/spec/controllers/spree/api/inventory_units_controller_spec.rb +11 -11
  51. data/spec/controllers/spree/api/line_items_controller_spec.rb +20 -19
  52. data/spec/controllers/spree/api/option_types_controller_spec.rb +23 -24
  53. data/spec/controllers/spree/api/option_values_controller_spec.rb +28 -29
  54. data/spec/controllers/spree/api/orders_controller_spec.rb +157 -179
  55. data/spec/controllers/spree/api/payments_controller_spec.rb +35 -45
  56. data/spec/controllers/spree/api/product_properties_controller_spec.rb +14 -15
  57. data/spec/controllers/spree/api/products_controller_spec.rb +64 -70
  58. data/spec/controllers/spree/api/promotion_application_spec.rb +4 -4
  59. data/spec/controllers/spree/api/promotions_controller_spec.rb +1 -1
  60. data/spec/controllers/spree/api/properties_controller_spec.rb +15 -15
  61. data/spec/controllers/spree/api/resource_controller_spec.rb +31 -2
  62. data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +31 -31
  63. data/spec/controllers/spree/api/shipments_controller_spec.rb +6 -8
  64. data/spec/controllers/spree/api/states_controller_spec.rb +11 -12
  65. data/spec/controllers/spree/api/stock_items_controller_spec.rb +10 -7
  66. data/spec/controllers/spree/api/stock_locations_controller_spec.rb +3 -4
  67. data/spec/controllers/spree/api/stock_movements_controller_spec.rb +2 -3
  68. data/spec/controllers/spree/api/store_credit_events_controller_spec.rb +0 -2
  69. data/spec/controllers/spree/api/stores_controller_spec.rb +1 -2
  70. data/spec/controllers/spree/api/taxonomies_controller_spec.rb +17 -18
  71. data/spec/controllers/spree/api/taxons_controller_spec.rb +22 -24
  72. data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +1 -2
  73. data/spec/controllers/spree/api/users_controller_spec.rb +13 -15
  74. data/spec/controllers/spree/api/variants_controller_spec.rb +42 -37
  75. data/spec/controllers/spree/api/zones_controller_spec.rb +18 -18
  76. data/spec/features/checkout_spec.rb +2 -2
  77. data/spec/models/spree/legacy_user_spec.rb +5 -5
  78. data/spec/requests/api/address_books_spec.rb +10 -11
  79. data/spec/requests/rabl_cache_spec.rb +7 -7
  80. data/spec/requests/ransackable_attributes_spec.rb +5 -7
  81. data/spec/shared_examples/protect_product_actions.rb +3 -4
  82. data/spec/spec_helper.rb +8 -4
  83. data/spec/support/controller_hacks.rb +5 -5
  84. data/spec/support/have_attributes_matcher.rb +0 -4
  85. data/spec/test_views/spree/api/widgets/show.v1.rabl +1 -1
  86. metadata +9 -10
  87. data/app/models/spree/option_value_decorator.rb +0 -9
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::AddressBooksController, :type => :request do
4
+ describe Api::AddressBooksController, type: :request do
5
5
  let!(:state) { create(:state) }
6
6
  let!(:harry_address_attributes) do
7
7
  {
@@ -38,14 +38,14 @@ module Spree
38
38
  user.save_in_address_book(harry_address_attributes, true)
39
39
  user.save_in_address_book(ron_address_attributes, false)
40
40
 
41
- get "/api/users/#{user.id}/address_book", nil, { 'X-SPREE-TOKEN' => 'galleon'}
41
+ get "/api/users/#{user.id}/address_book", nil, { 'X-SPREE-TOKEN' => 'galleon' }
42
42
 
43
43
  json_response = JSON.parse(response.body)
44
44
  expect(response.status).to eq(200)
45
45
  expect(json_response.length).to eq(2)
46
46
  expect(json_response).to include(
47
- hash_including(harry_address_attributes.merge!('default' => true)),
48
- hash_including(ron_address_attributes.merge!('default' => false)),
47
+ hash_including(harry_address_attributes.merge!('default' => true)),
48
+ hash_including(ron_address_attributes.merge!('default' => false))
49
49
  )
50
50
  end
51
51
 
@@ -99,7 +99,7 @@ module Spree
99
99
  user.save_in_address_book(address.attributes, false)
100
100
 
101
101
  expect {
102
- delete "/api/users/#{user.id}/address_book", { address_id: address.id }, { 'X-SPREE-TOKEN' => 'galleon'}
102
+ delete "/api/users/#{user.id}/address_book", { address_id: address.id }, { 'X-SPREE-TOKEN' => 'galleon' }
103
103
  }.to change { user.reload.user_addresses.count }.from(1).to(0)
104
104
 
105
105
  expect(response.status).to eq(200)
@@ -121,14 +121,14 @@ module Spree
121
121
  other_user.save_in_address_book(harry_address_attributes, true)
122
122
  other_user.save_in_address_book(ron_address_attributes, false)
123
123
 
124
- get "/api/users/#{other_user.id}/address_book", nil, { 'X-SPREE-TOKEN' => 'galleon'}
124
+ get "/api/users/#{other_user.id}/address_book", nil, { 'X-SPREE-TOKEN' => 'galleon' }
125
125
 
126
126
  json_response = JSON.parse(response.body)
127
127
  expect(response.status).to eq(200)
128
128
  expect(json_response.length).to eq(2)
129
129
  expect(json_response).to include(
130
- hash_including(harry_address_attributes.merge!('default' => true)),
131
- hash_including(ron_address_attributes.merge!('default' => false)),
130
+ hash_including(harry_address_attributes.merge!('default' => true)),
131
+ hash_including(ron_address_attributes.merge!('default' => false))
132
132
  )
133
133
  end
134
134
 
@@ -151,7 +151,7 @@ module Spree
151
151
  other_user.save_in_address_book(address.attributes, false)
152
152
 
153
153
  expect {
154
- delete "/api/users/#{other_user.id}/address_book", { address_id: address.id }, { 'X-SPREE-TOKEN' => 'galleon'}
154
+ delete "/api/users/#{other_user.id}/address_book", { address_id: address.id }, { 'X-SPREE-TOKEN' => 'galleon' }
155
155
  }.to change { other_user.reload.user_addresses.count }.from(1).to(0)
156
156
 
157
157
  expect(response.status).to eq(200)
@@ -164,7 +164,7 @@ module Spree
164
164
  other_user = create(:user)
165
165
  other_user.save_in_address_book(harry_address_attributes, true)
166
166
 
167
- get "/api/users/#{other_user.id}/address_book", nil, { 'X-SPREE-TOKEN' => 'galleon'}
167
+ get "/api/users/#{other_user.id}/address_book", nil, { 'X-SPREE-TOKEN' => 'galleon' }
168
168
 
169
169
  expect(response.status).to eq(401)
170
170
  end
@@ -197,7 +197,6 @@ module Spree
197
197
  end
198
198
  end
199
199
 
200
-
201
200
  context 'unauthenticated' do
202
201
  before do
203
202
  @user = create(:user)
@@ -1,27 +1,27 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "Rabl Cache", :type => :request, :caching => true do
3
+ describe "Rabl Cache", type: :request, caching: true do
4
4
  let!(:user) { create(:admin_user) }
5
5
 
6
6
  before do
7
- create(:variant)
7
+ create(:variant)
8
8
  user.generate_spree_api_key!
9
9
  expect(Spree::Product.count).to eq(1)
10
10
  end
11
-
11
+
12
12
  it "doesn't create a cache key collision for models with different rabl templates" do
13
- get "/api/variants", :token => user.spree_api_key
13
+ get "/api/variants", token: user.spree_api_key
14
14
  expect(response.status).to eq(200)
15
15
 
16
16
  # Make sure we get a non master variant
17
- variant_a = JSON.parse(response.body)['variants'].select do |v|
17
+ variant_a = JSON.parse(response.body)['variants'].find do |v|
18
18
  !v['is_master']
19
- end.first
19
+ end
20
20
 
21
21
  expect(variant_a['is_master']).to be false
22
22
  expect(variant_a['stock_items']).not_to be_nil
23
23
 
24
- get "/api/products/#{Spree::Product.first.id}", :token => user.spree_api_key
24
+ get "/api/products/#{Spree::Product.first.id}", token: user.spree_api_key
25
25
  expect(response.status).to eq(200)
26
26
  variant_b = JSON.parse(response.body)['variants'].last
27
27
  expect(variant_b['is_master']).to be false
@@ -33,7 +33,7 @@ describe "Ransackable Attributes" do
33
33
 
34
34
  get "/api/variants?q[product_name_or_sku_cont]=fritos", token: user.spree_api_key
35
35
 
36
- skus = JSON.parse(response.body)['variants'].map { |variant| variant['sku'] }
36
+ skus = JSON.parse(response.body)['variants'].map { |x| x['sku'] }
37
37
  expect(skus).to include variant.sku
38
38
  expect(skus).not_to include other_variant.sku
39
39
  end
@@ -41,8 +41,8 @@ describe "Ransackable Attributes" do
41
41
 
42
42
  context "filtering by attributes" do
43
43
  it "most attributes are not filterable by default" do
44
- product = create(:product, description: "special product")
45
- other_product = create(:product)
44
+ create(:product, description: "special product")
45
+ create(:product)
46
46
 
47
47
  get "/api/products?q[description_cont]=special", token: user.spree_api_key
48
48
 
@@ -56,7 +56,7 @@ describe "Ransackable Attributes" do
56
56
 
57
57
  get "/api/products?q[id_eq]=#{product.id}", token: user.spree_api_key
58
58
 
59
- product_names = JSON.parse(response.body)['products'].map { |product| product['name'] }
59
+ product_names = JSON.parse(response.body)['products'].map { |x| x['name'] }
60
60
  expect(product_names).to include product.name
61
61
  expect(product_names).not_to include other_product.name
62
62
  end
@@ -69,11 +69,9 @@ describe "Ransackable Attributes" do
69
69
 
70
70
  get "/api/products?q[name_cont]=fritos", token: user.spree_api_key
71
71
 
72
- product_names = JSON.parse(response.body)['products'].map { |product| product['name'] }
72
+ product_names = JSON.parse(response.body)['products'].map { |x| x['name'] }
73
73
  expect(product_names).to include product.name
74
74
  expect(product_names).not_to include other_product.name
75
75
  end
76
76
  end
77
-
78
-
79
77
  end
@@ -1,17 +1,16 @@
1
1
  shared_examples "modifying product actions are restricted" do
2
2
  it "cannot create a new product if not an admin" do
3
- api_post :create, :product => { :name => "Brand new product!" }
3
+ api_post :create, product: { name: "Brand new product!" }
4
4
  assert_unauthorized!
5
5
  end
6
6
 
7
7
  it "cannot update a product" do
8
- api_put :update, :id => product.to_param, :product => { :name => "I hacked your store!" }
8
+ api_put :update, id: product.to_param, product: { name: "I hacked your store!" }
9
9
  assert_unauthorized!
10
10
  end
11
11
 
12
12
  it "cannot delete a product" do
13
- api_delete :destroy, :id => product.to_param
13
+ api_delete :destroy, id: product.to_param
14
14
  assert_unauthorized!
15
15
  end
16
16
  end
17
-
data/spec/spec_helper.rb CHANGED
@@ -26,11 +26,10 @@ require 'ffaker'
26
26
 
27
27
  # Requires supporting ruby files with custom matchers and macros, etc,
28
28
  # in spec/support/ and its subdirectories.
29
- Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
29
+ Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f }
30
30
 
31
31
  require 'spree/testing_support/factories'
32
32
  require 'spree/testing_support/preferences'
33
- require 'spree/testing_support/authorization_helpers'
34
33
 
35
34
  require 'spree/api/testing_support/caching'
36
35
  require 'spree/api/testing_support/helpers'
@@ -48,8 +47,8 @@ RSpec.configure do |config|
48
47
  end
49
48
 
50
49
  config.include FactoryGirl::Syntax::Methods
51
- config.include Spree::Api::TestingSupport::Helpers, :type => :controller
52
- config.extend Spree::Api::TestingSupport::Setup, :type => :controller
50
+ config.include Spree::Api::TestingSupport::Helpers, type: :controller
51
+ config.extend Spree::Api::TestingSupport::Setup, type: :controller
53
52
  config.include Spree::TestingSupport::Preferences
54
53
 
55
54
  config.extend WithModel
@@ -62,6 +61,11 @@ RSpec.configure do |config|
62
61
  Spree::Api::Config[:requires_authentication] = true
63
62
  end
64
63
 
64
+ config.include VersionCake::TestHelpers, type: :controller
65
+ config.before(:each, type: :controller) do
66
+ set_request_version('', 1)
67
+ end
68
+
65
69
  config.use_transactional_fixtures = true
66
70
 
67
71
  config.example_status_persistence_file_path = "./spec/examples.txt"
@@ -7,23 +7,23 @@ module ControllerHacks
7
7
  routes { Spree::Core::Engine.routes }
8
8
  end
9
9
 
10
- def api_get(action, params={}, session=nil, flash=nil)
10
+ def api_get(action, params = {}, session = nil, flash = nil)
11
11
  api_process(action, params, session, flash, "GET")
12
12
  end
13
13
 
14
- def api_post(action, params={}, session=nil, flash=nil)
14
+ def api_post(action, params = {}, session = nil, flash = nil)
15
15
  api_process(action, params, session, flash, "POST")
16
16
  end
17
17
 
18
- def api_put(action, params={}, session=nil, flash=nil)
18
+ def api_put(action, params = {}, session = nil, flash = nil)
19
19
  api_process(action, params, session, flash, "PUT")
20
20
  end
21
21
 
22
- def api_delete(action, params={}, session=nil, flash=nil)
22
+ def api_delete(action, params = {}, session = nil, flash = nil)
23
23
  api_process(action, params, session, flash, "DELETE")
24
24
  end
25
25
 
26
- def api_process(action, params={}, session=nil, flash=nil, method="get")
26
+ def api_process(action, params = {}, session = nil, flash = nil, method = "get")
27
27
  scoping = respond_to?(:resource_scoping) ? resource_scoping : {}
28
28
  process(action, method, params.merge(scoping).reverse_merge!(format: :json), session, flash)
29
29
  end
@@ -1,7 +1,4 @@
1
1
 
2
-
3
-
4
-
5
2
  RSpec::Matchers.define :have_attributes do |expected_attributes|
6
3
  match do |actual|
7
4
  # actual is a Hash object representing an object, like this:
@@ -10,4 +7,3 @@ RSpec::Matchers.define :have_attributes do |expected_attributes|
10
7
  expected_attributes.map(&:to_sym).all? { |attr| actual_attributes.include?(attr) }
11
8
  end
12
9
  end
13
-
@@ -1,2 +1,2 @@
1
1
  object @object
2
- attributes :name, :position
2
+ attributes :id, :name, :position
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2016-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.3
19
+ version: 1.3.0.beta1
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: 1.2.3
26
+ version: 1.3.0.beta1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rabl
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 2.3.1
53
+ version: '3.0'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 2.3.1
60
+ version: '3.0'
61
61
  description: REST API for the Solidus e-commerce framework.
62
62
  email: contact@solidus.io
63
63
  executables: []
@@ -105,7 +105,6 @@ files:
105
105
  - app/controllers/spree/api/zones_controller.rb
106
106
  - app/helpers/spree/api/api_helpers.rb
107
107
  - app/models/spree/api_configuration.rb
108
- - app/models/spree/option_value_decorator.rb
109
108
  - app/views/spree/api/address_books/show.v1.rabl
110
109
  - app/views/spree/api/addresses/show.v1.rabl
111
110
  - app/views/spree/api/adjustments/show.v1.rabl
@@ -279,12 +278,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
279
278
  version: '0'
280
279
  required_rubygems_version: !ruby/object:Gem::Requirement
281
280
  requirements:
282
- - - ">="
281
+ - - ">"
283
282
  - !ruby/object:Gem::Version
284
- version: '0'
283
+ version: 1.3.1
285
284
  requirements: []
286
285
  rubyforge_project:
287
- rubygems_version: 2.6.11
286
+ rubygems_version: 2.5.1
288
287
  signing_key:
289
288
  specification_version: 4
290
289
  summary: REST API for the Solidus e-commerce framework.
@@ -1,9 +0,0 @@
1
- Spree::OptionValue.class_eval do
2
- def option_type_name
3
- option_type.name
4
- end
5
-
6
- def option_type_presentation
7
- option_type.presentation
8
- end
9
- end