-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow "data" key for module navigations
This allows specifying a `data` key in module navigations. That way one can add, for example, `data-turbolinks='false'` to a navigation entry. In a module definition, it looks like this: ``` alchemy_module = { engine_name: 'spree', name: 'solidus', navigation: { controller: 'spree/admin/orders', action: 'index', name: 'Store', image: 'alchemy/solidus/alchemy_module_icon.png', data: { turbolinks: false }, sub_navigation: [ { controller: 'spree/admin/orders', action: 'index', name: 'Orders', } ] } } ```
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
app/views/alchemy/admin/partials/_main_navigation_entry.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
spec/views/alchemy/admin/partials/_main_navigation_entry.html.erb_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |