Sha256: a4dff3227704340874d440c0a1f257007e04abb83fecdc1fd2c654c60df47b4f

Contents?: true

Size: 1.43 KB

Versions: 25

Compression:

Stored size: 1.43 KB

Contents

require 'rails_helper'

describe ActiveAdmin::Resource::PagePresenters do

  let(:namespace){ ActiveAdmin::Namespace.new(ActiveAdmin::Application.new, :admin) }
  let(:resource){ namespace.register(Post) }

  it "should have an empty set of configs on initialize" do
    expect(resource.page_presenters).to eq ({})
  end

  it "should add a show page presenter" do
    page_presenter = ActiveAdmin::PagePresenter.new
    resource.set_page_presenter(:show, page_presenter)
    expect(resource.page_presenters[:show]).to eq page_presenter
  end

  it "should add an index page presenter" do
    page_presenter = ActiveAdmin::PagePresenter.new({as: :table})
    resource.set_page_presenter(:index, page_presenter)
    expect(resource.page_presenters[:index].default).to eq page_presenter
  end

  describe "#get_page_presenter" do

    it "should return a page config when set" do
      page_presenter = ActiveAdmin::PagePresenter.new
      resource.set_page_presenter(:index, page_presenter)
      expect(resource.get_page_presenter(:index)).to eq page_presenter
    end

    it "should return a specific index page config when set" do
      page_presenter = ActiveAdmin::PagePresenter.new
      resource.set_page_presenter(:index, page_presenter)
      expect(resource.get_page_presenter(:index, "table")).to eq page_presenter
    end

    it "should return nil when no page config set" do
      expect(resource.get_page_presenter(:index)).to eq nil
    end

  end

end

Version data entries

25 entries across 25 versions & 4 rubygems

Version Path
activeadmin_addons-1.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/resource/page_presenters_spec.rb
activeadmin_addons-1.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/resource/page_presenters_spec.rb
yousty-activeadmin-1.0.17.pre spec/unit/resource/page_presenters_spec.rb
yousty-activeadmin-1.0.16.pre spec/unit/resource/page_presenters_spec.rb
activeadmin_addons-1.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/resource/page_presenters_spec.rb
activeadmin_addons-1.0.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/resource/page_presenters_spec.rb
activeadmin_addons-1.0.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/resource/page_presenters_spec.rb
yousty-activeadmin-1.0.15.pre spec/unit/resource/page_presenters_spec.rb
activeadmin-orac-1.0.0.pre4 spec/unit/resource/page_presenters_spec.rb
activeadmin-orac-1.0.0 spec/unit/resource/page_presenters_spec.rb
activeadmin-orac-1.0.0.pre.orac spec/unit/resource/page_presenters_spec.rb
yousty-activeadmin-1.0.14.pre spec/unit/resource/page_presenters_spec.rb
yousty-activeadmin-1.0.13.pre spec/unit/resource/page_presenters_spec.rb
yousty-activeadmin-1.0.12.pre spec/unit/resource/page_presenters_spec.rb
yousty-activeadmin-1.0.11.pre spec/unit/resource/page_presenters_spec.rb
yousty-activeadmin-1.0.10.pre spec/unit/resource/page_presenters_spec.rb
yousty-activeadmin-1.0.9.pre spec/unit/resource/page_presenters_spec.rb
yousty-activeadmin-1.0.8.pre spec/unit/resource/page_presenters_spec.rb
activeadmin-1.0.0.pre4 spec/unit/resource/page_presenters_spec.rb
activeadmin-1.0.0.pre3 spec/unit/resource/page_presenters_spec.rb