Skip to content

Commit

Permalink
Merge pull request #1512 from mamhoff/add-data-attribute-to-navigation
Browse files Browse the repository at this point in the history
Allow "data" key for module navigations
  • Loading branch information
tvdeyen authored Nov 5, 2018
2 parents 5114d5a + c345c3f commit 48a65b8
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if can? *navigate_module(navigation) %>
<%= content_tag :div, class: main_navigation_css_classes(navigation) do %>
<%= content_tag :div, class: main_navigation_css_classes(navigation), data: navigation["data"] do %>
<%= link_to url_for_module(alchemy_module) do %>
<% if navigation["image"] %>
<%= image_tag(navigation["image"]) %>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# frozen_string_literal: true

require "spec_helper"

describe "alchemy/admin/partials/_main_navigation_entry.html.erb" do
let(:alchemy_module) do
{
engine_name: 'alchemy',
name: 'what_a_name',
navigation: {
controller: 'alchemy/admin/pages',
action: 'index',
name: 'Pages',
image: 'alchemy/alchemy-logo.svg',
data: { turbolinks: false },
sub_navigation: []
}
}.with_indifferent_access
end

let(:navigation) { alchemy_module[:navigation] }

before do
allow(view).to receive(:navigation).and_return(navigation)
allow(view).to receive(:alchemy_module).and_return(alchemy_module)
allow(view).to receive(:can?).and_return(true)
view.extend Alchemy::Admin::NavigationHelper
end

it "renders navigation with data attribute" do
render

expect(rendered).to have_selector('div[data-turbolinks="false"]')
end

context 'with no data attribute' do
let(:alchemy_module) do
{
engine_name: 'alchemy',
name: 'what_a_name',
navigation: {
controller: 'alchemy/admin/pages',
action: 'index',
name: 'Pages',
image: 'alchemy/alchemy-logo.svg',
sub_navigation: []
}
}.with_indifferent_access
end

it "renders navigation without data attribute" do
render

expect(rendered).not_to have_selector('div[data-turbolinks="false"]')
end
end
end

0 comments on commit 48a65b8

Please sign in to comment.