Sha256: 17f68cc4030e9d3d198480b9c49c7604570bbb7db1eaca0fe6a5424fa2ac92b9

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

require 'spec_helper'

describe Datagrid::Drivers::ActiveRecord do

  describe ".match?" do
    subject { described_class }

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

  it "should convert any scope to AR::Relation" do
    subject.to_scope(Entry).should be_a(ActiveRecord::Relation)
    subject.to_scope(Entry.limit(5)).should be_a(ActiveRecord::Relation)
    subject.to_scope(Group.create!.entries).should be_a(ActiveRecord::Relation)
  end

  it "should support append_column_queries" do
    scope = subject.append_column_queries(Entry.scoped, [Datagrid::Columns::Column.new(SimpleReport, :sum_group_id, 'sum(entries.group_id)')])
    scope.to_sql.should == 'SELECT "entries".*, sum(entries.group_id) AS sum_group_id FROM "entries" '
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datagrid-1.1.1 spec/datagrid/drivers/active_record_spec.rb