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
@@ -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 do
5
5
  render_views
6
6
 
7
7
  let!(:stock_location) { create(:stock_location) }
@@ -14,12 +14,12 @@ module Spree
14
14
  context "as a user" do
15
15
  it "cannot see stock locations" do
16
16
  api_get :index
17
- expect(response.status).to eq(401)
17
+ response.status.should == 401
18
18
  end
19
19
 
20
20
  it "cannot see a single stock location" do
21
21
  api_get :show, :id => stock_location.id
22
- expect(response.status).to eq(404)
22
+ response.status.should == 404
23
23
  end
24
24
 
25
25
  it "cannot create a new stock location" do
@@ -31,17 +31,17 @@ module Spree
31
31
  }
32
32
 
33
33
  api_post :create, params
34
- expect(response.status).to eq(401)
34
+ response.status.should == 401
35
35
  end
36
36
 
37
37
  it "cannot update a stock location" do
38
38
  api_put :update, :stock_location => { :name => "South Pole" }, :id => stock_location.to_param
39
- expect(response.status).to eq(404)
39
+ response.status.should == 404
40
40
  end
41
41
 
42
42
  it "cannot delete a stock location" do
43
43
  api_put :destroy, :id => stock_location.to_param
44
- expect(response.status).to eq(404)
44
+ response.status.should == 404
45
45
  end
46
46
  end
47
47
 
@@ -51,30 +51,30 @@ module Spree
51
51
 
52
52
  it "gets list of stock locations" do
53
53
  api_get :index
54
- expect(json_response['stock_locations'].first).to have_attributes(attributes)
55
- expect(json_response['stock_locations'].first['country']).not_to be_nil
56
- expect(json_response['stock_locations'].first['state']).not_to be_nil
54
+ json_response['stock_locations'].first.should have_attributes(attributes)
55
+ json_response['stock_locations'].first['country'].should_not be_nil
56
+ json_response['stock_locations'].first['state'].should_not be_nil
57
57
  end
58
58
 
59
59
  it 'can control the page size through a parameter' do
60
60
  create(:stock_location)
61
61
  api_get :index, per_page: 1
62
- expect(json_response['count']).to eq(1)
63
- expect(json_response['current_page']).to eq(1)
64
- expect(json_response['pages']).to eq(2)
62
+ json_response['count'].should == 1
63
+ json_response['current_page'].should == 1
64
+ json_response['pages'].should == 2
65
65
  end
66
66
 
67
67
  it 'can query the results through a paramter' do
68
68
  expected_result = create(:stock_location, name: 'South America')
69
69
  api_get :index, q: { name_cont: 'south' }
70
- expect(json_response['count']).to eq(1)
71
- expect(json_response['stock_locations'].first['name']).to eq expected_result.name
70
+ json_response['count'].should == 1
71
+ json_response['stock_locations'].first['name'].should eq expected_result.name
72
72
  end
73
73
 
74
74
  it "gets a stock location" do
75
75
  api_get :show, id: stock_location.to_param
76
- expect(json_response).to have_attributes(attributes)
77
- expect(json_response['name']).to eq stock_location.name
76
+ json_response.should have_attributes(attributes)
77
+ json_response['name'].should eq stock_location.name
78
78
  end
79
79
 
80
80
  it "can create a new stock location" do
@@ -86,8 +86,8 @@ module Spree
86
86
  }
87
87
 
88
88
  api_post :create, params
89
- expect(response.status).to eq(201)
90
- expect(json_response).to have_attributes(attributes)
89
+ response.status.should == 201
90
+ json_response.should have_attributes(attributes)
91
91
  end
92
92
 
93
93
  it "can update a stock location" do
@@ -99,14 +99,14 @@ module Spree
99
99
  }
100
100
 
101
101
  api_put :update, params
102
- expect(response.status).to eq(200)
103
- expect(json_response['name']).to eq 'South Pole'
102
+ response.status.should == 200
103
+ json_response['name'].should eq 'South Pole'
104
104
  end
105
105
 
106
106
  it "can delete a stock location" do
107
107
  api_delete :destroy, id: stock_location.to_param
108
- expect(response.status).to eq(204)
109
- expect { stock_location.reload }.to raise_error(ActiveRecord::RecordNotFound)
108
+ response.status.should == 204
109
+ lambda { stock_location.reload }.should raise_error(ActiveRecord::RecordNotFound)
110
110
  end
