solidus_api 2.5.2 → 2.6.0.rc1
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/Rakefile +3 -1
- data/app/controllers/spree/api/address_books_controller.rb +2 -0
- data/app/controllers/spree/api/addresses_controller.rb +2 -0
- data/app/controllers/spree/api/base_controller.rb +2 -0
- data/app/controllers/spree/api/checkouts_controller.rb +2 -0
- data/app/controllers/spree/api/classifications_controller.rb +2 -0
- data/app/controllers/spree/api/config_controller.rb +2 -0
- data/app/controllers/spree/api/countries_controller.rb +2 -0
- data/app/controllers/spree/api/credit_cards_controller.rb +2 -0
- data/app/controllers/spree/api/images_controller.rb +2 -0
- data/app/controllers/spree/api/inventory_units_controller.rb +2 -0
- data/app/controllers/spree/api/line_items_controller.rb +2 -0
- data/app/controllers/spree/api/option_types_controller.rb +2 -0
- data/app/controllers/spree/api/option_values_controller.rb +2 -0
- data/app/controllers/spree/api/orders_controller.rb +2 -0
- data/app/controllers/spree/api/payments_controller.rb +3 -1
- data/app/controllers/spree/api/product_properties_controller.rb +2 -0
- data/app/controllers/spree/api/products_controller.rb +2 -0
- data/app/controllers/spree/api/promotions_controller.rb +2 -0
- data/app/controllers/spree/api/properties_controller.rb +2 -0
- data/app/controllers/spree/api/resource_controller.rb +2 -0
- data/app/controllers/spree/api/return_authorizations_controller.rb +2 -0
- data/app/controllers/spree/api/shipments_controller.rb +2 -0
- data/app/controllers/spree/api/states_controller.rb +4 -2
- data/app/controllers/spree/api/stock_items_controller.rb +2 -0
- data/app/controllers/spree/api/stock_locations_controller.rb +2 -0
- data/app/controllers/spree/api/stock_movements_controller.rb +2 -0
- data/app/controllers/spree/api/store_credit_events_controller.rb +2 -0
- data/app/controllers/spree/api/stores_controller.rb +2 -0
- data/app/controllers/spree/api/taxonomies_controller.rb +2 -0
- data/app/controllers/spree/api/taxons_controller.rb +2 -0
- data/app/controllers/spree/api/users_controller.rb +2 -0
- data/app/controllers/spree/api/variants_controller.rb +2 -0
- data/app/controllers/spree/api/zones_controller.rb +2 -0
- data/app/helpers/spree/api/api_helpers.rb +6 -4
- data/app/models/spree/api_configuration.rb +2 -0
- data/app/views/spree/api/address_books/show.json.jbuilder +2 -0
- data/app/views/spree/api/addresses/_address.json.jbuilder +2 -0
- data/app/views/spree/api/addresses/show.json.jbuilder +2 -0
- data/app/views/spree/api/adjustments/_adjustment.json.jbuilder +2 -0
- data/app/views/spree/api/config/money.json.jbuilder +2 -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 +2 -0
- data/app/views/spree/api/credit_cards/_credit_card.json.jbuilder +2 -0
- data/app/views/spree/api/credit_cards/index.json.jbuilder +2 -0
- data/app/views/spree/api/credit_cards/show.json.jbuilder +2 -0
- data/app/views/spree/api/errors/delete_restriction.json.jbuilder +2 -0
- data/app/views/spree/api/errors/gateway_error.json.jbuilder +2 -0
- data/app/views/spree/api/errors/invalid_api_key.json.jbuilder +2 -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 +2 -0
- data/app/views/spree/api/errors/not_found.json.jbuilder +2 -0
- data/app/views/spree/api/errors/unauthorized.json.jbuilder +2 -0
- data/app/views/spree/api/images/_image.json.jbuilder +2 -0
- data/app/views/spree/api/images/index.json.jbuilder +2 -0
- data/app/views/spree/api/images/show.json.jbuilder +2 -0
- data/app/views/spree/api/inventory_units/show.json.jbuilder +2 -0
- data/app/views/spree/api/line_items/_line_item.json.jbuilder +2 -0
- data/app/views/spree/api/line_items/new.json.jbuilder +2 -0
- data/app/views/spree/api/line_items/show.json.jbuilder +2 -0
- data/app/views/spree/api/option_types/_option_type.json.jbuilder +2 -0
- data/app/views/spree/api/option_types/index.json.jbuilder +2 -0
- data/app/views/spree/api/option_types/show.json.jbuilder +2 -0
- data/app/views/spree/api/option_values/_option_value.json.jbuilder +2 -0
- data/app/views/spree/api/option_values/index.json.jbuilder +2 -0
- data/app/views/spree/api/option_values/show.json.jbuilder +2 -0
- data/app/views/spree/api/orders/_big.json.jbuilder +13 -5
- data/app/views/spree/api/orders/_order.json.jbuilder +2 -0
- data/app/views/spree/api/orders/could_not_apply_coupon.json.jbuilder +2 -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 +2 -0
- data/app/views/spree/api/orders/index.json.jbuilder +2 -0
- data/app/views/spree/api/orders/invalid_shipping_method.json.jbuilder +2 -0
- data/app/views/spree/api/orders/mine.json.jbuilder +2 -0
- data/app/views/spree/api/orders/show.json.jbuilder +2 -0
- data/app/views/spree/api/payments/credit_over_limit.json.jbuilder +2 -0
- data/app/views/spree/api/payments/index.json.jbuilder +2 -0
- data/app/views/spree/api/payments/new.json.jbuilder +2 -0
- data/app/views/spree/api/payments/show.json.jbuilder +2 -0
- data/app/views/spree/api/payments/source_views/_check.json.jbuilder +1 -0
- data/app/views/spree/api/payments/source_views/_gateway.json.jbuilder +6 -0
- data/app/views/spree/api/payments/source_views/_storecredit.json.jbuilder +3 -0
- data/app/views/spree/api/payments/update_forbidden.json.jbuilder +2 -0
- data/app/views/spree/api/product_properties/index.json.jbuilder +2 -0
- data/app/views/spree/api/product_properties/new.json.jbuilder +2 -0
- data/app/views/spree/api/product_properties/show.json.jbuilder +2 -0
- data/app/views/spree/api/products/_product.json.jbuilder +2 -0
- data/app/views/spree/api/products/index.json.jbuilder +2 -0
- data/app/views/spree/api/products/new.json.jbuilder +2 -0
- data/app/views/spree/api/products/show.json.jbuilder +2 -0
- data/app/views/spree/api/promotions/handler.json.jbuilder +2 -0
- data/app/views/spree/api/promotions/show.json.jbuilder +2 -0
- data/app/views/spree/api/properties/index.json.jbuilder +2 -0
- data/app/views/spree/api/properties/new.json.jbuilder +2 -0
- data/app/views/spree/api/properties/show.json.jbuilder +2 -0
- data/app/views/spree/api/return_authorizations/index.json.jbuilder +2 -0
- data/app/views/spree/api/return_authorizations/new.json.jbuilder +2 -0
- data/app/views/spree/api/return_authorizations/show.json.jbuilder +2 -0
- data/app/views/spree/api/shared/_pagination.json.jbuilder +2 -0
- data/app/views/spree/api/shipments/_big.json.jbuilder +8 -4
- data/app/views/spree/api/shipments/_small.json.jbuilder +2 -0
- data/app/views/spree/api/shipments/cannot_ready_shipment.json.jbuilder +2 -0
- data/app/views/spree/api/shipments/estimated_rates.json.jbuilder +2 -0
- data/app/views/spree/api/shipments/mine.json.jbuilder +2 -0
- data/app/views/spree/api/shipments/show.json.jbuilder +2 -0
- data/app/views/spree/api/shipping_rates/_shipping_rate.json.jbuilder +2 -0
- data/app/views/spree/api/states/index.json.jbuilder +2 -0
- data/app/views/spree/api/states/show.json.jbuilder +2 -0
- data/app/views/spree/api/stock_items/_stock_item.json.jbuilder +2 -0
- data/app/views/spree/api/stock_items/index.json.jbuilder +2 -0
- data/app/views/spree/api/stock_items/show.json.jbuilder +2 -0
- data/app/views/spree/api/stock_locations/_stock_location.json.jbuilder +2 -0
- data/app/views/spree/api/stock_locations/index.json.jbuilder +2 -0
- data/app/views/spree/api/stock_locations/show.json.jbuilder +2 -0
- data/app/views/spree/api/stock_movements/_stock_movement.json.jbuilder +2 -0
- data/app/views/spree/api/stock_movements/index.json.jbuilder +2 -0
- data/app/views/spree/api/stock_movements/show.json.jbuilder +2 -0
- data/app/views/spree/api/store_credit_events/mine.json.jbuilder +2 -0
- data/app/views/spree/api/stores/index.json.jbuilder +2 -0
- data/app/views/spree/api/stores/show.json.jbuilder +2 -0
- data/app/views/spree/api/taxonomies/_nested.json.jbuilder +2 -0
- data/app/views/spree/api/taxonomies/_taxonomy.json.jbuilder +2 -0
- data/app/views/spree/api/taxonomies/index.json.jbuilder +2 -0
- data/app/views/spree/api/taxonomies/jstree.json.jbuilder +2 -0
- data/app/views/spree/api/taxonomies/new.json.jbuilder +2 -0
- data/app/views/spree/api/taxonomies/show.json.jbuilder +2 -0
- data/app/views/spree/api/taxons/_taxon.json.jbuilder +2 -0
- data/app/views/spree/api/taxons/_taxons.json.jbuilder +2 -0
- data/app/views/spree/api/taxons/index.json.jbuilder +2 -0
- data/app/views/spree/api/taxons/jstree.json.jbuilder +2 -0
- data/app/views/spree/api/taxons/new.json.jbuilder +2 -0
- data/app/views/spree/api/taxons/show.json.jbuilder +2 -0
- data/app/views/spree/api/users/_user.json.jbuilder +2 -0
- data/app/views/spree/api/users/index.json.jbuilder +2 -0
- data/app/views/spree/api/users/new.json.jbuilder +2 -0
- data/app/views/spree/api/users/show.json.jbuilder +2 -0
- data/app/views/spree/api/variants/_big.json.jbuilder +2 -0
- data/app/views/spree/api/variants/_small.json.jbuilder +2 -0
- data/app/views/spree/api/variants/index.json.jbuilder +2 -0
- data/app/views/spree/api/variants/new.json.jbuilder +2 -0
- data/app/views/spree/api/variants/show.json.jbuilder +2 -0
- data/app/views/spree/api/zones/_zone.json.jbuilder +2 -0
- data/app/views/spree/api/zones/index.json.jbuilder +2 -0
- data/app/views/spree/api/zones/show.json.jbuilder +2 -0
- data/config/routes.rb +9 -7
- data/db/migrate/20100107141738_add_api_key_to_spree_users.rb +2 -0
- data/db/migrate/20120411123334_resize_api_key_field.rb +2 -0
- data/db/migrate/20120530054546_rename_api_key_to_spree_api_key.rb +2 -0
- data/db/migrate/20131017162334_add_index_to_user_spree_api_key.rb +2 -0
- data/lib/solidus_api.rb +2 -0
- data/lib/spree/api/engine.rb +2 -0
- data/lib/spree/api/responders/rabl_template.rb +2 -0
- data/lib/spree/api/responders.rb +2 -0
- data/lib/spree/api/testing_support/caching.rb +2 -0
- data/lib/spree/api/testing_support/helpers.rb +2 -0
- data/lib/spree/api/testing_support/setup.rb +2 -0
- data/lib/spree/api.rb +2 -0
- data/lib/spree_api.rb +2 -0
- data/script/rails +4 -2
- data/solidus_api.gemspec +4 -3
- data/spec/controllers/spree/api/base_controller_spec.rb +2 -0
- data/spec/controllers/spree/api/resource_controller_spec.rb +8 -4
- data/spec/features/checkout_spec.rb +2 -0
- data/spec/models/spree/legacy_user_spec.rb +2 -0
- data/spec/requests/api/address_books_spec.rb +2 -0
- data/spec/requests/rabl_cache_spec.rb +2 -0
- data/spec/requests/ransackable_attributes_spec.rb +2 -0
- data/spec/requests/spree/api/addresses_controller_spec.rb +2 -1
- data/spec/requests/spree/api/checkouts_controller_spec.rb +2 -1
- data/spec/requests/spree/api/classifications_controller_spec.rb +2 -0
- data/spec/requests/spree/api/config_controller_spec.rb +3 -1
- data/spec/requests/spree/api/countries_controller_spec.rb +2 -1
- data/spec/requests/spree/api/credit_cards_controller_spec.rb +2 -1
- data/spec/requests/spree/api/images_controller_spec.rb +2 -1
- data/spec/requests/spree/api/inventory_units_controller_spec.rb +2 -0
- data/spec/requests/spree/api/line_items_controller_spec.rb +2 -1
- data/spec/requests/spree/api/option_types_controller_spec.rb +2 -1
- data/spec/requests/spree/api/option_values_controller_spec.rb +3 -2
- data/spec/requests/spree/api/orders_controller_spec.rb +17 -13
- data/spec/requests/spree/api/payments_controller_spec.rb +2 -0
- data/spec/requests/spree/api/product_properties_controller_spec.rb +2 -1
- data/spec/requests/spree/api/products_controller_spec.rb +4 -3
- data/spec/requests/spree/api/promotion_application_spec.rb +2 -1
- data/spec/requests/spree/api/promotions_controller_spec.rb +2 -1
- data/spec/requests/spree/api/properties_controller_spec.rb +2 -1
- data/spec/requests/spree/api/return_authorizations_controller_spec.rb +2 -1
- data/spec/requests/spree/api/shipments_controller_spec.rb +13 -0
- data/spec/requests/spree/api/states_controller_spec.rb +2 -1
- data/spec/requests/spree/api/stock_items_controller_spec.rb +2 -1
- data/spec/requests/spree/api/stock_locations_controller_spec.rb +2 -1
- data/spec/requests/spree/api/stock_movements_controller_spec.rb +2 -1
- data/spec/requests/spree/api/store_credit_events_controller_spec.rb +2 -0
- data/spec/requests/spree/api/stores_controller_spec.rb +9 -6
- data/spec/requests/spree/api/taxonomies_controller_spec.rb +2 -1
- data/spec/requests/spree/api/taxons_controller_spec.rb +2 -1
- data/spec/requests/spree/api/unauthenticated_products_controller_spec.rb +3 -2
- data/spec/requests/spree/api/users_controller_spec.rb +2 -1
- data/spec/requests/spree/api/variants_controller_spec.rb +2 -2
- data/spec/requests/spree/api/zones_controller_spec.rb +2 -1
- data/spec/shared_examples/protect_product_actions.rb +2 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/support/be_paginated_matcher.rb +2 -0
- data/spec/support/controller_hacks.rb +2 -0
- data/spec/support/database_cleaner.rb +2 -0
- data/spec/support/have_attributes_matcher.rb +2 -0
- data/spec/test_views/spree/api/widgets/_widget.json.jbuilder +2 -0
- data/spec/test_views/spree/api/widgets/index.json.jbuilder +3 -1
- data/spec/test_views/spree/api/widgets/new.json.jbuilder +2 -0
- data/spec/test_views/spree/api/widgets/show.json.jbuilder +2 -0
- metadata +27 -23
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Spree
|
4
6
|
describe Api::ConfigController, type: :request do
|
5
|
-
let!(:default_country) { create :country, iso: "US"}
|
7
|
+
let!(:default_country) { create :country, iso: "US" }
|
6
8
|
|
7
9
|
before do
|
8
10
|
stub_authentication!
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Spree
|
@@ -10,7 +12,6 @@ module Spree
|
|
10
12
|
end
|
11
13
|
|
12
14
|
describe Api::LineItemsController, type: :request do
|
13
|
-
|
14
15
|
let!(:order) { create(:order_with_line_items, line_items_count: 1) }
|
15
16
|
|
16
17
|
let(:product) { create(:product) }
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Spree
|
4
6
|
describe Api::OptionTypesController, type: :request do
|
5
|
-
|
6
7
|
let(:attributes) { [:id, :name, :position, :presentation] }
|
7
8
|
let!(:option_value) { create(:option_value) }
|
8
9
|
let!(:option_type) { option_value.option_type }
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Spree
|
4
6
|
describe Api::OptionValuesController, type: :request do
|
5
|
-
|
6
7
|
let(:attributes) { [:id, :name, :presentation, :option_type_name, :option_type_name] }
|
7
8
|
let!(:option_value) { create(:option_value) }
|
8
9
|
let!(:option_type) { option_value.option_type }
|
@@ -101,7 +102,7 @@ module Spree
|
|
101
102
|
end
|
102
103
|
|
103
104
|
it "cannot create an option type with invalid attributes" do
|
104
|
-
post spree.api_option_type_option_values_path(option_type), params: { option_value: {name: ""} }
|
105
|
+
post spree.api_option_type_option_values_path(option_type), params: { option_value: { name: "" } }
|
105
106
|
expect(response.status).to eq(422)
|
106
107
|
end
|
107
108
|
|
@@ -1,5 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
|
-
require 'spree/testing_support/bar_ability'
|
3
4
|
|
4
5
|
module Spree
|
5
6
|
describe Api::OrdersController, type: :request do
|
@@ -347,6 +348,21 @@ module Spree
|
|
347
348
|
expect(credit_cards[0]['id']).to eq payment.source.id
|
348
349
|
expect(credit_cards[0]['address']['id']).to eq credit_card.address_id
|
349
350
|
end
|
351
|
+
|
352
|
+
it 'renders the payment source view for gateway' do
|
353
|
+
subject
|
354
|
+
expect(response).to render_template partial: 'spree/api/payments/source_views/_gateway'
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
context 'when store credit is present' do
|
359
|
+
let!(:payment) { create(:store_credit_payment, order: order, source: store_credit) }
|
360
|
+
let(:store_credit) { create(:store_credit) }
|
361
|
+
|
362
|
+
it 'renders the payment source view for store credit' do
|
363
|
+
subject
|
364
|
+
expect(response).to render_template partial: 'spree/api/payments/source_views/_storecredit'
|
365
|
+
end
|
350
366
|
end
|
351
367
|
end
|
352
368
|
|
@@ -373,18 +389,6 @@ module Spree
|
|
373
389
|
expect(response.status).to eq(200)
|
374
390
|
end
|
375
391
|
|
376
|
-
context "with BarAbility registered" do
|
377
|
-
before { Spree::Ability.register_ability(::BarAbility) }
|
378
|
-
after { Spree::Ability.remove_ability(::BarAbility) }
|
379
|
-
|
380
|
-
it "can view an order" do
|
381
|
-
user = build(:user, spree_roles: [Spree::Role.new(name: 'bar')])
|
382
|
-
allow(Spree.user_class).to receive_messages find_by: user
|
383
|
-
get spree.api_order_path(order)
|
384
|
-
expect(response.status).to eq(200)
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
392
|
it "cannot cancel an order that doesn't belong to them" do
|
389
393
|
order.update_attribute(:completed_at, Time.current)
|
390
394
|
order.update_attribute(:shipment_state, "ready")
|
@@ -1,9 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'shared_examples/protect_product_actions'
|
3
5
|
|
4
6
|
module Spree
|
5
7
|
describe Spree::Api::ProductPropertiesController, type: :request do
|
6
|
-
|
7
8
|
let!(:product) { create(:product) }
|
8
9
|
let!(:property_1) { product.product_properties.create(property_name: "My Property 1", value: "my value 1", position: 0) }
|
9
10
|
let!(:property_2) { product.product_properties.create(property_name: "My Property 2", value: "my value 2", position: 1) }
|
@@ -1,9 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'shared_examples/protect_product_actions'
|
3
5
|
|
4
6
|
module Spree
|
5
7
|
describe Spree::Api::ProductsController, type: :request do
|
6
|
-
|
7
8
|
let!(:product) { create(:product) }
|
8
9
|
let!(:inactive_product) { create(:product, available_on: Time.current.tomorrow, name: "inactive") }
|
9
10
|
let(:base_attributes) { Api::ApiHelpers.product_attributes }
|
@@ -349,7 +350,7 @@ module Spree
|
|
349
350
|
expect(response.status).to eq 200
|
350
351
|
expect(json_response['variants'].count).to eq(2) # 2 variants
|
351
352
|
|
352
|
-
variants = json_response['variants'].
|
353
|
+
variants = json_response['variants'].reject { |v| v['is_master'] }
|
353
354
|
size_option_value = variants.last['option_values'].detect{ |x| x['option_type_name'] == 'size' }
|
354
355
|
expect(size_option_value['name']).to eq('small')
|
355
356
|
|
@@ -373,7 +374,7 @@ module Spree
|
|
373
374
|
} }
|
374
375
|
|
375
376
|
expect(json_response['variants'].count).to eq(1)
|
376
|
-
variants = json_response['variants'].
|
377
|
+
variants = json_response['variants'].reject { |v| v['is_master'] }
|
377
378
|
expect(variants.last['option_values'][0]['name']).to eq('large')
|
378
379
|
expect(variants.last['sku']).to eq('456')
|
379
380
|
expect(variants.count).to eq(1)
|
@@ -1,7 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
module Spree
|
3
5
|
describe Spree::Api::PropertiesController, type: :request do
|
4
|
-
|
5
6
|
let!(:property_1) { Property.create!(name: "foo", presentation: "Foo") }
|
6
7
|
let!(:property_2) { Property.create!(name: "bar", presentation: "Bar") }
|
7
8
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Spree::Api::ShipmentsController, type: :request do
|
@@ -212,6 +214,17 @@ describe Spree::Api::ShipmentsController, type: :request do
|
|
212
214
|
expect(json_response['shipments'][0]['order']['payments'][0]['source'].keys).to match_array ["id"]
|
213
215
|
end
|
214
216
|
end
|
217
|
+
|
218
|
+
context "check payment" do
|
219
|
+
let(:current_api_user) { shipped_order.user }
|
220
|
+
let(:shipped_order) { create(:shipped_order, payment_type: :check_payment) }
|
221
|
+
|
222
|
+
before { subject }
|
223
|
+
|
224
|
+
it 'does not try to render a nil source' do
|
225
|
+
expect(json_response['shipments'][0]['order']['payments'][0]['source']).to eq(nil)
|
226
|
+
end
|
227
|
+
end
|
215
228
|
end
|
216
229
|
|
217
230
|
context 'with filtering' do
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Spree
|
4
6
|
describe Api::StockItemsController, type: :request do
|
5
|
-
|
6
7
|
let!(:stock_location) { create(:stock_location_with_items) }
|
7
8
|
let!(:stock_item) { stock_location.stock_items.order(:id).first }
|
8
9
|
let!(:attributes) {
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Spree
|
4
6
|
describe Api::StockLocationsController, type: :request do
|
5
|
-
|
6
7
|
let!(:stock_location) { create(:stock_location) }
|
7
8
|
let!(:attributes) { [:id, :name, :address1, :address2, :city, :state_id, :state_name, :country_id, :zipcode, :phone, :active] }
|
8
9
|
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Spree
|
4
6
|
describe Api::StockMovementsController, type: :request do
|
5
|
-
|
6
7
|
let!(:stock_location) { create(:stock_location_with_items) }
|
7
8
|
let!(:stock_item) { stock_location.stock_items.order(:id).first }
|
8
9
|
let!(:stock_movement) { create(:stock_movement, stock_item: stock_item) }
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
module Spree
|
4
6
|
describe Api::StoresController, type: :request do
|
5
|
-
|
6
7
|
let!(:store) do
|
7
8
|
create(:store, name: "My Spree Store", url: "spreestore.example.com")
|
8
9
|
end
|
@@ -18,8 +19,7 @@ module Spree
|
|
18
19
|
create(:store,
|
19
20
|
name: "Extra Store",
|
20
21
|
url: "spreestore-5.example.com",
|
21
|
-
default: false
|
22
|
-
)
|
22
|
+
default: false)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "can list the available stores" do
|
@@ -35,7 +35,8 @@ module Spree
|
|
35
35
|
"mail_from_address" => "spree@example.org",
|
36
36
|
"default_currency" => nil,
|
37
37
|
"code" => store.code,
|
38
|
-
"default" => true
|
38
|
+
"default" => true,
|
39
|
+
"available_locales" => ["en"]
|
39
40
|
},
|
40
41
|
{
|
41
42
|
"id" => non_default_store.id,
|
@@ -47,7 +48,8 @@ module Spree
|
|
47
48
|
"mail_from_address" => "spree@example.org",
|
48
49
|
"default_currency" => nil,
|
49
50
|
"code" => non_default_store.code,
|
50
|
-
"default" => false
|
51
|
+
"default" => false,
|
52
|
+
"available_locales" => ["en"]
|
51
53
|
}
|
52
54
|
])
|
53
55
|
end
|
@@ -64,7 +66,8 @@ module Spree
|
|
64
66
|
"mail_from_address" => "spree@example.org",
|
65
67
|
"default_currency" => nil,
|
66
68
|
"code" => store.code,
|
67
|
-
"default" => true
|
69
|
+
"default" => true,
|
70
|
+
"available_locales" => ["en"]
|
68
71
|
)
|
69
72
|
end
|
70
73
|
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Spree
|
4
6
|
describe Api::TaxonomiesController, type: :request do
|
5
|
-
|
6
7
|
let(:taxonomy) { create(:taxonomy) }
|
7
8
|
let(:taxon) { create(:taxon, name: "Ruby", taxonomy: taxonomy) }
|
8
9
|
let(:taxon2) { create(:taxon, name: "Rails", taxonomy: taxonomy) }
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Spree
|
4
6
|
describe Api::TaxonsController, type: :request do
|
5
|
-
|
6
7
|
let(:taxonomy) { create(:taxonomy) }
|
7
8
|
let(:taxon) { create(:taxon, name: "Ruby", taxonomy: taxonomy) }
|
8
9
|
let(:taxon2) { create(:taxon, name: "Rails", taxonomy: taxonomy) }
|
@@ -1,11 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'shared_examples/protect_product_actions'
|
2
4
|
require 'spec_helper'
|
3
5
|
|
4
6
|
module Spree
|
5
7
|
describe Spree::Api::ProductsController, type: :request do
|
6
|
-
|
7
8
|
let!(:product) { create(:product) }
|
8
|
-
let(:attributes) { [:id, :name, :description, :price, :available_on, :slug, :meta_description, :meta_keywords, :taxon_ids] }
|
9
|
+
let(:attributes) { [:id, :name, :description, :price, :available_on, :slug, :meta_description, :meta_keywords, :taxon_ids, :meta_title] }
|
9
10
|
|
10
11
|
context "without authentication" do
|
11
12
|
before { Spree::Api::Config[:requires_authentication] = false }
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Spree
|
4
6
|
describe Api::UsersController, type: :request do
|
5
|
-
|
6
7
|
let(:user) { create(:user, spree_api_key: SecureRandom.hex) }
|
7
8
|
let(:stranger) { create(:user, email: 'stranger@example.com') }
|
8
9
|
let(:attributes) { [:id, :email, :created_at, :updated_at] }
|
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
module Spree
|
4
6
|
describe Api::VariantsController, type: :request do
|
5
|
-
|
6
7
|
let!(:product) { create(:product) }
|
7
8
|
let!(:variant) do
|
8
9
|
variant = product.master
|
@@ -87,7 +88,6 @@ module Spree
|
|
87
88
|
end
|
88
89
|
|
89
90
|
context "stock filtering" do
|
90
|
-
|
91
91
|
context "only variants in stock" do
|
92
92
|
subject { get spree.api_variants_path, params: { in_stock_only: "true" } }
|
93
93
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
if ENV["COVERAGE"]
|
2
4
|
require 'simplecov'
|
3
5
|
SimpleCov.start('rails')
|
@@ -9,7 +11,7 @@ ENV["RAILS_ENV"] ||= 'test'
|
|
9
11
|
require 'solidus_api'
|
10
12
|
require 'spree/testing_support/dummy_app'
|
11
13
|
DummyApp.setup(
|
12
|
-
gem_root: File.expand_path('
|
14
|
+
gem_root: File.expand_path('..', __dir__),
|
13
15
|
lib_name: 'solidus_api'
|
14
16
|
)
|
15
17
|
|
@@ -1,7 +1,9 @@
|
|
1
1
|
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
json.widgets(@collection) do |widget|
|
3
5
|
json.partial!("spree/api/widgets/widget", widget: widget)
|
4
6
|
end
|
5
7
|
json.count @collection.count
|
6
|
-
json.current_page
|
8
|
+
json.current_page(params[:page] || 1)
|
7
9
|
json.pages @collection.total_pages
|