Sha256: d74ef1e5fe165bd71978fd163c5fe1f351cb2d8f3fb041acbac821deb1167849

Contents?: true

Size: 1.73 KB

Versions: 11

Compression:

Stored size: 1.73 KB

Contents

require 'rails_helper'

describe ActiveAdmin::Views::SidebarSection do

  let(:options) { {} }

  let(:section) do
    ActiveAdmin::SidebarSection.new("Help Section", options) do
      span "Help Me"
    end
  end

  let(:html) do
    render_arbre_component section: section do
      sidebar_section(assigns[:section])
    end
  end

  it "should have a title h3" do
    expect(html.find_by_tag("h3").first.content).to eq "Help Section"
  end

  it "should have the class of 'sidebar_section'" do
    expect(html.class_list).to include("sidebar_section")
  end

  it "should have an id based on the title" do
    expect(html.id).to eq "help-section_sidebar_section"
  end

  it "should have a contents div" do
    expect(html.find_by_tag("div").first.class_list).to include("panel_contents")
  end

  it "should add children to the contents div" do
    expect(html.find_by_tag("span").first.parent).to eq html.find_by_tag("div").first
  end

  context 'with a custom class attribute' do
    let(:options) { { class: 'custom_class' } }

    it "should have 'custom_class' class" do
      expect(html.class_list).to include("custom_class")
    end
  end

  context "with attributes_table for resource" do
    let(:post) { Post.create!(title: "Testing.") }
    let(:section) do
      ActiveAdmin::SidebarSection.new("Summary", options) do
        attributes_table do
          row :title
        end
      end
    end
    let(:assigns) { { resource: post, section: section } }
    let(:html) do
      render_arbre_component assigns do
        sidebar_section(assigns[:section])
      end
    end

    it "should have table" do
      expect(html.find_by_tag("th").first.content).to eq "Title"
      expect(html.find_by_tag("td").first.content).to eq "Testing."
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
activeadmin_addons-1.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/views/components/sidebar_section_spec.rb
activeadmin_addons-1.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/views/components/sidebar_section_spec.rb
activeadmin_addons-1.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/views/components/sidebar_section_spec.rb
activeadmin_addons-1.0.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/views/components/sidebar_section_spec.rb
activeadmin_addons-1.0.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/spec/unit/views/components/sidebar_section_spec.rb
activeadmin-orac-1.0.0.pre4 spec/unit/views/components/sidebar_section_spec.rb
activeadmin-orac-1.0.0 spec/unit/views/components/sidebar_section_spec.rb
activeadmin-orac-1.0.0.pre.orac spec/unit/views/components/sidebar_section_spec.rb
activeadmin-1.0.0.pre4 spec/unit/views/components/sidebar_section_spec.rb
activeadmin-1.0.0.pre3 spec/unit/views/components/sidebar_section_spec.rb
activeadmin-1.0.0.pre2 spec/unit/views/components/sidebar_section_spec.rb