111
111
  end
112
112
  end
@@ -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 do
5
5
  render_views
6
6
 
7
7
  let!(:stock_location) { create(:stock_location_with_items) }
@@ -16,12 +16,12 @@ module Spree
16
16
  context 'as a user' do
17
17
  it 'cannot see a list of stock movements' do
18
18
  api_get :index, stock_location_id: stock_location.to_param
19
- expect(response.status).to eq(404)
19
+ response.status.should == 404
20
20
  end
21
21
 
22
22
  it 'cannot see a stock movement' do
23
23
  api_get :show, stock_location_id: stock_location.to_param, id: stock_movement.id
24
- expect(response.status).to eq(404)
24
+ response.status.should == 404
25
25
  end
26
26
 
27
27
  it 'cannot create a stock movement' do
@@ -33,7 +33,7 @@ module Spree
33
33
  }
34
34
 
35
35
  api_post :create, params
36
- expect(response.status).to eq(404)
36
+ response.status.should == 404
37
37
  end
38
38
  end
39
39
 
@@ -42,34 +42,34 @@ module Spree
42
42
 
43
43
  it 'gets list of stock movements' do
44
44
  api_get :index, stock_location_id: stock_location.to_param
45
- expect(json_response['stock_movements'].first).to have_attributes(attributes)
46
- expect(json_response['stock_movements'].first['stock_item']['count_on_hand']).to eq 11
45
+ json_response['stock_movements'].first.should have_attributes(attributes)
46
+ json_response['stock_movements'].first['stock_item']['count_on_hand'].should eq 11
47
47
  end
48
48
 
49
49
  it 'requires a stock_location_id to be passed as a parameter' do
50
50
  api_get :index
51
- expect(json_response['error']).to match(/stock_location_id parameter must be provided/)
52
- expect(response.status).to eq(422)
51
+ json_response['error'].should =~ /stock_location_id parameter must be provided/
52
+ response.status.should == 422
53
53
  end
54
54
 
55
55
  it 'can control the page size through a parameter' do
56
56
  create(:stock_movement, stock_item: stock_item)
57
57
  api_get :index, stock_location_id: stock_location.to_param, per_page: 1
58
- expect(json_response['count']).to eq(1)
59
- expect(json_response['current_page']).to eq(1)
60
- expect(json_response['pages']).to eq(2)
58
+ json_response['count'].should == 1
59
+ json_response['current_page'].should == 1
60
+ json_response['pages'].should == 2
61
61
  end
62
62
 
63
63
  it 'can query the results through a paramter' do
64
64
  expected_result = create(:stock_movement, :received, quantity: 10, stock_item: stock_item)
65
65
  api_get :index, stock_location_id: stock_location.to_param, q: { quantity_eq: '10' }
66
- expect(json_response['count']).to eq(1)
66
+ json_response['count'].should == 1
67
67
  end
68
68
 
69
69
  it 'gets a stock movement' do
70
70
  api_get :show, stock_location_id: stock_location.to_param, id: stock_movement.to_param
71
- expect(json_response).to have_attributes(attributes)
72
- expect(json_response['stock_item_id']).to eq stock_movement.stock_item_id
71
+ json_response.should have_attributes(attributes)
72
+ json_response['stock_item_id'].should eq stock_movement.stock_item_id
73
73
  end
74
74
 
75
75
  it 'can create a new stock movement' do
@@ -81,8 +81,8 @@ module Spree
81
81
  }
82
82
 
83
83
  api_post :create, params
84
- expect(response.status).to eq(201)
85
- expect(json_response).to have_attributes(attributes)
84
+ response.status.should == 201
85
+ json_response.should have_attributes(attributes)
86
86
  end
87
87
  end
88
88
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::TaxonomiesController, :type => :controller do
4
+ describe Api::TaxonomiesController do
5
5
  render_views
6
6
 
7
7
  let(:taxonomy) { create(:taxonomy) }
@@ -20,57 +20,57 @@ module Spree
20
20
  it "gets all taxonomies" do
21
21
  api_get :index
22
22
 
