Sha256: 3a91e046c1dcfb15707f7c05cbf90eadae3d1cce95a8c3ac956e4597fcc109e3

Contents?: true

Size: 951 Bytes

Versions: 12

Compression:

Stored size: 951 Bytes

Contents

require 'spec_helper'

describe RailsAdmin::Config::HasFields do

  it 'shows hidden fields when added through the DSL' do
    expect(RailsAdmin.config(Team).fields.find{|f| f.name == :division_id}).to_not be_visible

    RailsAdmin.config do |config|
      config.model Team do
        field :division_id
      end
    end

    expect(RailsAdmin.config(Team).fields.find{|f| f.name == :division_id}).to be_visible
  end

  it 'does not set visibility for fields with bindings' do
    RailsAdmin.config do |config|
      config.model Team do
        field :division do
          visible do
            bindings[:controller].current_user.email == 'test@email.com'
          end
        end
      end
    end
    expect {RailsAdmin.config(Team).fields.find{|f| f.name == :division }}.to_not raise_error
    expect {RailsAdmin.config(Team).fields.find{|f| f.name == :division }.visible?}.to raise_error "undefined method `[]' for nil:NilClass"
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
rails_admin-0.5.0 spec/rails_admin/config/has_fields_spec.rb
rails_admin-0.4.9 spec/rails_admin/config/has_fields_spec.rb
rails_admin-0.4.8 spec/rails_admin/config/has_fields_spec.rb
rails_admin-0.4.7 spec/rails_admin/config/has_fields_spec.rb
rails_admin-0.4.6 spec/rails_admin/config/has_fields_spec.rb
rails_admin-0.4.5 spec/rails_admin/config/has_fields_spec.rb
rails_admin-0.4.4 spec/rails_admin/config/has_fields_spec.rb
rails_admin-lbgraham-0.4.2 spec/rails_admin/config/has_fields_spec.rb
rails_admin-0.4.3 spec/rails_admin/config/has_fields_spec.rb
rails_admin-0.4.2 spec/rails_admin/config/has_fields_spec.rb
rails_admin-0.4.1 spec/rails_admin/config/has_fields_spec.rb
rails_admin-0.4.0 spec/rails_admin/config/has_fields_spec.rb