solidus_api 2.2.2 → 2.3.0.beta1

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

Potentially problematic release.


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

Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/spree/api/images_controller.rb +2 -2
  3. data/app/controllers/spree/api/line_items_controller.rb +2 -10
  4. data/app/controllers/spree/api/orders_controller.rb +2 -12
  5. data/app/controllers/spree/api/payments_controller.rb +0 -1
  6. data/app/controllers/spree/api/promotions_controller.rb +1 -1
  7. data/app/controllers/spree/api/variants_controller.rb +2 -1
  8. data/app/views/spree/api/orders/show.v1.rabl +2 -1
  9. data/lib/spree/api/testing_support/setup.rb +1 -1
  10. data/spec/controllers/spree/api/base_controller_spec.rb +7 -7
  11. data/spec/controllers/spree/api/resource_controller_spec.rb +16 -16
  12. data/spec/requests/api/address_books_spec.rb +1 -1
  13. data/spec/{controllers → requests}/spree/api/addresses_controller_spec.rb +6 -9
  14. data/spec/{controllers → requests}/spree/api/checkouts_controller_spec.rb +38 -69
  15. data/spec/{controllers → requests}/spree/api/classifications_controller_spec.rb +4 -4
  16. data/spec/{controllers → requests}/spree/api/config_controller_spec.rb +3 -4
  17. data/spec/{controllers → requests}/spree/api/countries_controller_spec.rb +6 -7
  18. data/spec/{controllers → requests}/spree/api/credit_cards_controller_spec.rb +8 -9
  19. data/spec/{controllers → requests}/spree/api/images_controller_spec.rb +19 -16
  20. data/spec/{controllers → requests}/spree/api/inventory_units_controller_spec.rb +17 -14
  21. data/spec/{controllers → requests}/spree/api/line_items_controller_spec.rb +32 -32
  22. data/spec/{controllers → requests}/spree/api/option_types_controller_spec.rb +27 -27
  23. data/spec/{controllers → requests}/spree/api/option_values_controller_spec.rb +32 -29
  24. data/spec/{controllers → requests}/spree/api/orders_controller_spec.rb +103 -133
  25. data/spec/{controllers → requests}/spree/api/payments_controller_spec.rb +30 -44
  26. data/spec/{controllers → requests}/spree/api/product_properties_controller_spec.rb +15 -17
  27. data/spec/{controllers → requests}/spree/api/products_controller_spec.rb +44 -43
  28. data/spec/{controllers → requests}/spree/api/promotion_application_spec.rb +3 -4
  29. data/spec/{controllers → requests}/spree/api/promotions_controller_spec.rb +8 -6
  30. data/spec/{controllers → requests}/spree/api/properties_controller_spec.rb +15 -16
  31. data/spec/{controllers → requests}/spree/api/return_authorizations_controller_spec.rb +19 -21
  32. data/spec/requests/spree/api/shipments_controller_spec.rb +394 -88
  33. data/spec/{controllers → requests}/spree/api/states_controller_spec.rb +8 -9
  34. data/spec/{controllers → requests}/spree/api/stock_items_controller_spec.rb +21 -21
  35. data/spec/{controllers → requests}/spree/api/stock_locations_controller_spec.rb +18 -20
  36. data/spec/{controllers → requests}/spree/api/stock_movements_controller_spec.rb +9 -12
  37. data/spec/{controllers → requests}/spree/api/stock_transfers_controller_spec.rb +2 -3
  38. data/spec/requests/spree/api/store_credit_events_controller_spec.rb +57 -0
  39. data/spec/{controllers → requests}/spree/api/stores_controller_spec.rb +19 -20
  40. data/spec/{controllers → requests}/spree/api/taxonomies_controller_spec.rb +14 -15
  41. data/spec/{controllers → requests}/spree/api/taxons_controller_spec.rb +17 -18
  42. data/spec/{controllers → requests}/spree/api/transfer_items_controller_spec.rb +7 -9
  43. data/spec/{controllers → requests}/spree/api/unauthenticated_products_controller_spec.rb +2 -3
  44. data/spec/{controllers → requests}/spree/api/users_controller_spec.rb +18 -19
  45. data/spec/{controllers → requests}/spree/api/variants_controller_spec.rb +70 -37
  46. data/spec/{controllers → requests}/spree/api/zones_controller_spec.rb +13 -14
  47. data/spec/shared_examples/protect_product_actions.rb +3 -3
  48. data/spec/spec_helper.rb +4 -1
  49. metadata +70 -72
  50. data/spec/controllers/spree/api/shipments_controller_spec.rb +0 -301
  51. data/spec/controllers/spree/api/store_credit_events_controller_spec.rb +0 -66
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  module Spree
4
4
  describe Api::StockTransfersController do
