solidus_api 1.2.3 → 1.3.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::ReturnAuthorizationsController, :type => :controller do
4
+ describe Api::ReturnAuthorizationsController, type: :controller do
5
5
  render_views
6
6
 
7
7
  let!(:order) { create(:shipped_order) }
8
8
 
9
9
  let(:product) { create(:product) }
10
10
  let(:attributes) { [:id, :memo, :state] }
11
- let(:resource_scoping) { { :order_id => order.to_param } }
11
+ let(:resource_scoping) { { order_id: order.to_param } }
12
12
 
13
13
  before do
14
14
  stub_authentication!
@@ -18,10 +18,10 @@ module Spree
18
18
  it "can create a new return authorization" do
19
19
  stock_location = FactoryGirl.create(:stock_location)
20
20
  reason = FactoryGirl.create(:return_reason)
21
- rma_params = { :stock_location_id => stock_location.id,
22
- :return_reason_id => reason.id,
23
- :memo => "Defective" }
24
- api_post :create, :order_id => order.number, :return_authorization => rma_params
21
+ rma_params = { stock_location_id: stock_location.id,
22
+ return_reason_id: reason.id,
23
+ memo: "Defective" }
24
+ api_post :create, order_id: order.number, return_authorization: rma_params
25
25
  expect(response.status).to eq(201)
26
26
  expect(json_response).to have_attributes(attributes)
27
27
  expect(json_response["state"]).not_to be_blank
@@ -30,7 +30,7 @@ module Spree
30
30
 
31
31
  context "as the order owner" do
32
32
  before do
33
- allow_any_instance_of(Order).to receive_messages :user => current_api_user
33
+ allow_any_instance_of(Order).to receive_messages user: current_api_user
34
34
  end
35
35
 
36
36
  it "cannot see any return authorizations" do
@@ -39,7 +39,7 @@ module Spree
39
39
  end
40
40
 
41
41
  it "cannot see a single return authorization" do
42
- api_get :show, :id => 1
42
+ api_get :show, id: 1
43
43
  assert_unauthorized!
44
44
  end
45
45
 
@@ -63,7 +63,7 @@ module Spree
63
63
 
64
64
  context "as another non-admin user that's not the order's owner" do
65
65
  before do
66
- allow_any_instance_of(Order).to receive_messages :user => create(:user)
66
+ allow_any_instance_of(Order).to receive_messages user: create(:user)
67
67
  end
68
68
 
69
69
  it "cannot create a new return authorization" do
@@ -76,18 +76,18 @@ module Spree
76
76
  sign_in_as_admin!
77
77
 
78
78
  it "can show return authorization" do
79
- FactoryGirl.create(:return_authorization, :order => order)
79
+ FactoryGirl.create(:return_authorization, order: order)
80
80
  return_authorization = order.return_authorizations.first
81
- api_get :show, :order_id => order.number, :id => return_authorization.id
81
+ api_get :show, order_id: order.number, id: return_authorization.id
82
82
  expect(response.status).to eq(200)
83
83
  expect(json_response).to have_attributes(attributes)
84
84
  expect(json_response["state"]).not_to be_blank
85
85
  end
86
86
 
87
87
  it "can get a list of return authorizations" do
88
- FactoryGirl.create(:return_authorization, :order => order)
89
- FactoryGirl.create(:return_authorization, :order => order)
90
- api_get :index, { :order_id => order.number }
88
+ FactoryGirl.create(:return_authorization, order: order)
89
+ FactoryGirl.create(:return_authorization, order: order)
90
+ api_get :index, { order_id: order.number }
91
91
  expect(response.status).to eq(200)
92
92
  return_authorizations = json_response["return_authorizations"]
93
93
  expect(return_authorizations.first).to have_attributes(attributes)
@@ -95,19 +95,19 @@ module Spree
95
95
  end
96
96
 
97
97
  it 'can control the page size through a parameter' do
