Sha256: 07360a03e4ef6e22e958997e36b26d85423b6450c5150a9edec62aa65ce5468b

Contents?: true

Size: 790 Bytes

Versions: 6

Compression:

Stored size: 790 Bytes

Contents

require 'spec_helper'

# This is a bit of a insane spec I have to admit
# Chosed the spree_payment_methods table because it has a `name` column
# already. Stubs wouldn't work here (the delegation runs before this spec is
# loaded) and adding a column here might make the test even crazy so here we go
module Spree
  class DelegateBelongsToStubModel < Spree::Base
    self.table_name = "spree_payment_methods"
    belongs_to :product
    ActiveSupport::Deprecation.silence do
      delegate_belongs_to :product, :name
    end
  end

  describe DelegateBelongsToStubModel do
    context "model has column attr delegated to associated object" do
      it "doesnt touch the associated object" do
        expect(subject).not_to receive(:product)
        subject.name
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_core-1.3.2 spec/lib/spree/core/delegate_belongs_to_spec.rb
solidus_core-1.3.1 spec/lib/spree/core/delegate_belongs_to_spec.rb
solidus_core-1.3.0 spec/lib/spree/core/delegate_belongs_to_spec.rb
solidus_core-1.3.0.rc2 spec/lib/spree/core/delegate_belongs_to_spec.rb
solidus_core-1.3.0.rc1 spec/lib/spree/core/delegate_belongs_to_spec.rb
solidus_core-1.3.0.beta1 spec/lib/spree/core/delegate_belongs_to_spec.rb