Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow "data" key for module navigations #1512

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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] }

mamhoff marked this conversation as resolved.
Show resolved Hide resolved
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