spree_api 2.4.0.rc2 → 2.4.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/api/base_controller.rb +4 -6
  3. data/app/controllers/spree/api/option_types_controller.rb +2 -2
  4. data/app/controllers/spree/api/orders_controller.rb +9 -1
  5. data/app/controllers/spree/api/return_authorizations_controller.rb +0 -9
  6. data/app/controllers/spree/api/taxons_controller.rb +3 -3
  7. data/app/helpers/spree/api/api_helpers.rb +0 -2
  8. data/app/views/spree/api/orders/show.v1.rabl +4 -0
  9. data/app/views/spree/api/products/show.v1.rabl +4 -0
  10. data/app/views/spree/api/shipments/small.v1.rabl +4 -0
  11. data/lib/spree/api/testing_support/helpers.rb +6 -6
  12. data/lib/spree/api/testing_support/setup.rb +2 -2
  13. data/spec/controllers/spree/api/addresses_controller_spec.rb +8 -8
  14. data/spec/controllers/spree/api/base_controller_spec.rb +22 -22
  15. data/spec/controllers/spree/api/checkouts_controller_spec.rb +53 -53
  16. data/spec/controllers/spree/api/classifications_controller_spec.rb +5 -5
  17. data/spec/controllers/spree/api/config_controller_spec.rb +9 -9
  18. data/spec/controllers/spree/api/countries_controller_spec.rb +11 -11
  19. data/spec/controllers/spree/api/credit_cards_controller_spec.rb +16 -16
  20. data/spec/controllers/spree/api/images_controller_spec.rb +21 -21
  21. data/spec/controllers/spree/api/inventory_units_controller_spec.rb +6 -6
  22. data/spec/controllers/spree/api/line_items_controller_spec.rb +33 -33
  23. data/spec/controllers/spree/api/option_types_controller_spec.rb +19 -19
  24. data/spec/controllers/spree/api/option_values_controller_spec.rb +23 -23
  25. data/spec/controllers/spree/api/orders_controller_spec.rb +186 -143
  26. data/spec/controllers/spree/api/payments_controller_spec.rb +39 -39
  27. data/spec/controllers/spree/api/product_properties_controller_spec.rb +21 -21
  28. data/spec/controllers/spree/api/products_controller_spec.rb +71 -66
  29. data/spec/controllers/spree/api/promotion_application_spec.rb +13 -13
  30. data/spec/controllers/spree/api/promotions_controller_spec.rb +1 -1
  31. data/spec/controllers/spree/api/properties_controller_spec.rb +25 -25
  32. data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +27 -36
  33. data/spec/controllers/spree/api/shipments_controller_spec.rb +22 -22
  34. data/spec/controllers/spree/api/states_controller_spec.rb +18 -18
  35. data/spec/controllers/spree/api/stock_items_controller_spec.rb +26 -26
  36. data/spec/controllers/spree/api/stock_locations_controller_spec.rb +22 -22
  37. data/spec/controllers/spree/api/stock_movements_controller_spec.rb +16 -16
  38. data/spec/controllers/spree/api/taxonomies_controller_spec.rb +24 -24
  39. data/spec/controllers/spree/api/taxons_controller_spec.rb +39 -39
  40. data/spec/controllers/spree/api/unauthenticated_products_controller_spec.rb +6 -6
  41. data/spec/controllers/spree/api/users_controller_spec.rb +25 -25
  42. data/spec/controllers/spree/api/variants_controller_spec.rb +36 -36
  43. data/spec/controllers/spree/api/zones_controller_spec.rb +20 -20
  44. data/spec/models/spree/legacy_user_spec.rb +5 -5
  45. data/spec/requests/rabl_cache_spec.rb +9 -9
  46. data/spec/spec_helper.rb +0 -1
  47. data/spec/support/controller_hacks.rb +4 -0
  48. metadata +4 -4
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::StockItemsController do
4
+ describe Api::StockItemsController, :type => :controller 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 normal user" do
17
17
  it "cannot list stock items for a stock location" do
18
18
  api_get :index, stock_location_id: stock_location.to_param
19
- response.status.should == 404
19
+ expect(response.status).to eq(404)
20
20
  end
21
21
 
22
22
  it "cannot see a stock item" do
23
23
  api_get :show, stock_location_id: stock_location.to_param, id: stock_item.to_param
24
- response.status.should == 404
24
+ expect(response.status).to eq(404)
25
25
  end
26
26
 
27
27
  it "cannot create a stock item" do
@@ -35,17 +35,17 @@ module Spree
35
35
  }
36
36
 
37
37
  api_post :create, params
38
- response.status.should == 404
38
+ expect(response.status).to eq(404)
39
39
  end
