spree_api 2.3.13 → 2.4.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1 -43
  3. data/Gemfile +1 -1
  4. data/app/controllers/spree/api/addresses_controller.rb +1 -1
  5. data/app/controllers/spree/api/base_controller.rb +22 -9
  6. data/app/controllers/spree/api/checkouts_controller.rb +2 -2
  7. data/app/controllers/spree/api/countries_controller.rb +2 -2
  8. data/app/controllers/spree/api/credit_cards_controller.rb +1 -1
  9. data/app/controllers/spree/api/images_controller.rb +5 -0
  10. data/app/controllers/spree/api/inventory_units_controller.rb +1 -1
  11. data/app/controllers/spree/api/line_items_controller.rb +7 -7
  12. data/app/controllers/spree/api/option_types_controller.rb +2 -2
  13. data/app/controllers/spree/api/orders_controller.rb +17 -6
  14. data/app/controllers/spree/api/payments_controller.rb +3 -11
  15. data/app/controllers/spree/api/product_properties_controller.rb +2 -2
  16. data/app/controllers/spree/api/promotions_controller.rb +26 -0
  17. data/app/controllers/spree/api/properties_controller.rb +1 -1
  18. data/app/controllers/spree/api/return_authorizations_controller.rb +0 -10
  19. data/app/controllers/spree/api/shipments_controller.rb +71 -4
  20. data/app/controllers/spree/api/states_controller.rb +3 -3
  21. data/app/controllers/spree/api/stock_items_controller.rb +1 -1
  22. data/app/controllers/spree/api/stock_movements_controller.rb +1 -1
  23. data/app/controllers/spree/api/taxons_controller.rb +1 -1
  24. data/app/controllers/spree/api/variants_controller.rb +1 -2
  25. data/app/helpers/spree/api/api_helpers.rb +19 -5
  26. data/app/views/spree/api/images/index.v1.rabl +4 -0
  27. data/app/views/spree/api/products/show.v1.rabl +4 -1
  28. data/app/views/spree/api/promotions/handler.v1.rabl +2 -1
  29. data/app/views/spree/api/promotions/show.v1.rabl +2 -0
  30. data/app/views/spree/api/shipments/big.v1.rabl +48 -0
  31. data/app/views/spree/api/shipments/mine.v1.rabl +9 -0
  32. data/app/views/spree/api/shipments/small.v1.rabl +1 -5
  33. data/app/views/spree/api/shipping_rates/show.v1.rabl +2 -2
  34. data/app/views/spree/api/taxonomies/show.v1.rabl +2 -2
  35. data/app/views/spree/api/variants/big.v1.rabl +6 -1
  36. data/app/views/spree/api/variants/show.v1.rabl +1 -1
  37. data/app/views/spree/api/variants/small.v1.rabl +2 -3
  38. data/config/routes.rb +9 -0
  39. data/lib/spree/api/responders/rabl_template.rb +1 -1
  40. data/lib/spree/api/testing_support/helpers.rb +6 -6
  41. data/lib/spree/api/testing_support/setup.rb +2 -2
  42. data/spec/controllers/spree/api/addresses_controller_spec.rb +7 -7
  43. data/spec/controllers/spree/api/base_controller_spec.rb +66 -19
  44. data/spec/controllers/spree/api/checkouts_controller_spec.rb +54 -54
  45. data/spec/controllers/spree/api/classifications_controller_spec.rb +5 -5
  46. data/spec/controllers/spree/api/config_controller_spec.rb +9 -9
  47. data/spec/controllers/spree/api/countries_controller_spec.rb +11 -11
  48. data/spec/controllers/spree/api/credit_cards_controller_spec.rb +16 -16
  49. data/spec/controllers/spree/api/images_controller_spec.rb +37 -11
  50. data/spec/controllers/spree/api/inventory_units_controller_spec.rb +6 -6
  51. data/spec/controllers/spree/api/line_items_controller_spec.rb +34 -35
  52. data/spec/controllers/spree/api/option_types_controller_spec.rb +18 -18
  53. data/spec/controllers/spree/api/option_values_controller_spec.rb +21 -21
  54. data/spec/controllers/spree/api/orders_controller_spec.rb +177 -161
  55. data/spec/controllers/spree/api/payments_controller_spec.rb +52 -89
  56. data/spec/controllers/spree/api/product_properties_controller_spec.rb +21 -21
  57. data/spec/controllers/spree/api/products_controller_spec.rb +103 -60
  58. data/spec/controllers/spree/api/promotion_application_spec.rb +14 -12
  59. data/spec/controllers/spree/api/promotions_controller_spec.rb +64 -0
  60. data/spec/controllers/spree/api/properties_controller_spec.rb +25 -25
  61. data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +42 -66
  62. data/spec/controllers/spree/api/shipments_controller_spec.rb +69 -21
  63. data/spec/controllers/spree/api/states_controller_spec.rb +18 -18
  64. data/spec/controllers/spree/api/stock_items_controller_spec.rb +26 -26
  65. data/spec/controllers/spree/api/stock_locations_controller_spec.rb +22 -22
  66. data/spec/controllers/spree/api/stock_movements_controller_spec.rb +16 -16
  67. data/spec/controllers/spree/api/taxonomies_controller_spec.rb +24 -24
  68. data/spec/controllers/spree/api/taxons_controller_spec.rb +39 -39
  69. data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +5 -5
  70. data/spec/controllers/spree/api/users_controller_spec.rb +41 -41
  71. data/spec/controllers/spree/api/variants_controller_spec.rb +47 -37
  72. data/spec/controllers/spree/api/zones_controller_spec.rb +40 -18
  73. data/spec/models/spree/legacy_user_spec.rb +5 -5
  74. data/spec/requests/rabl_cache_spec.rb +9 -9
  75. data/spec/spec_helper.rb +1 -0
  76. metadata +14 -9
  77. data/spec/requests/ransackable_attributes_spec.rb +0 -79
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'shared_examples/protect_product_actions'
3
3
 
