Sha256: 5548cb578e29e6c8d6ebaea20d22dc10c11d31802cd7c7010c7d979c39024d9b

Contents?: true

Size: 1.98 KB

Versions: 13

Compression:

Stored size: 1.98 KB

Contents

require 'spec_helper'

describe RailsAdmin::Config::Model do

  describe "#excluded?" do
    before do
      RailsAdmin.config do |config|
        config.included_models = [Comment]
      end
    end

    it "should say false when included, true otherwise" do
      RailsAdmin.config(Player).excluded?.should == true
      RailsAdmin.config(Comment).excluded?.should == false
    end
  end

  describe "#object_label" do
    before do
      RailsAdmin.config(Comment) do
        object_label_method :content
      end
    end

    it "should send object_label_method to binding[:object]" do
      c = Comment.new(:content => 'test')
      RailsAdmin.config(Comment).with(:object => c).object_label.should == 'test'
    end
  end

  describe "#object_label_method" do
    it "should be first of Config.label_methods if found as a column on model, or :rails_admin_default_object_label_method" do
      RailsAdmin.config(Comment).object_label_method.should == :rails_admin_default_object_label_method
      RailsAdmin.config(Division).object_label_method.should == :name
    end
  end

  describe "#label" do
    it "should be pretty" do
      RailsAdmin.config(Comment).label.should == 'Comment'
    end
  end

  describe "#label_plural" do
    it "should be pretty" do
      RailsAdmin.config(Comment).label_plural.should == 'Comments'
    end
  end

  describe "#weight" do
    it "should be 0" do
      RailsAdmin.config(Comment).weight.should == 0
    end
  end

  describe "#parent" do
    it "should be nil for ActiveRecord::Base inherited models" do
      RailsAdmin.config(Comment).parent.should be_nil
    end

    it "should be parent model otherwise" do
      RailsAdmin.config(Hardball).parent.should == Ball
    end
  end

  describe "#navigation_label" do
    it "should be nil if parent module is Object" do
      RailsAdmin.config(Comment).navigation_label.should be_nil
    end

    it "should be parent module otherwise" do
      RailsAdmin.config(Cms::BasicPage).navigation_label.should == "Cms"
    end
  end
end

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
rails_admin-0.1.1 spec/unit/config/model_spec.rb
rails_admin-0.1.0 spec/unit/config/model_spec.rb
rails_admin-0.0.5 spec/unit/config/model_spec.rb
rails_admin-0.0.4 spec/unit/config/model_spec.rb
rails_admin-0.0.3 spec/unit/config/model_spec.rb
rails_admin-0.0.2 spec/unit/config/model_spec.rb
upstream-rails_admin-1.0.2 spec/unit/config/model_spec.rb
rails_admin-0.0.1 spec/unit/config/model_spec.rb
obitum-rails_admin-0.0.5 spec/unit/config/model_spec.rb
drewda_rails_admin-0.0.1 spec/unit/config/model_spec.rb
obitum-rails_admin-0.0.4 spec/unit/config/model_spec.rb
obitum-rails_admin-0.0.3 spec/unit/config/model_spec.rb
obitum-rails_admin-0.0.2 spec/unit/config/model_spec.rb