Sha256: 2305b1960151a68bb946fbc5906a2bd48511eaa6bc3167205eb9fce1b537de14

Contents?: true

Size: 1.65 KB

Versions: 14

Compression:

Stored size: 1.65 KB

Contents

require 'rails_helper'

describe ActiveAdmin::Views::Panel do
  let(:arbre_panel) do
    render_arbre_component do
      panel "My Title", icon: :arrow_down do
        header_action link_to("My Link", "https://www.github.com/activeadmin/activeadmin")
        span("Hello World")
      end
    end
  end

  let(:panel_html) { Capybara.string(arbre_panel.to_s) }

  it "should have a title h3" do
    expect(panel_html).to have_css 'h3', text: "My Title"
  end

  it "should add panel actions to the panel header" do
    link = panel_html.find('h3 > div.header_action a')
    expect(link.text).to eq('My Link')
    expect(link[:href]).to eq("https://www.github.com/activeadmin/activeadmin")
  end

  it "should have a contents div" do
    expect(panel_html).to have_css 'div.panel_contents'
  end

  it "should add children to the contents div" do
    expect(panel_html).to have_css 'div.panel_contents > span', text: "Hello World"
  end

  it "should set the icon" do
    expect(panel_html).to have_css "h3 > span.icon"
  end

  context "with html-safe title" do
    let(:arbre_panel) do
      title_with_html = %q[Title with <abbr>HTML</abbr>].html_safe
      render_arbre_component do
        panel(title_with_html)
      end
    end

    it "should allow a html_safe title" do
      expect(panel_html).to have_css "h3", text: "Title with HTML"
      expect(panel_html).to have_css "h3 > abbr", text: "HTML"
    end
  end

  describe "#children?" do
    let(:arbre_panel) do
      render_arbre_component do
        panel("A Panel")
      end
    end

    it "returns false if no children have been added to the panel" do
      expect(arbre_panel.children?).to eq false
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
yousty-activeadmin-1.0.17.pre spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.16.pre spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.15.pre spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.14.pre spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.13.pre spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.12.pre spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.11.pre spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.10.pre spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.9.pre spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.8.pre spec/unit/views/components/panel_spec.rb
activeadmin-1.0.0.pre1 spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.7.pre spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.6.pre spec/unit/views/components/panel_spec.rb
yousty-activeadmin-1.0.5.pre spec/unit/views/components/panel_spec.rb