23
- expect(json_response["taxonomies"].first['name']).to eq taxonomy.name
24
- expect(json_response["taxonomies"].first['root']['taxons'].count).to eq 1
23
+ json_response["taxonomies"].first['name'].should eq taxonomy.name
24
+ json_response["taxonomies"].first['root']['taxons'].count.should eq 1
25
25
  end
26
26
 
27
27
  it 'can control the page size through a parameter' do
28
28
  create(:taxonomy)
29
29
  api_get :index, :per_page => 1
30
- expect(json_response['count']).to eq(1)
31
- expect(json_response['current_page']).to eq(1)
32
- expect(json_response['pages']).to eq(2)
30
+ json_response['count'].should == 1
31
+ json_response['current_page'].should == 1
32
+ json_response['pages'].should == 2
33
33
  end
34
34
 
35
35
  it 'can query the results through a paramter' do
36
36
  expected_result = create(:taxonomy, :name => 'Style')
37
37
  api_get :index, :q => { :name_cont => 'style' }
38
- expect(json_response['count']).to eq(1)
39
- expect(json_response['taxonomies'].first['name']).to eq expected_result.name
38
+ json_response['count'].should == 1
39
+ json_response['taxonomies'].first['name'].should eq expected_result.name
40
40
  end
41
41
 
42
42
  it "gets a single taxonomy" do
43
43
  api_get :show, :id => taxonomy.id
44
44
 
45
- expect(json_response['name']).to eq taxonomy.name
45
+ json_response['name'].should eq taxonomy.name
46
46
 
47
47
  children = json_response['root']['taxons']
48
- expect(children.count).to eq 1
49
- expect(children.first['name']).to eq taxon.name
50
- expect(children.first.key?('taxons')).to be false
48
+ children.count.should eq 1
49
+ children.first['name'].should eq taxon.name
50
+ children.first.key?('taxons').should be false
51
51
  end
52
52
 
53
53
  it "gets a single taxonomy with set=nested" do
54
54
  api_get :show, :id => taxonomy.id, :set => 'nested'
55
55
 
56
- expect(json_response['name']).to eq taxonomy.name
56
+ json_response['name'].should eq taxonomy.name
57
57
 
58
58
  children = json_response['root']['taxons']
59
- expect(children.first.key?('taxons')).to be true
59
+ children.first.key?('taxons').should be true
60
60
  end
61
61
 
62
62
  it "gets the jstree-friendly version of a taxonomy" do
63
63
  api_get :jstree, :id => taxonomy.id
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})
66
- expect(json_response["state"]).to eq("closed")
64
+ json_response["data"].should eq(taxonomy.root.name)
65
+ json_response["attr"].should eq({ "id" => taxonomy.root.id, "name" => taxonomy.root.name})
66
+ json_response["state"].should eq("closed")
67
67
  end
68
68
 
69
69
  it "can learn how to create a new taxonomy" do
70
70
  api_get :new
71
- expect(json_response["attributes"]).to eq(attributes.map(&:to_s))
71
+ json_response["attributes"].should == attributes.map(&:to_s)
72
72
  required_attributes = json_response["required_attributes"]
73
- expect(required_attributes).to include("name")
73
+ required_attributes.should include("name")
74
74
  end
75
75
 
76
76
  it "cannot create a new taxonomy if not an admin" do
@@ -94,20 +94,20 @@ module Spree
94
94
 
95
95
  it "can create" do
96
96
  api_post :create, :taxonomy => { :name => "Colors"}
97
- expect(json_response).to have_attributes(attributes)
98
- expect(response.status).to eq(201)
97
+ json_response.should have_attributes(attributes)
98
+ response.status.should == 201
99
99
  end
100
100
 
101
101
  it "cannot create a new taxonomy with invalid attributes" do
102
102
  api_post :create, :taxonomy => {}
103
- expect(response.status).to eq(422)
104
- expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
103
+ response.status.should == 422
104
+ json_response["error"].should == "Invalid resource. Please fix errors and try again."
105
105
  errors = json_response["errors"]
106
106
  end
107
107
 
108
108
  it "can destroy" do
109
109
  api_delete :destroy, :id => taxonomy.id
110
- expect(response.status).to eq(204)
110
+ response.status.should == 204
111
111
  end
112
112
  end
113
113
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::TaxonsController, :type => :controller do
4
+ describe Api::TaxonsController do
5
5
  render_views
6
6
 
7
7
  let(:taxonomy) { create(:taxonomy) }
