solidus_api 1.0.0.pre3 → 1.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of solidus_api might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/controllers/spree/api/checkouts_controller.rb +0 -5
- data/app/views/spree/api/orders/show.v1.rabl +2 -2
- data/spec/controllers/spree/api/base_controller_spec.rb +4 -4
- data/spec/controllers/spree/api/checkouts_controller_spec.rb +9 -9
- data/spec/controllers/spree/api/inventory_units_controller_spec.rb +1 -1
- data/spec/controllers/spree/api/orders_controller_spec.rb +8 -6
- data/spec/controllers/spree/api/payments_controller_spec.rb +8 -8
- data/spec/controllers/spree/api/return_authorizations_controller_spec.rb +4 -4
- data/spec/controllers/spree/api/shipments_controller_spec.rb +3 -3
- data/spec/controllers/spree/api/stock_items_controller_spec.rb +8 -8
- data/spec/controllers/spree/api/stock_locations_controller_spec.rb +17 -17
- data/spec/controllers/spree/api/stores_controller_spec.rb +1 -1
- data/spec/controllers/spree/api/variants_controller_spec.rb +24 -24
- data/spec/spec_helper.rb +2 -2
- metadata +4 -9
- data/app/views/spree/api/orders/address.v1.rabl +0 -0
- data/app/views/spree/api/orders/canceled.v1.rabl +0 -0
- data/app/views/spree/api/orders/cart.v1.rabl +0 -0
- data/app/views/spree/api/orders/complete.v1.rabl +0 -0
- data/app/views/spree/api/orders/payment.v1.rabl +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7c271766717aaef1ae950109c06fecb37cdec93
|
4
|
+
data.tar.gz: ce730cc176f7a37b64198be1964a56e6a04c78b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f236ad20fa754fb22a647fb63f61e61b71875f42677dfb4193ae288026e5582c4edf861171366750feae74b19d0d93c5b639beb51a4c16f8ecc7f081e092aada
|
7
|
+
data.tar.gz: 8f72358eb2effe84b6110cdd583fcb14779b14396948aed11af21a245d40030f678720f4632174a75a0d80640430815cef462c850225ceee6ed5d812773edca6
|
@@ -86,7 +86,6 @@ module Spree
|
|
86
86
|
|
87
87
|
def load_order
|
88
88
|
@order = Spree::Order.find_by!(number: params[:id])
|
89
|
-
raise_insufficient_quantity and return if @order.insufficient_stock_lines.present?
|
90
89
|
end
|
91
90
|
|
92
91
|
def update_order_state
|
@@ -94,10 +93,6 @@ module Spree
|
|
94
93
|
state_callback(:before)
|
95
94
|
end
|
96
95
|
|
97
|
-
def raise_insufficient_quantity
|
98
|
-
respond_with(@order, default_template: 'spree/api/orders/insufficient_quantity')
|
99
|
-
end
|
100
|
-
|
101
96
|
def state_callback(before_or_after = :before)
|
102
97
|
method_name = :"#{before_or_after}_#{@order.state}"
|
103
98
|
send(method_name) if respond_to?(method_name, true)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
object @order
|
2
2
|
extends "spree/api/orders/order"
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
child :available_payment_methods => :payment_methods do
|
5
|
+
attributes :id, :name, :environment, :method_type
|
6
6
|
end
|
7
7
|
|
8
8
|
child :billing_address => :bill_address do
|
@@ -135,8 +135,8 @@ describe Spree::Api::BaseController, :type => :controller do
|
|
135
135
|
|
136
136
|
context 'insufficient stock' do
|
137
137
|
before do
|
138
|
-
subject.
|
139
|
-
subject.
|
138
|
+
expect(subject).to receive(:authenticate_user).and_return(true)
|
139
|
+
expect(subject).to receive(:index).and_raise(Spree::Order::InsufficientStock)
|
140
140
|
get :index, :token => "fake_key"
|
141
141
|
end
|
142
142
|
|
@@ -165,7 +165,7 @@ describe Spree::Api::BaseController, :type => :controller do
|
|
165
165
|
context 'without an existing lock' do
|
166
166
|
it 'succeeds' do
|
167
167
|
api_get :index, order_token: order.guest_token, order_id: order.number
|
168
|
-
response.status.
|
168
|
+
expect(response.status).to eq(200)
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -176,7 +176,7 @@ describe Spree::Api::BaseController, :type => :controller do
|
|
176
176
|
|
177
177
|
it 'returns a 409 conflict' do
|
178
178
|
api_get :index, order_token: order.guest_token, order_id: order.number
|
179
|
-
response.status.
|
179
|
+
expect(response.status).to eq(409)
|
180
180
|
end
|
181
181
|
end
|
182
182
|
end
|
@@ -155,7 +155,7 @@ module Spree
|
|
155
155
|
|
156
156
|
it "can update payment method and transition from payment to confirm" do
|
157
157
|
order.update_column(:state, "payment")
|
158
|
-
Spree::Gateway::Bogus.
|
158
|
+
allow_any_instance_of(Spree::Gateway::Bogus).to receive(:source_required?).and_return(false)
|
159
159
|
api_put :update, id: order.to_param, order_token: order.guest_token,
|
160
160
|
order: { payments_attributes: [{ payment_method_id: @payment_method.id }] }
|
161
161
|
expect(json_response['state']).to eq('confirm')
|
@@ -168,9 +168,9 @@ module Spree
|
|
168
168
|
order.update_column(:state, "payment")
|
169
169
|
api_put :update, :id => order.to_param, :order_token => order.guest_token,
|
170
170
|
:order => { :payments_attributes => [{ :payment_method_id => @payment_method.id }] }
|
171
|
-
response.status.
|
171
|
+
expect(response.status).to eq(422)
|
172
172
|
source_errors = json_response['errors']['payments.source']
|
173
|
-
source_errors.
|
173
|
+
expect(source_errors).to include("can't be blank")
|
174
174
|
end
|
175
175
|
|
176
176
|
it "can update payment method with source and transition from payment to confirm" do
|
@@ -325,16 +325,16 @@ module Spree
|
|
325
325
|
end
|
326
326
|
|
327
327
|
it "can transition from confirm to complete" do
|
328
|
-
Spree::Order.
|
328
|
+
allow_any_instance_of(Spree::Order).to receive_messages(:payment_required? => false)
|
329
329
|
subject
|
330
|
-
json_response['state'].
|
331
|
-
response.status.
|
330
|
+
expect(json_response['state']).to eq('complete')
|
331
|
+
expect(response.status).to eq(200)
|
332
332
|
end
|
333
333
|
|
334
334
|
it "returns a sensible error when no payment method is specified" do
|
335
335
|
# api_put :complete, :id => order.to_param, :order_token => order.token, :order => {}
|
336
336
|
subject
|
337
|
-
json_response["errors"]["base"].
|
337
|
+
expect(json_response["errors"]["base"]).to include(Spree.t(:no_payment_found))
|
338
338
|
end
|
339
339
|
|
340
340
|
context "with mismatched expected_total" do
|
@@ -343,8 +343,8 @@ module Spree
|
|
343
343
|
it "returns an error if expected_total is present and does not match actual total" do
|
344
344
|
# api_put :complete, :id => order.to_param, :order_token => order.token, :expected_total => order.total + 1
|
345
345
|
subject
|
346
|
-
response.status.
|
347
|
-
json_response['errors']['expected_total'].
|
346
|
+
expect(response.status).to eq(400)
|
347
|
+
expect(json_response['errors']['expected_total']).to include(Spree.t(:expected_total_mismatch, :scope => 'api.order'))
|
348
348
|
end
|
349
349
|
end
|
350
350
|
end
|
@@ -21,7 +21,7 @@ module Spree
|
|
21
21
|
it "updates an inventory unit" do
|
22
22
|
api_put :update, :id => @inventory_unit.id,
|
23
23
|
:inventory_unit => { variant_id: variant.id }
|
24
|
-
json_response['variant_id'].
|
24
|
+
expect(json_response['variant_id']).to eq variant.id
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'fires state event' do
|
@@ -52,11 +52,12 @@ module Spree
|
|
52
52
|
it "does not include unpermitted params, or allow overriding the user", focus: true do
|
53
53
|
expect(Spree::Core::Importer::Order).to receive(:import).
|
54
54
|
once.
|
55
|
-
with(current_api_user, { "email" => target_user.email })
|
55
|
+
with(current_api_user, { "email" => target_user.email }).
|
56
|
+
and_call_original
|
56
57
|
subject
|
57
58
|
end
|
58
59
|
|
59
|
-
it {
|
60
|
+
it { is_expected.to be_success }
|
60
61
|
end
|
61
62
|
|
62
63
|
context "when the current user can administrate the order" do
|
@@ -65,11 +66,12 @@ module Spree
|
|
65
66
|
it "it permits all params and allows overriding the user" do
|
66
67
|
expect(Spree::Core::Importer::Order).to receive(:import).
|
67
68
|
once.
|
68
|
-
with(target_user, { "user_id" => target_user.id, "created_at" => date_override, "email" => target_user.email})
|
69
|
+
with(target_user, { "user_id" => target_user.id, "created_at" => date_override, "email" => target_user.email}).
|
70
|
+
and_call_original
|
69
71
|
subject
|
70
72
|
end
|
71
73
|
|
72
|
-
it {
|
74
|
+
it { is_expected.to be_success }
|
73
75
|
end
|
74
76
|
end
|
75
77
|
|
@@ -103,7 +105,7 @@ module Spree
|
|
103
105
|
subject
|
104
106
|
end
|
105
107
|
|
106
|
-
it {
|
108
|
+
it { is_expected.to be_success }
|
107
109
|
|
108
110
|
context "when the user can administer the order" do
|
109
111
|
let(:can_admin) { true }
|
@@ -790,7 +792,7 @@ module Spree
|
|
790
792
|
let(:promo_code) { promo.codes.first }
|
791
793
|
|
792
794
|
before do
|
793
|
-
Order.
|
795
|
+
allow_any_instance_of(Order).to receive_messages :user => current_api_user
|
794
796
|
end
|
795
797
|
|
796
798
|
context 'when successful' do
|
@@ -35,13 +35,13 @@ module Spree
|
|
35
35
|
|
36
36
|
context "payment source is not required" do
|
37
37
|
before do
|
38
|
-
Spree::Gateway::Bogus.
|
38
|
+
allow_any_instance_of(Spree::Gateway::Bogus).to receive(:source_required?).and_return(false)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "can create a new payment" do
|
42
42
|
api_post :create, :payment => { :payment_method_id => PaymentMethod.first.id, :amount => 50 }
|
43
|
-
response.status.
|
44
|
-
json_response.
|
43
|
+
expect(response.status).to eq(201)
|
44
|
+
expect(json_response).to have_attributes(attributes)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -49,17 +49,17 @@ module Spree
|
|
49
49
|
context "no source is provided" do
|
50
50
|
it "returns errors" do
|
51
51
|
api_post :create, :payment => { :payment_method_id => PaymentMethod.first.id, :amount => 50 }
|
52
|
-
response.status.
|
53
|
-
json_response['error'].
|
54
|
-
json_response['errors']['source'].
|
52
|
+
expect(response.status).to eq(422)
|
53
|
+
expect(json_response['error']).to eq("Invalid resource. Please fix errors and try again.")
|
54
|
+
expect(json_response['errors']['source']).to eq(["can't be blank"])
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
context "source is provided" do
|
59
59
|
it "can create a new payment" do
|
60
60
|
api_post :create, :payment => { :payment_method_id => PaymentMethod.first.id, :amount => 50, source_attributes: {gateway_payment_profile_id: 1} }
|
61
|
-
response.status.
|
62
|
-
json_response.
|
61
|
+
expect(response.status).to eq(201)
|
62
|
+
expect(json_response).to have_attributes(attributes)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -22,9 +22,9 @@ module Spree
|
|
22
22
|
:return_reason_id => reason.id,
|
23
23
|
:memo => "Defective" }
|
24
24
|
api_post :create, :order_id => order.number, :return_authorization => rma_params
|
25
|
-
response.status.
|
26
|
-
json_response.
|
27
|
-
json_response["state"].
|
25
|
+
expect(response.status).to eq(201)
|
26
|
+
expect(json_response).to have_attributes(attributes)
|
27
|
+
expect(json_response["state"]).not_to be_blank
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -63,7 +63,7 @@ module Spree
|
|
63
63
|
|
64
64
|
context "as another non-admin user that's not the order's owner" do
|
65
65
|
before do
|
66
|
-
Order.
|
66
|
+
allow_any_instance_of(Order).to receive_messages :user => create(:user)
|
67
67
|
end
|
68
68
|
|
69
69
|
it "cannot create a new return authorization" do
|
@@ -125,13 +125,13 @@ describe Spree::Api::ShipmentsController, :type => :controller do
|
|
125
125
|
|
126
126
|
it 'adds a variant to a shipment' do
|
127
127
|
api_put :add, { variant_id: variant.to_param, quantity: 2 }
|
128
|
-
response.status.
|
129
|
-
json_response['manifest'].detect { |h| h['variant']['id'] == variant.id }["quantity"].
|
128
|
+
expect(response.status).to eq(200)
|
129
|
+
expect(json_response['manifest'].detect { |h| h['variant']['id'] == variant.id }["quantity"]).to eq(2)
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'cannot remove a variant from a shipment' do
|
133
133
|
api_put :remove, { variant_id: variant.to_param, quantity: 1 }
|
134
|
-
response.status.
|
134
|
+
expect(response.status).to eq(422)
|
135
135
|
expect(json_response['errors']['base'].join).to match /Cannot remove items/
|
136
136
|
end
|
137
137
|
|
@@ -18,8 +18,8 @@ module Spree
|
|
18
18
|
it "can list stock items for an active stock location" do
|
19
19
|
api_get :index, stock_location_id: stock_location.to_param
|
20
20
|
expect(response).to be_success
|
21
|
-
json_response['stock_items'].first.
|
22
|
-
json_response['stock_items'].first['variant']['sku'].
|
21
|
+
expect(json_response['stock_items'].first).to have_attributes(attributes)
|
22
|
+
expect(json_response['stock_items'].first['variant']['sku']).to match /\ASKU-\d+\z/
|
23
23
|
end
|
24
24
|
|
25
25
|
it "cannot list stock items for an inactive stock location" do
|
@@ -32,14 +32,14 @@ module Spree
|
|
32
32
|
describe "#show" do
|
33
33
|
it "can see a stock item for an active stock location" do
|
34
34
|
api_get :show, stock_location_id: stock_location.to_param, id: stock_item.to_param
|
35
|
-
json_response.
|
36
|
-
json_response['count_on_hand'].
|
35
|
+
expect(json_response).to have_attributes(attributes)
|
36
|
+
expect(json_response['count_on_hand']).to eq stock_item.count_on_hand
|
37
37
|
end
|
38
38
|
|
39
39
|
it "cannot see a stock item for an inactive stock location" do
|
40
40
|
stock_location.update_attributes!(active: false)
|
41
41
|
api_get :show, stock_location_id: stock_location.to_param, id: stock_item.to_param
|
42
|
-
response.status.
|
42
|
+
expect(response.status).to eq(404)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -55,21 +55,21 @@ module Spree
|
|
55
55
|
}
|
56
56
|
|
57
57
|
api_post :create, params
|
58
|
-
response.status.
|
58
|
+
expect(response.status).to eq(404)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
describe "#update" do
|
63
63
|
it "cannot update a stock item" do
|
64
64
|
api_put :update, stock_location_id: stock_location.to_param, id: stock_item.to_param
|
65
|
-
response.status.
|
65
|
+
expect(response.status).to eq(404)
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
69
|
describe "#destroy" do
|
70
70
|
it "cannot destroy a stock item" do
|
71
71
|
api_delete :destroy, stock_location_id: stock_location.to_param, id: stock_item.to_param
|
72
|
-
response.status.
|
72
|
+
expect(response.status).to eq(404)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -53,21 +53,21 @@ module Spree
|
|
53
53
|
}
|
54
54
|
|
55
55
|
api_post :create, params
|
56
|
-
response.status.
|
56
|
+
expect(response.status).to eq(401)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe "#update" do
|
61
61
|
it "cannot update a stock location" do
|
62
62
|
api_put :update, :stock_location => { :name => "South Pole" }, :id => stock_location.to_param
|
63
|
-
response.status.
|
63
|
+
expect(response.status).to eq(401)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe "#destroy" do
|
68
68
|
it "cannot delete a stock location" do
|
69
69
|
api_put :destroy, :id => stock_location.to_param
|
70
|
-
response.status.
|
70
|
+
expect(response.status).to eq(401)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -93,24 +93,24 @@ module Spree
|
|
93
93
|
|
94
94
|
it "gets stock location information" do
|
95
95
|
api_get :index
|
96
|
-
json_response['stock_locations'].first.
|
97
|
-
json_response['stock_locations'].first['country'].
|
98
|
-
json_response['stock_locations'].first['state'].
|
96
|
+
expect(json_response['stock_locations'].first).to have_attributes(attributes)
|
97
|
+
expect(json_response['stock_locations'].first['country']).not_to be_nil
|
98
|
+
expect(json_response['stock_locations'].first['state']).not_to be_nil
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'can control the page size through a parameter' do
|
102
102
|
create(:stock_location)
|
103
103
|
api_get :index, per_page: 1
|
104
|
-
json_response['count'].
|
105
|
-
json_response['current_page'].
|
106
|
-
json_response['pages'].
|
104
|
+
expect(json_response['count']).to eq(1)
|
105
|
+
expect(json_response['current_page']).to eq(1)
|
106
|
+
expect(json_response['pages']).to eq(2)
|
107
107
|
end
|
108
108
|
|
109
109
|
it 'can query the results through a paramter' do
|
110
110
|
expected_result = create(:stock_location, name: 'South America')
|
111
111
|
api_get :index, q: { name_cont: 'south' }
|
112
|
-
json_response['count'].
|
113
|
-
json_response['stock_locations'].first['name'].
|
112
|
+
expect(json_response['count']).to eq(1)
|
113
|
+
expect(json_response['stock_locations'].first['name']).to eq expected_result.name
|
114
114
|
end
|
115
115
|
|
116
116
|
end
|
@@ -140,8 +140,8 @@ module Spree
|
|
140
140
|
}
|
141
141
|
|
142
142
|
api_post :create, params
|
143
|
-
response.status.
|
144
|
-
json_response.
|
143
|
+
expect(response.status).to eq(201)
|
144
|
+
expect(json_response).to have_attributes(attributes)
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -155,16 +155,16 @@ module Spree
|
|
155
155
|
}
|
156
156
|
|
157
157
|
api_put :update, params
|
158
|
-
response.status.
|
159
|
-
json_response['name'].
|
158
|
+
expect(response.status).to eq(200)
|
159
|
+
expect(json_response['name']).to eq 'South Pole'
|
160
160
|
end
|
161
161
|
end
|
162
162
|
|
163
163
|
describe "#destroy" do
|
164
164
|
it "can delete a stock location" do
|
165
165
|
api_delete :destroy, id: stock_location.to_param
|
166
|
-
response.status.
|
167
|
-
|
166
|
+
expect(response.status).to eq(204)
|
167
|
+
expect { stock_location.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
168
168
|
end
|
169
169
|
end
|
170
170
|
end
|
@@ -24,32 +24,32 @@ module Spree
|
|
24
24
|
it "can see a paginated list of variants" do
|
25
25
|
api_get :index
|
26
26
|
first_variant = json_response["variants"].first
|
27
|
-
first_variant.
|
28
|
-
first_variant["stock_items"].
|
29
|
-
json_response["count"].
|
30
|
-
json_response["current_page"].
|
31
|
-
json_response["pages"].
|
27
|
+
expect(first_variant).to have_attributes(show_attributes)
|
28
|
+
expect(first_variant["stock_items"]).to be_present
|
29
|
+
expect(json_response["count"]).to eq(1)
|
30
|
+
expect(json_response["current_page"]).to eq(1)
|
31
|
+
expect(json_response["pages"]).to eq(1)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'can control the page size through a parameter' do
|
35
35
|
create(:variant)
|
36
36
|
api_get :index, :per_page => 1
|
37
|
-
json_response['count'].
|
38
|
-
json_response['current_page'].
|
39
|
-
json_response['pages'].
|
37
|
+
expect(json_response['count']).to eq(1)
|
38
|
+
expect(json_response['current_page']).to eq(1)
|
39
|
+
expect(json_response['pages']).to eq(3)
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'can query the results through a paramter' do
|
43
43
|
expected_result = create(:variant, :sku => 'FOOBAR')
|
44
44
|
api_get :index, :q => { :sku_cont => 'FOO' }
|
45
|
-
json_response['count'].
|
46
|
-
json_response['variants'].first['sku'].
|
45
|
+
expect(json_response['count']).to eq(1)
|
46
|
+
expect(json_response['variants'].first['sku']).to eq expected_result.sku
|
47
47
|
end
|
48
48
|
|
49
49
|
it "variants returned contain option values data" do
|
50
50
|
api_get :index
|
51
51
|
option_values = json_response["variants"].last["option_values"]
|
52
|
-
option_values.first.
|
52
|
+
expect(option_values.first).to have_attributes([:name,
|
53
53
|
:presentation,
|
54
54
|
:option_type_name,
|
55
55
|
:option_type_id])
|
@@ -60,8 +60,8 @@ module Spree
|
|
60
60
|
|
61
61
|
api_get :index
|
62
62
|
|
63
|
-
json_response["variants"].last.
|
64
|
-
json_response['variants'].first['images'].first.
|
63
|
+
expect(json_response["variants"].last).to have_attributes([:images])
|
64
|
+
expect(json_response['variants'].first['images'].first).to have_attributes([:attachment_file_name,
|
65
65
|
:attachment_width,
|
66
66
|
:attachment_height,
|
67
67
|
:attachment_content_type,
|
@@ -80,12 +80,12 @@ module Spree
|
|
80
80
|
|
81
81
|
it "is not returned in the results" do
|
82
82
|
api_get :index
|
83
|
-
json_response["variants"].count.
|
83
|
+
expect(json_response["variants"].count).to eq(0)
|
84
84
|
end
|
85
85
|
|
86
86
|
it "is not returned even when show_deleted is passed" do
|
87
87
|
api_get :index, :show_deleted => true
|
88
|
-
json_response["variants"].count.
|
88
|
+
expect(json_response["variants"].count).to eq(0)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -119,10 +119,10 @@ module Spree
|
|
119
119
|
it "can select the next page of variants" do
|
120
120
|
second_variant = create(:variant)
|
121
121
|
api_get :index, :page => 2, :per_page => 1
|
122
|
-
json_response["variants"].first.
|
123
|
-
json_response["total_count"].
|
124
|
-
json_response["current_page"].
|
125
|
-
json_response["pages"].
|
122
|
+
expect(json_response["variants"].first).to have_attributes(show_attributes)
|
123
|
+
expect(json_response["total_count"]).to eq(3)
|
124
|
+
expect(json_response["current_page"]).to eq(2)
|
125
|
+
expect(json_response["pages"]).to eq(3)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -145,10 +145,10 @@ module Spree
|
|
145
145
|
|
146
146
|
it "can see a single variant" do
|
147
147
|
api_get :show, :id => variant.to_param
|
148
|
-
json_response.
|
149
|
-
json_response["stock_items"].
|
148
|
+
expect(json_response).to have_attributes(show_attributes)
|
149
|
+
expect(json_response["stock_items"]).to be_present
|
150
150
|
option_values = json_response["option_values"]
|
151
|
-
option_values.first.
|
151
|
+
expect(option_values.first).to have_attributes([:name,
|
152
152
|
:presentation,
|
153
153
|
:option_type_name,
|
154
154
|
:option_type_id])
|
@@ -159,9 +159,9 @@ module Spree
|
|
159
159
|
|
160
160
|
api_get :show, :id => variant.to_param
|
161
161
|
|
162
|
-
json_response.
|
162
|
+
expect(json_response).to have_attributes(show_attributes + [:images])
|
163
163
|
option_values = json_response["option_values"]
|
164
|
-
option_values.first.
|
164
|
+
expect(option_values.first).to have_attributes([:name,
|
165
165
|
:presentation,
|
166
166
|
:option_type_name,
|
167
167
|
:option_type_id])
|
data/spec/spec_helper.rb
CHANGED
@@ -17,8 +17,8 @@ ENV["RAILS_ENV"] ||= 'test'
|
|
17
17
|
begin
|
18
18
|
require File.expand_path("../dummy/config/environment", __FILE__)
|
19
19
|
rescue LoadError
|
20
|
-
puts "Could not load dummy application. Please ensure you have run `bundle exec rake test_app`"
|
21
|
-
exit
|
20
|
+
$stderr.puts "Could not load dummy application. Please ensure you have run `bundle exec rake test_app`"
|
21
|
+
exit 1
|
22
22
|
end
|
23
23
|
|
24
24
|
require 'rspec/rails'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.0.
|
19
|
+
version: 1.0.0.rc1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0.0.
|
26
|
+
version: 1.0.0.rc1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rabl
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,10 +129,6 @@ files:
|
|
129
129
|
- app/views/spree/api/option_types/show.v1.rabl
|
130
130
|
- app/views/spree/api/option_values/index.v1.rabl
|
131
131
|
- app/views/spree/api/option_values/show.v1.rabl
|
132
|
-
- app/views/spree/api/orders/address.v1.rabl
|
133
|
-
- app/views/spree/api/orders/canceled.v1.rabl
|
134
|
-
- app/views/spree/api/orders/cart.v1.rabl
|
135
|
-
- app/views/spree/api/orders/complete.v1.rabl
|
136
132
|
- app/views/spree/api/orders/could_not_apply_coupon.v1.rabl
|
137
133
|
- app/views/spree/api/orders/could_not_transition.v1.rabl
|
138
134
|
- app/views/spree/api/orders/expected_total_mismatch.v1.rabl
|
@@ -140,7 +136,6 @@ files:
|
|
140
136
|
- app/views/spree/api/orders/invalid_shipping_method.v1.rabl
|
141
137
|
- app/views/spree/api/orders/mine.v1.rabl
|
142
138
|
- app/views/spree/api/orders/order.v1.rabl
|
143
|
-
- app/views/spree/api/orders/payment.v1.rabl
|
144
139
|
- app/views/spree/api/orders/show.v1.rabl
|
145
140
|
- app/views/spree/api/payments/credit_over_limit.v1.rabl
|
146
141
|
- app/views/spree/api/payments/index.v1.rabl
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|