require 'spec_helper' class MyFormBuilder include Datagrid::FormBuilder end class MyTemplate include ActionView::Helpers::FormHelper end describe Datagrid::FormBuilder do let(:template) { ActionView::Base.new} let(:grid) { SimpleReport.new } let(:view) { ActionView::Helpers::FormBuilder.new(:report, grid, template, {}, Proc.new {|f| })} subject { view } describe ".datagrid_filter" do subject { view.datagrid_filter(_filter)} context "with default filter type" do let(:_filter) { :name } it { should equal_to_dom( '' )} end context "with integer filter type" do let(:_filter) { :group_id } it { should equal_to_dom( '' )} end context "with enum filter type" do let(:_filter) { :category } it { should equal_to_dom( '' )} context "when first option is selected" do before(:each) do grid.category = "first" end it { should equal_to_dom( '' )} end end context "with eboolean filter type" do let(:_filter) { :disabled } it { should equal_to_dom( '' )} end context "with string filter" do let(:grid) do test_report do scope {Entry} filter(:name, :string) end end let(:_filter) { :name } it {should equal_to_dom('')} end context "with non multiple filter" do let(:grid) do test_report do scope {Entry} filter( :name, :enum, :include_blank => false, :multiple => false, :select => [] ) end end let(:_filter) { :name } it {should equal_to_dom('')} end end describe ".datagrid_label" do it "should generate label for filter" do view.datagrid_label(:name).should equal_to_dom( '' ) end end end