@@ -20,19 +20,19 @@ module Spree
20
20
  it "gets all taxons for a taxonomy" do
21
21
  api_get :index, :taxonomy_id => taxonomy.id
22
22
 
23
- expect(json_response['taxons'].first['name']).to eq taxon.name
23
+ json_response['taxons'].first['name'].should eq taxon.name
24
24
  children = json_response['taxons'].first['taxons']
25
- expect(children.count).to eq 1
26
- expect(children.first['name']).to eq taxon2.name
27
- expect(children.first['taxons'].count).to eq 1
25
+ children.count.should eq 1
26
+ children.first['name'].should eq taxon2.name
27
+ children.first['taxons'].count.should eq 1
28
28
  end
29
29
 
30
30
  # Regression test for #4112
31
31
  it "does not include children when asked not to" do
32
32
  api_get :index, :taxonomy_id => taxonomy.id, :without_children => 1
33
33
 
34
- expect(json_response['taxons'].first['name']).to eq(taxon.name)
35
- expect(json_response['taxons'].first['taxons']).to be_nil
34
+ json_response['taxons'].first['name'].should eq(taxon.name)
35
+ json_response['taxons'].first['taxons'].should be_nil
36
36
  end
37
37
 
38
38
  it "paginates through taxons" do
@@ -57,8 +57,8 @@ module Spree
57
57
  let(:name) { "Ruby" }
58
58
 
59
59
  it "returns an array including the matching taxon" do
60
- expect(json_response['taxons'].count).to eq(1)
61
- expect(json_response['taxons'].first['name']).to eq "Ruby"
60
+ json_response['taxons'].count.should == 1
61
+ json_response['taxons'].first['name'].should eq "Ruby"
62
62
  end
63
63
  end
64
64
 
@@ -66,8 +66,8 @@ module Spree
66
66
  let(:name) { "Imaginary" }
67
67
 
68
68
  it 'returns an empty array of taxons' do
69
- expect(json_response.keys).to include('taxons')
70
- expect(json_response['taxons'].count).to eq(0)
69
+ json_response.keys.should include('taxons')
70
+ json_response['taxons'].count.should == 0
71
71
  end
72
72
  end
73
73
  end
@@ -76,11 +76,11 @@ module Spree
76
76
  it "gets all taxons" do
77
77
  api_get :index
78
78
 
79
- expect(json_response['taxons'].first['name']).to eq taxonomy.root.name
79
+ json_response['taxons'].first['name'].should eq taxonomy.root.name
80
80
  children = json_response['taxons'].first['taxons']
81
- expect(children.count).to eq 1
82
- expect(children.first['name']).to eq taxon.name
83
- expect(children.first['taxons'].count).to eq 1
81
+ children.count.should eq 1
82
+ children.first['name'].should eq taxon.name
83
+ children.first['taxons'].count.should eq 1
84
84
  end
85
85
  end
86
86
  end
@@ -88,23 +88,23 @@ module Spree
88
88
  it "gets a single taxon" do
89
89
  api_get :show, :id => taxon.id, :taxonomy_id => taxonomy.id
90
90
 
91
- expect(json_response['name']).to eq taxon.name
92
- expect(json_response['taxons'].count).to eq 1
91
+ json_response['name'].should eq taxon.name
92
+ json_response['taxons'].count.should eq 1
93
93
  end
94
94
 
95
95
  it "gets all taxons in JSTree form" do
96
96
  api_get :jstree, :taxonomy_id => taxonomy.id, :id => taxon.id
97
97
  response = json_response.first
98
- expect(response["data"]).to eq(taxon2.name)
99
- expect(response["attr"]).to eq({ "name" => taxon2.name, "id" => taxon2.id})
100
- expect(response["state"]).to eq("closed")
98
+ response["data"].should eq(taxon2.name)
99
+ response["attr"].should eq({ "name" => taxon2.name, "id" => taxon2.id})
100
+ response["state"].should eq("closed")
101
101
  end
102
102
 
103
103
  it "can learn how to create a new taxon" do
104
104
  api_get :new, :taxonomy_id => taxonomy.id
105
- expect(json_response["attributes"]).to eq(attributes.map(&:to_s))
105
+ json_response["attributes"].should == attributes.map(&:to_s)
106
106
  required_attributes = json_response["required_attributes"]