4
4
  module Spree
5
- describe Spree::Api::ProductsController, :type => :controller do
5
+ describe Spree::Api::ProductsController do
6
6
  render_views
7
7
 
8
8
  let!(:product) { create(:product) }
@@ -51,20 +51,48 @@ module Spree
51
51
 
52
52
  it "retrieves a list of products" do
53
53
  api_get :index
54
- expect(json_response["products"].first).to have_attributes(show_attributes)
55
- expect(json_response["total_count"]).to eq(1)
56
- expect(json_response["current_page"]).to eq(1)
57
- expect(json_response["pages"]).to eq(1)
58
- expect(json_response["per_page"]).to eq(Kaminari.config.default_per_page)
54
+ json_response["products"].first.should have_attributes(show_attributes)
55
+ json_response["total_count"].should == 1
56
+ json_response["current_page"].should == 1
57
+ json_response["pages"].should == 1
58
+ json_response["per_page"].should == Kaminari.config.default_per_page
59
59
  end
60
60
 
61
61
  it "retrieves a list of products by id" do
62
62
  api_get :index, :ids => [product.id]
63
- expect(json_response["products"].first).to have_attributes(show_attributes)
64
- expect(json_response["total_count"]).to eq(1)
65
- expect(json_response["current_page"]).to eq(1)
66
- expect(json_response["pages"]).to eq(1)
67
- expect(json_response["per_page"]).to eq(Kaminari.config.default_per_page)
63
+ json_response["products"].first.should have_attributes(show_attributes)
64
+ json_response["total_count"].should == 1
65
+ json_response["current_page"].should == 1
66
+ json_response["pages"].should == 1
67
+ json_response["per_page"].should == Kaminari.config.default_per_page
68
+ end
69
+
70
+ context "specifying a rabl template for a custom action" do
71
+ before do
72
+ Spree::Api::ProductsController.class_eval do
73
+ def custom_show
74
+ @product = find_product(params[:id])
75
+ respond_with(@product)
76
+ end
77
+ end
78
+ end
79
+
80
+ it "uses the specified custom template through the request header" do
81
+ request.headers['X-Spree-Template'] = 'show'
82
+ api_get :custom_show, :id => product.id
83
+ response.should render_template('spree/api/products/show')
84
+ end
85
+
86
+ it "uses the specified custom template through the template URL parameter" do
87
+ api_get :custom_show, :id => product.id, :template => 'show'
88
+ response.should render_template('spree/api/products/show')
89
+ end
90
+
91
+ it "falls back to the default template if the specified template does not exist" do
92
+ request.headers['X-Spree-Template'] = 'invoice'
93
+ api_get :show, :id => product.id
94
+ response.should render_template('spree/api/products/show')
95
+ end
68
96
  end