98
- FactoryGirl.create(:return_authorization, :order => order)
99
- FactoryGirl.create(:return_authorization, :order => order)
100
- api_get :index, :order_id => order.number, :per_page => 1
98
+ FactoryGirl.create(:return_authorization, order: order)
99
+ FactoryGirl.create(:return_authorization, order: order)
100
+ api_get :index, order_id: order.number, per_page: 1
101
101
  expect(json_response['count']).to eq(1)
102
102
  expect(json_response['current_page']).to eq(1)
103
103
  expect(json_response['pages']).to eq(2)
104
104
  end
105
105
 
106
106
  it 'can query the results through a paramter' do
107
- FactoryGirl.create(:return_authorization, :order => order)
108
- expected_result = create(:return_authorization, :memo => 'damaged')
107
+ FactoryGirl.create(:return_authorization, order: order)
108
+ expected_result = create(:return_authorization, memo: 'damaged')
109
109
  order.return_authorizations << expected_result
110
- api_get :index, :q => { :memo_cont => 'damaged' }
110
+ api_get :index, q: { memo_cont: 'damaged' }
111
111
  expect(json_response['count']).to eq(1)
112
112
  expect(json_response['return_authorizations'].first['memo']).to eq expected_result.memo
113
113
  end
@@ -120,26 +120,26 @@ module Spree
120
120
  end
121
121
 
122
122
  it "can update a return authorization on the order" do
123
- FactoryGirl.create(:return_authorization, :order => order)
123
+ FactoryGirl.create(:return_authorization, order: order)
124
124
  return_authorization = order.return_authorizations.first
125
- api_put :update, :id => return_authorization.id, :return_authorization => { :memo => "ABC" }
125
+ api_put :update, id: return_authorization.id, return_authorization: { memo: "ABC" }
126
126
  expect(response.status).to eq(200)
127
127
  expect(json_response).to have_attributes(attributes)
128
128
  end
129
129
 
130
130
  it "can cancel a return authorization on the order" do
131
- FactoryGirl.create(:new_return_authorization, :order => order)
131
+ FactoryGirl.create(:new_return_authorization, order: order)
132
132
  return_authorization = order.return_authorizations.first
133
133
  expect(return_authorization.state).to eq("authorized")
134
- api_delete :cancel, :id => return_authorization.id
134
+ api_delete :cancel, id: return_authorization.id
135
135
  expect(response.status).to eq(200)
136
136
  expect(return_authorization.reload.state).to eq("canceled")
137
137
  end
138
138
 
139
139
  it "can delete a return authorization on the order" do
140
- FactoryGirl.create(:return_authorization, :order => order)
140
+ FactoryGirl.create(:return_authorization, order: order)
141
141
  return_authorization = order.return_authorizations.first
142
- api_delete :destroy, :id => return_authorization.id
142
+ api_delete :destroy, id: return_authorization.id
143
143
  expect(response.status).to eq(204)
144
144
  expect { return_authorization.reload }.to raise_error(ActiveRecord::RecordNotFound)
145
145
  end
@@ -149,22 +149,22 @@ module Spree
149
149
 
150
150
  context "as just another user" do
151
151
  it "cannot add a return authorization to the order" do
152
- api_post :create, :return_autorization => { :order_id => order.number, :memo => "Defective" }
152
+ api_post :create, return_autorization: { order_id: order.number, memo: "Defective" }
153
153
  assert_unauthorized!
154
154
  end
155
155
 
156
156
  it "cannot update a return authorization on the order" do
157
- FactoryGirl.create(:return_authorization, :order => order)
157
+ FactoryGirl.create(:return_authorization, order: order)
158
158
  return_authorization = order.return_authorizations.first
159
- api_put :update, :id => return_authorization.id, :return_authorization => { :memo => "ABC" }
159
+ api_put :update, id: return_authorization.id, return_authorization: { memo: "ABC" }
160
160
  assert_unauthorized!
161
161
  expect(return_authorization.reload.memo).not_to eq("ABC")
162
162
  end
163
163
 
164
164
  it "cannot delete a return authorization on the order" do
165
- FactoryGirl.create(:return_authorization, :order => order)
165
+ FactoryGirl.create(:return_authorization, order: order)
166
166
  return_authorization = order.return_authorizations.first
