solidus_graphql_api 0.2.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/.circleci/config.yml +42 -82
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +1 -167
- data/CONTRIBUTING.md +5 -5
- data/Gemfile +6 -1
- data/Gemfile-local +1 -0
- data/OLD_CHANGELOG.md +170 -0
- data/README.md +4 -4
- data/Rakefile +1 -0
- data/bin/sandbox +2 -6
- data/lib/solidus_graphql_api/batch_loader.rb +1 -1
- data/lib/solidus_graphql_api/context.rb +2 -2
- data/lib/solidus_graphql_api/queries/taxon/children_query.rb +1 -1
- data/lib/solidus_graphql_api/queries/taxonomy/taxons_query.rb +1 -1
- data/lib/solidus_graphql_api/version.rb +1 -1
- data/solidus_graphql_api.gemspec +5 -7
- data/spec/integration/mutations/checkout/add_addresses_to_checkout_spec.rb +1 -1
- data/spec/integration/queries/countries_spec.rb +2 -2
- data/spec/integration/queries/current_user_spec.rb +7 -2
- data/spec/integration/queries/taxonomies_spec.rb +5 -2
- data/spec/lib/solidus_graphql_api/batch_loader/belongs_to_spec.rb +24 -25
- data/spec/lib/solidus_graphql_api/batch_loader/has_many_spec.rb +17 -15
- data/spec/lib/solidus_graphql_api/batch_loader/has_many_through_spec.rb +23 -18
- data/spec/lib/solidus_graphql_api/batch_loader/has_one_spec.rb +17 -15
- data/spec/lib/solidus_graphql_api/queries/taxon/children_query_spec.rb +9 -5
- data/spec/lib/solidus_graphql_api/queries/taxonomy/taxons_query_spec.rb +8 -5
- data/spec/spec_helper.rb +6 -4
- data/spec/support/helpers/active_record.rb +18 -0
- data/spec/support/helpers/graphql.rb +4 -4
- metadata +16 -40
    
        data/README.md
    CHANGED
    
    | @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            # SolidusGraphqlApi
         | 
