Sha256: 1a6ff9e656da263d0be2a8e4a89d8967e9c63354cbbbac5970b174de1a3e88bb

Contents?: true

Size: 646 Bytes

Versions: 2

Compression:

Stored size: 646 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe SolidusGraphqlApi::BatchLoader::HasOne do
  subject(:loader) do
    described_class.new(
      article,
      Article.reflect_on_association(:image)
    )
  end

  with_model :Article, scope: :all do
    model do
      has_one :image
    end
  end

  with_model :Image, scope: :all do
    table do |t|
      t.belongs_to :article
    end

    model do
      belongs_to :article
    end
  end

  let!(:article) { Article.create! }

  before do
    article.create_image!
  end

  it 'loads the association properly' do
    expect(loader.load.sync).to eq(article.image)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_graphql_api-0.2.0 spec/lib/solidus_graphql_api/batch_loader/has_one_spec.rb
solidus_graphql_api-0.1.0 spec/lib/solidus_graphql_api/batch_loader/has_one_spec.rb