167
- api_delete :destroy, :id => return_authorization.id
167
+ api_delete :destroy, id: return_authorization.id
168
168
  assert_unauthorized!
169
169
  expect { return_authorization.reload }.not_to raise_error
170
170
  end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Spree::Api::ShipmentsController, :type => :controller do
3
+ describe Spree::Api::ShipmentsController, type: :controller do
4
4
  render_views
5
5
  let!(:shipment) { create(:shipment, address: create(:address), inventory_units: [build(:inventory_unit, shipment: nil)]) }
6
- let!(:attributes) { [:id, :tracking, :number, :cost, :shipped_at, :stock_location_name, :order_id, :shipping_rates, :shipping_methods] }
6
+ let!(:attributes) { [:id, :tracking, :tracking_url, :number, :cost, :shipped_at, :stock_location_name, :order_id, :shipping_rates, :shipping_methods] }
7
7
 
8
8
  before do
9
9
  stub_authentication!
@@ -68,7 +68,7 @@ describe Spree::Api::ShipmentsController, :type => :controller do
68
68
  it 'should return proper error' do
69
69
  subject
70
70
  expect(response.status).to eq(422)
71
- expect(json_response['exception']).to eq("param is missing or the value is empty: #{field.to_s}")
71
+ expect(json_response['exception']).to eq("param is missing or the value is empty: #{field}")
72
72
  end
73
73
  end
74
74
  end
@@ -92,7 +92,7 @@ describe Spree::Api::ShipmentsController, :type => :controller do
92
92
  end
93
93
 
94
94
  it "can make a shipment ready" do
95
- allow_any_instance_of(Spree::Order).to receive_messages(:paid? => true, :complete? => true)
95
+ allow_any_instance_of(Spree::Order).to receive_messages(paid?: true, complete?: true)
96
96
  api_put :ready
97
97
  expect(json_response).to have_attributes(attributes)
98
98
  expect(json_response["state"]).to eq("ready")
@@ -100,7 +100,7 @@ describe Spree::Api::ShipmentsController, :type => :controller do
100
100
  end
101
101
 
102
102
  it "cannot make a shipment ready if the order is unpaid" do
103
- allow_any_instance_of(Spree::Order).to receive_messages(:paid? => false)
103
+ allow_any_instance_of(Spree::Order).to receive_messages(paid?: false)
104
104
  api_put :ready
105
105
  expect(json_response["error"]).to eq("Cannot ready shipment.")
106
106
  expect(response.status).to eq(422)
@@ -149,7 +149,6 @@ describe Spree::Api::ShipmentsController, :type => :controller do
149
149
  expect(response.status).to eq(422)
150
150
  expect(json_response['errors']['base'].join).to match /Cannot remove items/
151
151
  end
152
-
153
152
  end
154
153
 
155
154
  describe '#mine' do
@@ -199,7 +198,7 @@ describe Spree::Api::ShipmentsController, :type => :controller do
199
198
  end
200
199
 
201
200
  context 'with filtering' do
202
- let(:params) { {q: {order_completed_at_not_null: 1}} }
201
+ let(:params) { { q: { order_completed_at_not_null: 1 } } }
203
202
 
204
203
  let!(:incomplete_order) { create(:order_with_line_items, user: current_api_user) }
205
204
 
@@ -219,7 +218,6 @@ describe Spree::Api::ShipmentsController, :type => :controller do
219
218
  end
220
219
  end
221
220
  end
222
-
223
221
  end
224
222
 
225
223
  describe "#ship" do
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::StatesController, :type => :controller do
4
+ describe Api::StatesController, type: :controller do
5
5
  render_views
6
6
 
7
- let!(:state) { create(:state, :name => "Victoria") }
7
+ let!(:state) { create(:state, name: "Victoria") }
8
8
  let(:attributes) { [:id, :name, :abbr, :country_id] }
9
9
 
10
10
  before do
@@ -18,7 +18,7 @@ module Spree
18
18
  end