107
- expect(required_attributes).to include("name")
107
+ required_attributes.should include("name")
108
108
  end
109
109
 
110
110
  it "cannot create a new taxon if not an admin" do
@@ -128,48 +128,48 @@ module Spree
128
128
 
129
129
  it "can create" do
130
130
  api_post :create, :taxonomy_id => taxonomy.id, :taxon => { :name => "Colors" }
131
- expect(json_response).to have_attributes(attributes)
132
- expect(response.status).to eq(201)
131
+ json_response.should have_attributes(attributes)
132
+ response.status.should == 201
133
133
 
134
- expect(taxonomy.reload.root.children.count).to eq 2
134
+ taxonomy.reload.root.children.count.should eq 2
135
135
  taxon = Spree::Taxon.where(:name => 'Colors').first
136
136
 
137
- expect(taxon.parent_id).to eq taxonomy.root.id
138
- expect(taxon.taxonomy_id).to eq taxonomy.id
137
+ taxon.parent_id.should eq taxonomy.root.id
138
+ taxon.taxonomy_id.should eq taxonomy.id
139
139
  end
140
140
 
141
141
  it "can update the position in the list" do
142
142
  taxonomy.root.children << taxon2
143
143
  api_put :update, :taxonomy_id => taxonomy.id, :id => taxon.id, :taxon => {:parent_id => taxon.parent_id, :child_index => 2 }
144
- expect(response.status).to eq(200)
145
- expect(taxonomy.reload.root.children[0]).to eql taxon2
146
- expect(taxonomy.reload.root.children[1]).to eql taxon
144
+ response.status.should == 200
145
+ taxonomy.reload.root.children[0].should eql taxon2
146
+ taxonomy.reload.root.children[1].should eql taxon
147
147
  end
148
148
 
149
149
  it "cannot create a new taxon with invalid attributes" do
150
150
  api_post :create, :taxonomy_id => taxonomy.id, :taxon => {}
151
- expect(response.status).to eq(422)
152
- expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
151
+ response.status.should == 422
152
+ json_response["error"].should == "Invalid resource. Please fix errors and try again."
153
153
  errors = json_response["errors"]
154
154
 
155
- expect(taxonomy.reload.root.children.count).to eq 1
155
+ taxonomy.reload.root.children.count.should eq 1
156
156
  end
157
157
 
158
158
  it "cannot create a new taxon with invalid taxonomy_id" do
159
159
  api_post :create, :taxonomy_id => 1000, :taxon => { :name => "Colors" }
160
- expect(response.status).to eq(422)
161
- expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
160
+ response.status.should == 422
161
+ json_response["error"].should == "Invalid resource. Please fix errors and try again."
162
162
 
163
163
  errors = json_response["errors"]
164
- expect(errors["taxonomy_id"]).not_to be_nil
165
- expect(errors["taxonomy_id"].first).to eq "Invalid taxonomy id."
164
+ errors["taxonomy_id"].should_not be_nil
165
+ errors["taxonomy_id"].first.should eq "Invalid taxonomy id."
166
166
 
167
- expect(taxonomy.reload.root.children.count).to eq 1
167
+ taxonomy.reload.root.children.count.should eq 1
168
168
  end
169
169
 
170
170
  it "can destroy" do
171
171
  api_delete :destroy, :taxonomy_id => taxonomy.id, :id => taxon.id
172
- expect(response.status).to eq(204)
172
+ response.status.should == 204
173
173
  end
174
174
  end
175
175
 
@@ -2,7 +2,7 @@ require 'shared_examples/protect_product_actions'
2
2
  require 'spec_helper'
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) }
@@ -13,10 +13,10 @@ module Spree
13
13
 
14
14
  it "retreives a list of products" do
15
15
  api_get :index
16
- expect(json_response["products"].first).to have_attributes(attributes)
17
- expect(json_response["count"]).to eq(1)
18
- expect(json_response["current_page"]).to eq(1)
19
- expect(json_response["pages"]).to eq(1)
16
+ json_response["products"].first.should have_attributes(attributes)
17
+ json_response["count"].should == 1
18
+ json_response["current_page"].should == 1
19
+ json_response["pages"].should == 1
20
20
  end
21
21
 
22
22
  it_behaves_like "modifying product actions are restricted"