5
- render_views
6
5
 
7
6
  let!(:stock_transfer) { create(:stock_transfer_with_items) }
8
7
  let(:transfer_item) { stock_transfer.transfer_items.first }
@@ -14,7 +13,7 @@ module Spree
14
13
  context "as a normal user" do
15
14
  describe "#receive" do
16
15
  it "cannot receive transfer items from a stock transfer" do
17
- api_post :receive, id: stock_transfer.to_param, variant_id: transfer_item.variant.to_param
16
+ post spree.receive_api_stock_transfer_path(stock_transfer), params: { variant_id: transfer_item.variant }
18
17
  expect(response.status).to eq 401
19
18
  end
20
19
  end
@@ -25,7 +24,7 @@ module Spree
25
24
 
26
25
  describe "#receive" do
27
26
  subject do
28
- api_post :receive, id: stock_transfer.to_param, variant_id: variant_id
27
+ post spree.receive_api_stock_transfer_path(stock_transfer), params: { variant_id: variant_id }
29
28
  end
30
29
 
31
30
  context "valid parameters" do
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe Spree::Api::StoreCreditEventsController, type: :request do
4
+ let(:api_user) { create(:user, :with_api_key) }
5
+
6
+ describe "GET mine" do
7
+ subject do
8
+ get spree.mine_api_store_credit_events_path(format: :json), headers: { 'X-Spree-Token' => api_key }
9
+ end
10
+
11
+ context "no current api user" do
12
+ let(:api_key) { nil }
13
+
14
+ before { subject }
15
+
16
+ it "returns a 401" do
17
+ expect(response.status).to eq 401
18
+ end
19
+ end
20
+
21
+ context "the current api user is authenticated" do
22
+ let(:current_api_user) { create(:user, :with_api_key) }
23
+ let(:api_key) { current_api_user.spree_api_key }
24
+
25
+ context "the user doesn't have store credit" do
26
+ before { subject }
27
+
28
+ it "should set the events variable to empty list" do
29
+ expect(json_response["store_credit_events"]).to eq []
30
+ end
31
+
32
+ it "returns a 200" do
33
+ expect(response.status).to eq 200
34
+ end
35
+ end
36
+
37
+ context "the user has store credit" do
38
+ let!(:store_credit) { create(:store_credit, user: current_api_user) }
39
+
40
+ before { subject }
41
+
42
+ it "should contain the store credit allocation event" do
43
+ expect(json_response["store_credit_events"].size).to eq 1
44
+ expect(json_response["store_credit_events"][0]).to include(
45
+ "display_amount" => "$150.00",
46
+ "display_user_total_amount" => "$150.00",
47
+ "display_action" => "Added"
48
+ )
49
+ end
50
+
51
+ it "returns a 200" do
52
+ expect(response.status).to eq 200
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,8 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  module Spree
4
- describe Api::StoresController, type: :controller do
5
- render_views
4
+ describe Api::StoresController, type: :request do
6
5
 
7
6
  let!(:store) do
8
7
  create(:store, name: "My Spree Store", url: "spreestore.example.com")
