Sha256: b87696177cb49596b1ba2c3b97eedf57e9593153690a93ada38f20b339fd8771

Contents?: true

Size: 742 Bytes

Versions: 33

Compression:

Stored size: 742 Bytes

Contents

require 'rails_helper'

describe Tabulatr::Renderer::Association do

  describe '#principal_value' do

    before {
      @p = Product.create(title: 'product')
      @p.tags.create(title: 'foo')
      @p.tags.create(title: 'bar')
    }

    context 'name == "count"' do
      it 'returns the associations\'s count' do
        assoc = Tabulatr::Renderer::Association.from(table_name: 'tags', name: :count)
        expect(assoc.principal_value(@p, nil)).to eq 2

      end
    end

    context 'name != "count"' do
      it 'maps the association' do
        assoc = Tabulatr::Renderer::Association.from(table_name: 'tags', name: :title)
        expect(assoc.principal_value(@p, nil)).to match_array(['foo', 'bar'])
      end
    end

  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
tabulatr2-0.10.4 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.10.3 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.10.2 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.10.1 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.10.0 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.48 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.47 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.46 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.45 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.44 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.43 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.42 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.41 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.40 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.39 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.38 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.37 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.36 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.35 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.34 spec/lib/tabulatr/renderer/association_spec.rb