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.
506 lines
19 KiB
506 lines
19 KiB
13 years ago
|
#-- encoding: UTF-8
|
||
14 years ago
|
#-- copyright
|
||
12 years ago
|
# OpenProject is a project management system.
|
||
10 years ago
|
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
14 years ago
|
#
|
||
17 years ago
|
# This program is free software; you can redistribute it and/or
|
||
12 years ago
|
# modify it under the terms of the GNU General Public License version 3.
|
||
14 years ago
|
#
|
||
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.
|
||
|
#
|
||
14 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
10 years ago
|
require 'legacy_spec_helper'
|
||
17 years ago
|
require 'wiki_controller'
|
||
|
|
||
11 years ago
|
describe WikiController, type: :controller do
|
||
|
render_views
|
||
|
|
||
12 years ago
|
fixtures :all
|
||
14 years ago
|
|
||
11 years ago
|
before do
|
||
17 years ago
|
User.current = nil
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
def wiki
|
||
|
Project.first.wiki
|
||
|
end
|
||
|
|
||
|
def redirect_page
|
||
|
wiki.find_page(wiki.start_page) || wiki.pages.first
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should show start page' do
|
||
10 years ago
|
get :show, project_id: 'ecookbook'
|
||
17 years ago
|
assert_response :success
|
||
|
assert_template 'show'
|
||
10 years ago
|
assert_tag tag: 'h1', content: /CookBook documentation/
|
||
17 years ago
|
|
||
|
# child_pages macro
|
||
10 years ago
|
assert_tag :ul, attributes: { class: 'pages-hierarchy' },
|
||
10 years ago
|
child: { tag: 'li',
|
||
|
child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/Page_with_an_inline_image' },
|
||
|
content: 'Page with an inline image' } }
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should show page with name' do
|
||
10 years ago
|
get :show, project_id: 1, id: 'Another_page'
|
||
17 years ago
|
assert_response :success
|
||
|
assert_template 'show'
|
||
10 years ago
|
assert_tag tag: 'h1', content: /Another page/
|
||
17 years ago
|
# Included page with an inline image
|
||
10 years ago
|
assert_tag tag: 'p', content: /This is an inline image/
|
||
|
assert_tag tag: 'img', attributes: { src: '/attachments/3/download',
|
||
10 years ago
|
alt: 'This is a logo' }
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should show with sidebar' do
|
||
10 years ago
|
page = Project.find(1).wiki.pages.new(title: 'Sidebar')
|
||
|
page.content = WikiContent.new(text: 'Side bar content for test_show_with_sidebar')
|
||
15 years ago
|
page.save!
|
||
14 years ago
|
|
||
10 years ago
|
get :show, project_id: 1, id: 'Another_page'
|
||
15 years ago
|
assert_response :success
|
||
10 years ago
|
assert_tag tag: 'div', attributes: { id: 'sidebar' },
|
||
|
content: /Side bar content for test_show_with_sidebar/
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should show unexistent page without edit right' do
|
||
10 years ago
|
get :show, project_id: 1, id: 'Unexistent page'
|
||
17 years ago
|
assert_response 404
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should show unexistent page with edit right' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
get :show, project_id: 1, id: 'Unexistent page'
|
||
17 years ago
|
assert_response :success
|
||
|
assert_template 'edit'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should create page' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
put :update, project_id: 1,
|
||
10 years ago
|
id: 'New page',
|
||
|
content: { comments: 'Created the page',
|
||
|
text: "h1. New page\n\nThis is a new page" }
|
||
10 years ago
|
assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'New_page'
|
||
11 years ago
|
page = wiki.find_page('New page')
|
||
17 years ago
|
assert !page.new_record?
|
||
|
assert_not_nil page.content
|
||
14 years ago
|
assert_equal 'Created the page', page.content.last_journal.notes
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should create page with attachments' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
15 years ago
|
assert_difference 'WikiPage.count' do
|
||
|
assert_difference 'Attachment.count' do
|
||
10 years ago
|
put :update, project_id: 1,
|
||
10 years ago
|
id: 'New page',
|
||
|
content: { comments: 'Created the page',
|
||
|
text: "h1. New page\n\nThis is a new page",
|
||
|
lock_version: 0 },
|
||
|
attachments: { '1' => { 'file' => uploaded_test_file('testfile.txt', 'text/plain') } }
|
||
15 years ago
|
end
|
||
|
end
|
||
11 years ago
|
page = wiki.find_page('New page')
|
||
15 years ago
|
assert_equal 1, page.attachments.count
|
||
|
assert_equal 'testfile.txt', page.attachments.first.filename
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should update page' do
|
||
11 years ago
|
page = Wiki.find(1).pages.find_by_title('Another_page')
|
||
|
page.content.recreate_initial_journal!
|
||
|
|
||
10 years ago
|
session[:user_id] = 2
|
||
14 years ago
|
assert_no_difference 'WikiPage.count' do
|
||
|
assert_no_difference 'WikiContent.count' do
|
||
11 years ago
|
assert_difference 'Journal.count' do
|
||
10 years ago
|
put :update, project_id: 1,
|
||
10 years ago
|
id: 'Another_page',
|
||
|
content: {
|
||
|
comments: 'my comments',
|
||
|
text: 'edited',
|
||
|
lock_version: 2
|
||
|
}
|
||
14 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
assert_redirected_to '/projects/ecookbook/wiki/Another_page'
|
||
14 years ago
|
|
||
11 years ago
|
page.reload
|
||
10 years ago
|
assert_equal 'edited', page.content.text
|
||
11 years ago
|
assert_equal page.content.journals.map(&:version).max, page.content.version
|
||
10 years ago
|
assert_equal 'my comments', page.content.last_journal.notes
|
||
14 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should update page with failure' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
14 years ago
|
assert_no_difference 'WikiPage.count' do
|
||
|
assert_no_difference 'WikiContent.count' do
|
||
11 years ago
|
assert_no_difference 'Journal.count' do
|
||
10 years ago
|
put :update, project_id: 1,
|
||
10 years ago
|
id: 'Another_page',
|
||
|
content: {
|
||
|
comments: 'a' * 300, # failure here, comment is too long
|
||
|
text: 'edited',
|
||
|
lock_version: 1
|
||
|
}
|
||
14 years ago
|
end
|
||
|
end
|
||
10 years ago
|
end
|
||
14 years ago
|
assert_response :success
|
||
|
assert_template 'edit'
|
||
14 years ago
|
|
||
10 years ago
|
assert_error_tag descendant: { content: /Comment is too long/ }
|
||
|
assert_tag tag: 'textarea', attributes: { id: 'content_text' }, content: /edited/
|
||
|
assert_tag tag: 'input', attributes: { id: 'content_lock_version', value: '1' }
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
# NOTE: this test seems to depend on other tests in suite
|
||
|
# because running whole suite is fine, but running only this test
|
||
|
# results in failure
|
||
11 years ago
|
it 'should update stale page should not raise an error' do
|
||
11 years ago
|
journal = FactoryGirl.create :wiki_content_journal,
|
||
|
journable_id: 2,
|
||
11 years ago
|
version: 1,
|
||
11 years ago
|
data: FactoryGirl.build(:journal_wiki_content_journal,
|
||
|
text: "h1. Another page\n\n\nthis is a link to ticket: #2")
|
||
10 years ago
|
session[:user_id] = 2
|
||
14 years ago
|
c = Wiki.find(1).find_page('Another_page').content
|
||
|
c.text = 'Previous text'
|
||
|
c.save!
|
||
|
assert_equal 2, c.version
|
||
14 years ago
|
|
||
14 years ago
|
assert_no_difference 'WikiPage.count' do
|
||
|
assert_no_difference 'WikiContent.count' do
|
||
11 years ago
|
assert_no_difference 'Journal.count' do
|
||
10 years ago
|
put :update, project_id: 1,
|
||
10 years ago
|
id: 'Another_page',
|
||
|
content: {
|
||
|
comments: 'My comments',
|
||
|
text: 'Text should not be lost',
|
||
|
lock_version: 1
|
||
|
}
|
||
14 years ago
|
end
|
||
|
end
|
||
|
end
|
||
|
assert_response :success
|
||
|
assert_template 'edit'
|
||
|
assert_tag :div,
|
||
10 years ago
|
attributes: { class: /error/ },
|
||
|
content: /Information has been updated by at least one other user in the meantime/
|
||
14 years ago
|
assert_tag 'textarea',
|
||
10 years ago
|
attributes: { name: 'content[text]' },
|
||
|
content: /Text should not be lost/
|
||
14 years ago
|
assert_tag 'input',
|
||
10 years ago
|
attributes: { name: 'content[comments]', value: 'My comments' }
|
||
14 years ago
|
|
||
14 years ago
|
c.reload
|
||
|
assert_equal 'Previous text', c.text
|
||
11 years ago
|
assert_equal 2, c.version
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should history' do
|
||
11 years ago
|
FactoryGirl.create :wiki_content_journal,
|
||
|
journable_id: 1,
|
||
|
data: FactoryGirl.build(:journal_wiki_content_journal,
|
||
10 years ago
|
text: 'h1. CookBook documentation')
|
||
11 years ago
|
FactoryGirl.create :wiki_content_journal,
|
||
|
journable_id: 1,
|
||
|
data: FactoryGirl.build(:journal_wiki_content_journal,
|
||
|
text: "h1. CookBook documentation\n\n\nSome updated [[documentation]] here...")
|
||
|
FactoryGirl.create :wiki_content_journal,
|
||
|
journable_id: 1,
|
||
|
data: FactoryGirl.build(:journal_wiki_content_journal,
|
||
|
text: "h1. CookBook documentation\nSome updated [[documentation]] here...")
|
||
|
|
||
10 years ago
|
get :history, project_id: 1, id: 'CookBook_documentation'
|
||
17 years ago
|
assert_response :success
|
||
|
assert_template 'history'
|
||
|
assert_not_nil assigns(:versions)
|
||
|
assert_equal 3, assigns(:versions).size
|
||
10 years ago
|
assert_select 'input[type=submit][name=commit]'
|
||
17 years ago
|
end
|
||
16 years ago
|
|
||
11 years ago
|
it 'should history with one version' do
|
||
11 years ago
|
FactoryGirl.create :wiki_content_journal,
|
||
|
journable_id: 2,
|
||
|
data: FactoryGirl.build(:journal_wiki_content_journal,
|
||
|
text: "h1. Another page\n\n\nthis is a link to ticket: #2")
|
||
10 years ago
|
get :history, project_id: 1, id: 'Another_page'
|
||
16 years ago
|
assert_response :success
|
||
|
assert_template 'history'
|
||
|
assert_not_nil assigns(:versions)
|
||
|
assert_equal 1, assigns(:versions).size
|
||
10 years ago
|
assert_select 'input[type=submit][name=commit]', false
|
||
16 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should diff' do
|
||
11 years ago
|
journal_from = FactoryGirl.create :wiki_content_journal,
|
||
|
journable_id: 1,
|
||
|
data: FactoryGirl.build(:journal_wiki_content_journal,
|
||
10 years ago
|
text: 'h1. CookBook documentation')
|
||
11 years ago
|
journal_to = FactoryGirl.create :wiki_content_journal,
|
||
|
journable_id: 1,
|
||
|
data: FactoryGirl.build(:journal_wiki_content_journal,
|
||
|
text: "h1. CookBook documentation\n\n\nSome updated [[documentation]] here...")
|
||
|
|
||
10 years ago
|
get :diff, project_id: 1, id: 'CookBook_documentation', version: journal_to.version, version_from: journal_from.version
|
||
17 years ago
|
assert_response :success
|
||
|
assert_template 'diff'
|
||
10 years ago
|
assert_tag tag: 'ins', attributes: { class: 'diffins' },
|
||
|
content: /updated/
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should annotate' do
|
||
11 years ago
|
FactoryGirl.create :wiki_content_journal,
|
||
|
journable_id: 1,
|
||
|
data: FactoryGirl.build(:journal_wiki_content_journal,
|
||
10 years ago
|
text: 'h1. CookBook documentation')
|
||
11 years ago
|
journal_to = FactoryGirl.create :wiki_content_journal,
|
||
|
journable_id: 1,
|
||
|
data: FactoryGirl.build(:journal_wiki_content_journal,
|
||
|
text: "h1. CookBook documentation\n\n\nSome [[documentation]] here...")
|
||
|
|
||
10 years ago
|
get :annotate, project_id: 1, id: 'CookBook_documentation', version: journal_to.version
|
||
17 years ago
|
assert_response :success
|
||
|
assert_template 'annotate'
|
||
|
# Line 1
|
||
10 years ago
|
assert_tag tag: 'tr', child: { tag: 'th', attributes: { class: 'line-num' }, content: '1' },
|
||
|
child: { tag: 'td', attributes: { class: 'author' }, content: /John Smith/ },
|
||
|
child: { tag: 'td', content: /h1\. CookBook documentation/ }
|
||
17 years ago
|
# Line 2
|
||
10 years ago
|
assert_tag tag: 'tr', child: { tag: 'th', attributes: { class: 'line-num' }, content: '2' },
|
||
|
child: { tag: 'td', attributes: { class: 'author' }, content: /redMine Admin/ },
|
||
|
child: { tag: 'td', content: /Some updated \[\[documentation\]\] here/ }
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should get rename' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
get :rename, project_id: 1, id: 'Another_page'
|
||
14 years ago
|
assert_response :success
|
||
|
assert_template 'rename'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should get rename child page' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
get :rename, project_id: 1, id: 'Child_1'
|
||
14 years ago
|
assert_response :success
|
||
|
assert_template 'rename'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should rename with redirect' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
put :rename, project_id: 1, id: 'Another_page',
|
||
|
page: { title: 'Another renamed page',
|
||
10 years ago
|
redirect_existing_links: 1 }
|
||
10 years ago
|
assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'Another_renamed_page'
|
||
17 years ago
|
# Check redirects
|
||
|
assert_not_nil wiki.find_page('Another page')
|
||
10 years ago
|
assert_nil wiki.find_page('Another page', with_redirect: false)
|
||
17 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should rename without redirect' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
put :rename, project_id: 1, id: 'Another_page',
|
||
|
page: { title: 'Another renamed page',
|
||
10 years ago
|
redirect_existing_links: '0' }
|
||
10 years ago
|
assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'Another_renamed_page'
|
||
17 years ago
|
# Check that there's no redirects
|
||
|
assert_nil wiki.find_page('Another page')
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should destroy child' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
delete :destroy, project_id: 1, id: 'Child_1'
|
||
11 years ago
|
assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page
|
||
16 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should destroy parent' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
16 years ago
|
assert_no_difference('WikiPage.count') do
|
||
10 years ago
|
delete :destroy, project_id: 1, id: 'Another_page'
|
||
16 years ago
|
end
|
||
|
assert_response :success
|
||
|
assert_template 'destroy'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should destroy parent with nullify' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
16 years ago
|
assert_difference('WikiPage.count', -1) do
|
||
10 years ago
|
delete :destroy, project_id: 1, id: 'Another_page', todo: 'nullify'
|
||
16 years ago
|
end
|
||
11 years ago
|
assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page
|
||
16 years ago
|
assert_nil WikiPage.find_by_id(2)
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should destroy parent with cascade' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
16 years ago
|
assert_difference('WikiPage.count', -3) do
|
||
10 years ago
|
delete :destroy, project_id: 1, id: 'Another_page', todo: 'destroy'
|
||
16 years ago
|
end
|
||
11 years ago
|
assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page
|
||
16 years ago
|
assert_nil WikiPage.find_by_id(2)
|
||
|
assert_nil WikiPage.find_by_id(5)
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should destroy parent with reassign' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
16 years ago
|
assert_difference('WikiPage.count', -1) do
|
||
10 years ago
|
delete :destroy, project_id: 1, id: 'Another_page', todo: 'reassign', reassign_to_id: 1
|
||
16 years ago
|
end
|
||
11 years ago
|
assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page
|
||
16 years ago
|
assert_nil WikiPage.find_by_id(2)
|
||
|
assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should index' do
|
||
10 years ago
|
get :index, project_id: 'ecookbook'
|
||
17 years ago
|
assert_response :success
|
||
14 years ago
|
assert_template 'index'
|
||
17 years ago
|
pages = assigns(:pages)
|
||
|
assert_not_nil pages
|
||
11 years ago
|
assert_equal wiki.pages.size, pages.size
|
||
14 years ago
|
assert_equal pages.first.content.updated_on, pages.first.updated_on
|
||
14 years ago
|
|
||
10 years ago
|
assert_tag :ul, attributes: { class: 'pages-hierarchy' },
|
||
|
child: { tag: 'li', child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/CookBook_documentation' },
|
||
10 years ago
|
content: 'CookBook documentation' },
|
||
|
child: { tag: 'ul',
|
||
|
child: { tag: 'li',
|
||
|
child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/Page_with_an_inline_image' },
|
||
|
content: 'Page with an inline image' } } } },
|
||
10 years ago
|
child: { tag: 'li', child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/Another_page' },
|
||
10 years ago
|
content: 'Another page' } }
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should index should include atom link' do
|
||
10 years ago
|
get :index, project_id: 'ecookbook'
|
||
10 years ago
|
assert_tag 'a', attributes: { href: '/projects/ecookbook/activity.atom?show_wiki_edits=1' }
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
context 'GET :export' do
|
||
|
context 'with an authorized user to export the wiki' do
|
||
11 years ago
|
before do
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
get :export, project_id: 'ecookbook'
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
it { is_expected.to respond_with :success }
|
||
11 years ago
|
it { should_assign_to :pages }
|
||
|
it { should_respond_with_content_type 'text/html' }
|
||
|
it 'should export all of the wiki pages to a single html file' do
|
||
10 years ago
|
assert_select 'a[name=?]', 'CookBook_documentation'
|
||
|
assert_select 'a[name=?]', 'Another_page'
|
||
|
assert_select 'a[name=?]', 'Page_with_an_inline_image'
|
||
14 years ago
|
end
|
||
|
end
|
||
|
|
||
10 years ago
|
context 'with an unauthorized user' do
|
||
11 years ago
|
before do
|
||
10 years ago
|
get :export, project_id: 'ecookbook'
|
||
14 years ago
|
|
||
10 years ago
|
it { is_expected.to respond_with :redirect }
|
||
|
it { is_expected.to redirect_to('wiki index') { { action: 'show', project_id: @project, id: nil } } }
|
||
14 years ago
|
end
|
||
|
end
|
||
|
end
|
||
14 years ago
|
|
||
10 years ago
|
context 'GET :date_index' do
|
||
11 years ago
|
before do
|
||
10 years ago
|
get :date_index, project_id: 'ecookbook'
|
||
14 years ago
|
end
|
||
|
|
||
10 years ago
|
it { is_expected.to respond_with :success }
|
||
11 years ago
|
it { should_assign_to :pages }
|
||
|
it { should_assign_to :pages_by_date }
|
||
10 years ago
|
it { is_expected.to render_template 'wiki/date_index' }
|
||
14 years ago
|
|
||
11 years ago
|
it 'should include atom link' do
|
||
10 years ago
|
assert_tag 'a', attributes: { href: '/projects/ecookbook/activity.atom?show_wiki_edits=1' }
|
||
14 years ago
|
end
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should not found' do
|
||
10 years ago
|
get :show, project_id: 999
|
||
17 years ago
|
assert_response 404
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should protect page' do
|
||
17 years ago
|
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
|
||
|
assert !page.protected?
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
post :protect, project_id: 1, id: page.title, protected: '1'
|
||
|
assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'Another_page'
|
||
17 years ago
|
assert page.reload.protected?
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should unprotect page' do
|
||
17 years ago
|
page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation')
|
||
|
assert page.protected?
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
post :protect, project_id: 1, id: page.title, protected: '0'
|
||
|
assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'CookBook_documentation'
|
||
17 years ago
|
assert !page.reload.protected?
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should show page with edit link' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
get :show, project_id: 1
|
||
17 years ago
|
assert_response :success
|
||
|
assert_template 'show'
|
||
10 years ago
|
assert_tag tag: 'a', attributes: { href: '/projects/1/wiki/CookBook_documentation/edit' }
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should show page without edit link' do
|
||
10 years ago
|
session[:user_id] = 4
|
||
10 years ago
|
get :show, project_id: 1
|
||
17 years ago
|
assert_response :success
|
||
|
assert_template 'show'
|
||
10 years ago
|
assert_no_tag tag: 'a', attributes: { href: '/projects/1/wiki/CookBook_documentation/edit' }
|
||
14 years ago
|
end
|
||
|
|
||
11 years ago
|
it 'should edit unprotected page' do
|
||
17 years ago
|
# Non members can edit unprotected wiki pages
|
||
10 years ago
|
session[:user_id] = 4
|
||
10 years ago
|
get :edit, project_id: 1, id: 'Another_page'
|
||
17 years ago
|
assert_response :success
|
||
|
assert_template 'edit'
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should edit protected page by nonmember' do
|
||
17 years ago
|
# Non members can't edit protected wiki pages
|
||
10 years ago
|
session[:user_id] = 4
|
||
10 years ago
|
get :edit, project_id: 1, id: 'CookBook_documentation'
|
||
17 years ago
|
assert_response 403
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should edit protected page by member' do
|
||
10 years ago
|
session[:user_id] = 2
|
||
10 years ago
|
get :edit, project_id: 1, id: 'CookBook_documentation'
|
||
17 years ago
|
assert_response :success
|
||
14 years ago
|
assert_template 'edit'
|
||
17 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should history of non existing page should return 404' do
|
||
10 years ago
|
get :history, project_id: 1, id: 'Unknown_page'
|
||
16 years ago
|
assert_response 404
|
||
|
end
|
||
17 years ago
|
end
|