@@ -23,8 +22,8 @@ module Spree
23
22
  )
24
23
  end
25
24
 
26
- it "I can list the available stores" do
27
- api_get :index
25
+ it "can list the available stores" do
26
+ get spree.api_stores_path
28
27
  expect(json_response["stores"]).to match_array([
29
28
  {
30
29
  "id" => store.id,
@@ -53,8 +52,8 @@ module Spree
53
52
  ])
54
53
  end
55
54
 
56
- it "I can get the store details" do
57
- api_get :show, id: store.id
55
+ it "can get the store details" do
56
+ get spree.api_store_path(store)
58
57
  expect(json_response).to eq(
59
58
  "id" => store.id,
60
59
  "name" => "My Spree Store",
@@ -69,23 +68,23 @@ module Spree
69
68
  )
70
69
  end
71
70
 
72
- it "I can create a new store" do
71
+ it "can create a new store" do
73
72
  store_hash = {
74
73
  code: "spree123",
75
74
  name: "Hack0rz",
76
75
  url: "spree123.example.com",
77
76
  mail_from_address: "me@example.com"
78
77
  }
79
- api_post :create, store: store_hash
78
+ post spree.api_stores_path, params: { store: store_hash }
80
79
  expect(response.status).to eq(201)
81
80
  end
82
81
 
83
- it "I can update an existing store" do
82
+ it "can update an existing store" do
84
83
  store_hash = {
85
84
  url: "spree123.example.com",
86
85
  mail_from_address: "me@example.com"
87
86
  }
88
- api_put :update, id: store.id, store: store_hash
87
+ put spree.api_store_path(store), params: { store: store_hash }
89
88
  expect(response.status).to eq(200)
90
89
  expect(store.reload.url).to eql "spree123.example.com"
91
90
  expect(store.reload.mail_from_address).to eql "me@example.com"
@@ -93,7 +92,7 @@ module Spree
93
92
 
94
93
  context "deleting a store" do
95
94
  it "will fail if it's the default Store" do
96
- api_delete :destroy, id: store.id
95
+ delete spree.api_store_path(store)
97
96
  expect(response.status).to eq(422)
98
97
  expect(json_response["errors"]["base"]).to eql(
99
98
  ["Cannot destroy the default Store."]
@@ -101,30 +100,30 @@ module Spree
101
100
  end
102
101
 
103
102
  it "will destroy the store" do
104
- api_delete :destroy, id: non_default_store.id
103
+ delete spree.api_store_path(non_default_store)
105
104
  expect(response.status).to eq(204)
106
105
  end
107
106
  end
108
107
  end
109
108
 
110
109
  context "as an user" do
111
- it "I cannot list all the stores" do
112
- api_get :index
110
+ it "cannot list all the stores" do
111
+ get spree.api_stores_path
113
112
  expect(response.status).to eq(401)
114
113
  end
115
114
 
116
- it "I cannot get the store details" do
117
- api_get :show, id: store.id
115
+ it "cannot get the store details" do
116
+ get spree.api_store_path(store)
118
117
  expect(response.status).to eq(401)
119
118
  end
120
119
 
121
- it "I cannot create a new store" do
122
- api_post :create, store: {}
120
+ it "cannot create a new store" do
121
+ post spree.api_stores_path, params: { store: {} }
123
122
  expect(response.status).to eq(401)
124
123
  end
125
124
 
126
- it "I cannot update an existing store" do
127
- api_put :update, id: store.id, store: {}
125
+ it "cannot update an existing store" do
126
+ put spree.api_store_path(store), params: { store: {} }
128
127
  expect(response.status).to eq(401)
129
128
  end
130
129
  end
@@ -1,8 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::TaxonomiesController, type: :controller do
5
- render_views
4
+ describe Api::TaxonomiesController, type: :request do
6
5
 
7
6
  let(:taxonomy) { create(:taxonomy) }
8
7
  let(:taxon) { create(:taxon, name: "Ruby", taxonomy: taxonomy) }
@@ -18,7 +17,7 @@ module Spree
18
17
 
19
18
  context "as a normal user" do
20
19
  it "gets all taxonomies" do
21
- api_get :index
20
+ get spree.api_taxonomies_path
22
21
 
23
22
  expect(json_response["taxonomies"].first['name']).to eq taxonomy.name
24
23
  expect(json_response["taxonomies"].first['root']['taxons'].count).to eq 1
@@ -26,7 +25,7 @@ module Spree
26
25
 
27
26
  it 'can control the page size through a parameter' do
28
27
  create(:taxonomy)
29
- api_get :index, per_page: 1
28
+ get spree.api_taxonomies_path, params: { per_page: 1 }
30
29
  expect(json_response['count']).to eq(1)
31
30
  expect(json_response['current_page']).to eq(1)
32
31
  expect(json_response['pages']).to eq(2)
@@ -34,13 +33,13 @@ module Spree
34
33
 
35
34
  it 'can query the results through a paramter' do
36
35
  expected_result = create(:taxonomy, name: 'Style')
37
- api_get :index, q: { name_cont: 'style' }
36
+ get spree.api_taxonomies_path, params: { q: { name_cont: 'style' } }
38
37
  expect(json_response['count']).to eq(1)
39
38
  expect(json_response['taxonomies'].first['name']).to eq expected_result.name
40
39
  end
41
40
 
42
41
  it "gets a single taxonomy" do
43
- api_get :show, id: taxonomy.id
42
+ get spree.api_taxonomy_path(taxonomy.id)
44
43
 
45
44
  expect(json_response['name']).to eq taxonomy.name
46
45
 
@@ -51,7 +50,7 @@ module Spree
51
50
  end
52
51
 
53
52
  it "gets a single taxonomy with set=nested" do
54
- api_get :show, id: taxonomy.id, set: 'nested'
53
+ get spree.api_taxonomy_path(taxonomy.id), params: { set: 'nested' }
55
54
 
56
55
  expect(json_response['name']).to eq taxonomy.name
57
56
 
@@ -60,31 +59,31 @@ module Spree
60
59
  end
61
60
 
62
61
  it "gets the jstree-friendly version of a taxonomy" do
63
- api_get :jstree, id: taxonomy.id
62
+ get spree.jstree_api_taxonomy_path(taxonomy.id)
64
63
  expect(json_response["data"]).to eq(taxonomy.root.name)
65
64
  expect(json_response["attr"]).to eq({ "id" => taxonomy.root.id, "name" => taxonomy.root.name })
66
65
  expect(json_response["state"]).to eq("closed")
67
66
  end
68
67
 
69
68
  it "can learn how to create a new taxonomy" do
70
- api_get :new
69
+ get spree.new_api_taxonomy_path(taxonomy.id)
71
70
  expect(json_response["attributes"]).to eq(attributes.map(&:to_s))
72
71
  required_attributes = json_response["required_attributes"]
73
72
  expect(required_attributes).to include("name")
74
73
  end
75
74
 
76
75
  it "cannot create a new taxonomy if not an admin" do
77
- api_post :create, taxonomy: { name: "Location" }
76
+ post spree.api_taxonomies_path, params: { taxonomy: { name: "Location" } }
78
77
  assert_unauthorized!
79
78
  end
80
79
 
81
80
  it "cannot update a taxonomy" do
82
- api_put :update, id: taxonomy.id, taxonomy: { name: "I hacked your store!" }
81
+ put spree.api_taxonomy_path(taxonomy.id), params: { taxonomy: { name: "I hacked your store!" } }
83
82
  assert_unauthorized!
84
83
  end
85
84
 
86
85
  it "cannot delete a taxonomy" do
87
- api_delete :destroy, id: taxonomy.id
86
+ delete spree.api_taxonomy_path(taxonomy.id)
88
87
  assert_unauthorized!
89
88
  end
90
89
  end
@@ -93,19 +92,19 @@ module Spree
93
92
  sign_in_as_admin!
94
93
 
95
94
  it "can create" do
96
- api_post :create, taxonomy: { name: "Colors" }
95
+ post spree.api_taxonomies_path, params: { taxonomy: { name: "Colors" } }
97
96
  expect(json_response).to have_attributes(attributes)
98
97
  expect(response.status).to eq(201)
99
98
  end
100
99
 
101
100
  it "cannot create a new taxonomy with invalid attributes" do
102
- api_post :create, taxonomy: {}
101
+ post spree.api_taxonomies_path, params: { taxonomy: {} }
103
102
  expect(response.status).to eq(422)
104
103
  expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
105
104
  end
106
105
 
107
106
  it "can destroy" do
108
- api_delete :destroy, id: taxonomy.id
107
+ delete spree.api_taxonomy_path(taxonomy.id)
109
108
  expect(response.status).to eq(204)
110
109
  end
111
110
  end
@@ -1,8 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module Spree
4
- describe Api::TaxonsController, type: :controller do
5
- render_views
4
+ describe Api::TaxonsController, type: :request do
6
5
 
7
6
  let(:taxonomy) { create(:taxonomy) }
8
7
  let(:taxon) { create(:taxon, name: "Ruby", taxonomy: taxonomy) }
@@ -18,7 +17,7 @@ module Spree
18
17
 
19
18
  context "as a normal user" do
20
19
  it "gets all taxons for a taxonomy" do
21
- api_get :index, taxonomy_id: taxonomy.id
20
+ get spree.api_taxonomy_taxons_path(taxonomy)
22
21
 
23
22
  expect(json_response['taxons'].first['name']).to eq taxon.name
24
23
  children = json_response['taxons'].first['taxons']
@@ -29,7 +28,7 @@ module Spree
29
28
 
30
29
  # Regression test for https://github.com/spree/spree/issues/4112
31
30
  it "does not include children when asked not to" do
32
- api_get :index, taxonomy_id: taxonomy.id, without_children: 1
31
+ get spree.api_taxonomy_taxons_path(taxonomy), params: { without_children: 1 }
33
32
 
34
33
  expect(json_response['taxons'].first['name']).to eq(taxon.name)
35
34
  expect(json_response['taxons'].first['taxons']).to be_nil
@@ -39,7 +38,7 @@ module Spree
39
38
  new_taxon = create(:taxon, name: "Go", taxonomy: taxonomy)
40
39
  taxonomy.root.children << new_taxon
41
40
  expect(taxonomy.root.children.count).to eql(2)
42
- api_get :index, taxonomy_id: taxonomy.id, page: 1, per_page: 1
41
+ get spree.api_taxonomy_taxons_path(taxonomy), params: { page: 1, per_page: 1 }
43
42
  expect(json_response["count"]).to eql(1)
44
43
  expect(json_response["total_count"]).to eql(2)
45
44
  expect(json_response["current_page"]).to eql(1)
@@ -50,7 +49,7 @@ module Spree
50
49
  describe 'searching' do
51
50
  context 'with a name' do
52
51
  before do
53
- api_get :index, q: { name_cont: name }
52
+ get spree.api_taxons_path, params: { q: { name_cont: name } }
54
53
  end
55
54
 
56
55
  context 'with one result' do
@@ -74,7 +73,7 @@ module Spree
74
73
 
75
74
  context 'with no filters' do
76
75
  it "gets all taxons" do
77
- api_get :index
76
+ get spree.api_taxons_path
78
77
 
79
78
  expect(json_response['taxons'].first['name']).to eq taxonomy.root.name
80
79
  children = json_response['taxons'].first['taxons']
@@ -86,14 +85,14 @@ module Spree
86
85
  end
87
86
 
88
87
  it "gets a single taxon" do
89
- api_get :show, id: taxon.id, taxonomy_id: taxonomy.id
88
+ get spree.api_taxonomy_taxon_path(taxonomy, taxon.id)
90
89
 
91
90
  expect(json_response['name']).to eq taxon.name
92
91
  expect(json_response['taxons'].count).to eq 1
93
92
  end
94
93
 
95
94
  it "gets all taxons in JSTree form" do
96
- api_get :jstree, taxonomy_id: taxonomy.id, id: taxon.id
95
+ get spree.jstree_api_taxonomy_taxon_path(taxonomy, taxon.id)
97
96
  response = json_response.first
98
97
  expect(response["data"]).to eq(taxon2.name)
99
98
  expect(response["attr"]).to eq({ "name" => taxon2.name, "id" => taxon2.id })
@@ -101,24 +100,24 @@ module Spree
101
100
  end
102
101
 
103
102
  it "can learn how to create a new taxon" do
104
- api_get :new, taxonomy_id: taxonomy.id
103
+ get spree.new_api_taxonomy_taxon_path(taxonomy)
105
104
  expect(json_response["attributes"]).to eq(attributes.map(&:to_s))
106
105
  required_attributes = json_response["required_attributes"]
107
106
  expect(required_attributes).to include("name")
108
107
  end
109
108
 
110
109
  it "cannot create a new taxon if not an admin" do
111
- api_post :create, taxonomy_id: taxonomy.id, taxon: { name: "Location" }
110
+ post spree.api_taxonomy_taxons_path(taxonomy), params: { taxon: { name: "Location" } }
112
111
  assert_unauthorized!
113
112
  end
114
113
 
115
114
  it "cannot update a taxon" do
116
- api_put :update, taxonomy_id: taxonomy.id, id: taxon.id, taxon: { name: "I hacked your store!" }
115
+ put spree.api_taxonomy_taxon_path(taxonomy, taxon.id), params: { taxon: { name: "I hacked your store!" } }
117
116
  assert_unauthorized!
118
117
  end
119
118
 
120
119
  it "cannot delete a taxon" do
121
- api_delete :destroy, taxonomy_id: taxonomy.id, id: taxon.id
120
+ delete spree.api_taxonomy_taxon_path(taxonomy, taxon.id)
122
121
  assert_unauthorized!
123
122
  end
124
123
  end
@@ -127,7 +126,7 @@ module Spree
127
126
  sign_in_as_admin!
128
127
 
129
128
  it "can create" do
130
- api_post :create, taxonomy_id: taxonomy.id, taxon: { name: "Colors" }
129
+ post spree.api_taxonomy_taxons_path(taxonomy), params: { taxon: { name: "Colors" } }
131
130
  expect(json_response).to have_attributes(attributes)
132
131
  expect(response.status).to eq(201)
133
132
 
@@ -140,14 +139,14 @@ module Spree
140
139
 
141
140
  it "can update the position in the list" do
142
141
  taxonomy.root.children << taxon2
143
- api_put :update, taxonomy_id: taxonomy.id, id: taxon.id, taxon: { parent_id: taxon.parent_id, child_index: 2 }
142
+ put spree.api_taxonomy_taxon_path(taxonomy, taxon.id), params: { taxon: { parent_id: taxon.parent_id, child_index: 2 } }
144
143
  expect(response.status).to eq(200)
145
144
  expect(taxonomy.reload.root.children[0]).to eql taxon2
146
145
  expect(taxonomy.reload.root.children[1]).to eql taxon
147
146
  end
148
147
 
149
148
  it "cannot create a new taxon with invalid attributes" do
150
- api_post :create, taxonomy_id: taxonomy.id, taxon: { foo: :bar }
149
+ post spree.api_taxonomy_taxons_path(taxonomy), params: { taxon: { foo: :bar } }
151
150
  expect(response.status).to eq(422)
152
151
  expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
153
152
 
@@ -155,7 +154,7 @@ module Spree
155
154
  end
156
155
 
157
156
  it "cannot create a new taxon with invalid taxonomy_id" do
158
- api_post :create, taxonomy_id: 1000, taxon: { name: "Colors" }
157
+ post spree.api_taxonomy_taxons_path(1000), params: { taxon: { name: "Colors" } }
159
158
  expect(response.status).to eq(422)
160
159
  expect(json_response["error"]).to eq("Invalid resource. Please fix errors and try again.")
161
160
 
@@ -167,7 +166,7 @@ module Spree
167
166
  end
168
167
 
169
168
  it "can destroy" do
170
- api_delete :destroy, taxonomy_id: taxonomy.id, id: taxon.id
169
+ delete spree.api_taxonomy_taxon_path(taxonomy, taxon.id)
171
170
  expect(response.status).to eq(204)
172
171
  end
173
172
  end
@@ -2,7 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  module Spree
4
4
  describe Api::TransferItemsController do
5
- render_views
6
5
 
7
6
  let!(:stock_transfer) { create(:stock_transfer_with_items) }
8
7
  let(:transfer_item) { stock_transfer.transfer_items.first }
@@ -14,21 +13,21 @@ module Spree
14
13
  context "as a normal user" do
15
14
  describe "#create" do
16
15
  it "cannot create a transfer item" do
17
- api_post :create, stock_transfer_id: stock_transfer.to_param
16
+ post spree.api_stock_transfer_transfer_items_path(stock_transfer)
18
17
  expect(response.status).to eq 401
19
18
  end
20
19
  end
21
20
 
22
21
  describe "#update" do
23
22
  it "cannot update a transfer item" do
24
- api_put :update, stock_transfer_id: stock_transfer.to_param, id: transfer_item.to_param
23
+ put spree.api_stock_transfer_transfer_item_path(stock_transfer, transfer_item)
25
24
  expect(response.status).to eq 401
26
25
  end
27
26
  end
28
27
 
29
28
  describe "#destroy" do
30
29
  it "cannot delete a transfer item" do
31
- api_delete :destroy, stock_transfer_id: stock_transfer.to_param, id: transfer_item.to_param
30
+ delete spree.api_stock_transfer_transfer_item_path(stock_transfer, transfer_item)
32
31
  expect(response.status).to eq 401
33
32
  end
34
33
  end
@@ -40,13 +39,12 @@ module Spree
40
39
  describe "#create" do
41
40
  subject do
42
41
  create_params = {
43
- stock_transfer_id: stock_transfer.to_param,
44
42
  transfer_item: {
45
43
  variant_id: variant_id,
46
44
  expected_quantity: 1
47
45
  }
48
46
  }
49
- api_post :create, create_params
47
+ post spree.api_stock_transfer_transfer_items_path(stock_transfer), params: create_params
50
48
  end
51
49
 
52
50
  context "valid parameters" do
@@ -87,8 +85,8 @@ module Spree
87
85
 
88
86
  describe "#update" do
89
87
  subject do
90
- update_params = { id: transfer_item.to_param, stock_transfer_id: stock_transfer.to_param, transfer_item: { received_quantity: received_quantity } }
91
- api_put :update, update_params
88
+ update_params = { transfer_item: { received_quantity: received_quantity } }
89
+ put spree.api_stock_transfer_transfer_item_path(stock_transfer, transfer_item), params: update_params
92
90
  end
93
91
 
94
92
  context "valid parameters" do
@@ -119,7 +117,7 @@ module Spree
119
117
  end
120
118
 
121
119
  describe "#destroy" do
122
- subject { api_delete :destroy, id: transfer_item.to_param, stock_transfer_id: stock_transfer.to_param }
120
+ subject { delete spree.api_stock_transfer_transfer_item_path(stock_transfer, transfer_item) }
123
121
 
124
122
  context "hasn't been finalized" do
125
123
  it "can delete a transfer item" do