Sha256: adfbe022fb0246906c16d246ad458fe3667cfb73b935d6fd55595fc55a4153e7

Contents?: true

Size: 923 Bytes

Versions: 5

Compression:

Stored size: 923 Bytes

Contents

require 'spec_helper'

describe Datagrid::Scaffold do
  subject { Datagrid::Scaffold.new(["user"]) }


  describe '.pagination_helper_code' do
    it 'uses kaminari by default' do
      expect(subject.pagination_helper_code).to eql('paginate(@grid.assets)')
    end

    context "when WillPaginate exists" do
      before(:each) do
        Object.const_set("WillPaginate", 1)
      end
      it 'uses willpaginate' do
        expect(subject.pagination_helper_code).to eql('will_paginate(@grid.assets)')
      end

      after(:each) do
        Object.send(:remove_const, "WillPaginate")
      end
    end
  end

  describe ".index_action" do

    it "works" do
      expect(subject.index_action).to eq(<<-RUBY)
  def index
    @grid = UsersGrid.new(grid_params) do |scope|
      scope.page(params[:page])
    end
  end

  protected

  def grid_params
    params.fetch(:users_grid, {}).permit!
  end
RUBY
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
datagrid-1.6.1 spec/datagrid/scaffold_spec.rb
datagrid-1.6.0 spec/datagrid/scaffold_spec.rb
datagrid-1.5.9 spec/datagrid/scaffold_spec.rb
datagrid-1.5.8 spec/datagrid/scaffold_spec.rb
datagrid-1.5.7 spec/datagrid/scaffold_spec.rb