Merge pull request #4808 from oliverguenther/fix/23818/wikimenuitem-title

Use the actual menu item's title for wiki pages
pull/4814/head
Oliver Günther 8 years ago committed by GitHub
commit dceda2be7a
  1. 4
      app/controllers/wiki_menu_items_controller.rb
  2. 8
      app/views/wiki_menu_items/edit.html.erb
  3. 6
      features/menu_items/wiki_menu_items.feature
  4. 4
      lib/redmine/menu_manager/menu_helper.rb
  5. 10
      spec/controllers/projects_controller_spec.rb
  6. 2
      spec/features/wiki/wiki_menu_item_migration_spec.rb

@ -62,8 +62,8 @@ class WikiMenuItemsController < ApplicationController
end
else
@wiki_menu_item.navigatable_id = @page.wiki.id
@wiki_menu_item.name = wiki_menu_item_params[:name]
@wiki_menu_item.title = @page_title
@wiki_menu_item.name = @page.slug
@wiki_menu_item.title = wiki_menu_item_params[:title] || @page_title
if wiki_menu_setting == 'sub_item'
@wiki_menu_item.parent_id = parent_wiki_menu_item

@ -33,11 +33,11 @@ See doc/COPYRIGHT.rdoc for more details.
<%= toolbar title: l(:wiki_menu_item_for, title: @page_title) %>
<%= form_for @wiki_menu_item, html: {id: 'wiki_menu_item_form', class: 'menu-item-form', method: :put}, url: wiki_menu_item_path(@project, @page) do |form| %>
<p class="item-name">
<%= form.label :name, l(:label_menu_item_name), {id: 'item-name'} %>
<% if @wiki_menu_item.name.nil? %>
<%= form.text_field :name, size: 20, value: @page_title %>
<%= form.label :title, l(:label_menu_item_name), {id: 'item-name'} %>
<% if @wiki_menu_item.title.nil? %>
<%= form.text_field :title, size: 20, value: @page_title %>
<% else %>
<%= form.text_field :name, size: 20 %>
<%= form.text_field :title, size: 20 %>
<% end %>
</p>
<br>

@ -51,7 +51,7 @@ Feature: Wiki menu items
When I go to the wiki page "AwesomePage" for the project called "Awesome Project"
And I click on "More"
And I click on "Configure menu item"
And I fill in "Avocado Wuaärst" for "menu_items_wiki_menu_item_name"
And I fill in "Avocado Wuaärst" for "menu_items_wiki_menu_item_title"
And I choose "Show as menu item in project navigation"
And I press "Save"
And I should see "Avocado Wuaärst" within "#main-menu"
@ -61,7 +61,7 @@ Feature: Wiki menu items
When I go to the wiki page "AwesomePage" for the project called "Awesome Project"
And I click on "More"
And I click on "Configure menu item"
And I fill in "Avocado Wuaärst" for "menu_items_wiki_menu_item_name"
And I fill in "Avocado Wuaärst" for "menu_items_wiki_menu_item_title"
And I choose "Show as menu item in project navigation"
And I press "Save"
When I go to the wiki page "AwesomePage" for the project called "Awesome Project"
@ -72,7 +72,7 @@ Feature: Wiki menu items
When I go to the wiki page "Wiki" for the project called "Awesome Project"
When I click on "More"
And I click on "Configure menu item"
And I fill in "Wikikiki" for "menu_items_wiki_menu_item_name"
And I fill in "Wikikiki" for "menu_items_wiki_menu_item_title"
And I press "Save"
When I go to the wiki page "Wiki" for the project called "Awesome Project"
Then I should see "Wikikiki" within "#main-menu"

@ -54,7 +54,7 @@ module Redmine::MenuManager::MenuHelper
menu.push "#{main_item.item_class}".to_sym,
{ controller: '/wiki', action: 'show', id: main_item.slug },
param: :project_id,
caption: main_item.name,
caption: main_item.title,
after: :repository,
html: { class: 'icon2 icon-wiki' }
@ -62,7 +62,7 @@ module Redmine::MenuManager::MenuHelper
menu.push "#{child.item_class}".to_sym,
{ controller: '/wiki', action: 'show', id: child.slug },
param: :project_id,
caption: child.name,
caption: child.title,
html: { class: 'icon2 icon-wiki2' },
parent: "#{main_item.item_class}".to_sym
end

@ -98,14 +98,14 @@ describe ProjectsController, type: :controller do
it 'renders main menu with wiki menu item' do
get 'show', @params
assert_select '#main-menu a.wiki-menu-item', 'wiki'
assert_select '#main-menu a.wiki-menu-item', 'Wiki'
end
end
describe 'with custom wiki menu item' do
before do
main_item = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id, name: 'example', title: 'Example')
sub_item = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id, name: 'sub', title: 'Sub', parent_id: main_item.id)
main_item = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id, name: 'example', title: 'Example Title')
sub_item = FactoryGirl.create(:wiki_menu_item, navigatable_id: @project.wiki.id, name: 'sub', title: 'Sub Title', parent_id: main_item.id)
end
it 'renders show' do
@ -117,13 +117,13 @@ describe ProjectsController, type: :controller do
it 'renders main menu with wiki menu item' do
get 'show', @params
assert_select '#main-menu a.example-menu-item', 'example'
assert_select '#main-menu a.example-menu-item', 'Example Title'
end
it 'renders main menu with sub wiki menu item' do
get 'show', @params
assert_select '#main-menu a.sub-menu-item', 'sub'
assert_select '#main-menu a.sub-menu-item', 'Sub Title'
end
end
end

@ -68,7 +68,7 @@ describe 'Wiki menu_items migration', type: :feature do
it 'shows the menu item' do
visit project_wiki_path(project, project.wiki)
link = page.find('#menu-sidebar a.icon-wiki', text: menu_item.name)
link = page.find('#menu-sidebar a.icon-wiki', text: menu_item.title)
link.click
expect(page).to have_selector('.wiki-title', text: wiki_page.title)

Loading…
Cancel
Save