solidus_api 2.10.2 → 2.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/controllers/spree/api/addresses_controller.rb +1 -1
- data/app/controllers/spree/api/base_controller.rb +11 -3
- data/app/controllers/spree/api/checkouts_controller.rb +1 -11
- data/app/controllers/spree/api/countries_controller.rb +2 -2
- data/app/controllers/spree/api/credit_cards_controller.rb +2 -2
- data/app/controllers/spree/api/customer_returns_controller.rb +67 -0
- data/app/controllers/spree/api/images_controller.rb +4 -4
- data/app/controllers/spree/api/inventory_units_controller.rb +1 -1
- data/app/controllers/spree/api/option_types_controller.rb +3 -3
- data/app/controllers/spree/api/option_values_controller.rb +2 -2
- data/app/controllers/spree/api/orders_controller.rb +1 -1
- data/app/controllers/spree/api/payments_controller.rb +1 -1
- data/app/controllers/spree/api/product_properties_controller.rb +9 -14
- data/app/controllers/spree/api/promotions_controller.rb +3 -12
- data/app/controllers/spree/api/properties_controller.rb +3 -3
- data/app/controllers/spree/api/resource_controller.rb +2 -2
- data/app/controllers/spree/api/return_authorizations_controller.rb +3 -3
- data/app/controllers/spree/api/shipments_controller.rb +1 -1
- data/app/controllers/spree/api/states_controller.rb +3 -3
- data/app/controllers/spree/api/stock_items_controller.rb +2 -2
- data/app/controllers/spree/api/stock_locations_controller.rb +3 -3
- data/app/controllers/spree/api/stock_movements_controller.rb +3 -3
- data/app/controllers/spree/api/stores_controller.rb +3 -3
- data/app/controllers/spree/api/taxonomies_controller.rb +2 -2
- data/app/controllers/spree/api/taxons_controller.rb +4 -4
- data/app/controllers/spree/api/users_controller.rb +13 -0
- data/app/controllers/spree/api/variants_controller.rb +3 -3
- data/app/controllers/spree/api/zones_controller.rb +2 -2
- data/app/helpers/spree/api/api_helpers.rb +18 -5
- data/app/views/spree/api/customer_returns/index.json.jbuilder +6 -0
- data/app/views/spree/api/customer_returns/new.json.jbuilder +4 -0
- data/app/views/spree/api/customer_returns/show.json.jbuilder +3 -0
- data/app/views/spree/api/errors/could_not_transition.json.jbuilder +4 -0
- data/app/views/spree/api/orders/could_not_transition.json.jbuilder +5 -0
- data/config/locales/en.yml +2 -0
- data/config/routes.rb +6 -3
- data/lib/spree/api/testing_support/helpers.rb +11 -2
- data/openapi/authentication.md +9 -1
- data/openapi/checkout-flow.md +17 -4
- data/openapi/main.hub.yml +1 -1
- data/openapi/solidus-api.oas.yml +6753 -0
- data/solidus_api.gemspec +19 -19
- metadata +17 -117
- data/openapi/api.oas2.yml +0 -6108
- data/script/rails +0 -10
- data/spec/controllers/spree/api/base_controller_spec.rb +0 -118
- data/spec/controllers/spree/api/resource_controller_spec.rb +0 -190
- data/spec/features/checkout_spec.rb +0 -192
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/lib/spree_api_responders_spec.rb +0 -10
- data/spec/models/spree/legacy_user_spec.rb +0 -103
- data/spec/requests/api/address_books_spec.rb +0 -240
- data/spec/requests/jbuilder_cache_spec.rb +0 -34
- data/spec/requests/ransackable_attributes_spec.rb +0 -79
- data/spec/requests/spree/api/addresses_controller_spec.rb +0 -57
- data/spec/requests/spree/api/checkouts_controller_spec.rb +0 -484
- data/spec/requests/spree/api/classifications_controller_spec.rb +0 -50
- data/spec/requests/spree/api/config_controller_spec.rb +0 -26
- data/spec/requests/spree/api/countries_controller_spec.rb +0 -48
- data/spec/requests/spree/api/coupon_codes_controller_spec.rb +0 -105
- data/spec/requests/spree/api/credit_cards_controller_spec.rb +0 -105
- data/spec/requests/spree/api/images_controller_spec.rb +0 -99
- data/spec/requests/spree/api/inventory_units_controller_spec.rb +0 -55
- data/spec/requests/spree/api/line_items_controller_spec.rb +0 -213
- data/spec/requests/spree/api/option_types_controller_spec.rb +0 -116
- data/spec/requests/spree/api/option_values_controller_spec.rb +0 -138
- data/spec/requests/spree/api/orders_controller_spec.rb +0 -954
- data/spec/requests/spree/api/payments_controller_spec.rb +0 -259
- data/spec/requests/spree/api/product_properties_controller_spec.rb +0 -114
- data/spec/requests/spree/api/products_controller_spec.rb +0 -422
- data/spec/requests/spree/api/promotion_application_spec.rb +0 -50
- data/spec/requests/spree/api/promotions_controller_spec.rb +0 -67
- data/spec/requests/spree/api/properties_controller_spec.rb +0 -102
- data/spec/requests/spree/api/return_authorizations_controller_spec.rb +0 -180
- data/spec/requests/spree/api/shipments_controller_spec.rb +0 -532
- data/spec/requests/spree/api/states_controller_spec.rb +0 -69
- data/spec/requests/spree/api/stock_items_controller_spec.rb +0 -311
- data/spec/requests/spree/api/stock_locations_controller_spec.rb +0 -170
- data/spec/requests/spree/api/stock_movements_controller_spec.rb +0 -81
- data/spec/requests/spree/api/store_credit_events_controller_spec.rb +0 -59
- data/spec/requests/spree/api/stores_controller_spec.rb +0 -134
- data/spec/requests/spree/api/taxonomies_controller_spec.rb +0 -114
- data/spec/requests/spree/api/taxons_controller_spec.rb +0 -217
- data/spec/requests/spree/api/unauthenticated_products_controller_spec.rb +0 -27
- data/spec/requests/spree/api/users_controller_spec.rb +0 -151
- data/spec/requests/spree/api/variants_controller_spec.rb +0 -340
- data/spec/requests/spree/api/zones_controller_spec.rb +0 -89
- data/spec/shared_examples/protect_product_actions.rb +0 -18
- data/spec/spec_helper.rb +0 -73
- data/spec/support/be_paginated_matcher.rb +0 -9
- data/spec/support/controller_hacks.rb +0 -43
- data/spec/support/database_cleaner.rb +0 -16
- data/spec/support/have_attributes_matcher.rb +0 -11
- data/spec/test_views/spree/api/widgets/_widget.json.jbuilder +0 -3
- data/spec/test_views/spree/api/widgets/index.json.jbuilder +0 -9
- data/spec/test_views/spree/api/widgets/new.json.jbuilder +0 -3
- data/spec/test_views/spree/api/widgets/show.json.jbuilder +0 -3
@@ -1,89 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
module Spree
|
6
|
-
describe Api::ZonesController, type: :request do
|
7
|
-
let!(:attributes) { [:id, :name, :zone_members] }
|
8
|
-
let!(:zone) { create(:zone, name: 'Europe') }
|
9
|
-
|
10
|
-
before do
|
11
|
-
stub_authentication!
|
12
|
-
end
|
13
|
-
|
14
|
-
it "gets list of zones" do
|
15
|
-
get spree.api_zones_path
|
16
|
-
expect(json_response['zones'].first).to have_attributes(attributes)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'can control the page size through a parameter' do
|
20
|
-
create(:zone)
|
21
|
-
get spree.api_zones_path, params: { per_page: 1 }
|
22
|
-
expect(json_response['count']).to eq(1)
|
23
|
-
expect(json_response['current_page']).to eq(1)
|
24
|
-
expect(json_response['pages']).to eq(2)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'can query the results through a paramter' do
|
28
|
-
expected_result = create(:zone, name: 'South America')
|
29
|
-
get spree.api_zones_path, params: { q: { name_cont: 'south' } }
|
30
|
-
expect(json_response['count']).to eq(1)
|
31
|
-
expect(json_response['zones'].first['name']).to eq expected_result.name
|
32
|
-
end
|
33
|
-
|
34
|
-
it "gets a zone" do
|
35
|
-
get spree.api_zone_path(zone)
|
36
|
-
expect(json_response).to have_attributes(attributes)
|
37
|
-
expect(json_response['name']).to eq zone.name
|
38
|
-
expect(json_response['zone_members'].size).to eq zone.zone_members.count
|
39
|
-
end
|
40
|
-
|
41
|
-
context "as an admin" do
|
42
|
-
sign_in_as_admin!
|
43
|
-
|
44
|
-
it "can create a new zone" do
|
45
|
-
params = {
|
46
|
-
zone: {
|
47
|
-
name: "North Pole",
|
48
|
-
zone_members: [
|
49
|
-
{
|
50
|
-
zoneable_type: "Spree::Country",
|
51
|
-
zoneable_id: 1
|
52
|
-
}
|
53
|
-
]
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
post spree.api_zones_path, params: params
|
58
|
-
expect(response.status).to eq(201)
|
59
|
-
expect(json_response).to have_attributes(attributes)
|
60
|
-
expect(json_response["zone_members"]).not_to be_empty
|
61
|
-
end
|
62
|
-
|
63
|
-
it "updates a zone" do
|
64
|
-
params = {
|
65
|
-
zone: {
|
66
|
-
name: "North Pole",
|
67
|
-
zone_members: [
|
68
|
-
{
|
69
|
-
zoneable_type: "Spree::Country",
|
70
|
-
zoneable_id: 1
|
71
|
-
}
|
72
|
-
]
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
put spree.api_zone_path(zone), params: params
|
77
|
-
expect(response.status).to eq(200)
|
78
|
-
expect(json_response['name']).to eq 'North Pole'
|
79
|
-
expect(json_response['zone_members']).not_to be_blank
|
80
|
-
end
|
81
|
-
|
82
|
-
it "can delete a zone" do
|
83
|
-
delete spree.api_zone_path(zone)
|
84
|
-
expect(response.status).to eq(204)
|
85
|
-
expect { zone.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
shared_examples "modifying product actions are restricted" do
|
4
|
-
it "cannot create a new product if not an admin" do
|
5
|
-
post spree.api_products_path, params: { product: { name: "Brand new product!" } }
|
6
|
-
assert_unauthorized!
|
7
|
-
end
|
8
|
-
|
9
|
-
it "cannot update a product" do
|
10
|
-
put spree.api_product_path(product), params: { product: { name: "I hacked your store!" } }
|
11
|
-
assert_unauthorized!
|
12
|
-
end
|
13
|
-
|
14
|
-
it "cannot delete a product" do
|
15
|
-
delete spree.api_product_path(product)
|
16
|
-
assert_unauthorized!
|
17
|
-
end
|
18
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
if ENV["COVERAGE"]
|
4
|
-
require 'simplecov'
|
5
|
-
SimpleCov.start('rails')
|
6
|
-
end
|
7
|
-
|
8
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
9
|
-
ENV["RAILS_ENV"] ||= 'test'
|
10
|
-
|
11
|
-
require 'solidus_api'
|
12
|
-
require 'spree/testing_support/dummy_app'
|
13
|
-
DummyApp.setup(
|
14
|
-
gem_root: File.expand_path('..', __dir__),
|
15
|
-
lib_name: 'solidus_api'
|
16
|
-
)
|
17
|
-
|
18
|
-
require 'rails-controller-testing'
|
19
|
-
require 'rspec/rails'
|
20
|
-
require 'rspec-activemodel-mocks'
|
21
|
-
|
22
|
-
require 'database_cleaner'
|
23
|
-
require 'with_model'
|
24
|
-
|
25
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
26
|
-
# in spec/support/ and its subdirectories.
|
27
|
-
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each { |f| require f }
|
28
|
-
|
29
|
-
require 'spree/testing_support/partial_double_verification'
|
30
|
-
require 'spree/testing_support/factories'
|
31
|
-
require 'spree/testing_support/preferences'
|
32
|
-
require 'spree/testing_support/authorization_helpers'
|
33
|
-
|
34
|
-
require 'spree/api/testing_support/caching'
|
35
|
-
require 'spree/api/testing_support/helpers'
|
36
|
-
require 'spree/api/testing_support/setup'
|
37
|
-
|
38
|
-
ActiveJob::Base.queue_adapter = :test
|
39
|
-
|
40
|
-
RSpec.configure do |config|
|
41
|
-
config.backtrace_exclusion_patterns = [/gems\/activesupport/, /gems\/actionpack/, /gems\/rspec/]
|
42
|
-
config.color = true
|
43
|
-
config.infer_spec_type_from_file_location!
|
44
|
-
config.expect_with :rspec do |c|
|
45
|
-
c.syntax = :expect
|
46
|
-
end
|
47
|
-
config.mock_with :rspec do |c|
|
48
|
-
c.syntax = :expect
|
49
|
-
end
|
50
|
-
|
51
|
-
config.include FactoryBot::Syntax::Methods
|
52
|
-
config.include Spree::Api::TestingSupport::Helpers, type: :request
|
53
|
-
config.extend Spree::Api::TestingSupport::Setup, type: :request
|
54
|
-
config.include Spree::Api::TestingSupport::Helpers, type: :controller
|
55
|
-
config.extend Spree::Api::TestingSupport::Setup, type: :controller
|
56
|
-
config.include Spree::TestingSupport::Preferences
|
57
|
-
|
58
|
-
config.extend WithModel
|
59
|
-
|
60
|
-
config.before(:each) do
|
61
|
-
Rails.cache.clear
|
62
|
-
end
|
63
|
-
|
64
|
-
config.include ActiveJob::TestHelper
|
65
|
-
|
66
|
-
config.use_transactional_fixtures = true
|
67
|
-
|
68
|
-
config.example_status_persistence_file_path = "./spec/examples.txt"
|
69
|
-
|
70
|
-
config.order = :random
|
71
|
-
|
72
|
-
Kernel.srand config.seed
|
73
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'active_support/all'
|
4
|
-
|
5
|
-
module ControllerHacks
|
6
|
-
extend ActiveSupport::Concern
|
7
|
-
|
8
|
-
included do
|
9
|
-
routes { Spree::Core::Engine.routes }
|
10
|
-
end
|
11
|
-
|
12
|
-
def api_get(action, params = {}, session = nil, flash = nil)
|
13
|
-
api_process(action, params, session, flash, "GET")
|
14
|
-
end
|
15
|
-
|
16
|
-
def api_post(action, params = {}, session = nil, flash = nil)
|
17
|
-
api_process(action, params, session, flash, "POST")
|
18
|
-
end
|
19
|
-
|
20
|
-
def api_put(action, params = {}, session = nil, flash = nil)
|
21
|
-
api_process(action, params, session, flash, "PUT")
|
22
|
-
end
|
23
|
-
|
24
|
-
def api_delete(action, params = {}, session = nil, flash = nil)
|
25
|
-
api_process(action, params, session, flash, "DELETE")
|
26
|
-
end
|
27
|
-
|
28
|
-
def api_process(action, params = {}, session = nil, flash = nil, method = "get")
|
29
|
-
scoping = respond_to?(:resource_scoping) ? resource_scoping : {}
|
30
|
-
process(
|
31
|
-
action,
|
32
|
-
method: method,
|
33
|
-
params: params.merge(scoping),
|
34
|
-
session: session,
|
35
|
-
flash: flash,
|
36
|
-
format: :json
|
37
|
-
)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
RSpec.configure do |config|
|
42
|
-
config.include ControllerHacks, type: :controller
|
43
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.configure do |config|
|
4
|
-
config.before(:suite) do
|
5
|
-
DatabaseCleaner.strategy = :transaction
|
6
|
-
DatabaseCleaner.clean_with(:truncation)
|
7
|
-
end
|
8
|
-
|
9
|
-
config.before(:each) do
|
10
|
-
DatabaseCleaner.start
|
11
|
-
end
|
12
|
-
|
13
|
-
config.after(:each) do
|
14
|
-
DatabaseCleaner.clean
|
15
|
-
end
|
16
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
RSpec::Matchers.define :have_attributes do |expected_attributes|
|
5
|
-
match do |actual|
|
6
|
-
# actual is a Hash object representing an object, like this:
|
7
|
-
# { "name" => "Product #1" }
|
8
|
-
actual_attributes = actual.keys.map(&:to_sym)
|
9
|
-
expected_attributes.map(&:to_sym).all? { |attr| actual_attributes.include?(attr) }
|
10
|
-
end
|
11
|
-
end
|