Sha256: fdadb2594772b59ed443ce84b865a29a4fc28ad39ee2e78ae06006e53cfdbed4

Contents?: true

Size: 1.62 KB

Versions: 11

Compression:

Stored size: 1.62 KB

Contents

require 'spec_helper'
require "datagrid/rspec"


describe SimpleReport do
  
  it_should_behave_like 'Datagrid'
  
  let(:group) { Group.create!(:name => "Pop") }
  
  subject do
    SimpleReport.new(
      :group_id => group.id,
      :name => "Star",
      :category => "first",
      :disabled => false,
      :confirmed => false
    )
  end

  let!(:entry) {  Entry.create!(
    :group => group, :name => "Star", :disabled => false, :confirmed => false, :category => "first"
  ) }

  describe '#assets' do
    subject { super().assets }
    it { should include(entry) }
  end

  describe ".attributes" do
    it "should return report attributes" do
      (subject.filters.map(&:name) + [:order, :descending]).each do |attribute|
        expect(subject.attributes).to have_key(attribute)
      end
    end

  end

  describe ".scope" do
    it "should return defined scope of objects" do
      expect(subject.scope).to respond_to(:each)
    end
      

    context "when not defined on class level" do
      subject do
        test_report {}
      end

      it "should raise ConfigurationError" do
        expect {
          subject.scope
        }.to raise_error(Datagrid::ConfigurationError)

      end
    end
  end

  describe ".batch_size" do
    context "when not defined on class level" do
      it "returns nil" do
        expect(subject.batch_size).to eq(nil)
      end
    end

    context "when defined in the grid class" do
      subject do
        test_report do
          self.batch_size = 25
        end
      end

      it "returns the configured batch size" do
        expect(subject.batch_size).to eq(25)
      end
    end

  end


end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
datagrid-1.3.7 spec/datagrid_spec.rb
datagrid-1.3.6 spec/datagrid_spec.rb
datagrid-1.3.5 spec/datagrid_spec.rb
datagrid-1.3.4 spec/datagrid_spec.rb
datagrid-1.3.3 spec/datagrid_spec.rb
datagrid-1.3.2 spec/datagrid_spec.rb
datagrid-1.3.1 spec/datagrid_spec.rb
datagrid-1.3.0 spec/datagrid_spec.rb
datagrid-1.2.3 spec/datagrid_spec.rb
datagrid-1.2.2 spec/datagrid_spec.rb
datagrid-1.2.1 spec/datagrid_spec.rb