40
40
 
41
41
  it "cannot update a stock item" do
42
42
  api_put :update, stock_location_id: stock_location.to_param, stock_item_id: stock_item.to_param
43
- response.status.should == 404
43
+ expect(response.status).to eq(404)
44
44
  end
45
45
 
46
46
  it "cannot destroy a stock item" do
47
47
  api_delete :destroy, stock_location_id: stock_location.to_param, stock_item_id: stock_item.to_param
48
- response.status.should == 404
48
+ expect(response.status).to eq(404)
49
49
  end
50
50
  end
51
51
 
@@ -54,33 +54,33 @@ module Spree
54
54
 
55
55
  it 'cannot list of stock items' do
56
56
  api_get :index, stock_location_id: stock_location.to_param
57
- json_response['stock_items'].first.should have_attributes(attributes)
58
- json_response['stock_items'].first['variant']['sku'].should include 'SKU'
57
+ expect(json_response['stock_items'].first).to have_attributes(attributes)
58
+ expect(json_response['stock_items'].first['variant']['sku']).to include 'SKU'
59
59
  end
60
60
 
61
61
  it 'requires a stock_location_id to be passed as a parameter' do
62
62
  api_get :index
63
- json_response['error'].should =~ /stock_location_id parameter must be provided/
64
- response.status.should == 422
63
+ expect(json_response['error']).to match(/stock_location_id parameter must be provided/)
64
+ expect(response.status).to eq(422)
65
65
  end
66
66
 
67
67
  it 'can control the page size through a parameter' do
68
68
  api_get :index, stock_location_id: stock_location.to_param, per_page: 1
69
- json_response['count'].should == 1
70
- json_response['current_page'].should == 1
69
+ expect(json_response['count']).to eq(1)
70
+ expect(json_response['current_page']).to eq(1)
71
71
  end
72
72
 
73
73
  it 'can query the results through a paramter' do
74
74
  stock_item.update_column(:count_on_hand, 30)
75
75
  api_get :index, stock_location_id: stock_location.to_param, q: { count_on_hand_eq: '30' }
76
- json_response['count'].should == 1
77
- json_response['stock_items'].first['count_on_hand'].should eq 30
76
+ expect(json_response['count']).to eq(1)
77
+ expect(json_response['stock_items'].first['count_on_hand']).to eq 30
78
78
  end
79
79
 
80
80
  it 'gets a stock item' do
81
81
  api_get :show, stock_location_id: stock_location.to_param, id: stock_item.to_param
82
- json_response.should have_attributes(attributes)
83
- json_response['count_on_hand'].should eq stock_item.count_on_hand
82
+ expect(json_response).to have_attributes(attributes)
83
+ expect(json_response['count_on_hand']).to eq stock_item.count_on_hand
84
84
  end
85
85
 
86
86
  it 'can create a new stock item' do
@@ -97,12 +97,12 @@ module Spree
97
97
  }
98
98
 
99
99
  api_post :create, params
100
- response.status.should == 201
101
- json_response.should have_attributes(attributes)
100
+ expect(response.status).to eq(201)
101
+ expect(json_response).to have_attributes(attributes)
102
102
  end
103
103
 
104
104
  it 'can update a stock item to add new inventory' do