19
19
 
20
20
  it "gets all the states for a particular country" do
21
- api_get :index, :country_id => state.country.id
21
+ api_get :index, country_id: state.country.id
22
22
  expect(json_response["states"].first).to have_attributes(attributes)
23
23
  expect(json_response['states'].first['name']).to eq(state.name)
24
24
  end
@@ -38,26 +38,25 @@ module Spree
38
38
  it "paginates when page parameter is passed through" do
39
39
  expect(@scope).to receive(:page).with(1).and_return(@scope)
40
40
  expect(@scope).to receive(:per).with(nil)
41
- api_get :index, :page => 1
41
+ api_get :index, page: 1
42
42
  end
43
43
 
44
44
  it "paginates when per_page parameter is passed through" do
45
45
  expect(@scope).to receive(:page).with(nil).and_return(@scope)
46
46
  expect(@scope).to receive(:per).with(25)
47
- api_get :index, :per_page => 25
47
+ api_get :index, per_page: 25
48
48
  end
49
49
  end
50
50
 
51
-
52
51
  context "with two states" do
53
- before { create(:state, :name => "New South Wales") }
52
+ before { create(:state, name: "New South Wales") }
54
53
 
55
54
  it "gets all states for a country" do
56
- country = create(:country, :states_required => true)
57
- state.country = country
55
+ country = create(:country, states_required: true)
56
+ state.country = country
58
57
  state.save
59
58
 
60
- api_get :index, :country_id => country.id
59
+ api_get :index, country_id: country.id
61
60
  expect(json_response["states"].first).to have_attributes(attributes)
62
61
  expect(json_response["states"].count).to eq(1)
63
62
  json_response["states_required"] = true
@@ -69,13 +68,13 @@ module Spree
69
68
  end
70
69
 
71
70
  it 'can query the results through a paramter' do
72
- api_get :index, :q => { :name_cont => 'Vic' }
71
+ api_get :index, q: { name_cont: 'Vic' }
73
72
  expect(json_response['states'].first['name']).to eq("Victoria")
74
73
  end
75
74
  end
76
75
 
77
76
  it "can view a state" do
78
- api_get :show, :id => state.id
77
+ api_get :show, id: state.id
79
78
  expect(json_response).to have_attributes(attributes)
80
79
  end
81
80
  end
@@ -1,13 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::StockItemsController, :type => :controller do
4
+ describe Api::StockItemsController, type: :controller do
5
5
  render_views
6
6
 
7
7
  let!(:stock_location) { create(:stock_location_with_items) }
8
8
  let!(:stock_item) { stock_location.stock_items.order(:id).first }
9
- let!(:attributes) { [:id, :count_on_hand, :backorderable,
10
- :stock_location_id, :variant_id] }
9
+ let!(:attributes) {
10
+ [:id, :count_on_hand, :backorderable,
11
+ :stock_location_id, :variant_id]
12
+ }
11
13
 
12
14
  before do
13
15
  stub_authentication!
@@ -210,9 +212,9 @@ module Spree
210
212
  expect(stock_item.should_track_inventory?).to eq true
211
213
  end
212
214
 
213
- it "sets the stock item's count_on_hand" do
214
- subject
215
- expect(assigns(:stock_item).count_on_hand).to eq 50
215
+ it "sets the stock item's count_on_hand" do
216
+ subject
217
+ expect(assigns(:stock_item).count_on_hand).to eq 50
216
218
  end
217
219
  end
218
220
 
@@ -246,7 +248,8 @@ module Spree
246
248
  id: stock_item.to_param,
247
249
  stock_item: {
248
250
  count_on_hand: count_on_hand,
249
- force: true,
251
+ backorderable: true,
252
+ force: true
250
253
  }
251
254
  }
252
255
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::StockLocationsController, :type => :controller do
4
+ describe Api::StockLocationsController, type: :controller do
5
5
  render_views
6
6
 
7
7
  let!(:stock_location) { create(:stock_location) }
@@ -59,14 +59,14 @@ module Spree
59
59
 
60
60
  describe "#update" do
