kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.6 KiB
101 lines
3.6 KiB
12 years ago
|
#-- copyright
|
||
|
# OpenProject is a project management system.
|
||
11 years ago
|
# Copyright (C) 2012-2013 the OpenProject Foundation (OPF)
|
||
12 years ago
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
11 years ago
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
#
|
||
12 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
|
|
||
12 years ago
|
require 'spec_helper'
|
||
12 years ago
|
|
||
11 years ago
|
describe MenuItems::WikiMenuItem do
|
||
11 years ago
|
before(:each) do
|
||
|
@project = FactoryGirl.create(:project, :enabled_module_names => %w[activity])
|
||
|
@current = FactoryGirl.create(:user, :login => "user1", :mail => "user1@users.com")
|
||
12 years ago
|
|
||
11 years ago
|
User.stub(:current).and_return(@current)
|
||
|
end
|
||
12 years ago
|
|
||
11 years ago
|
it 'should create a default wiki menu item when enabling the wiki' do
|
||
11 years ago
|
MenuItems::WikiMenuItem.all.should_not be_any
|
||
12 years ago
|
|
||
11 years ago
|
@project.enabled_modules << EnabledModule.new(:name => 'wiki')
|
||
|
@project.reload
|
||
12 years ago
|
|
||
11 years ago
|
wiki_item = @project.wiki.wiki_menu_items.first
|
||
|
wiki_item.name.should eql 'Wiki'
|
||
|
wiki_item.title.should eql 'Wiki'
|
||
|
wiki_item.options[:index_page].should eql true
|
||
|
wiki_item.options[:new_wiki_page].should eql true
|
||
|
end
|
||
12 years ago
|
|
||
11 years ago
|
it 'should change title when a wikipage is renamed' do
|
||
|
wikipage = FactoryGirl.create(:wiki_page, :title => 'Oldtitle')
|
||
12 years ago
|
|
||
11 years ago
|
menu_item_1 = FactoryGirl.create(:wiki_menu_item, :navigatable_id => wikipage.wiki.id,
|
||
|
:name => 'Item 1',
|
||
|
:title => 'Oldtitle')
|
||
12 years ago
|
|
||
11 years ago
|
wikipage.title = 'Newtitle'
|
||
|
wikipage.save!
|
||
12 years ago
|
|
||
11 years ago
|
menu_item_1.reload
|
||
|
menu_item_1.title.should == wikipage.title
|
||
|
end
|
||
12 years ago
|
|
||
11 years ago
|
describe 'it should destroy' do
|
||
|
before(:each) do
|
||
|
@project.enabled_modules << EnabledModule.new(:name => 'wiki')
|
||
|
@project.reload
|
||
12 years ago
|
|
||
11 years ago
|
@menu_item_1 = FactoryGirl.create(:wiki_menu_item, :wiki => @project.wiki,
|
||
11 years ago
|
:name => 'Item 1',
|
||
|
:title => 'Item 1')
|
||
12 years ago
|
|
||
11 years ago
|
@menu_item_2 = FactoryGirl.create(:wiki_menu_item, :wiki => @project.wiki,
|
||
11 years ago
|
:name => 'Item 2',
|
||
|
:parent_id => @menu_item_1.id,
|
||
|
:title => 'Item 2')
|
||
|
end
|
||
12 years ago
|
|
||
11 years ago
|
it 'all children when deleting the parent' do
|
||
|
@menu_item_1.destroy
|
||
12 years ago
|
|
||
11 years ago
|
expect {MenuItems::WikiMenuItem.find(@menu_item_1.id)}.to raise_error(ActiveRecord::RecordNotFound)
|
||
|
expect {MenuItems::WikiMenuItem.find(@menu_item_2.id)}.to raise_error(ActiveRecord::RecordNotFound)
|
||
11 years ago
|
end
|
||
12 years ago
|
|
||
11 years ago
|
describe 'all items when destroying' do
|
||
|
it 'the associated project' do
|
||
|
@project.destroy
|
||
11 years ago
|
MenuItems::WikiMenuItem.all.should_not be_any
|
||
11 years ago
|
end
|
||
12 years ago
|
|
||
11 years ago
|
it 'the associated wiki' do
|
||
|
@project.wiki.destroy
|
||
11 years ago
|
MenuItems::WikiMenuItem.all.should_not be_any
|
||
12 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|