Sha256: 4d72a6920d4393bdf27130743ee85bd09ed18779452c73c220c09a86379fd2c6

Contents?: true

Size: 1.08 KB

Versions: 21

Compression:

Stored size: 1.08 KB

Contents

require 'rails_helper'

RSpec.describe ActiveAdmin::Resource::Sidebars do

  let(:resource) do
    namespace = ActiveAdmin::Namespace.new(ActiveAdmin::Application.new, :admin)
    namespace.register(Post)
  end

  let(:sidebar) { ActiveAdmin::SidebarSection.new(:help) }

  describe "adding a new sidebar section" do

    before do
      resource.clear_sidebar_sections!
      resource.sidebar_sections << sidebar
    end

    it "should add a sidebar section" do
      expect(resource.sidebar_sections.size).to eq(1)
    end

  end

  describe "retrieving sections for a controller action" do

    let(:only_index){ ActiveAdmin::SidebarSection.new(:help, only: :index) }
    let(:only_show){ ActiveAdmin::SidebarSection.new(:help, only: :show) }

    before do
      resource.clear_sidebar_sections!
      resource.sidebar_sections << only_index
      resource.sidebar_sections << only_show
    end

    it "should only return the relevant action items" do
      expect(resource.sidebar_sections.size).to eq(2)
      expect(resource.sidebar_sections_for("index")).to eq [only_index]
    end

  end

end

Version data entries

21 entries across 21 versions & 4 rubygems

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