Sha256: ae45ea1422447f0651eee9f28eb8d7b2e1beb954d65986302febf13dc1678572

Contents?: true

Size: 864 Bytes

Versions: 10

Compression:

Stored size: 864 Bytes

Contents

require 'spec_helper'

module Ransack
  module Adapters
    module ActiveRecord
      describe Context do
        before do
          @c = Context.new(Person)
        end

        it 'contextualizes strings to attributes' do
          attribute = @c.contextualize 'children_children_parent_name'
          attribute.should be_a Arel::Attributes::Attribute
          attribute.name.to_s.should eq 'name'
          attribute.relation.table_alias.should eq 'parents_people'
        end

        it 'builds new associations if not yet built' do
          attribute = @c.contextualize 'children_articles_title'
          attribute.should be_a Arel::Attributes::Attribute
          attribute.name.to_s.should eq 'title'
          attribute.relation.name.should eq 'articles'
          attribute.relation.table_alias.should be_nil
        end

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ransack-0.5.3 spec/ransack/adapters/active_record/context_spec.rb
ransack-0.5.2 spec/ransack/adapters/active_record/context_spec.rb
ransack-0.5.1 spec/ransack/adapters/active_record/context_spec.rb
ransack-0.5.0 spec/ransack/adapters/active_record/context_spec.rb
ransack-0.4.2 spec/ransack/adapters/active_record/context_spec.rb
ransack-0.4.1 spec/ransack/adapters/active_record/context_spec.rb
ransack-0.4.0 spec/ransack/adapters/active_record/context_spec.rb
ransack-0.3.0 spec/ransack/adapters/active_record/context_spec.rb
ransack-0.2.1 spec/ransack/adapters/active_record/context_spec.rb
ransack-0.2.0 spec/ransack/adapters/active_record/context_spec.rb