Sha256: e8f0d2504236c9cd7819ae9bdd0eeaec141d876f55f5e74a131dc613a1f856f6

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

require 'test_helper'

class AutocompleterTest < ActiveSupport::TestCase
  context 'AssociationConfig' do
    setup do
      @config = ActiveAdminAssociations::AssociationConfig.new do
        associations :pages, :photos
        association :tags, [:name]
        association :posts do
          fields :title, :published_at, :creator
        end
        association :videos do
          field :title
          field :description
        end
        association :products, [:name, :pid] do
          field :description
        end
      end
    end
    
    should 'correctly configure multiple associtions at a time' do
      assert @config[:pages].fields.blank?
      assert @config[:photos].fields.blank?
    end
    
    should 'correctly configure with a fields parameter' do
      assert_equal [:name], @config[:tags].fields
    end
    
    should 'correctly configure with a block using the fields method' do
      assert_equal [:title, :published_at, :creator], @config[:posts].fields
    end
    
    should 'correctly configure with a block using the field method' do
      assert_equal [:title, :description], @config[:videos].fields
    end
    
    should 'correctly configure with a block and the fields parameter' do
      assert_equal [:name, :pid, :description], @config[:products].fields
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aa_associations-0.1.2 test/association_config_test.rb
aa_associations-0.1.1 test/association_config_test.rb
aa_associations-0.1.0 test/association_config_test.rb