Sha256: 89acb8d6d7aa072775f42e7169c38ce5f4b6ea7a66f4f77db5c3de59b5b86a83

Contents?: true

Size: 1.44 KB

Versions: 21

Compression:

Stored size: 1.44 KB

Contents

require 'rails_helper'

RSpec.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

21 entries across 21 versions & 4 rubygems

Version Path
activeadmin-rails-1.7.1 spec/unit/resource/page_presenters_spec.rb
activeadmin-rails-1.7.0 spec/unit/resource/page_presenters_spec.rb
activeadmin-rb-1.6.0 spec/unit/resource/page_presenters_spec.rb
activeadmin-rb-1.5.2 spec/unit/resource/page_presenters_spec.rb
activeadmin-rb-1.5.1 spec/unit/resource/page_presenters_spec.rb
activeadmin-rb-1.5.0 spec/unit/resource/page_presenters_spec.rb
activeadmin_addons-1.7.1 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/page_presenters_spec.rb
activeadmin-rb-1.4.0 spec/unit/resource/page_presenters_spec.rb
activeadmin_addons-1.7.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/page_presenters_spec.rb
activeadmin-1.3.1 spec/unit/resource/page_presenters_spec.rb
activeadmin_addons-1.6.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/page_presenters_spec.rb
activeadmin_addons-1.5.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/page_presenters_spec.rb
activeadmin-1.3.0 spec/unit/resource/page_presenters_spec.rb
activeadmin_addons-1.4.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/page_presenters_spec.rb
activeadmin_addons-1.3.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/page_presenters_spec.rb
activeadmin_addons-1.2.0 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-f71b375325eb/spec/unit/resource/page_presenters_spec.rb
activeadmin-1.2.1 spec/unit/resource/page_presenters_spec.rb
activeadmin-1.2.0 spec/unit/resource/page_presenters_spec.rb
activeadmin-1.1.0 spec/unit/resource/page_presenters_spec.rb
activeadmin-1.0.0 spec/unit/resource/page_presenters_spec.rb