solidus_api 2.3.1 → 2.4.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.
- checksums.yaml +4 -4
- data/app/controllers/spree/api/base_controller.rb +9 -12
- data/app/controllers/spree/api/checkouts_controller.rb +3 -5
- data/app/controllers/spree/api/orders_controller.rb +2 -12
- data/app/controllers/spree/api/payments_controller.rb +0 -1
- data/app/controllers/spree/api/resource_controller.rb +2 -0
- data/app/controllers/spree/api/shipments_controller.rb +17 -6
- data/app/controllers/spree/api/stock_items_controller.rb +6 -0
- data/app/helpers/spree/api/api_helpers.rb +3 -4
- data/app/views/.rubocop.yml +4 -0
- data/app/views/spree/api/address_books/show.json.jbuilder +11 -0
- data/app/views/spree/api/addresses/_address.json.jbuilder +17 -0
- data/app/views/spree/api/addresses/show.json.jbuilder +1 -0
- data/app/views/spree/api/adjustments/_adjustment.json.jbuilder +4 -0
- data/app/views/spree/api/config/money.json.jbuilder +1 -0
- data/app/views/spree/api/config/show.json.jbuilder +2 -0
- data/app/views/spree/api/countries/index.json.jbuilder +2 -0
- data/app/views/spree/api/countries/show.json.jbuilder +4 -0
- data/app/views/spree/api/credit_cards/_credit_card.json.jbuilder +10 -0
- data/app/views/spree/api/credit_cards/index.json.jbuilder +4 -0
- data/app/views/spree/api/credit_cards/show.json.jbuilder +1 -0
- data/app/views/spree/api/errors/delete_restriction.json.jbuilder +1 -0
- data/app/views/spree/api/errors/gateway_error.json.jbuilder +1 -0
- data/app/views/spree/api/errors/invalid_api_key.json.jbuilder +1 -0
- data/app/views/spree/api/errors/invalid_resource.json.jbuilder +2 -0
- data/app/views/spree/api/errors/must_specify_api_key.json.jbuilder +1 -0
- data/app/views/spree/api/errors/not_found.json.jbuilder +1 -0
- data/app/views/spree/api/errors/unauthorized.json.jbuilder +1 -0
- data/app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder +1 -0
- data/app/views/spree/api/images/_image.json.jbuilder +5 -0
- data/app/views/spree/api/images/index.json.jbuilder +3 -0
- data/app/views/spree/api/images/show.json.jbuilder +1 -0
- data/app/views/spree/api/inventory_units/show.json.jbuilder +1 -0
- data/app/views/spree/api/line_items/_line_item.json.jbuilder +16 -0
- data/app/views/spree/api/line_items/new.json.jbuilder +2 -0
- data/app/views/spree/api/line_items/show.json.jbuilder +1 -0
- data/app/views/spree/api/option_types/_option_type.json.jbuilder +4 -0
- data/app/views/spree/api/option_types/index.json.jbuilder +3 -0
- data/app/views/spree/api/option_types/show.json.jbuilder +1 -0
- data/app/views/spree/api/option_values/_option_value.json.jbuilder +1 -0
- data/app/views/spree/api/option_values/index.json.jbuilder +3 -0
- data/app/views/spree/api/option_values/show.json.jbuilder +1 -0
- data/app/views/spree/api/orders/_big.json.jbuilder +49 -0
- data/app/views/spree/api/orders/_order.json.jbuilder +10 -0
- data/app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder +1 -0
- data/app/views/spree/api/orders/could_not_transition.json.jbuilder +2 -0
- data/app/views/spree/api/orders/expected_total_mismatch.json.jbuilder +1 -0
- data/app/views/spree/api/orders/index.json.jbuilder +4 -0
- data/app/views/spree/api/orders/invalid_shipping_method.json.jbuilder +1 -0
- data/app/views/spree/api/orders/mine.json.jbuilder +4 -0
- data/app/views/spree/api/orders/show.json.jbuilder +1 -0
- data/app/views/spree/api/payments/credit_over_limit.json.jbuilder +1 -0
- data/app/views/spree/api/payments/index.json.jbuilder +2 -0
- data/app/views/spree/api/payments/new.json.jbuilder +4 -0
- data/app/views/spree/api/payments/show.json.jbuilder +1 -0
- data/app/views/spree/api/payments/update_forbidden.json.jbuilder +1 -0
- data/app/views/spree/api/product_properties/index.json.jbuilder +4 -0
- data/app/views/spree/api/product_properties/new.json.jbuilder +2 -0
- data/app/views/spree/api/product_properties/show.json.jbuilder +1 -0
- data/app/views/spree/api/products/_product.json.jbuilder +34 -0
- data/app/views/spree/api/products/index.json.jbuilder +4 -0
- data/app/views/spree/api/products/new.json.jbuilder +2 -0
- data/app/views/spree/api/products/show.json.jbuilder +1 -0
- data/app/views/spree/api/promotions/handler.json.jbuilder +4 -0
- data/app/views/spree/api/promotions/show.json.jbuilder +1 -0
- data/app/views/spree/api/properties/index.json.jbuilder +4 -0
- data/app/views/spree/api/properties/new.json.jbuilder +2 -0
- data/app/views/spree/api/properties/show.json.jbuilder +1 -0
- data/app/views/spree/api/return_authorizations/index.json.jbuilder +4 -0
- data/app/views/spree/api/return_authorizations/new.json.jbuilder +2 -0
- data/app/views/spree/api/return_authorizations/show.json.jbuilder +1 -0
- data/app/views/spree/api/shared/_pagination.json.jbuilder +5 -0
- data/app/views/spree/api/shipments/_big.json.jbuilder +51 -0
- data/app/views/spree/api/shipments/_small.json.jbuilder +32 -0
- data/app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder +1 -0
- data/app/views/spree/api/shipments/mine.json.jbuilder +4 -0
- data/app/views/spree/api/shipments/show.json.jbuilder +31 -0
- data/app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder +2 -0
- data/app/views/spree/api/states/index.json.jbuilder +5 -0
- data/app/views/spree/api/states/show.json.jbuilder +1 -0
- data/app/views/spree/api/stock_items/_stock_item.json.jbuilder +4 -0
- data/app/views/spree/api/stock_items/index.json.jbuilder +4 -0
- data/app/views/spree/api/stock_items/show.json.jbuilder +1 -0
- data/app/views/spree/api/stock_locations/_stock_location.json.jbuilder +15 -0
- data/app/views/spree/api/stock_locations/index.json.jbuilder +4 -0
- data/app/views/spree/api/stock_locations/show.json.jbuilder +1 -0
- data/app/views/spree/api/stock_movements/_stock_movement.json.jbuilder +4 -0
- data/app/views/spree/api/stock_movements/index.json.jbuilder +4 -0
- data/app/views/spree/api/stock_movements/show.json.jbuilder +1 -0
- data/app/views/spree/api/stock_transfers/receive.json.jbuilder +4 -0
- data/app/views/spree/api/store_credit_events/mine.json.jbuilder +5 -0
- data/app/views/spree/api/stores/index.json.jbuilder +1 -0
- data/app/views/spree/api/stores/show.json.jbuilder +1 -0
- data/app/views/spree/api/taxonomies/_nested.json.jbuilder +8 -0
- data/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder +11 -0
- data/app/views/spree/api/taxonomies/index.json.jbuilder +4 -0
- data/app/views/spree/api/taxonomies/jstree.json.jbuilder +6 -0
- data/app/views/spree/api/taxonomies/new.json.jbuilder +2 -0
- data/app/views/spree/api/taxonomies/show.json.jbuilder +1 -0
- data/app/views/spree/api/taxons/_taxon.json.jbuilder +2 -0
- data/app/views/spree/api/taxons/_taxons.json.jbuilder +4 -0
- data/app/views/spree/api/taxons/index.json.jbuilder +7 -0
- data/app/views/spree/api/taxons/jstree.json.jbuilder +8 -0
- data/app/views/spree/api/taxons/new.json.jbuilder +2 -0
- data/app/views/spree/api/taxons/show.json.jbuilder +1 -0
- data/app/views/spree/api/transfer_items/_transfer_item.json.jbuilder +5 -0
- data/app/views/spree/api/transfer_items/show.json.jbuilder +1 -0
- data/app/views/spree/api/users/_user.json.jbuilder +15 -0
- data/app/views/spree/api/users/index.json.jbuilder +4 -0
- data/app/views/spree/api/users/new.json.jbuilder +2 -0
- data/app/views/spree/api/users/show.json.jbuilder +1 -0
- data/app/views/spree/api/variants/_big.json.jbuilder +13 -0
- data/app/views/spree/api/variants/_small.json.jbuilder +16 -0
- data/app/views/spree/api/variants/index.json.jbuilder +4 -0
- data/app/views/spree/api/variants/new.json.jbuilder +2 -0
- data/app/views/spree/api/variants/show.json.jbuilder +1 -0
- data/app/views/spree/api/zones/_zone.json.jbuilder +4 -0
- data/app/views/spree/api/zones/index.json.jbuilder +4 -0
- data/app/views/spree/api/zones/show.json.jbuilder +1 -0
- data/config/locales/en.yml +1 -0
- data/lib/spree/api/engine.rb +0 -14
- data/lib/spree/api.rb +1 -1
- data/lib/spree_api.rb +1 -0
- data/solidus_api.gemspec +3 -1
- data/spec/controllers/spree/api/base_controller_spec.rb +0 -56
- data/spec/requests/spree/api/checkouts_controller_spec.rb +8 -13
- data/spec/requests/spree/api/orders_controller_spec.rb +7 -60
- data/spec/requests/spree/api/payments_controller_spec.rb +0 -11
- data/spec/requests/spree/api/shipments_controller_spec.rb +16 -1
- data/spec/requests/spree/api/states_controller_spec.rb +1 -0
- data/spec/requests/spree/api/taxons_controller_spec.rb +25 -0
- data/spec/requests/spree/api/users_controller_spec.rb +1 -1
- data/spec/support/be_paginated_matcher.rb +7 -0
- data/spec/test_views/spree/api/widgets/_widget.json.jbuilder +1 -0
- data/spec/test_views/spree/api/widgets/index.json.jbuilder +7 -0
- data/spec/test_views/spree/api/widgets/new.json.jbuilder +1 -0
- data/spec/test_views/spree/api/widgets/show.json.jbuilder +1 -0
- metadata +166 -111
- data/app/views/spree/api/address_books/show.v1.rabl +0 -7
- data/app/views/spree/api/addresses/show.v1.rabl +0 -10
- data/app/views/spree/api/adjustments/show.v1.rabl +0 -4
- data/app/views/spree/api/config/money.v1.rabl +0 -2
- data/app/views/spree/api/config/show.v1.rabl +0 -3
- data/app/views/spree/api/countries/index.v1.rabl +0 -7
- data/app/views/spree/api/countries/show.v1.rabl +0 -5
- data/app/views/spree/api/credit_cards/index.v1.rabl +0 -7
- data/app/views/spree/api/credit_cards/show.v1.rabl +0 -7
- data/app/views/spree/api/errors/gateway_error.v1.rabl +0 -2
- data/app/views/spree/api/errors/invalid_api_key.v1.rabl +0 -2
- data/app/views/spree/api/errors/invalid_resource.v1.rabl +0 -3
- data/app/views/spree/api/errors/must_specify_api_key.v1.rabl +0 -2
- data/app/views/spree/api/errors/not_found.v1.rabl +0 -2
- data/app/views/spree/api/errors/unauthorized.v1.rabl +0 -2
- data/app/views/spree/api/errors/variant_not_in_stock_transfer.v1.rabl +0 -2
- data/app/views/spree/api/images/index.v1.rabl +0 -4
- data/app/views/spree/api/images/show.v1.rabl +0 -6
- data/app/views/spree/api/inventory_units/show.rabl +0 -2
- data/app/views/spree/api/line_items/new.v1.rabl +0 -3
- data/app/views/spree/api/line_items/show.v1.rabl +0 -15
- data/app/views/spree/api/option_types/index.v1.rabl +0 -3
- data/app/views/spree/api/option_types/show.v1.rabl +0 -5
- data/app/views/spree/api/option_values/index.v1.rabl +0 -3
- data/app/views/spree/api/option_values/show.v1.rabl +0 -2
- data/app/views/spree/api/orders/could_not_apply_coupon.v1.rabl +0 -2
- data/app/views/spree/api/orders/could_not_transition.v1.rabl +0 -3
- data/app/views/spree/api/orders/expected_total_mismatch.v1.rabl +0 -2
- data/app/views/spree/api/orders/index.v1.rabl +0 -7
- data/app/views/spree/api/orders/invalid_shipping_method.v1.rabl +0 -2
- data/app/views/spree/api/orders/mine.v1.rabl +0 -9
- data/app/views/spree/api/orders/order.v1.rabl +0 -9
- data/app/views/spree/api/orders/show.v1.rabl +0 -53
- data/app/views/spree/api/payments/credit_over_limit.v1.rabl +0 -2
- data/app/views/spree/api/payments/index.v1.rabl +0 -7
- data/app/views/spree/api/payments/new.v1.rabl +0 -5
- data/app/views/spree/api/payments/show.v1.rabl +0 -2
- data/app/views/spree/api/payments/update_forbidden.v1.rabl +0 -2
- data/app/views/spree/api/product_properties/index.v1.rabl +0 -7
- data/app/views/spree/api/product_properties/new.v1.rabl +0 -2
- data/app/views/spree/api/product_properties/show.v1.rabl +0 -2
- data/app/views/spree/api/products/index.v1.rabl +0 -9
- data/app/views/spree/api/products/new.v1.rabl +0 -3
- data/app/views/spree/api/products/product.v1.rabl +0 -1
- data/app/views/spree/api/products/show.v1.rabl +0 -42
- data/app/views/spree/api/promotions/handler.v1.rabl +0 -5
- data/app/views/spree/api/promotions/show.v1.rabl +0 -2
- data/app/views/spree/api/properties/index.v1.rabl +0 -7
- data/app/views/spree/api/properties/new.v1.rabl +0 -2
- data/app/views/spree/api/properties/show.v1.rabl +0 -2
- data/app/views/spree/api/return_authorizations/index.v1.rabl +0 -7
- data/app/views/spree/api/return_authorizations/new.v1.rabl +0 -3
- data/app/views/spree/api/return_authorizations/show.v1.rabl +0 -2
- data/app/views/spree/api/shipments/big.v1.rabl +0 -55
- data/app/views/spree/api/shipments/cannot_ready_shipment.v1.rabl +0 -2
- data/app/views/spree/api/shipments/mine.v1.rabl +0 -9
- data/app/views/spree/api/shipments/show.v1.rabl +0 -32
- data/app/views/spree/api/shipments/small.v1.rabl +0 -37
- data/app/views/spree/api/shipping_rates/show.v1.rabl +0 -2
- data/app/views/spree/api/states/index.v1.rabl +0 -14
- data/app/views/spree/api/states/show.v1.rabl +0 -2
- data/app/views/spree/api/stock_items/index.v1.rabl +0 -7
- data/app/views/spree/api/stock_items/show.v1.rabl +0 -5
- data/app/views/spree/api/stock_locations/index.v1.rabl +0 -7
- data/app/views/spree/api/stock_locations/show.v1.rabl +0 -8
- data/app/views/spree/api/stock_movements/index.v1.rabl +0 -7
- data/app/views/spree/api/stock_movements/show.v1.rabl +0 -5
- data/app/views/spree/api/stock_transfers/receive.v1.rabl +0 -5
- data/app/views/spree/api/store_credit_events/mine.v1.rabl +0 -10
- data/app/views/spree/api/stores/index.v1.rabl +0 -4
- data/app/views/spree/api/stores/show.v1.rabl +0 -2
- data/app/views/spree/api/taxonomies/index.v1.rabl +0 -7
- data/app/views/spree/api/taxonomies/jstree.rabl +0 -8
- data/app/views/spree/api/taxonomies/nested.v1.rabl +0 -11
- data/app/views/spree/api/taxonomies/new.v1.rabl +0 -3
- data/app/views/spree/api/taxonomies/show.v1.rabl +0 -15
- data/app/views/spree/api/taxons/index.v1.rabl +0 -12
- data/app/views/spree/api/taxons/jstree.rabl +0 -8
- data/app/views/spree/api/taxons/new.v1.rabl +0 -3
- data/app/views/spree/api/taxons/show.v1.rabl +0 -6
- data/app/views/spree/api/taxons/taxons.v1.rabl +0 -5
- data/app/views/spree/api/transfer_items/show.v1.rabl +0 -6
- data/app/views/spree/api/users/index.v1.rabl +0 -7
- data/app/views/spree/api/users/new.v1.rabl +0 -3
- data/app/views/spree/api/users/show.v1.rabl +0 -10
- data/app/views/spree/api/variants/big.v1.rabl +0 -20
- data/app/views/spree/api/variants/index.v1.rabl +0 -9
- data/app/views/spree/api/variants/new.v1.rabl +0 -2
- data/app/views/spree/api/variants/show.v1.rabl +0 -3
- data/app/views/spree/api/variants/small.v1.rabl +0 -17
- data/app/views/spree/api/zones/index.v1.rabl +0 -7
- data/app/views/spree/api/zones/show.v1.rabl +0 -6
- data/config/initializers/rails5_rabl_hacks.rb +0 -12
- data/spec/test_views/spree/api/widgets/index.v1.rabl +0 -7
- data/spec/test_views/spree/api/widgets/new.v1.rabl +0 -2
- data/spec/test_views/spree/api/widgets/show.v1.rabl +0 -2
@@ -31,10 +31,9 @@ module Spree
|
|
31
31
|
describe "POST create" do
|
32
32
|
let(:target_user) { create :user }
|
33
33
|
let(:date_override) { Time.parse('2015-01-01') }
|
34
|
-
let(:attributes) { { user_id: target_user.id, created_at: date_override, email: target_user.email } }
|
35
34
|
|
36
35
|
subject do
|
37
|
-
post spree.api_orders_path, params: { order:
|
36
|
+
post spree.api_orders_path, params: { order: { user_id: target_user.id, created_at: date_override, email: target_user.email } }
|
38
37
|
response
|
39
38
|
end
|
40
39
|
|
@@ -45,37 +44,12 @@ module Spree
|
|
45
44
|
|
46
45
|
it "does not include unpermitted params, or allow overriding the user" do
|
47
46
|
subject
|
48
|
-
expect(response).to be_success
|
49
47
|
order = Spree::Order.last
|
50
48
|
expect(order.user).to eq current_api_user
|
51
49
|
expect(order.email).to eq target_user.email
|
52
50
|
end
|
53
51
|
|
54
52
|
it { is_expected.to be_success }
|
55
|
-
|
56
|
-
context 'creating payment' do
|
57
|
-
let(:attributes) { super().merge(payments_attributes: [{ payment_method_id: payment_method.id }]) }
|
58
|
-
|
59
|
-
context "with allowed payment method" do
|
60
|
-
let!(:payment_method) { create(:check_payment_method, name: "allowed" ) }
|
61
|
-
it { is_expected.to be_success }
|
62
|
-
it "creates a payment" do
|
63
|
-
expect {
|
64
|
-
subject
|
65
|
-
}.to change { Spree::Payment.count }.by(1)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "with disallowed payment method" do
|
70
|
-
let!(:payment_method) { create(:check_payment_method, name: "forbidden", available_to_users: false) }
|
71
|
-
it { is_expected.to be_not_found }
|
72
|
-
it "creates no payments" do
|
73
|
-
expect {
|
74
|
-
subject
|
75
|
-
}.not_to change { Spree::Payment.count }
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
53
|
end
|
80
54
|
|
81
55
|
context "when the current user can administrate the order" do
|
@@ -95,7 +69,7 @@ module Spree
|
|
95
69
|
end
|
96
70
|
|
97
71
|
context 'when the line items have custom attributes' do
|
98
|
-
it "can create an order with line items that have custom permitted attributes"
|
72
|
+
it "can create an order with line items that have custom permitted attributes" do
|
99
73
|
PermittedAttributes.line_item_attributes << { options: [:some_option] }
|
100
74
|
expect_any_instance_of(Spree::LineItem).to receive(:some_option=).once.with('4')
|
101
75
|
post spree.api_orders_path, params: { order: { line_items: { "0" => { variant_id: variant.to_param, quantity: 5, options: { some_option: 4 } } } } }
|
@@ -139,30 +113,6 @@ module Spree
|
|
139
113
|
subject
|
140
114
|
}.to_not change{ order.reload.number }
|
141
115
|
end
|
142
|
-
|
143
|
-
context 'creating payment' do
|
144
|
-
let(:order_params) { super().merge(payments_attributes: [{ payment_method_id: payment_method.id }]) }
|
145
|
-
|
146
|
-
context "with allowed payment method" do
|
147
|
-
let!(:payment_method) { create(:check_payment_method, name: "allowed" ) }
|
148
|
-
it { is_expected.to be_success }
|
149
|
-
it "creates a payment" do
|
150
|
-
expect {
|
151
|
-
subject
|
152
|
-
}.to change { Spree::Payment.count }.by(1)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
context "with disallowed payment method" do
|
157
|
-
let!(:payment_method) { create(:check_payment_method, name: "forbidden", available_to_users: false) }
|
158
|
-
it { is_expected.to be_not_found }
|
159
|
-
it "creates no payments" do
|
160
|
-
expect {
|
161
|
-
subject
|
162
|
-
}.not_to change { Spree::Payment.count }
|
163
|
-
end
|
164
|
-
end
|
165
|
-
end
|
166
116
|
end
|
167
117
|
|
168
118
|
context "when the user can administer the order" do
|
@@ -327,13 +277,6 @@ module Spree
|
|
327
277
|
expect(json_response["checkout_steps"]).to eq(%w[address delivery confirm complete])
|
328
278
|
end
|
329
279
|
|
330
|
-
# Regression test for https://github.com/spree/spree/issues/1992
|
331
|
-
it "can view an order not in a standard state" do
|
332
|
-
allow_any_instance_of(Order).to receive_messages user: current_api_user
|
333
|
-
order.update_column(:state, 'shipped')
|
334
|
-
get spree.api_order_path(order)
|
335
|
-
end
|
336
|
-
|
337
280
|
it "can not view someone else's order" do
|
338
281
|
allow_any_instance_of(Order).to receive_messages user: stub_model(Spree::LegacyUser)
|
339
282
|
get spree.api_order_path(order)
|
@@ -394,7 +337,10 @@ module Spree
|
|
394
337
|
|
395
338
|
# Regression test for https://github.com/spree/spree/issues/3404
|
396
339
|
it "can specify additional parameters for a line item" do
|
397
|
-
|
340
|
+
expect(Order).to receive(:create!).and_return(order = Spree::Order.new)
|
341
|
+
allow(order).to receive(:associate_user!)
|
342
|
+
allow(order).to receive_message_chain(:contents, :add).and_return(line_item = double('LineItem'))
|
343
|
+
expect(line_item).to receive(:update_attributes!).with(hash_including("special" => "foo"))
|
398
344
|
|
399
345
|
allow_any_instance_of(Spree::Api::OrdersController).to receive_messages(permitted_line_item_attributes: [:id, :variant_id, :quantity, :special])
|
400
346
|
post spree.api_orders_path, params: {
|
@@ -560,6 +506,7 @@ module Spree
|
|
560
506
|
|
561
507
|
context "with a line item" do
|
562
508
|
let(:order) { create(:order_with_line_items) }
|
509
|
+
let(:line_item) { order.line_items.first }
|
563
510
|
|
564
511
|
it "can empty an order" do
|
565
512
|
create(:adjustment, order: order, adjustable: order)
|
@@ -42,17 +42,6 @@ module Spree
|
|
42
42
|
expect(response.status).to eq(201)
|
43
43
|
expect(json_response).to have_attributes(attributes)
|
44
44
|
end
|
45
|
-
|
46
|
-
context "disallowed payment method" do
|
47
|
-
it "does not create a new payment" do
|
48
|
-
PaymentMethod.first.update!(available_to_users: false)
|
49
|
-
|
50
|
-
expect {
|
51
|
-
post spree.api_order_payments_path(order), params: { payment: { payment_method_id: PaymentMethod.first.id, amount: 50 } }
|
52
|
-
}.not_to change { Spree::Payment.count }
|
53
|
-
expect(response.status).to eq(404)
|
54
|
-
end
|
55
|
-
end
|
56
45
|
end
|
57
46
|
|
58
47
|
context "payment source is required" do
|
@@ -354,6 +354,21 @@ describe Spree::Api::ShipmentsController, type: :request do
|
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
357
|
+
context "for an unsuccessful transfer" do
|
358
|
+
before do
|
359
|
+
source_shipment
|
360
|
+
variant
|
361
|
+
stock_location.stock_items.update_all(backorderable: false)
|
362
|
+
end
|
363
|
+
|
364
|
+
it "returns the correct message" do
|
365
|
+
subject
|
366
|
+
expect(response).to be_accepted
|
367
|
+
expect(parsed_response["success"]).to be false
|
368
|
+
expect(parsed_response["message"]).to eq("Desired shipment not enough stock in desired stock location")
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
357
372
|
context "if the source shipment can not be found" do
|
358
373
|
let(:stock_location_id) { 9999 }
|
359
374
|
|
@@ -422,7 +437,7 @@ describe Spree::Api::ShipmentsController, type: :request do
|
|
422
437
|
|
423
438
|
it "returns the correct message" do
|
424
439
|
subject
|
425
|
-
expect(response).to
|
440
|
+
expect(response).to be_accepted
|
426
441
|
expect(parsed_response["success"]).to be true
|
427
442
|
expect(parsed_response["message"]).to eq("Variants successfully transferred")
|
428
443
|
end
|
@@ -27,6 +27,7 @@ module Spree
|
|
27
27
|
create(:state)
|
28
28
|
get spree.api_states_path, params: { page: 2, per_page: 1 }
|
29
29
|
|
30
|
+
expect(json_response).to be_paginated
|
30
31
|
expect(json_response["states"].size).to eq(1)
|
31
32
|
expect(json_response["pages"]).to eq(2)
|
32
33
|
expect(json_response["current_page"]).to eq(2)
|
@@ -120,6 +120,31 @@ module Spree
|
|
120
120
|
delete spree.api_taxonomy_taxon_path(taxonomy, taxon.id)
|
121
121
|
assert_unauthorized!
|
122
122
|
end
|
123
|
+
|
124
|
+
context "with caching enabled" do
|
125
|
+
let!(:product) { create(:product, taxons: [taxon]) }
|
126
|
+
|
127
|
+
before do
|
128
|
+
ActionController::Base.perform_caching = true
|
129
|
+
end
|
130
|
+
|
131
|
+
it "handles exclude_data correctly" do
|
132
|
+
get spree.api_taxon_products_path, params: { id: taxon.id, simple: true }
|
133
|
+
expect(response).to be_success
|
134
|
+
simple_response = json_response
|
135
|
+
|
136
|
+
get spree.api_taxon_products_path, params: { id: taxon.id }
|
137
|
+
expect(response).to be_success
|
138
|
+
full_response = json_response
|
139
|
+
|
140
|
+
expect(simple_response["products"][0]["description"]).to be_nil
|
141
|
+
expect(full_response["products"][0]["description"]).not_to be_nil
|
142
|
+
end
|
143
|
+
|
144
|
+
after do
|
145
|
+
ActionController::Base.perform_caching = false
|
146
|
+
end
|
147
|
+
end
|
123
148
|
end
|
124
149
|
|
125
150
|
context "as an admin" do
|
@@ -142,8 +142,8 @@ module Spree
|
|
142
142
|
it "cannot destroy user with orders" do
|
143
143
|
create(:completed_order_with_totals, user: user)
|
144
144
|
delete spree.api_user_path(user)
|
145
|
-
expect(json_response["exception"]).to eq "Spree::Core::DestroyWithOrdersError"
|
146
145
|
expect(response.status).to eq(422)
|
146
|
+
expect(json_response).to eq({ "error" => "Cannot delete record." })
|
147
147
|
end
|
148
148
|
end
|
149
149
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
json.(widget, :id, :name, :position)
|
@@ -0,0 +1 @@
|
|
1
|
+
json.attributes [:name]
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial!("spree/api/widgets/widget", widget: @object)
|
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: 2.
|
4
|
+
version: 2.4.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -16,42 +16,76 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.4.0.beta1
|
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: 2.
|
26
|
+
version: 2.4.0.beta1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: versioncake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: responders
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jbuilder
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
61
|
+
version: '2.6'
|
48
62
|
type: :runtime
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
68
|
+
version: '2.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: kaminari
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.17'
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '2.0'
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0.17'
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '2.0'
|
55
89
|
description: REST API for the Solidus e-commerce framework.
|
56
90
|
email: contact@solidus.io
|
57
91
|
executables: []
|
@@ -100,99 +134,116 @@ files:
|
|
100
134
|
- app/controllers/spree/api/zones_controller.rb
|
101
135
|
- app/helpers/spree/api/api_helpers.rb
|
102
136
|
- app/models/spree/api_configuration.rb
|
103
|
-
- app/views
|
104
|
-
- app/views/spree/api/
|
105
|
-
- app/views/spree/api/
|
106
|
-
- app/views/spree/api/
|
107
|
-
- app/views/spree/api/
|
108
|
-
- app/views/spree/api/
|
109
|
-
- app/views/spree/api/
|
110
|
-
- app/views/spree/api/
|
111
|
-
- app/views/spree/api/
|
112
|
-
- app/views/spree/api/
|
113
|
-
- app/views/spree/api/
|
114
|
-
- app/views/spree/api/
|
115
|
-
- app/views/spree/api/errors/
|
116
|
-
- app/views/spree/api/errors/
|
117
|
-
- app/views/spree/api/errors/
|
118
|
-
- app/views/spree/api/errors/
|
119
|
-
- app/views/spree/api/
|
120
|
-
- app/views/spree/api/
|
121
|
-
- app/views/spree/api/
|
122
|
-
- app/views/spree/api/
|
123
|
-
- app/views/spree/api/
|
124
|
-
- app/views/spree/api/
|
125
|
-
- app/views/spree/api/
|
126
|
-
- app/views/spree/api/
|
127
|
-
- app/views/spree/api/
|
128
|
-
- app/views/spree/api/
|
129
|
-
- app/views/spree/api/
|
130
|
-
- app/views/spree/api/
|
131
|
-
- app/views/spree/api/
|
132
|
-
- app/views/spree/api/
|
133
|
-
- app/views/spree/api/
|
134
|
-
- app/views/spree/api/
|
135
|
-
- app/views/spree/api/
|
136
|
-
- app/views/spree/api/
|
137
|
-
- app/views/spree/api/
|
138
|
-
- app/views/spree/api/
|
139
|
-
- app/views/spree/api/
|
140
|
-
- app/views/spree/api/
|
141
|
-
- app/views/spree/api/
|
142
|
-
- app/views/spree/api/
|
143
|
-
- app/views/spree/api/
|
144
|
-
- app/views/spree/api/
|
145
|
-
- app/views/spree/api/
|
146
|
-
- app/views/spree/api/
|
147
|
-
- app/views/spree/api/
|
148
|
-
- app/views/spree/api/
|
149
|
-
- app/views/spree/api/
|
150
|
-
- app/views/spree/api/
|
151
|
-
- app/views/spree/api/
|
152
|
-
- app/views/spree/api/
|
153
|
-
- app/views/spree/api/
|
154
|
-
- app/views/spree/api/
|
155
|
-
- app/views/spree/api/
|
156
|
-
- app/views/spree/api/
|
157
|
-
- app/views/spree/api/
|
158
|
-
- app/views/spree/api/
|
159
|
-
- app/views/spree/api/
|
160
|
-
- app/views/spree/api/
|
161
|
-
- app/views/spree/api/
|
162
|
-
- app/views/spree/api/
|
163
|
-
- app/views/spree/api/
|
164
|
-
- app/views/spree/api/
|
165
|
-
- app/views/spree/api/
|
166
|
-
- app/views/spree/api/
|
167
|
-
- app/views/spree/api/
|
168
|
-
- app/views/spree/api/
|
169
|
-
- app/views/spree/api/
|
170
|
-
- app/views/spree/api/
|
171
|
-
- app/views/spree/api/
|
172
|
-
- app/views/spree/api/
|
173
|
-
- app/views/spree/api/
|
174
|
-
- app/views/spree/api/
|
175
|
-
- app/views/spree/api/
|
176
|
-
- app/views/spree/api/
|
177
|
-
- app/views/spree/api/
|
178
|
-
- app/views/spree/api/
|
179
|
-
- app/views/spree/api/
|
180
|
-
- app/views/spree/api/
|
181
|
-
- app/views/spree/api/
|
182
|
-
- app/views/spree/api/
|
183
|
-
- app/views/spree/api/
|
184
|
-
- app/views/spree/api/
|
185
|
-
- app/views/spree/api/
|
186
|
-
- app/views/spree/api/
|
187
|
-
- app/views/spree/api/
|
188
|
-
- app/views/spree/api/
|
189
|
-
- app/views/spree/api/
|
190
|
-
- app/views/spree/api/
|
191
|
-
- app/views/spree/api/
|
192
|
-
- app/views/spree/api/
|
193
|
-
- app/views/spree/api/
|
194
|
-
- app/views/spree/api/
|
195
|
-
-
|
137
|
+
- app/views/.rubocop.yml
|
138
|
+
- app/views/spree/api/address_books/show.json.jbuilder
|
139
|
+
- app/views/spree/api/addresses/_address.json.jbuilder
|
140
|
+
- app/views/spree/api/addresses/show.json.jbuilder
|
141
|
+
- app/views/spree/api/adjustments/_adjustment.json.jbuilder
|
142
|
+
- app/views/spree/api/config/money.json.jbuilder
|
143
|
+
- app/views/spree/api/config/show.json.jbuilder
|
144
|
+
- app/views/spree/api/countries/index.json.jbuilder
|
145
|
+
- app/views/spree/api/countries/show.json.jbuilder
|
146
|
+
- app/views/spree/api/credit_cards/_credit_card.json.jbuilder
|
147
|
+
- app/views/spree/api/credit_cards/index.json.jbuilder
|
148
|
+
- app/views/spree/api/credit_cards/show.json.jbuilder
|
149
|
+
- app/views/spree/api/errors/delete_restriction.json.jbuilder
|
150
|
+
- app/views/spree/api/errors/gateway_error.json.jbuilder
|
151
|
+
- app/views/spree/api/errors/invalid_api_key.json.jbuilder
|
152
|
+
- app/views/spree/api/errors/invalid_resource.json.jbuilder
|
153
|
+
- app/views/spree/api/errors/must_specify_api_key.json.jbuilder
|
154
|
+
- app/views/spree/api/errors/not_found.json.jbuilder
|
155
|
+
- app/views/spree/api/errors/unauthorized.json.jbuilder
|
156
|
+
- app/views/spree/api/errors/variant_not_in_stock_transfer.json.jbuilder
|
157
|
+
- app/views/spree/api/images/_image.json.jbuilder
|
158
|
+
- app/views/spree/api/images/index.json.jbuilder
|
159
|
+
- app/views/spree/api/images/show.json.jbuilder
|
160
|
+
- app/views/spree/api/inventory_units/show.json.jbuilder
|
161
|
+
- app/views/spree/api/line_items/_line_item.json.jbuilder
|
162
|
+
- app/views/spree/api/line_items/new.json.jbuilder
|
163
|
+
- app/views/spree/api/line_items/show.json.jbuilder
|
164
|
+
- app/views/spree/api/option_types/_option_type.json.jbuilder
|
165
|
+
- app/views/spree/api/option_types/index.json.jbuilder
|
166
|
+
- app/views/spree/api/option_types/show.json.jbuilder
|
167
|
+
- app/views/spree/api/option_values/_option_value.json.jbuilder
|
168
|
+
- app/views/spree/api/option_values/index.json.jbuilder
|
169
|
+
- app/views/spree/api/option_values/show.json.jbuilder
|
170
|
+
- app/views/spree/api/orders/_big.json.jbuilder
|
171
|
+
- app/views/spree/api/orders/_order.json.jbuilder
|
172
|
+
- app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder
|
173
|
+
- app/views/spree/api/orders/could_not_transition.json.jbuilder
|
174
|
+
- app/views/spree/api/orders/expected_total_mismatch.json.jbuilder
|
175
|
+
- app/views/spree/api/orders/index.json.jbuilder
|
176
|
+
- app/views/spree/api/orders/invalid_shipping_method.json.jbuilder
|
177
|
+
- app/views/spree/api/orders/mine.json.jbuilder
|
178
|
+
- app/views/spree/api/orders/show.json.jbuilder
|
179
|
+
- app/views/spree/api/payments/credit_over_limit.json.jbuilder
|
180
|
+
- app/views/spree/api/payments/index.json.jbuilder
|
181
|
+
- app/views/spree/api/payments/new.json.jbuilder
|
182
|
+
- app/views/spree/api/payments/show.json.jbuilder
|
183
|
+
- app/views/spree/api/payments/update_forbidden.json.jbuilder
|
184
|
+
- app/views/spree/api/product_properties/index.json.jbuilder
|
185
|
+
- app/views/spree/api/product_properties/new.json.jbuilder
|
186
|
+
- app/views/spree/api/product_properties/show.json.jbuilder
|
187
|
+
- app/views/spree/api/products/_product.json.jbuilder
|
188
|
+
- app/views/spree/api/products/index.json.jbuilder
|
189
|
+
- app/views/spree/api/products/new.json.jbuilder
|
190
|
+
- app/views/spree/api/products/show.json.jbuilder
|
191
|
+
- app/views/spree/api/promotions/handler.json.jbuilder
|
192
|
+
- app/views/spree/api/promotions/show.json.jbuilder
|
193
|
+
- app/views/spree/api/properties/index.json.jbuilder
|
194
|
+
- app/views/spree/api/properties/new.json.jbuilder
|
195
|
+
- app/views/spree/api/properties/show.json.jbuilder
|
196
|
+
- app/views/spree/api/return_authorizations/index.json.jbuilder
|
197
|
+
- app/views/spree/api/return_authorizations/new.json.jbuilder
|
198
|
+
- app/views/spree/api/return_authorizations/show.json.jbuilder
|
199
|
+
- app/views/spree/api/shared/_pagination.json.jbuilder
|
200
|
+
- app/views/spree/api/shipments/_big.json.jbuilder
|
201
|
+
- app/views/spree/api/shipments/_small.json.jbuilder
|
202
|
+
- app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder
|
203
|
+
- app/views/spree/api/shipments/mine.json.jbuilder
|
204
|
+
- app/views/spree/api/shipments/show.json.jbuilder
|
205
|
+
- app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder
|
206
|
+
- app/views/spree/api/states/index.json.jbuilder
|
207
|
+
- app/views/spree/api/states/show.json.jbuilder
|
208
|
+
- app/views/spree/api/stock_items/_stock_item.json.jbuilder
|
209
|
+
- app/views/spree/api/stock_items/index.json.jbuilder
|
210
|
+
- app/views/spree/api/stock_items/show.json.jbuilder
|
211
|
+
- app/views/spree/api/stock_locations/_stock_location.json.jbuilder
|
212
|
+
- app/views/spree/api/stock_locations/index.json.jbuilder
|
213
|
+
- app/views/spree/api/stock_locations/show.json.jbuilder
|
214
|
+
- app/views/spree/api/stock_movements/_stock_movement.json.jbuilder
|
215
|
+
- app/views/spree/api/stock_movements/index.json.jbuilder
|
216
|
+
- app/views/spree/api/stock_movements/show.json.jbuilder
|
217
|
+
- app/views/spree/api/stock_transfers/receive.json.jbuilder
|
218
|
+
- app/views/spree/api/store_credit_events/mine.json.jbuilder
|
219
|
+
- app/views/spree/api/stores/index.json.jbuilder
|
220
|
+
- app/views/spree/api/stores/show.json.jbuilder
|
221
|
+
- app/views/spree/api/taxonomies/_nested.json.jbuilder
|
222
|
+
- app/views/spree/api/taxonomies/_taxonomy.json.jbuilder
|
223
|
+
- app/views/spree/api/taxonomies/index.json.jbuilder
|
224
|
+
- app/views/spree/api/taxonomies/jstree.json.jbuilder
|
225
|
+
- app/views/spree/api/taxonomies/new.json.jbuilder
|
226
|
+
- app/views/spree/api/taxonomies/show.json.jbuilder
|
227
|
+
- app/views/spree/api/taxons/_taxon.json.jbuilder
|
228
|
+
- app/views/spree/api/taxons/_taxons.json.jbuilder
|
229
|
+
- app/views/spree/api/taxons/index.json.jbuilder
|
230
|
+
- app/views/spree/api/taxons/jstree.json.jbuilder
|
231
|
+
- app/views/spree/api/taxons/new.json.jbuilder
|
232
|
+
- app/views/spree/api/taxons/show.json.jbuilder
|
233
|
+
- app/views/spree/api/transfer_items/_transfer_item.json.jbuilder
|
234
|
+
- app/views/spree/api/transfer_items/show.json.jbuilder
|
235
|
+
- app/views/spree/api/users/_user.json.jbuilder
|
236
|
+
- app/views/spree/api/users/index.json.jbuilder
|
237
|
+
- app/views/spree/api/users/new.json.jbuilder
|
238
|
+
- app/views/spree/api/users/show.json.jbuilder
|
239
|
+
- app/views/spree/api/variants/_big.json.jbuilder
|
240
|
+
- app/views/spree/api/variants/_small.json.jbuilder
|
241
|
+
- app/views/spree/api/variants/index.json.jbuilder
|
242
|
+
- app/views/spree/api/variants/new.json.jbuilder
|
243
|
+
- app/views/spree/api/variants/show.json.jbuilder
|
244
|
+
- app/views/spree/api/zones/_zone.json.jbuilder
|
245
|
+
- app/views/spree/api/zones/index.json.jbuilder
|
246
|
+
- app/views/spree/api/zones/show.json.jbuilder
|
196
247
|
- config/locales/en.yml
|
197
248
|
- config/routes.rb
|
198
249
|
- db/migrate/20100107141738_add_api_key_to_spree_users.rb
|
@@ -254,12 +305,14 @@ files:
|
|
254
305
|
- spec/requests/spree/api/zones_controller_spec.rb
|
255
306
|
- spec/shared_examples/protect_product_actions.rb
|
256
307
|
- spec/spec_helper.rb
|
308
|
+
- spec/support/be_paginated_matcher.rb
|
257
309
|
- spec/support/controller_hacks.rb
|
258
310
|
- spec/support/database_cleaner.rb
|
259
311
|
- spec/support/have_attributes_matcher.rb
|
260
|
-
- spec/test_views/spree/api/widgets/
|
261
|
-
- spec/test_views/spree/api/widgets/
|
262
|
-
- spec/test_views/spree/api/widgets/
|
312
|
+
- spec/test_views/spree/api/widgets/_widget.json.jbuilder
|
313
|
+
- spec/test_views/spree/api/widgets/index.json.jbuilder
|
314
|
+
- spec/test_views/spree/api/widgets/new.json.jbuilder
|
315
|
+
- spec/test_views/spree/api/widgets/show.json.jbuilder
|
263
316
|
homepage: http://solidus.io/
|
264
317
|
licenses:
|
265
318
|
- BSD-3-Clause
|
@@ -329,9 +382,11 @@ test_files:
|
|
329
382
|
- spec/requests/spree/api/zones_controller_spec.rb
|
330
383
|
- spec/shared_examples/protect_product_actions.rb
|
331
384
|
- spec/spec_helper.rb
|
385
|
+
- spec/support/be_paginated_matcher.rb
|
332
386
|
- spec/support/controller_hacks.rb
|
333
387
|
- spec/support/database_cleaner.rb
|
334
388
|
- spec/support/have_attributes_matcher.rb
|
335
|
-
- spec/test_views/spree/api/widgets/
|
336
|
-
- spec/test_views/spree/api/widgets/
|
337
|
-
- spec/test_views/spree/api/widgets/
|
389
|
+
- spec/test_views/spree/api/widgets/_widget.json.jbuilder
|
390
|
+
- spec/test_views/spree/api/widgets/index.json.jbuilder
|
391
|
+
- spec/test_views/spree/api/widgets/new.json.jbuilder
|
392
|
+
- spec/test_views/spree/api/widgets/show.json.jbuilder
|