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