61
61
  it "cannot update a stock location" do
62
- api_put :update, :stock_location => { :name => "South Pole" }, :id => stock_location.to_param
62
+ api_put :update, stock_location: { name: "South Pole" }, id: stock_location.to_param
63
63
  expect(response.status).to eq(401)
64
64
  end
65
65
  end
66
66
 
67
67
  describe "#destroy" do
68
68
  it "cannot delete a stock location" do
69
- api_put :destroy, :id => stock_location.to_param
69
+ api_put :destroy, id: stock_location.to_param
70
70
  expect(response.status).to eq(401)
71
71
  end
72
72
  end
@@ -112,7 +112,6 @@ module Spree
112
112
  expect(json_response['count']).to eq(1)
113
113
  expect(json_response['stock_locations'].first['name']).to eq expected_result.name
114
114
  end
115
-
116
115
  end
117
116
 
118
117
  describe "#show" do
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::StockMovementsController, :type => :controller do
4
+ describe Api::StockMovementsController, type: :controller do
5
5
  render_views
6
6
 
7
7
  let!(:stock_location) { create(:stock_location_with_items) }
@@ -55,7 +55,7 @@ module Spree
55
55
  end
56
56
 
57
57
  it 'can query the results through a paramter' do
58
- expected_result = create(:stock_movement, :received, quantity: 10, stock_item: stock_item)
58
+ create(:stock_movement, :received, quantity: 10, stock_item: stock_item)
59
59
  api_get :index, stock_location_id: stock_location.to_param, q: { quantity_eq: '10' }
60
60
  expect(json_response['count']).to eq(1)
61
61
  end
@@ -81,4 +81,3 @@ module Spree
81
81
  end
82
82
  end
83
83
  end
84
-
@@ -11,7 +11,6 @@ describe Spree::Api::StoreCreditEventsController, type: :controller do
11
11
  end
12
12
 
13
13
  describe "GET mine" do
14
-
15
14
  subject { api_get :mine, { format: :json } }
16
15
 
17
16
  before { allow(controller).to receive_messages(current_api_user: current_api_user) }
@@ -65,4 +64,3 @@ describe Spree::Api::StoreCreditEventsController, type: :controller do
65
64
  end
66
65
  end
67
66
  end
68
-
@@ -96,7 +96,7 @@ module Spree
96
96
  api_delete :destroy, id: store.id
97
97
  expect(response.status).to eq(422)
98
98
  expect(json_response["errors"]["base"]).to eql(
99
- ["Cannot destroy the default Store."]
99
+ ["Cannot destroy the default Store."]
100
100
  )
101
101
  end
102
102
 
@@ -108,7 +108,6 @@ module Spree
108
108
  end
109
109
 
110
110
  context "as an user" do
111
-
112
111
  it "I cannot list all the stores" do
113
112
  api_get :index
114
113
  expect(response.status).to eq(401)
@@ -1,17 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::TaxonomiesController, :type => :controller do
4
+ describe Api::TaxonomiesController, type: :controller do
5
5
  render_views
6
6
 
7
7
  let(:taxonomy) { create(:taxonomy) }
8
- let(:taxon) { create(:taxon, :name => "Ruby", :taxonomy => taxonomy) }
9
- let(:taxon2) { create(:taxon, :name => "Rails", :taxonomy => taxonomy) }
8
+ let(:taxon) { create(:taxon, name: "Ruby", taxonomy: taxonomy) }
9
+ let(:taxon2) { create(:taxon, name: "Rails", taxonomy: taxonomy) }
10
10
  let(:attributes) { [:id, :name] }
11
11
 
12
12
  before do
13
13
  stub_authentication!
14
- taxon2.children << create(:taxon, :name => "3.2.2", :taxonomy => taxonomy)
14
+ taxon2.children << create(:taxon, name: "3.2.2", taxonomy: taxonomy)
15
15
  taxon.children << taxon2
16
16
  taxonomy.root.children << taxon
17
17
  end
@@ -26,21 +26,21 @@ module Spree
26
26
 
