Refactor the way a defaut wiki menu item gets created:

* move default wiki menu item to wiki class from enabled modules
* as we now ALWAYS have a menu item for a wiki, check for enabled modules when rendering a project menu

Conflicts:
	app/models/enabled_module.rb
	app/models/wiki.rb
pull/495/head
jwollert 11 years ago
parent 5fd0fb4350
commit c0e80e861a
  1. 2
      app/models/enabled_module.rb
  2. 2
      app/models/wiki.rb
  3. 4
      features/step_definitions/wiki_steps.rb
  4. 1
      lib/redmine/menu_manager/menu_helper.rb

@ -45,7 +45,7 @@ class EnabledModule < ActiveRecord::Base
when 'wiki'
# Create a wiki with a default start page
if project && project.wiki.nil?
wiki = Wiki.create(:project => project, :start_page => 'Wiki')
Wiki.create(:project => project, :start_page => 'Wiki')
end
end
end

@ -34,7 +34,6 @@ class Wiki < ActiveRecord::Base
has_many :wiki_menu_items, :class_name => 'WikiMenuItem', :dependent => :delete_all, :order => 'name'
has_many :redirects, :class_name => 'WikiRedirect', :dependent => :delete_all
acts_as_watchable
accepts_nested_attributes_for :wiki_menu_items,
@ -114,6 +113,7 @@ class Wiki < ActiveRecord::Base
wiki_menu_item = wiki_menu_items.find_or_initialize_by_title start_page, name: 'Wiki'
wiki_menu_item.new_wiki_page = true
wiki_menu_item.index_page = true
wiki_menu_item.save!
end
end

@ -29,7 +29,7 @@
Given /^the [Pp]roject "([^\"]*)" has 1 [wW]iki(?: )?[pP]age with the following:$/ do |project, table|
p = Project.find_by_name(project)
p.wiki.create! unless p.wiki
p.wiki = Wiki.create unless p.wiki
page = FactoryGirl.create(:wiki_page, :wiki => p.wiki)
content = FactoryGirl.create(:wiki_content, :page => page)
@ -75,7 +75,7 @@ end
Given /^the wiki page "([^"]*)" of the project "([^"]*)" has the following contents:$/ do |page, project, table|
project = Project.find_by_name project
wiki = project.wiki || project.wiki.create!
wiki = project.wiki || Wiki.create
wp = wiki.pages.find_or_create_by_title(page)
wc = wp.content || wp.create_content
wc.update_attribute(:text, table.raw.first)

@ -43,6 +43,7 @@ module Redmine::MenuManager::MenuHelper
end
def build_wiki_menus(project)
return unless project.enabled_module_names.include? 'wiki'
project_wiki = project.wiki
WikiMenuItem.main_items(project_wiki).each do |main_item|

Loading…
Cancel
Save