69
97
 
70
98
  context "product has more than one price" do
@@ -79,49 +107,64 @@ module Spree
79
107
  it "retrieves a list of products by ids string" do
80
108
  second_product = create(:product)
81
109
  api_get :index, :ids => [product.id, second_product.id].join(",")
82
- expect(json_response["products"].first).to have_attributes(show_attributes)
83
- expect(json_response["products"][1]).to have_attributes(show_attributes)
84
- expect(json_response["total_count"]).to eq(2)
85
- expect(json_response["current_page"]).to eq(1)
86
- expect(json_response["pages"]).to eq(1)
87
- expect(json_response["per_page"]).to eq(Kaminari.config.default_per_page)
110
+ json_response["products"].first.should have_attributes(show_attributes)
111
+ json_response["products"][1].should have_attributes(show_attributes)
112
+ json_response["total_count"].should == 2
113
+ json_response["current_page"].should == 1
114
+ json_response["pages"].should == 1
115
+ json_response["per_page"].should == Kaminari.config.default_per_page
88
116
  end
89
117
 
90
118
  it "does not return inactive products when queried by ids" do
91
119
  api_get :index, :ids => [inactive_product.id]
92
- expect(json_response["count"]).to eq(0)
120
+ json_response["count"].should == 0
93
121
  end
94
122
 
95
123
  it "does not list unavailable products" do
96
124
  api_get :index
97
- expect(json_response["products"].first["name"]).not_to eq("inactive")
125
+ json_response["products"].first["name"].should_not eq("inactive")
98
126
  end
99
127
 
100
128
  context "pagination" do
101
129
  it "can select the next page of products" do
102
130
  second_product = create(:product)
103
131
  api_get :index, :page => 2, :per_page => 1
104
- expect(json_response["products"].first).to have_attributes(show_attributes)
105
- expect(json_response["total_count"]).to eq(2)
106
- expect(json_response["current_page"]).to eq(2)
107
- expect(json_response["pages"]).to eq(2)
132
+ json_response["products"].first.should have_attributes(show_attributes)
133
+ json_response["total_count"].should == 2
134
+ json_response["current_page"].should == 2
135
+ json_response["pages"].should == 2
108
136
  end
109
137
 
110
138
  it 'can control the page size through a parameter' do
111
139
  create(:product)
112
140
  api_get :index, :per_page => 1