27
27
  it 'can control the page size through a parameter' do
28
28
  create(:taxonomy)
29
- api_get :index, :per_page => 1
29
+ api_get :index, per_page: 1
30
30
  expect(json_response['count']).to eq(1)
31
31
  expect(json_response['current_page']).to eq(1)
32
32
  expect(json_response['pages']).to eq(2)
33
33
  end
34
34
 
35
35
  it 'can query the results through a paramter' do
36
- expected_result = create(:taxonomy, :name => 'Style')
37
- api_get :index, :q => { :name_cont => 'style' }
36
+ expected_result = create(:taxonomy, name: 'Style')
37
+ api_get :index, q: { name_cont: 'style' }
38
38
  expect(json_response['count']).to eq(1)
39
39
  expect(json_response['taxonomies'].first['name']).to eq expected_result.name
40
40
  end
41
41
 
42
42
  it "gets a single taxonomy" do
43
- api_get :show, :id => taxonomy.id
43
+ api_get :show, id: taxonomy.id
44
44
 
45
45
  expect(json_response['name']).to eq taxonomy.name
46
46
 
@@ -51,7 +51,7 @@ module Spree
51
51
  end
52
52
 
53
53
  it "gets a single taxonomy with set=nested" do
54
- api_get :show, :id => taxonomy.id, :set => 'nested'
54
+ api_get :show, id: taxonomy.id, set: 'nested'
55
55
 
56
56
  expect(json_response['name']).to eq taxonomy.name
57
57
 
@@ -60,9 +60,9 @@ module Spree
60
60
  end
61
61
 
62
62
  it "gets the jstree-friendly version of a taxonomy" do
63
- api_get :jstree, :id => taxonomy.id
63
+ api_get :jstree, id: taxonomy.id
64
64
  expect(json_response["data"]).to eq(taxonomy.root.name)
65
- expect(json_response["attr"]).to eq({ "id" => taxonomy.root.id, "name" => taxonomy.root.name})
65
+ expect(json_response["attr"]).to eq({ "id" => taxonomy.root.id, "name" => taxonomy.root.name })
66
66
  expect(json_response["state"]).to eq("closed")
67
67
  end
68
68
 
@@ -74,17 +74,17 @@ module Spree
74
74
  end
75
75
 
76
76
  it "cannot create a new taxonomy if not an admin" do
77
- api_post :create, :taxonomy => { :name => "Location" }
77
+ api_post :create, taxonomy: { name: "Location" }
78
78
  assert_unauthorized!
79
79
  end
80
80
 
81
81
  it "cannot update a taxonomy" do
82
- api_put :update, :id => taxonomy.id, :taxonomy => { :name => "I hacked your store!" }
82
+ api_put :update, id: taxonomy.id, taxonomy: { name: "I hacked your store!" }
83
83
  assert_unauthorized!
84
84
  end
85
85
 
86
86
  it "cannot delete a taxonomy" do
87
- api_delete :destroy, :id => taxonomy.id
87
+ api_delete :destroy, id: taxonomy.id
88
88
  assert_unauthorized!
89
89
  end
90
90
  end
@@ -93,20 +93,19 @@ module Spree
93
93
  sign_in_as_admin!
94
94
 
95
95
  it "can create" do
96
- api_post :create, :taxonomy => { :name => "Colors"}
96
+ api_post :create, taxonomy: { name: "Colors" }
97
97
  expect(json_response).to have_attributes(attributes)
98
98
  expect(response.status).to eq(201)
99
99
  end
100
100
 
101
101
  it "cannot create a new taxonomy with invalid attributes" do
102
- api_post :create, :taxonomy => {}
102
+ api_post :create, taxonomy: {}
103
103
  expect(response.status).to eq(422)
104
104
  expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
105
- errors = json_response["errors"]
106
105
  end
107
106
 
108
107
  it "can destroy" do
109
- api_delete :destroy, :id => taxonomy.id
108
+ api_delete :destroy, id: taxonomy.id
110
109
  expect(response.status).to eq(204)
111
110
  end
112
111
  end