| 2 2 |  | 
| 3 | 
            -
            [](https://codeclimate.com/github/solidusio | 
| 4 | 
            -
            [](https://codeclimate.com/github/solidusio | 
| 5 | 
            -
            [](https://codeclimate.com/github/solidusio/solidus_graphql_api/maintainability)
         | 
| 4 | 
            +
            [](https://codeclimate.com/github/solidusio/solidus_graphql_api/test_coverage)
         | 
| 5 | 
            +
            [](https://circleci.com/gh/solidusio/solidus_graphql_api)
         | 
| 6 6 | 
             
            [](https://badge.fury.io/rb/solidus_graphql_api)
         | 
| 7 7 |  | 
| 8 8 | 
             
            Provides a [graphql](https://graphql.org/) api for the [Solidus](https://github.com/solidusio/solidus) ecommerce framework.
         | 
| @@ -36,7 +36,7 @@ POST http://localhost:3000/graphql | |
| 36 36 |  | 
| 37 37 | 
             
            ## Documentation
         | 
| 38 38 |  | 
| 39 | 
            -
            The Solidus GraphQL API documentation can be found [here](https://solidusio | 
| 39 | 
            +
            The Solidus GraphQL API documentation can be found [here](https://solidusio.github.io/solidus_graphql_api/docs/).
         | 
| 40 40 |  | 
| 41 41 | 
             
            ## Customizations
         | 
| 42 42 |  | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/bin/sandbox
    CHANGED
    
    | @@ -22,7 +22,7 @@ if [ ! -z $SOLIDUS_BRANCH ] | |
| 22 22 | 
             
            then
         | 
| 23 23 | 
             
              BRANCH=$SOLIDUS_BRANCH
         | 
| 24 24 | 
             
            else
         | 
| 25 | 
            -
              BRANCH=" | 
| 25 | 
            +
              BRANCH="main"
         | 
| 26 26 | 
             
            fi
         | 
| 27 27 |  | 
| 28 28 | 
             
            extension_name="solidus_graphql_api"
         | 
| @@ -50,7 +50,6 @@ fi | |
| 50 50 | 
             
            cd ./sandbox
         | 
| 51 51 | 
             
            cat <<RUBY >> Gemfile
         | 
| 52 52 | 
             
            gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
         | 
| 53 | 
            -
            gem 'solidus_auth_devise', '>= 2.1.0'
         | 
| 54 53 | 
             
            gem 'rails-i18n'
         | 
| 55 54 | 
             
            gem 'solidus_i18n'
         | 
| 56 55 |  | 
| @@ -69,13 +68,10 @@ unbundled bundle exec rake db:drop db:create | |
| 69 68 |  | 
| 70 69 | 
             
            unbundled bundle exec rails generate solidus:install \
         | 
| 71 70 | 
             
              --auto-accept \
         | 
| 72 | 
            -
              -- | 
| 73 | 
            -
              --enforce_available_locales=true \
         | 
| 74 | 
            -
              --with-authentication=false \
         | 
| 71 | 
            +
              --authentication=devise \
         | 
| 75 72 | 
             
              --payment-method=none \
         | 
| 76 73 | 
             
              $@
         | 
| 77 74 |  | 
| 78 | 
            -
            unbundled bundle exec rails generate solidus:auth:install
         | 
| 79 75 | 
             
            unbundled bundle exec rails generate ${extension_name}:install
         | 
| 80 76 |  | 
| 81 77 | 
             
            echo
         | 
| @@ -108,7 +108,7 @@ module SolidusGraphqlApi | |
| 108 108 | 
             
                end
         | 
| 109 109 |  | 
| 110 110 | 
             
                def graphql_loader_for(object_id, options = {}, &block)
         | 
| 111 | 
            -
                  ::BatchLoader::GraphQL.for(object_id).batch(default_options.merge(options), &block)
         | 
| 111 | 
            +
                  ::BatchLoader::GraphQL.for(object_id).batch(**default_options.merge(options), &block)
         | 
| 112 112 | 
             
                end
         | 
| 113 113 | 
             
              end
         | 
| 114 114 | 
             
            end
         | 
| @@ -3,7 +3,7 @@ | |
| 3 3 | 
             
            module SolidusGraphqlApi
         | 
| 4 4 | 
             
              class Context
         | 
| 5 5 | 
             
                AUTHORIZATION_HEADER = "Authorization"
         | 
| 6 | 
            -
                TOKEN_PATTERN = /^Bearer (?<token>.*) | 
| 6 | 
            +
                TOKEN_PATTERN = /^Bearer (?<token>.*)/
         | 
| 7 7 |  | 
| 8 8 | 
             
                attr_reader :request, :headers
         | 
| 9 9 |  | 
| @@ -23,7 +23,7 @@ module SolidusGraphqlApi | |
| 23 23 |  | 
| 24 24 | 
             
                def current_user
         | 
| 25 25 | 
             
                  @current_user ||= begin
         | 
| 26 | 
            -
                    return nil  | 
| 26 | 
            +
                    return nil if bearer_token.blank?
         | 
| 27 27 |  | 
| 28 28 | 
             
                    Spree.user_class.find_by(spree_api_key: bearer_token)
         | 
| 29 29 | 
             
                  end
         | 
    
        data/solidus_graphql_api.gemspec
    CHANGED
    
    | @@ -10,14 +10,14 @@ Gem::Specification.new do |spec| | |
| 10 10 |  | 
| 11 11 | 
             
              spec.summary = 'Solidus GraphQL API'
         | 
| 12 12 | 
             
              spec.description = 'GraphQL comes to Solidus'
         | 
| 13 | 
            -
              spec.homepage = 'https://github.com/solidusio | 
| 13 | 
            +
              spec.homepage = 'https://github.com/solidusio/solidus_graphql_api'
         | 
| 14 14 | 
             
              spec.license = 'BSD-3-Clause'
         | 
| 15 15 |  | 
| 16 16 | 
             
              spec.metadata['homepage_uri'] = spec.homepage
         | 
| 17 | 
            -
              spec.metadata['source_code_uri'] = 'https://github.com/solidusio | 
| 18 | 
            -
              spec.metadata['changelog_uri'] = 'https://github.com/solidusio | 
| 17 | 
            +
              spec.metadata['source_code_uri'] = 'https://github.com/solidusio/solidus_graphql_api'
         | 
| 18 | 
            +
              spec.metadata['changelog_uri'] = 'https://github.com/solidusio/solidus_graphql_api/releases'
         | 
| 19 19 |  | 
| 20 | 
            -
              spec.required_ruby_version = Gem::Requirement.new('~>  | 
| 20 | 
            +
              spec.required_ruby_version = Gem::Requirement.new('~> 3.0')
         | 
| 21 21 |  | 
| 22 22 | 
             
              # Specify which files should be added to the gem when it is released.
         | 
| 23 23 | 
             
              # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
         | 
| @@ -31,8 +31,7 @@ Gem::Specification.new do |spec| | |
| 31 31 |  | 
| 32 32 | 
             
              spec.add_dependency 'batch-loader', '~> 2.0'
         | 
| 33 33 | 
             
              spec.add_dependency 'graphql', '>= 1.10', '< 1.13'
         | 
| 34 | 
            -
              spec.add_dependency ' | 
| 35 | 
            -
              spec.add_dependency 'solidus_core', ['>= 2.10', '< 4']
         | 
| 34 | 
            +
              spec.add_dependency 'solidus_core', ['>= 3.2', '< 5']
         | 
| 36 35 | 
             
              spec.add_dependency 'solidus_support', '~> 0.6'
         | 
| 37 36 |  | 
| 38 37 | 
             
              spec.add_development_dependency 'graphql-docs', '~> 2.0.1'
         | 
| @@ -41,5 +40,4 @@ Gem::Specification.new do |spec| | |
| 41 40 | 
             
              spec.add_development_dependency 'simplecov', '~> 0.21'
         | 
| 42 41 | 
             
              spec.add_development_dependency 'solidus_dev_support', '~> 2.4'
         | 
| 43 42 | 
             
              spec.add_development_dependency 'timecop', '~> 0.9.1'
         | 
| 44 | 
            -
              spec.add_development_dependency 'with_model', '~> 2.1.2'
         | 
| 45 43 | 
             
            end
         | 
| @@ -13,7 +13,7 @@ RSpec.describe_mutation :add_addresses_to_checkout, mutation: :add_addresses_to_ | |
| 13 13 | 
             
                ]
         | 
| 14 14 | 
             
              }
         | 
| 15 15 |  | 
| 16 | 
            -
              let(:country_id) { SolidusGraphqlApi::Schema.id_from_object(create(:country), nil, nil) }
         | 
| 16 | 
            +
              let(:country_id) { SolidusGraphqlApi::Schema.id_from_object(create(:country, states_required: false), nil, nil) }
         | 
| 17 17 | 
             
              let(:address) {
         | 
| 18 18 | 
             
                address = build_stubbed(:address).slice(:address1, :city, :phone, :zipcode)
         | 
| 19 19 | 
             
                address[:countryId] = country_id
         | 
| @@ -9,8 +9,8 @@ RSpec.describe_query :countries, query: :countries, freeze_date: true do | |
| 9 9 | 
             
                end
         | 
| 10 10 |  | 
| 11 11 | 
             
                context 'when countries exists' do
         | 
| 12 | 
            -
                  let!(:us_country) { create(:country, :with_states, id: 1) }
         | 
| 13 | 
            -
                  let!(:it_country) { create(:country, id: 2, iso: 'IT') }
         | 
| 12 | 
            +
                  let!(:us_country) { create(:country, :with_states, id: 1, states_required: false) }
         | 
| 13 | 
            +
                  let!(:it_country) { create(:country, id: 2, iso: 'IT', states_required: false) }
         | 
| 14 14 |  | 
| 15 15 | 
             
                  it { is_expected.to match_response(:countries) }
         | 
| 16 16 | 
             
                end
         | 
| @@ -12,8 +12,13 @@ RSpec.describe_query :current_user, query: :current_user, freeze_date: true do | |
| 12 12 | 
             
                       bill_address: bill_address)
         | 
| 13 13 | 
             
              }
         | 
| 14 14 |  | 
| 15 | 
            -
               | 
| 16 | 
            -
               | 
| 15 | 
            +
              # Previos to Solidus v3.3, states_required was always false and the state was
         | 
| 16 | 
            +
              # always automatically assigned. We force the behavior here to have the same
         | 
| 17 | 
            +
              # response for any Solidus version.
         | 
| 18 | 
            +
              let(:country) { create(:country, states_required: false) }
         | 
| 19 | 
            +
              let(:state) { create(:state, name: "Alabama", abbr: "AL", country: country) }
         | 
| 20 | 
            +
              let(:ship_address) { create(:ship_address, id: 1, zipcode: 10_001, country: country, state: state) }
         | 
| 21 | 
            +
              let(:bill_address) { create(:bill_address, id: 2, zipcode: 10_002, country: country, state: state) }
         | 
| 17 22 | 
             
              let(:credit_card) {
         | 
| 18 23 | 
             
                create(:credit_card,
         | 
| 19 24 | 
             
                       user: user,
         | 
| @@ -9,9 +9,12 @@ RSpec.describe_query :taxonomies do | |
| 9 9 | 
             
                end
         | 
| 10 10 |  | 
| 11 11 | 
             
                context 'when taxonomies exists' do
         | 
| 12 | 
            -
                  let!(:brand_taxonomy)  | 
| 12 | 
            +
                  let!(:brand_taxonomy) do
         | 
| 13 | 
            +
                    create(:taxonomy, :with_taxon_meta, :with_root_icon, id: 1, name: "Brand", root_taxon_id: 1)
         | 
| 14 | 
            +
                  end
         | 
| 13 15 | 
             
                  let!(:category_taxonomy) { create(:taxonomy, :with_root_icon, id: 2, name: 'Category', root_taxon_id: 2) }
         | 
| 14 | 
            -
                   | 
| 16 | 
            +
                  # Need to reload taxon to get the correct icon url, because the icon is attached after the taxon is created
         | 
| 17 | 
            +
                  let!(:taxon) { create(:taxon, :with_icon, id: 3, name: 'Solidus', taxonomy: brand_taxonomy).tap(&:reload) }
         | 
| 15 18 |  | 
| 16 19 | 
             
                  before do
         | 
| 17 20 | 
             
                    taxon.update(parent: brand_taxonomy.root)
         | 
| @@ -2,7 +2,9 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            require 'spec_helper'
         | 
| 4 4 |  | 
| 5 | 
            -
            RSpec.describe SolidusGraphqlApi::BatchLoader::BelongsTo do
         | 
| 5 | 
            +
            RSpec.describe SolidusGraphqlApi::BatchLoader::BelongsTo, skip: (ENV["DB"] == "mysql") do
         | 
| 6 | 
            +
              include Helpers::ActiveRecord
         | 
| 7 | 
            +
             | 
| 6 8 | 
             
              subject(:loader) do
         | 
| 7 9 | 
             
                described_class.new(
         | 
| 8 10 | 
             
                  object,
         | 
| @@ -14,19 +16,21 @@ RSpec.describe SolidusGraphqlApi::BatchLoader::BelongsTo do | |
| 14 16 | 
             
              let(:options) { {} }
         | 
| 15 17 |  | 
| 16 18 | 
             
              context 'with a regular association' do
         | 
| 17 | 
            -
                 | 
| 18 | 
            -
                   | 
| 19 | 
            -
                     | 
| 19 | 
            +
                before do
         | 
| 20 | 
            +
                  run_migrations do
         | 
| 21 | 
            +
                    create_table :articles, force: true
         | 
| 22 | 
            +
                    create_table :comments, force: true do |t|
         | 
| 23 | 
            +
                      t.belongs_to :article
         | 
| 24 | 
            +
                    end
         | 
| 20 25 | 
             
                  end
         | 
| 26 | 
            +
                  create_model("Article")
         | 
| 27 | 
            +
                  create_model("Comment") { belongs_to :article }
         | 
| 21 28 | 
             
                end
         | 
| 22 29 |  | 
| 23 | 
            -
                 | 
| 24 | 
            -
                   | 
| 25 | 
            -
                     | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
                  model do
         | 
| 29 | 
            -
                    belongs_to :article
         | 
| 30 | 
            +
                after do
         | 
| 31 | 
            +
                  run_migrations do
         | 
| 32 | 
            +
                    drop_table :articles
         | 
| 33 | 
            +
                    drop_table :comments
         | 
| 30 34 | 
             
                  end
         | 
| 31 35 | 
             
                end
         | 
| 32 36 |  | 
| @@ -39,21 +43,16 @@ RSpec.describe SolidusGraphqlApi::BatchLoader::BelongsTo do | |
| 39 43 | 
             
              end
         | 
| 40 44 |  | 
| 41 45 | 
             
              context 'with a polymorphic association' do
         | 
| 42 | 
            -
                 | 
| 43 | 
            -
                   | 
| 44 | 
            -
                     | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
                    belongs_to :imageable, polymorphic: true
         | 
| 50 | 
            -
                  end
         | 
| 51 | 
            -
                end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
                with_model :Article, scope: :all do
         | 
| 54 | 
            -
                  model do
         | 
| 55 | 
            -
                    has_many :images, as: :imageable
         | 
| 46 | 
            +
                before do
         | 
| 47 | 
            +
                  run_migrations do
         | 
| 48 | 
            +
                    create_table :images, force: true do |t|
         | 
| 49 | 
            +
                      t.integer :imageable_id
         | 
| 50 | 
            +
                      t.string :imageable_type
         | 
| 51 | 
            +
                    end
         | 
| 52 | 
            +
                    create_table :articles, force: true
         | 
| 56 53 | 
             
                  end
         | 
| 54 | 
            +
                  create_model("Image") { belongs_to :imageable, polymorphic: true }
         | 
| 55 | 
            +
                  create_model("Article") { has_many :images, as: :imageable }
         | 
| 57 56 | 
             
                end
         | 
| 58 57 |  | 
| 59 58 | 
             
                let!(:object) { Image.create!(imageable: Article.create!) }
         | 
| @@ -2,7 +2,9 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            require 'spec_helper'
         | 
| 4 4 |  | 
| 5 | 
            -
            RSpec.describe SolidusGraphqlApi::BatchLoader::HasMany do
         | 
| 5 | 
            +
            RSpec.describe SolidusGraphqlApi::BatchLoader::HasMany, skip: (ENV["DB"] == "mysql") do
         | 
| 6 | 
            +
              include Helpers::ActiveRecord
         | 
| 7 | 
            +
             | 
| 6 8 | 
             
              subject(:loader) do
         | 
| 7 9 | 
             
                described_class.new(
         | 
| 8 10 | 
             
                  article,
         | 
| @@ -10,28 +12,28 @@ RSpec.describe SolidusGraphqlApi::BatchLoader::HasMany do | |
| 10 12 | 
             
                )
         | 
| 11 13 | 
             
              end
         | 
| 12 14 |  | 
| 13 | 
            -
               | 
| 14 | 
            -
                 | 
| 15 | 
            -
                   | 
| 15 | 
            +
              before do
         | 
| 16 | 
            +
                run_migrations do
         | 
| 17 | 
            +
                  create_table :articles, force: true
         | 
| 18 | 
            +
                  create_table :comments, force: true do |t|
         | 
| 19 | 
            +
                    t.belongs_to :article
         | 
| 20 | 
            +
                  end
         | 
| 16 21 | 
             
                end
         | 
| 17 | 
            -
             | 
| 22 | 
            +
                create_model("Article") { has_many :comments }
         | 
| 23 | 
            +
                create_model("Comment") { belongs_to :article }
         | 
| 18 24 |  | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
                  t.belongs_to :article
         | 
| 22 | 
            -
                end
         | 
| 25 | 
            +
                article.comments.create!
         | 
| 26 | 
            +
              end
         | 
| 23 27 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 28 | 
            +
              after do
         | 
| 29 | 
            +
                run_migrations do
         | 
| 30 | 
            +
                  drop_table :articles
         | 
| 31 | 
            +
                  drop_table :comments
         | 
| 26 32 | 
             
                end
         | 
| 27 33 | 
             
              end
         | 
| 28 34 |  | 
| 29 35 | 
             
              let!(:article) { Article.create! }
         | 
| 30 36 |  | 
| 31 | 
            -
              before do
         | 
| 32 | 
            -
                article.comments.create!
         | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
             | 
| 35 37 | 
             
              it 'loads the association properly' do
         | 
| 36 38 | 
             
                expect(loader.load.sync).to eq(article.comments)
         | 
| 37 39 | 
             
              end
         | 
| @@ -2,7 +2,9 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            require 'spec_helper'
         | 
| 4 4 |  | 
| 5 | 
            -
            RSpec.describe SolidusGraphqlApi::BatchLoader::HasManyThrough do
         | 
| 5 | 
            +
            RSpec.describe SolidusGraphqlApi::BatchLoader::HasManyThrough, skip: (ENV["DB"] == "mysql") do
         | 
| 6 | 
            +
              include Helpers::ActiveRecord
         | 
| 7 | 
            +
             | 
| 6 8 | 
             
              subject(:loader) do
         | 
| 7 9 | 
             
                described_class.new(
         | 
| 8 10 | 
             
                  physician,
         | 
| @@ -10,37 +12,40 @@ RSpec.describe SolidusGraphqlApi::BatchLoader::HasManyThrough do | |
| 10 12 | 
             
                )
         | 
| 11 13 | 
             
              end
         | 
| 12 14 |  | 
| 13 | 
            -
               | 
| 14 | 
            -
                 | 
| 15 | 
            +
              before do
         | 
| 16 | 
            +
                run_migrations do
         | 
| 17 | 
            +
                  create_table :physicians, force: true
         | 
| 18 | 
            +
                  create_table :patients, force: true
         | 
| 19 | 
            +
                  create_table :appointments, force: true do |t|
         | 
| 20 | 
            +
                    t.belongs_to :physician
         | 
| 21 | 
            +
                    t.belongs_to :patient
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
                create_model("Physician") do
         | 
| 15 25 | 
             
                  has_many :appointments
         | 
| 16 26 | 
             
                  has_many :patients, through: :appointments
         | 
| 17 27 | 
             
                end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 20 | 
            -
              with_model :Appointment, scope: :all do
         | 
| 21 | 
            -
                table do |t|
         | 
| 22 | 
            -
                  t.belongs_to :physician, index: { name: :appointment_on_physician }
         | 
| 23 | 
            -
                  t.belongs_to :patient
         | 
| 28 | 
            +
                create_model("Patient") do
         | 
| 29 | 
            +
                  has_many :appointments
         | 
| 24 30 | 
             
                end
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                model do
         | 
| 31 | 
            +
                create_model("Appointment") do
         | 
| 27 32 | 
             
                  belongs_to :physician
         | 
| 28 33 | 
             
                  belongs_to :patient
         | 
| 29 34 | 
             
                end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                physician.appointments.create!(patient: Patient.create!)
         | 
| 30 37 | 
             
              end
         | 
| 31 38 |  | 
| 32 | 
            -
               | 
| 33 | 
            -
                 | 
| 34 | 
            -
                   | 
| 39 | 
            +
              after do
         | 
| 40 | 
            +
                run_migrations do
         | 
| 41 | 
            +
                  drop_table :physicians
         | 
| 42 | 
            +
                  drop_table :patients
         | 
| 43 | 
            +
                  drop_table :appointments
         | 
| 35 44 | 
             
                end
         | 
| 36 45 | 
             
              end
         | 
| 37 46 |  | 
| 38 47 | 
             
              let!(:physician) { Physician.create! }
         | 
| 39 48 |  | 
| 40 | 
            -
              before do
         | 
| 41 | 
            -
                physician.appointments.create!(patient: Patient.create!)
         | 
| 42 | 
            -
              end
         | 
| 43 | 
            -
             | 
| 44 49 | 
             
              it 'loads the association properly' do
         | 
| 45 50 | 
             
                expect(loader.load.sync).to eq(physician.patients)
         | 
| 46 51 | 
             
              end
         | 
| @@ -2,7 +2,9 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            require 'spec_helper'
         | 
| 4 4 |  | 
| 5 | 
            -
            RSpec.describe SolidusGraphqlApi::BatchLoader::HasOne do
         | 
| 5 | 
            +
            RSpec.describe SolidusGraphqlApi::BatchLoader::HasOne, skip: (ENV["DB"] == "mysql") do
         | 
| 6 | 
            +
              include Helpers::ActiveRecord
         | 
| 7 | 
            +
             | 
| 6 8 | 
             
              subject(:loader) do
         | 
| 7 9 | 
             
                described_class.new(
         | 
| 8 10 | 
             
                  article,
         | 
| @@ -10,28 +12,28 @@ RSpec.describe SolidusGraphqlApi::BatchLoader::HasOne do | |
| 10 12 | 
             
                )
         | 
| 11 13 | 
             
              end
         | 
| 12 14 |  | 
| 13 | 
            -
               | 
| 14 | 
            -
                 | 
| 15 | 
            -
                   | 
| 15 | 
            +
              before do
         | 
| 16 | 
            +
                run_migrations do
         | 
| 17 | 
            +
                  create_table :articles, force: true
         | 
| 18 | 
            +
                  create_table :images, force: true do |t|
         | 
| 19 | 
            +
                    t.belongs_to :article
         | 
| 20 | 
            +
                  end
         | 
| 16 21 | 
             
                end
         | 
| 17 | 
            -
             | 
| 22 | 
            +
                create_model("Article") { has_one :image }
         | 
| 23 | 
            +
                create_model("Image") { belongs_to :article }
         | 
| 18 24 |  | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
                  t.belongs_to :article
         | 
| 22 | 
            -
                end
         | 
| 25 | 
            +
                article.create_image!
         | 
| 26 | 
            +
              end
         | 
| 23 27 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 28 | 
            +
              after do
         | 
| 29 | 
            +
                run_migrations do
         | 
| 30 | 
            +
                  drop_table :articles
         | 
| 31 | 
            +
                  drop_table :images
         | 
| 26 32 | 
             
                end
         | 
| 27 33 | 
             
              end
         | 
| 28 34 |  | 
| 29 35 | 
             
              let!(:article) { Article.create! }
         | 
| 30 36 |  | 
| 31 | 
            -
              before do
         | 
| 32 | 
            -
                article.create_image!
         | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
             | 
| 35 37 | 
             
              it 'loads the association properly' do
         | 
| 36 38 | 
             
                expect(loader.load.sync).to eq(article.image)
         | 
| 37 39 | 
             
              end
         | 
| @@ -3,9 +3,13 @@ | |
| 3 3 | 
             
            require 'spec_helper'
         | 
| 4 4 |  | 
| 5 5 | 
             
            RSpec.describe SolidusGraphqlApi::Queries::Taxon::ChildrenQuery do
         | 
| 6 | 
            -
               | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 6 | 
            +
              it do
         | 
| 7 | 
            +
                taxonomy = create(:taxonomy)
         | 
| 8 | 
            +
                root = taxonomy.root
         | 
| 9 | 
            +
                children = [
         | 
| 10 | 
            +
                  create(:taxon, name: "Taxon one", parent: root),
         | 
| 11 | 
            +
                  create(:taxon, name: "Taxon two", parent: root)
         | 
| 12 | 
            +
                ]
         | 
| 13 | 
            +
                expect(described_class.new(taxon: root).call.sync).to match_array(children)
         | 
| 14 | 
            +
              end
         | 
| 11 15 | 
             
            end
         | 
| @@ -3,9 +3,12 @@ | |
| 3 3 | 
             
            require 'spec_helper'
         | 
| 4 4 |  | 
| 5 5 | 
             
            RSpec.describe SolidusGraphqlApi::Queries::Taxonomy::TaxonsQuery do
         | 
| 6 | 
            -
               | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 6 | 
            +
              it do
         | 
| 7 | 
            +
                taxonomy = create(:taxonomy)
         | 
| 8 | 
            +
                root_taxon = taxonomy.root
         | 
| 9 | 
            +
                taxon = create(:taxon, taxonomy: taxonomy, parent: root_taxon)
         | 
| 10 | 
            +
                create(:taxon)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                expect(described_class.new(taxonomy: taxonomy).call.sync).to match_array([root_taxon, taxon])
         | 
| 13 | 
            +
              end
         | 
| 11 14 | 
             
            end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -14,7 +14,6 @@ require dummy_env | |
| 14 14 | 
             
            # Requires factories and other useful helpers defined in spree_core.
         | 
| 15 15 | 
             
            require 'solidus_dev_support/rspec/feature_helper'
         | 
| 16 16 | 
             
            require "graphql/schema_comparator"
         | 
| 17 | 
            -
            require 'with_model'
         | 
| 18 17 | 
             
            require 'timecop'
         | 
| 19 18 |  | 
| 20 19 | 
             
            # Requires supporting ruby files with custom matchers and macros, etc,
         | 
| @@ -35,7 +34,12 @@ RSpec.configure do |config| | |
| 35 34 |  | 
| 36 35 | 
             
              if defined?(ActiveStorage::Current)
         | 
| 37 36 | 
             
                config.before(:all) do
         | 
| 38 | 
            -
                   | 
| 37 | 
            +
                  test_host = 'https://www.example.com'
         | 
| 38 | 
            +
                  if Rails.gem_version >= Gem::Version.new(7)
         | 
| 39 | 
            +
                    ActiveStorage::Current.url_options = { host: test_host }
         | 
| 40 | 
            +
                  else
         | 
| 41 | 
            +
                    ActiveStorage::Current.host = test_host
         | 
| 42 | 
            +
                  end
         | 
| 39 43 | 
             
                end
         | 
| 40 44 | 
             
              end
         | 
| 41 45 |  | 
| @@ -63,6 +67,4 @@ RSpec.configure do |config| | |
| 63 67 | 
             
                  example.run
         | 
| 64 68 | 
             
                end
         | 
| 65 69 | 
             
              end
         | 
| 66 | 
            -
             | 
| 67 | 
            -
              config.extend WithModel
         | 
| 68 70 | 
             
            end
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Helpers
         | 
| 4 | 
            +
              module ActiveRecord
         | 
| 5 | 
            +
                def run_migrations(&block)
         | 
| 6 | 
            +
                  migration = Class.new(::ActiveRecord::Migration[6.1]).tap do |klass|
         | 
| 7 | 
            +
                    klass.define_method(:up, &block)
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
                  ::ActiveRecord::Migration.suppress_messages { migration.migrate(:up) }
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def create_model(name, &block)
         | 
| 13 | 
            +
                  stub_const(name, Class.new(ApplicationRecord)).tap do |klass|
         | 
| 14 | 
            +
                    klass.class_eval(&block) if block_given?
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -14,12 +14,12 @@ module Helpers | |
| 14 14 | 
             
                  JSON.parse(result.to_json, object_class: object_class, symbolize_names: true)
         | 
| 15 15 | 
             
                end
         | 
| 16 16 |  | 
| 17 | 
            -
                def execute_query(*args)
         | 
| 18 | 
            -
                  execute(RSpec.configuration.graphql_queries_dir, *args)
         | 
| 17 | 
            +
                def execute_query(*args, **kwargs)
         | 
| 18 | 
            +
                  execute(RSpec.configuration.graphql_queries_dir, *args, **kwargs)
         | 
| 19 19 | 
             
                end
         | 
| 20 20 |  | 
| 21 | 
            -
                def execute_mutation(*args)
         | 
| 22 | 
            -
                  execute(RSpec.configuration.graphql_mutations_dir, *args)
         | 
| 21 | 
            +
                def execute_mutation(*args, **kwargs)
         | 
| 22 | 
            +
                  execute(RSpec.configuration.graphql_mutations_dir, *args, **kwargs)
         | 
| 23 23 | 
             
                end
         | 
| 24 24 |  | 
| 25 25 | 
             
                def decode_field_ids(field)
         |