Sha256: 3d9fcc60190afce1120c4f721b378cdfdde8d9e2372c8bc22a2318d1cb507729
Contents?: true
Size: 1.67 KB
Versions: 3
Compression:
Stored size: 1.67 KB
Contents
require 'spec_helper' describe ActiveAdmin::Filters::ResourceExtension do let(:resource) do namespace = ActiveAdmin::Namespace.new(ActiveAdmin::Application.new, :admin) namespace.register(Post) end it "should return the defaults if no filters are set" do resource.filters.map{|f| f[:attribute].to_s }.sort.should == %w{ author body category created_at published_at title updated_at } end it "should not have defaults when filters are disabled on the resource" do resource.filters = false resource.filters.should be_empty end it "should not have defaults when the filters are disabled on the namespace" do resource.namespace.filters = false resource.filters.should be_empty end it "should not have defaults when the filters are disabled on the application" do resource.namespace.application.filters = false resource.filters.should be_empty end it "should add a filter" do resource.add_filter :title resource.filters.should == [{:attribute => :title}] end it "should add a filter with options" do resource.add_filter :title, :as => :string resource.filters.should == [{:attribute => :title, :as => :string}] end it "should raise an exception if trying to add a filter when they are disabled" do resource.filters = false expect { resource.add_filter :title }.should raise_error(RuntimeError) end it "should reset filters" do resource.add_filter :title resource.filters.size.should == 1 resource.reset_filters! resource.filters.size.should > 1 end it "should add a sidebar section for the filters" do resource.sidebar_sections.first.name.should == :filters end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activeadmin-0.5.0 | spec/unit/filters/resource_spec.rb |
activeadmin-0.5.0.pre1 | spec/unit/filters/resource_spec.rb |
activeadmin-0.5.0.pre | spec/unit/filters/resource_spec.rb |