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.9.33 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.32 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.31 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.30 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.29 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.28 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.27 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.26 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.25 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.24 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.23 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.22 spec/lib/tabulatr/renderer/association_spec.rb
tabulatr2-0.9.21 spec/lib/tabulatr/renderer/association_spec.rb