105
- stock_item.count_on_hand.should == 10
105
+ expect(stock_item.count_on_hand).to eq(10)
106
106
  params = {
107
107
  id: stock_item.to_param,
108
108
  stock_item: {
@@ -111,12 +111,12 @@ module Spree
111
111
  }
112
112
 
113
113
  api_put :update, params
114
- response.status.should == 200
115
- json_response['count_on_hand'].should eq 50
114
+ expect(response.status).to eq(200)
115
+ expect(json_response['count_on_hand']).to eq 50
116
116
  end
117
117
 
118
118
  it 'can set a stock item to modify the current inventory' do
119
- stock_item.count_on_hand.should == 10
119
+ expect(stock_item.count_on_hand).to eq(10)
120
120
 
121
121
  params = {
122
122
  id: stock_item.to_param,
@@ -127,14 +127,14 @@ module Spree
127
127
  }
128
128
 
129
129
  api_put :update, params
130
- response.status.should == 200
131
- json_response['count_on_hand'].should eq 40
130
+ expect(response.status).to eq(200)
131
+ expect(json_response['count_on_hand']).to eq 40
132
132
  end
133
133
 
134
134
  it 'can delete a stock item' do
135
135
  api_delete :destroy, id: stock_item.to_param
136
- response.status.should == 204
137
- lambda { Spree::StockItem.find(stock_item.id) }.should raise_error(ActiveRecord::RecordNotFound)
136
+ expect(response.status).to eq(204)
137
+ expect { Spree::StockItem.find(stock_item.id) }.to raise_error(ActiveRecord::RecordNotFound)
138
138
  end
139
139
  end
140
140
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::StockLocationsController do
4
+ describe Api::StockLocationsController, :type => :controller 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
- response.status.should == 401
17
+ expect(response.status).to eq(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
- response.status.should == 404
22
+ expect(response.status).to eq(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
- response.status.should == 401
34
+ expect(response.status).to eq(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
- response.status.should == 404
39
+ expect(response.status).to eq(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
- response.status.should == 404
44
+ expect(response.status).to eq(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
- 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
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
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
- json_response['count'].should == 1
63
- json_response['current_page'].should == 1
64
- json_response['pages'].should == 2
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)
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
- json_response['count'].should == 1
71
- json_response['stock_locations'].first['name'].should eq expected_result.name
70
+ expect(json_response['count']).to eq(1)
71
+ expect(json_response['stock_locations'].first['name']).to 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
- json_response.should have_attributes(attributes)
77
- json_response['name'].should eq stock_location.name
76
+ expect(json_response).to have_attributes(attributes)
77
+ expect(json_response['name']).to 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
- response.status.should == 201
90
- json_response.should have_attributes(attributes)
89
+ expect(response.status).to eq(201)
90
+ expect(json_response).to 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
- response.status.should == 200
103
- json_response['name'].should eq 'South Pole'
102
+ expect(response.status).to eq(200)
103
+ expect(json_response['name']).to 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
- response.status.should == 204
109
- lambda { stock_location.reload }.should raise_error(ActiveRecord::RecordNotFound)
108
+ expect(response.status).to eq(204)
109
+ expect { stock_location.reload }.to 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 do
4
+ describe Api::StockMovementsController, :type => :controller 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
- response.status.should == 404
19
+ expect(response.status).to eq(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
- response.status.should == 404
24
+ expect(response.status).to eq(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
- response.status.should == 404
36
+ expect(response.status).to eq(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
- json_response['stock_movements'].first.should have_attributes(attributes)
46
- json_response['stock_movements'].first['stock_item']['count_on_hand'].should eq 11
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
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
- json_response['error'].should =~ /stock_location_id parameter must be provided/
52
- response.status.should == 422
51
+ expect(json_response['error']).to match(/stock_location_id parameter must be provided/)
52
+ expect(response.status).to eq(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
- json_response['count'].should == 1
59
- json_response['current_page'].should == 1
60
- json_response['pages'].should == 2
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)
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
- json_response['count'].should == 1
66
+ expect(json_response['count']).to eq(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
- json_response.should have_attributes(attributes)
72
- json_response['stock_item_id'].should eq stock_movement.stock_item_id
71
+ expect(json_response).to have_attributes(attributes)
72
+ expect(json_response['stock_item_id']).to 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
- response.status.should == 201
85
- json_response.should have_attributes(attributes)
84
+ expect(response.status).to eq(201)
85
+ expect(json_response).to 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 do
4
+ describe Api::TaxonomiesController, :type => :controller 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
- json_response["taxonomies"].first['name'].should eq taxonomy.name
24
- json_response["taxonomies"].first['root']['taxons'].count.should eq 1
23
+ expect(json_response["taxonomies"].first['name']).to eq taxonomy.name
24
+ expect(json_response["taxonomies"].first['root']['taxons'].count).to 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
- json_response['count'].should == 1
31
- json_response['current_page'].should == 1
32
- json_response['pages'].should == 2
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)
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
- json_response['count'].should == 1
39
- json_response['taxonomies'].first['name'].should eq expected_result.name
38
+ expect(json_response['count']).to eq(1)
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
43
  api_get :show, :id => taxonomy.id
44
44
 
45
- json_response['name'].should eq taxonomy.name
45
+ expect(json_response['name']).to eq taxonomy.name
46
46
 
47
47
  children = json_response['root']['taxons']
48
- children.count.should eq 1
49
- children.first['name'].should eq taxon.name
50
- children.first.key?('taxons').should be false
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
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
- json_response['name'].should eq taxonomy.name
56
+ expect(json_response['name']).to eq taxonomy.name
57
57
 
58
58
  children = json_response['root']['taxons']
59
- children.first.key?('taxons').should be true
59
+ expect(children.first.key?('taxons')).to 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
- 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")
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")
67
67
  end
68
68
 
69
69
  it "can learn how to create a new taxonomy" do
70
70
  api_get :new
71
- json_response["attributes"].should == attributes.map(&:to_s)
71
+ expect(json_response["attributes"]).to eq(attributes.map(&:to_s))
72
72
  required_attributes = json_response["required_attributes"]
73
- required_attributes.should include("name")
73
+ expect(required_attributes).to 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
- json_response.should have_attributes(attributes)
98
- response.status.should == 201
97
+ expect(json_response).to have_attributes(attributes)
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
102
  api_post :create, :taxonomy => {}
103
- response.status.should == 422
104
- json_response["error"].should == "Invalid resource. Please fix errors and try again."
103
+ expect(response.status).to eq(422)
104
+ expect(json_response["error"]).to eq("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
- response.status.should == 204
110
+ expect(response.status).to eq(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 do
4
+ describe Api::TaxonsController, :type => :controller 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
- json_response['taxons'].first['name'].should eq taxon.name
23
+ expect(json_response['taxons'].first['name']).to eq taxon.name
24
24
  children = json_response['taxons'].first['taxons']
25
- children.count.should eq 1
26
- children.first['name'].should eq taxon2.name
27
- children.first['taxons'].count.should eq 1
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
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
- json_response['taxons'].first['name'].should eq(taxon.name)
35
- json_response['taxons'].first['taxons'].should be_nil
34
+ expect(json_response['taxons'].first['name']).to eq(taxon.name)
35
+ expect(json_response['taxons'].first['taxons']).to 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
- json_response['taxons'].count.should == 1
61
- json_response['taxons'].first['name'].should eq "Ruby"
60
+ expect(json_response['taxons'].count).to eq(1)
61
+ expect(json_response['taxons'].first['name']).to 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
- json_response.keys.should include('taxons')
70
- json_response['taxons'].count.should == 0
69
+ expect(json_response.keys).to include('taxons')
70
+ expect(json_response['taxons'].count).to eq(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
- json_response['taxons'].first['name'].should eq taxonomy.root.name
79
+ expect(json_response['taxons'].first['name']).to eq taxonomy.root.name
80
80
  children = json_response['taxons'].first['taxons']
81
- children.count.should eq 1
82
- children.first['name'].should eq taxon.name
83
- children.first['taxons'].count.should eq 1
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
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
- json_response['name'].should eq taxon.name
92
- json_response['taxons'].count.should eq 1
91
+ expect(json_response['name']).to eq taxon.name
92
+ expect(json_response['taxons'].count).to 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
- response["data"].should eq(taxon2.name)
99
- response["attr"].should eq({ "name" => taxon2.name, "id" => taxon2.id})
100
- response["state"].should eq("closed")
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")
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
- json_response["attributes"].should == attributes.map(&:to_s)
105
+ expect(json_response["attributes"]).to eq(attributes.map(&:to_s))
106
106
  required_attributes = json_response["required_attributes"]
107
- required_attributes.should include("name")
107
+ expect(required_attributes).to 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
- json_response.should have_attributes(attributes)
132
- response.status.should == 201
131
+ expect(json_response).to have_attributes(attributes)
132
+ expect(response.status).to eq(201)
133
133
 
134
- taxonomy.reload.root.children.count.should eq 2
134
+ expect(taxonomy.reload.root.children.count).to eq 2
135
135
  taxon = Spree::Taxon.where(:name => 'Colors').first
136
136
 
137
- taxon.parent_id.should eq taxonomy.root.id
138
- taxon.taxonomy_id.should eq taxonomy.id
137
+ expect(taxon.parent_id).to eq taxonomy.root.id
138
+ expect(taxon.taxonomy_id).to 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
- response.status.should == 200
145
- taxonomy.reload.root.children[0].should eql taxon2
146
- taxonomy.reload.root.children[1].should eql taxon
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
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
- response.status.should == 422
152
- json_response["error"].should == "Invalid resource. Please fix errors and try again."
151
+ expect(response.status).to eq(422)
152
+ expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
153
153
  errors = json_response["errors"]
154
154
 
155
- taxonomy.reload.root.children.count.should eq 1
155
+ expect(taxonomy.reload.root.children.count).to 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
- response.status.should == 422
161
- json_response["error"].should == "Invalid resource. Please fix errors and try again."
160
+ expect(response.status).to eq(422)
161
+ expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
162
162
 
163
163
  errors = json_response["errors"]
164
- errors["taxonomy_id"].should_not be_nil
165
- errors["taxonomy_id"].first.should eq "Invalid taxonomy id."
164
+ expect(errors["taxonomy_id"]).not_to be_nil
165
+ expect(errors["taxonomy_id"].first).to eq "Invalid taxonomy id."
166
166
 
167
- taxonomy.reload.root.children.count.should eq 1
167
+ expect(taxonomy.reload.root.children.count).to 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
- response.status.should == 204
172
+ expect(response.status).to eq(204)
173
173
  end
174
174
  end
175
175