113
- expect(json_response['count']).to eq(1)
114
- expect(json_response['total_count']).to eq(2)
115
- expect(json_response['current_page']).to eq(1)
116
- expect(json_response['pages']).to eq(2)
141
+ json_response['count'].should == 1
142
+ json_response['total_count'].should == 2
143
+ json_response['current_page'].should == 1
144
+ json_response['pages'].should == 2
145
+ end
146
+ end
147
+
148
+ context "jsonp" do
149
+ it "retrieves a list of products of jsonp" do
150
+ api_get :index, {:callback => 'callback'}
151
+ response.body.should =~ /^callback\(.*\)$/
152
+ response.header['Content-Type'].should include('application/javascript')
153
+ end
154
+
155
+ # Regression test for #4332
156
+ it "does not escape quotes" do
157
+ api_get :index, {:callback => 'callback'}
158
+ response.body.should =~ /^callback\({"count":1,"total_count":1/
159
+ response.header['Content-Type'].should include('application/javascript')
117
160
  end
118
161
  end
119
162
 
120
163
  it "can search for products" do
121
164
  create(:product, :name => "The best product in the world")
122
165
  api_get :index, :q => { :name_cont => "best" }
123
- expect(json_response["products"].first).to have_attributes(show_attributes)
124
- expect(json_response["count"]).to eq(1)
166
+ json_response["products"].first.should have_attributes(show_attributes)
167
+ json_response["count"].should == 1
125
168
  end
126
169
 
127
170
  it "gets a single product" do
@@ -130,14 +173,14 @@ module Spree
130
173
  product.variants.first.images.create!(:attachment => image("thinking-cat.jpg"))
131
174
  product.set_property("spree", "rocks")
132
175
  api_get :show, :id => product.to_param
133
- expect(json_response).to have_attributes(show_attributes)
134
- expect(json_response['variants'].first).to have_attributes([:name,
176
+ json_response.should have_attributes(show_attributes)
177
+ json_response['variants'].first.should have_attributes([:name,
135
178
  :is_master,
136
179
  :price,
137
180
  :images,
138
181
  :in_stock])
139
182
 
140
- expect(json_response['variants'].first['images'].first).to have_attributes([:attachment_file_name,
183
+ json_response['variants'].first['images'].first.should have_attributes([:attachment_file_name,
141
184
  :attachment_width,
142
185
  :attachment_height,
143
186
  :attachment_content_type,
@@ -146,7 +189,7 @@ module Spree
146
189
  :product_url,
147
190
  :large_url])
148
191
 
149
- expect(json_response["product_properties"].first).to have_attributes([:value,
192
+ json_response["product_properties"].first.should have_attributes([:value,
150
193
  :product_id,
151
194
  :property_name])
152
195
  end
@@ -172,11 +215,11 @@ module Spree
172
215
 
173
216
  specify do
174
217
  api_get :show, :id => product.to_param
175
- expect(json_response["slug"]).to match(/and-1-ways/)
218
+ json_response["slug"].should =~ /and-1-ways/
176
219
  product.destroy
177
220
 
178
221
  api_get :show, :id => other_product.id
179
- expect(json_response["slug"]).to match(/droids/)
222
+ json_response["slug"].should =~ /droids/
180
223
  end
181
224
  end
182
225
 
@@ -192,11 +235,11 @@ module Spree
192
235
 
193
236
  it "can learn how to create a new product" do
194
237
  api_get :new
195
- expect(json_response["attributes"]).to eq(new_attributes.map(&:to_s))
238
+ json_response["attributes"].should == new_attributes.map(&:to_s)
196
239
  required_attributes = json_response["required_attributes"]
197
- expect(required_attributes).to include("name")
198
- expect(required_attributes).to include("price")
199
- expect(required_attributes).to include("shipping_category_id")
240
+ required_attributes.should include("name")
241
+ required_attributes.should include("price")
242
+ required_attributes.should include("shipping_category_id")
200
243
  end
201
244
 
202
245
  it_behaves_like "modifying product actions are restricted"
@@ -210,10 +253,10 @@ module Spree
210
253
 
211
254
  it "can see all products" do
212
255
  api_get :index
213
- expect(json_response["products"].count).to eq(2)
214
- expect(json_response["count"]).to eq(2)
215
- expect(json_response["current_page"]).to eq(1)
216
- expect(json_response["pages"]).to eq(1)
256
+ json_response["products"].count.should == 2
257
+ json_response["count"].should == 2
258
+ json_response["current_page"].should == 1
259
+ json_response["pages"].should == 1
217
260
  end
218
261
 
219
262
  # Regression test for #1626
@@ -224,12 +267,12 @@ module Spree
224
267
 
225
268
  it "does not include deleted products" do
226
269
  api_get :index
227
- expect(json_response["products"].count).to eq(2)
270
+ json_response["products"].count.should == 2
228
271
  end
229
272
 
230
273
  it "can include deleted products" do
231
274
  api_get :index, :show_deleted => 1
232
- expect(json_response["products"].count).to eq(3)
275
+ json_response["products"].count.should == 3
233
276
  end
234
277
  end
235
278
 
@@ -238,8 +281,8 @@ module Spree
238
281
  api_post :create, :product => { :name => "The Other Product",
239
282
  :price => 19.99,
240
283
  :shipping_category_id => create(:shipping_category).id }
241
- expect(json_response).to have_attributes(base_attributes)
242
- expect(response.status).to eq(201)
284
+ json_response.should have_attributes(base_attributes)
285
+ response.status.should == 201
243
286
  end
244
287
 
245
288
  it "creates with embedded variants" do
@@ -318,25 +361,25 @@ module Spree
318
361
 
319
362
  it "can still create a product" do
320
363
  api_post :create, :product => product_data, :token => "fake"
321
- expect(json_response).to have_attributes(show_attributes)
322
- expect(response.status).to eq(201)
364
+ json_response.should have_attributes(show_attributes)
365
+ response.status.should == 201
323
366
  end
324
367
  end
325
368
 
326
369
  it "cannot create a new product with invalid attributes" do
327
- api_post :create, product: {}
328
- expect(response.status).to eq(422)
329
- expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
370
+ api_post :create, :product => {}
371
+ response.status.should == 422
372
+ json_response["error"].should == "Invalid resource. Please fix errors and try again."
330
373
  errors = json_response["errors"]
331
374
  errors.delete("slug") # Don't care about this one.
332
- expect(errors.keys).to match_array(["name", "price", "shipping_category_id"])
375
+ errors.keys.should =~ ["name", "price", "shipping_category_id"]
333
376
  end
334
377
  end
335
378
 
336
379
  context 'updating a product' do
337
380
  it "can update a product" do
338
381
  api_put :update, :id => product.to_param, :product => { :name => "New and Improved Product!" }
339
- expect(response.status).to eq(200)
382
+ response.status.should == 200
340
383
  end
341
384
 
342
385
  it "can create new option types on a product" do
@@ -381,9 +424,9 @@ module Spree
381
424
 
382
425
  it "cannot update a product with an invalid attribute" do
383
426
  api_put :update, :id => product.to_param, :product => { :name => "" }
384
- expect(response.status).to eq(422)
385
- expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
386
- expect(json_response["errors"]["name"]).to eq(["can't be blank"])
427
+ response.status.should == 422
428
+ json_response["error"].should == "Invalid resource. Please fix errors and try again."
429
+ json_response["errors"]["name"].should == ["can't be blank"]
387
430
  end
388
431
 
389
432
  # Regression test for #4123
@@ -400,10 +443,10 @@ module Spree
400
443
  end
401
444
 
402
445
  it "can delete a product" do
403
- expect(product.deleted_at).to be_nil
446
+ product.deleted_at.should be_nil
404
447
  api_delete :destroy, :id => product.to_param
405
- expect(response.status).to eq(204)
406
- expect(product.reload.deleted_at).not_to be_nil
448
+ response.status.should == 204
449
+ product.reload.deleted_at.should_not be_nil
407
450
  end
408
451
  end
409
452
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree::Api
4
- describe OrdersController, :type => :controller do
4
+ describe OrdersController do
5
5
  render_views
6
6
 
7
7
  before do
@@ -10,7 +10,7 @@ module Spree::Api
10
10
 
11
11
  context "with an available promotion" do
12
12
  let!(:order) { create(:order_with_line_items, :line_items_count => 1) }
13
- let!(:promotion) do
13
+ let!(:promotion) do
14
14
  promotion = Spree::Promotion.create(name: "10% off", code: "10off")
15
15
  calculator = Spree::Calculator::FlatPercentItemTotal.create(preferred_flat_percent: "10")
16
16
  action = Spree::Promotion::Actions::CreateItemAdjustments.create(calculator: calculator)
@@ -19,13 +19,14 @@ module Spree::Api
19
19
  end
20
20
 
21
21
  it "can apply a coupon code to the order" do
22
- expect(order.total).to eq(110.00)
22
+ order.total.should == 110.00
23
23
  api_put :apply_coupon_code, :id => order.to_param, :coupon_code => "10off", :order_token => order.guest_token
24
- expect(response.status).to eq(200)
25
- expect(order.reload.total).to eq(109.00)
26
- expect(json_response["success"]).to eq("The coupon code was successfully applied to your order.")
27
- expect(json_response["error"]).to be_blank
28
- expect(json_response["successful"]).to be true
24
+ response.status.should == 200
25
+ order.reload.total.should == 109.00
26
+ json_response["success"].should == "The coupon code was successfully applied to your order."
27
+ json_response["error"].should be_blank
28
+ json_response["successful"].should be true
29
+ json_response["status_code"].should eq("coupon_code_applied")
29
30
  end
30
31
 
31
32
  context "with an expired promotion" do
@@ -37,10 +38,11 @@ module Spree::Api
37
38
 
38
39
  it "fails to apply" do
39
40
  api_put :apply_coupon_code, :id => order.to_param, :coupon_code => "10off", :order_token => order.guest_token
40
- expect(response.status).to eq(422)
41
- expect(json_response["success"]).to be_blank
42
- expect(json_response["error"]).to eq("The coupon code is expired")
43
- expect(json_response["successful"]).to be false
41
+ response.status.should == 422
42
+ json_response["success"].should be_blank
43
+ json_response["error"].should == "The coupon code is expired"
44
+ json_response["successful"].should be false
45
+ json_response["status_code"].should eq("coupon_code_expired")
44
46
  end
45
47
  end
46
48
  end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ module Spree
4
+ describe Spree::Api::PromotionsController do
5
+ render_views
6
+
7
+ shared_examples "a JSON response" do
8
+ it 'should be ok' do
9
+ expect(subject).to be_ok
10
+ end
11
+
12
+ it 'should return JSON' do
13
+ payload = HashWithIndifferentAccess.new(JSON.parse(subject.body))
14
+ expect(payload).to_not be_nil
15
+ Spree::Api::ApiHelpers.promotion_attributes.each do |attribute|
16
+ expect(payload.has_key?(attribute)).to be true
17
+ end
18
+ end
19
+ end
20
+
21
+ before do
22
+ stub_authentication!
23
+ end
24
+
25
+ let(:promotion) { create :promotion, code: '10off' }
26
+
27
+ describe 'GET #show' do
28
+ subject { api_get :show, id: id }
29
+
30
+ context 'when admin' do
31
+ sign_in_as_admin!
32
+
33
+ context 'when finding by id' do
34
+ let(:id) { promotion.id }
35
+
36
+ it_behaves_like "a JSON response"
37
+ end
38
+
39
+ context 'when finding by code' do
40
+ let(:id) { promotion.code }
41
+
42
+ it_behaves_like "a JSON response"
43
+ end
44
+
45
+ context 'when id does not exist' do
46
+ let(:id) { 'argh' }
47
+
48
+ it 'should be 404' do
49
+ expect(subject.status).to eq(404)
50
+ end
51
+ end
52
+ end
53
+
54
+ context 'when non admin' do
55
+ let(:id) { promotion.id }
56
+
57
+ it 'should be unauthorized' do
58
+ subject
59
+ assert_unauthorized!
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
  module Spree
3
- describe Spree::Api::PropertiesController, :type => :controller do
3
+ describe Spree::Api::PropertiesController do
4
4
  render_views
5
5
 
6
6
  let!(:property_1) { Property.create!(:name => "foo", :presentation => "Foo") }
@@ -14,50 +14,50 @@ module Spree
14
14
 
15
15
  it "can see a list of all properties" do
16
16
  api_get :index
17
- expect(json_response["properties"].count).to eq(2)
18
- expect(json_response["properties"].first).to have_attributes(attributes)
17
+ json_response["properties"].count.should eq(2)
18
+ json_response["properties"].first.should have_attributes(attributes)
19
19
  end
20
20
 
21
21
  it "can control the page size through a parameter" do
22
22
  api_get :index, :per_page => 1
23
- expect(json_response['properties'].count).to eq(1)
24
- expect(json_response['current_page']).to eq(1)
25
- expect(json_response['pages']).to eq(2)
23
+ json_response['properties'].count.should == 1
24
+ json_response['current_page'].should == 1
25
+ json_response['pages'].should == 2
26
26
  end
27
27
 
28
28
  it 'can query the results through a parameter' do
29
29
  api_get :index, :q => { :name_cont => 'ba' }
30
- expect(json_response['count']).to eq(1)
31
- expect(json_response['properties'].first['presentation']).to eq property_2.presentation
30
+ json_response['count'].should == 1
31
+ json_response['properties'].first['presentation'].should eq property_2.presentation
32
32
  end
33
33
 
34
34
  it "retrieves a list of properties by id" do
35
35
  api_get :index, :ids => [property_1.id]
36
- expect(json_response["properties"].first).to have_attributes(attributes)
37
- expect(json_response["count"]).to eq(1)
36
+ json_response["properties"].first.should have_attributes(attributes)
37
+ json_response["count"].should == 1
38
38
  end
39
39
 
40
40
  it "retrieves a list of properties by ids string" do
41
41
  api_get :index, :ids => [property_1.id, property_2.id].join(",")
42
- expect(json_response["properties"].first).to have_attributes(attributes)
43
- expect(json_response["properties"][1]).to have_attributes(attributes)
44
- expect(json_response["count"]).to eq(2)
42
+ json_response["properties"].first.should have_attributes(attributes)
43
+ json_response["properties"][1].should have_attributes(attributes)
44
+ json_response["count"].should == 2
45
45
  end
46
46
 
47
47
  it "can see a single property" do
48
48
  api_get :show, :id => property_1.id
49
- expect(json_response).to have_attributes(attributes)
49
+ json_response.should have_attributes(attributes)
50
50
  end
51
51
 
52
52
  it "can see a property by name" do
53
53
  api_get :show, :id => property_1.name
54
- expect(json_response).to have_attributes(attributes)
54
+ json_response.should have_attributes(attributes)
55
55
  end
56
56
 
57
57
  it "can learn how to create a new property" do
58
58
  api_get :new
59
- expect(json_response["attributes"]).to eq(attributes.map(&:to_s))
60
- expect(json_response["required_attributes"]).to be_empty
59
+ json_response["attributes"].should == attributes.map(&:to_s)
60
+ json_response["required_attributes"].should be_empty
61
61
  end
62
62
 
63
63
  it "cannot create a new property if not an admin" do
@@ -73,29 +73,29 @@ module Spree
73
73
  it "cannot delete a property" do
74
74
  api_delete :destroy, :id => property_1.id
75
75
  assert_unauthorized!
76
- expect { property_1.reload }.not_to raise_error
76
+ lambda { property_1.reload }.should_not raise_error
77
77
  end
78
78
 
79
79
  context "as an admin" do
80
80
  sign_in_as_admin!
81
81
 
82
82
  it "can create a new property" do
83
- expect(Spree::Property.count).to eq(2)
83
+ Spree::Property.count.should == 2
84
84
  api_post :create, :property => { :name => "My Property 3", :presentation => "my value 3" }
85
- expect(json_response).to have_attributes(attributes)
86
- expect(response.status).to eq(201)
87
- expect(Spree::Property.count).to eq(3)
85
+ json_response.should have_attributes(attributes)
86
+ response.status.should == 201
87
+ Spree::Property.count.should == 3
88
88
  end
89
89
 
90
90
  it "can update a property" do
91
91
  api_put :update, :id => property_1.name, :property => { :presentation => "my value 456" }
92
- expect(response.status).to eq(200)
92
+ response.status.should == 200
93
93
  end
94
94
 
95
95
  it "can delete a property" do
96
96
  api_delete :destroy, :id => property_1.name
97
- expect(response.status).to eq(204)
98
- expect { property_1.reload }.to raise_error(ActiveRecord::RecordNotFound)
97
+ response.status.should == 204
98
+ lambda { property_1.reload }.should raise_error(ActiveRecord::RecordNotFound)
99
99
  end
100
100
  end
101
101
  end