Sha256: 8d7107d8ab405d2689e1f4ab30855bb2e4f110f984f29ff9a08455f761b0262c

Contents?: true

Size: 1.63 KB

Versions: 18

Compression:

Stored size: 1.63 KB

Contents

describe Datagrid::Drivers::Mongoid do

  describe ".match?" do
    
    subject { described_class }

    it {should be_match(MongoidEntry)}
    it {should be_match(MongoidEntry.scoped)}
    it {should_not be_match(Entry.scoped)}

  end
  describe "api" do

    subject do
      MongoidGrid.new(
        defined?(_attributes) ? _attributes : {}
      )
    end

    let!(:first) do
      MongoidEntry.create!(
        :group_id => 2,
        :name => "Main First",
        :disabled => false
      )
    end
    let!(:second) do
      MongoidEntry.create!(
        :group_id => 3,
        :name => "Main Second",
        :disabled => true
      )
    end


    its(:assets) {should include(first, second)}

    its(:"assets.size") {should == 2}
    its(:rows) {should == [["Main First", 2, false], ["Main Second", 3, true]]}
    its(:header) {should ==[ "Name", "Group", "Disabled"]}

    its(:data) {should == [[ "Name", "Group", "Disabled"], ["Main First", 2, false], ["Main Second", 3, true]]}


    describe "when some filters specified" do
      let(:_attributes) { {:from_group_id => 3} }
      its(:assets) {should_not include(first)}
      its(:assets) {should include(second)}
    end

    describe "when reverse ordering is specified" do
      let(:_attributes) { {:order => :name, :descending => true} }
      its(:rows) {should == [["Main Second", 3, true], ["Main First", 2, false]]}
    end

    it "should not provide default order for non declared fields" do
      proc {
        test_report(:order => :test) do
          scope { MongoidEntry }
          column(:test)
        end
      }.should raise_error(Datagrid::OrderUnsupported)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
datagrid-1.0.1 spec/datagrid/drivers/mongoid_spec.rb
datagrid-1.0.0 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.9.3 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.9.2 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.9.0 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.8.4 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.8.3 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.8.2 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.8.1 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.8.0 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.7.1 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.7.0 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.6.4 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.6.3 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.6.2 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.6.0 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.5.4 spec/datagrid/drivers/mongoid_spec.rb
datagrid-0.5.3 spec/datagrid/drivers/mongoid_spec.rb