OpenProject is the leading open source project management software.
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.
openproject/spec_legacy/functional/wiki_controller_spec.rb

418 lines
16 KiB

#-- encoding: UTF-8
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2021 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# 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.
#
# See COPYRIGHT and LICENSE files for more details.
#++
require_relative '../legacy_spec_helper'
require 'wiki_controller'
describe WikiController, type: :controller do
render_views
fixtures :all
before do
User.current = nil
end
def wiki
Project.first.wiki
end
def redirect_page
wiki.find_page(wiki.start_page) || wiki.pages.first
end
it 'should show start page' do
get :show, params: { project_id: 'ecookbook' }
assert_response :success
assert_template 'show'
assert_select 'h1', content: /CookBook documentation/
# child_pages macro
assert_select 'ul',
attributes: { class: 'pages-hierarchy' },
child: {
tag: 'li',
child: {
tag: 'a',
attributes: { href: '/projects/ecookbook/wiki/Page_with_an_inline_image' },
content: 'Page with an inline image'
}
}
end
it 'should show page with name' do
get :show, params: { project_id: 1, id: 'Another page' }
assert_response :success
assert_template 'show'
assert_select 'h1', content: /Another page/
end
it 'should show unexistent page without edit right' do
get :show, params: { project_id: 1, id: 'Unexistent page' }
assert_response 404
end
it 'should show unexistent page with edit right' do
session[:user_id] = 2
get :show, params: { project_id: 1, id: 'Unexistent page' }
assert_response :success
assert_template 'new'
end
it 'should create page' do
session[:user_id] = 2
post :create, params: { project_id: 1,
id: 'New page',
content: { comments: 'Created the page',
text: "h1. New page\n\nThis is a new page",
page: { title: 'New page',
parent_id: '' } } }
8 years ago
assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'new-page'
page = wiki.find_page('New page')
assert !page.new_record?
refute_nil page.content
assert_equal 'Created the page', page.content.last_journal.notes
end
it 'should update page with failure' do
session[:user_id] = 2
assert_no_difference 'WikiPage.count' do
assert_no_difference 'WikiContent.count' do
assert_no_difference 'Journal.count' do
put :update, params: { project_id: 1,
id: 'Another page',
content: {
comments: 'a' * 300, # failure here, comment is too long
text: 'edited',
lock_version: 1,
page: { title: 'Another page',
parent_id: '' }
} }
end
end
end
assert_response :success
assert_template 'edit'
assert_error_tag descendant: { content: /Comment is too long/ }
assert_select 'textarea', attributes: { id: 'content_text' }, content: /edited/
assert_select 'input', attributes: { id: 'content_lock_version', value: '1' }
end
it 'should history' do
FactoryBot.create :wiki_content_journal,
journable_id: 1,
data: FactoryBot.build(:journal_wiki_content_journal,
text: 'h1. CookBook documentation')
FactoryBot.create :wiki_content_journal,
journable_id: 1,
data: FactoryBot.build(:journal_wiki_content_journal,
text: "h1. CookBook documentation\n\n\nSome updated [[documentation]] here...")
FactoryBot.create :wiki_content_journal,
journable_id: 1,
data: FactoryBot.build(:journal_wiki_content_journal,
text: "h1. CookBook documentation\nSome updated [[documentation]] here...")
get :history, params: { project_id: 1, id: 'CookBook documentation' }
assert_response :success
assert_template 'history'
refute_nil assigns(:versions)
assert_equal 3, assigns(:versions).size
assert_select 'input[type=submit][name=commit]'
end
it 'should history with one version' do
FactoryBot.create :wiki_content_journal,
journable_id: 2,
data: FactoryBot.build(:journal_wiki_content_journal,
text: "h1. Another page\n\n\nthis is a link to ticket: #2")
get :history, params: { project_id: 1, id: 'Another page' }
assert_response :success
assert_template 'history'
refute_nil assigns(:versions)
assert_equal 1, assigns(:versions).size
assert_select 'input[type=submit][name=commit]', false
end
it 'should diff' do
journal_from = FactoryBot.create :wiki_content_journal,
journable_id: 1,
data: FactoryBot.build(:journal_wiki_content_journal,
text: 'h1. CookBook documentation')
journal_to = FactoryBot.create :wiki_content_journal,
journable_id: 1,
data: FactoryBot.build(:journal_wiki_content_journal,
text: "h1. CookBook documentation\n\n\nSome updated [[documentation]] here...")
get :diff,
params: { project_id: 1, id: 'CookBook documentation', version: journal_to.version, version_from: journal_from.version }
assert_response :success
assert_template 'diff'
assert_select 'ins', attributes: { class: 'diffins' },
content: /updated/
end
it 'should annotate' do
FactoryBot.create :wiki_content_journal,
journable_id: 1,
data: FactoryBot.build(:journal_wiki_content_journal,
text: 'h1. CookBook documentation')
journal_to = FactoryBot.create :wiki_content_journal,
journable_id: 1,
data: FactoryBot.build(:journal_wiki_content_journal,
text: "h1. CookBook documentation\n\n\nSome [[documentation]] here...")
get :annotate, params: { project_id: 1, id: 'CookBook documentation', version: journal_to.version }
assert_response :success
assert_template 'annotate'
# Line 1
assert_select '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/ }
# Line 2
assert_select '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/ }
end
it 'should get rename' do
session[:user_id] = 2
get :rename, params: { project_id: 1, id: 'Another page' }
assert_response :success
assert_template 'rename'
end
it 'should get rename child page' do
session[:user_id] = 2
get :rename, params: { project_id: 1, id: 'Child 1' }
assert_response :success
assert_template 'rename'
end
it 'should rename with redirect' do
session[:user_id] = 2
patch :rename, params: { project_id: 1, id: 'Another page',
page: { title: 'Another renamed page',
redirect_existing_links: 1 } }
8 years ago
assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'another-renamed-page'
# Check redirects
refute_nil wiki.find_page('Another page')
assert_nil wiki.find_page('Another page', with_redirect: false)
end
it 'should rename without redirect' do
session[:user_id] = 2
patch :rename, params: { project_id: 1, id: 'another-page',
page: { title: 'Another renamed page',
redirect_existing_links: '0' } }
8 years ago
assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'another-renamed-page'
# Check that there's no redirects
assert_nil wiki.find_page('Another page')
end
it 'should destroy child' do
session[:user_id] = 2
delete :destroy, params: { project_id: 1, id: 'Child 1' }
assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page
Converted routing and urls to follow the Rails REST convention. Patch supplied by commits from Gerrit Kaiser on Github. Existing routes will still work (backwards compatible) but any new urls will be generated using the new routing rules. Changes listed below: * made the URLs for some project tabs and project settings follow the new rails RESTful conventions of /collection/:id/subcollection/:sub_id * prettier URL for project roadmap * more nice project URLs * use GET for filtering form * prettified URLs used on issues tab * custom route for activity atom feeds * prettier repository urls * fixed broken route definition * fixed failing tests for issuecontroller that were hardcoding the url string * more RESTful routes for boards and messages * RESTful routes for wiki pages * RESTful routes for documents * moved old routes that are retained for compatibility to the bottom and grouped them together * added RESTful URIs for issues * RESTfulness for the news section * fixed route order * changed hardcoded URLs in tests * fixed badly written tests * fixed forgotten parameter in routes * changed hardcoded URLS to new scheme * changed project add url to the standard POST to collection * create new issue by POSTing to collection * changed hardcoded URLs in integrations tests * made project add form work again * restful routes for project deletion * prettier routes for project (un)archival * made routes table more readable * fixed note quoting * user routing * fixed bug * always sort by GET * Fixed: cross-project issue list should not show issues of projects for which the issue tracking module was disabled. * prettified URLs used on issues tab * urls for time log * fixed reply routing * eliminate revision query paremeter for diff and entry actions * fixed test failures with hard-coded urls * ensure ajax links always use get * refactored ajax link generation into separate method #1901 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2317 e93f8b46-1217-0410-a6f0-8f06a7374b81
16 years ago
end
it 'should destroy parent' do
session[:user_id] = 2
assert_no_difference('WikiPage.count') do
delete :destroy, params: { project_id: 1, id: 'Another page' }
end
assert_response :success
assert_template 'destroy'
end
it 'should destroy parent with nullify' do
session[:user_id] = 2
assert_difference('WikiPage.count', -1) do
delete :destroy, params: { project_id: 1, id: 'Another page', todo: 'nullify' }
end
assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page
assert_nil WikiPage.find_by(id: 2)
end
it 'should destroy parent with cascade' do
session[:user_id] = 2
assert_difference('WikiPage.count', -3) do
delete :destroy, params: { project_id: 1, id: 'Another page', todo: 'destroy' }
end
assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page
assert_nil WikiPage.find_by(id: 2)
assert_nil WikiPage.find_by(id: 5)
end
it 'should destroy parent with reassign' do
session[:user_id] = 2
assert_difference('WikiPage.count', -1) do
delete :destroy, params: { project_id: 1, id: 'Another page', todo: 'reassign', reassign_to_id: 1 }
end
assert_redirected_to action: 'index', project_id: 'ecookbook', id: redirect_page
assert_nil WikiPage.find_by(id: 2)
assert_equal WikiPage.find(1), WikiPage.find_by(id: 5).parent
end
it 'should index' do
get :index, params: { project_id: 'ecookbook' }
assert_response :success
assert_template 'index'
pages = assigns(:pages)
refute_nil pages
assert_equal wiki.pages.size, pages.size
assert_equal pages.first.content.updated_at, pages.first.updated_at
assert_select 'ul', attributes: { class: 'pages-hierarchy' },
child: { tag: 'li', child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/CookBook%20documentation' },
content: 'CookBook documentation' },
child: { tag: 'ul',
child: { tag: 'li',
child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/Page%20with%20an%20inline%20image' },
content: 'Page with an inline image' } } } },
child: { tag: 'li', child: { tag: 'a', attributes: { href: '/projects/ecookbook/wiki/Another%20page' },
content: 'Another page' } }
end
it 'should index should include atom link' do
get :index, params: { project_id: 'ecookbook' }
assert_select 'a', attributes: { href: '/projects/ecookbook/activity.atom?show_wiki_edits=1' }
end
context 'GET :export' do
context 'with an authorized user to export the wiki' do
before do
session[:user_id] = 2
get :export, params: { project_id: 'ecookbook' }
end
Convert specs to RSpec 3.2.0 syntax with Transpec This conversion is done by Transpec 3.1.0 with the following command: transpec -f -c "bundle exec rspec -Itest" test/functional/account_controller_test.rb test/functional/activities_controller_test.rb test/functional/admin_controller_test.rb test/functional/application_controller_test.rb test/functional/attachments_controller_test.rb test/functional/boards_controller_test.rb test/functional/custom_fields_controller_test.rb test/functional/enumerations_controller_test.rb test/functional/groups_controller_test.rb test/functional/help_controller_test.rb test/functional/journals_controller_test.rb test/functional/mail_handler_controller_test.rb test/functional/messages_controller_test.rb test/functional/my_controller_test.rb test/functional/project_enumerations_controller_test.rb test/functional/projects_controller_test.rb test/functional/repositories_controller_test.rb test/functional/repositories_filesystem_controller_test.rb test/functional/repositories_git_controller_test.rb test/functional/repositories_subversion_controller_test.rb test/functional/roles_controller_test.rb test/functional/search_controller_test.rb test/functional/settings_controller_test.rb test/functional/sys_controller_test.rb test/functional/time_entries/reports_controller_test.rb test/functional/timelog_controller_test.rb test/functional/types_controller_test.rb test/functional/user_mailer_test.rb test/functional/users_controller_test.rb test/functional/watchers_controller_test.rb test/functional/welcome_controller_test.rb test/functional/wiki_controller_test.rb test/functional/wikis_controller_test.rb test/functional/workflows_controller_test.rb test/integration/api_test/disabled_rest_api_test.rb test/integration/api_test/http_accept_auth_test.rb test/integration/api_test/http_basic_login_test.rb test/integration/api_test/http_basic_login_with_api_token_test.rb test/integration/api_test/token_authentication_test.rb test/integration/application_test.rb test/integration/layout_test.rb test/integration/lib/redmine/menu_manager_test.rb test/integration/lib/redmine/themes_test.rb test/integration/routing_test.rb test/unit/activity_test.rb test/unit/attachment_test.rb test/unit/board_test.rb test/unit/category_test.rb test/unit/changeset_test.rb test/unit/comment_test.rb test/unit/custom_field_test.rb test/unit/custom_field_user_format_test.rb test/unit/custom_value_test.rb test/unit/default_data_test.rb test/unit/enabled_module_test.rb test/unit/enumeration_test.rb test/unit/group_test.rb test/unit/helpers/application_helper_test.rb test/unit/helpers/custom_fields_helper_test.rb test/unit/helpers/sort_helper_test.rb test/unit/helpers/timelog_helper_test.rb test/unit/issue_nested_set_test.rb test/unit/issue_priority_test.rb test/unit/journal_observer_test.rb test/unit/journal_test.rb test/unit/ldap_auth_source_test.rb test/unit/lib/open_project/database_test.rb test/unit/lib/redmine/access_control_test.rb test/unit/lib/redmine/ciphering_test.rb test/unit/lib/redmine/codeset_util_test.rb test/unit/lib/redmine/helpers/calendar_test.rb test/unit/lib/redmine/hook_test.rb test/unit/lib/redmine/i18n_test.rb test/unit/lib/redmine/menu_manager/mapper_test.rb test/unit/lib/redmine/menu_manager/menu_helper_test.rb test/unit/lib/redmine/menu_manager/menu_item_test.rb test/unit/lib/redmine/menu_manager_test.rb test/unit/lib/redmine/mime_type_test.rb test/unit/lib/redmine/notifiable_test.rb test/unit/lib/redmine/plugin_test.rb test/unit/lib/redmine/safe_attributes_test.rb test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb test/unit/lib/redmine/scm/adapters/git_adapter_test.rb test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb test/unit/lib/redmine/unified_diff_test.rb test/unit/lib/redmine/wiki_formatting/macros_test.rb test/unit/lib/redmine/wiki_formatting/null_formatter_test.rb test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb test/unit/lib/redmine/wiki_formatting_test.rb test/unit/lib/redmine_test.rb test/unit/mail_handler_test.rb test/unit/member_test.rb test/unit/message_test.rb test/unit/principal_test.rb test/unit/project_nested_set_test.rb test/unit/project_test.rb test/unit/query_test.rb test/unit/relation_test.rb test/unit/repository_filesystem_test.rb test/unit/repository_git_test.rb test/unit/repository_subversion_test.rb test/unit/repository_test.rb test/unit/role_test.rb test/unit/search_test.rb test/unit/status_test.rb test/unit/time_entry_activity_test.rb test/unit/time_entry_test.rb test/unit/token_test.rb test/unit/type_test.rb test/unit/user_preference_test.rb test/unit/user_test.rb test/unit/version_test.rb test/unit/watcher_test.rb test/unit/wiki_content_test.rb test/unit/wiki_page_test.rb test/unit/wiki_redirect_test.rb test/unit/wiki_test.rb * 180 conversions from: it { should ... } to: it { is_expected.to ... } * 12 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 4 conversions from: Klass.any_instance.should_receive(:message) to: expect_any_instance_of(Klass).to receive(:message) * 4 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 2 conversions from: Klass.any_instance.stub(:message) to: allow_any_instance_of(Klass).to receive(:message) For more details: https://github.com/yujinakayama/transpec#supported-conversions
10 years ago
it { is_expected.to respond_with :success }
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
8 years ago
assert_select 'a[name=?]', 'cookbook-documentation'
assert_select 'a[name=?]', 'another-page'
assert_select 'a[name=?]', 'page-with-an-inline-image'
end
end
context 'with an unauthorized user' do
before do
get :export, params: { project_id: 'ecookbook' }
Convert specs to RSpec 3.2.0 syntax with Transpec This conversion is done by Transpec 3.1.0 with the following command: transpec -f -c "bundle exec rspec -Itest" test/functional/account_controller_test.rb test/functional/activities_controller_test.rb test/functional/admin_controller_test.rb test/functional/application_controller_test.rb test/functional/attachments_controller_test.rb test/functional/boards_controller_test.rb test/functional/custom_fields_controller_test.rb test/functional/enumerations_controller_test.rb test/functional/groups_controller_test.rb test/functional/help_controller_test.rb test/functional/journals_controller_test.rb test/functional/mail_handler_controller_test.rb test/functional/messages_controller_test.rb test/functional/my_controller_test.rb test/functional/project_enumerations_controller_test.rb test/functional/projects_controller_test.rb test/functional/repositories_controller_test.rb test/functional/repositories_filesystem_controller_test.rb test/functional/repositories_git_controller_test.rb test/functional/repositories_subversion_controller_test.rb test/functional/roles_controller_test.rb test/functional/search_controller_test.rb test/functional/settings_controller_test.rb test/functional/sys_controller_test.rb test/functional/time_entries/reports_controller_test.rb test/functional/timelog_controller_test.rb test/functional/types_controller_test.rb test/functional/user_mailer_test.rb test/functional/users_controller_test.rb test/functional/watchers_controller_test.rb test/functional/welcome_controller_test.rb test/functional/wiki_controller_test.rb test/functional/wikis_controller_test.rb test/functional/workflows_controller_test.rb test/integration/api_test/disabled_rest_api_test.rb test/integration/api_test/http_accept_auth_test.rb test/integration/api_test/http_basic_login_test.rb test/integration/api_test/http_basic_login_with_api_token_test.rb test/integration/api_test/token_authentication_test.rb test/integration/application_test.rb test/integration/layout_test.rb test/integration/lib/redmine/menu_manager_test.rb test/integration/lib/redmine/themes_test.rb test/integration/routing_test.rb test/unit/activity_test.rb test/unit/attachment_test.rb test/unit/board_test.rb test/unit/category_test.rb test/unit/changeset_test.rb test/unit/comment_test.rb test/unit/custom_field_test.rb test/unit/custom_field_user_format_test.rb test/unit/custom_value_test.rb test/unit/default_data_test.rb test/unit/enabled_module_test.rb test/unit/enumeration_test.rb test/unit/group_test.rb test/unit/helpers/application_helper_test.rb test/unit/helpers/custom_fields_helper_test.rb test/unit/helpers/sort_helper_test.rb test/unit/helpers/timelog_helper_test.rb test/unit/issue_nested_set_test.rb test/unit/issue_priority_test.rb test/unit/journal_observer_test.rb test/unit/journal_test.rb test/unit/ldap_auth_source_test.rb test/unit/lib/open_project/database_test.rb test/unit/lib/redmine/access_control_test.rb test/unit/lib/redmine/ciphering_test.rb test/unit/lib/redmine/codeset_util_test.rb test/unit/lib/redmine/helpers/calendar_test.rb test/unit/lib/redmine/hook_test.rb test/unit/lib/redmine/i18n_test.rb test/unit/lib/redmine/menu_manager/mapper_test.rb test/unit/lib/redmine/menu_manager/menu_helper_test.rb test/unit/lib/redmine/menu_manager/menu_item_test.rb test/unit/lib/redmine/menu_manager_test.rb test/unit/lib/redmine/mime_type_test.rb test/unit/lib/redmine/notifiable_test.rb test/unit/lib/redmine/plugin_test.rb test/unit/lib/redmine/safe_attributes_test.rb test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb test/unit/lib/redmine/scm/adapters/git_adapter_test.rb test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb test/unit/lib/redmine/unified_diff_test.rb test/unit/lib/redmine/wiki_formatting/macros_test.rb test/unit/lib/redmine/wiki_formatting/null_formatter_test.rb test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb test/unit/lib/redmine/wiki_formatting_test.rb test/unit/lib/redmine_test.rb test/unit/mail_handler_test.rb test/unit/member_test.rb test/unit/message_test.rb test/unit/principal_test.rb test/unit/project_nested_set_test.rb test/unit/project_test.rb test/unit/query_test.rb test/unit/relation_test.rb test/unit/repository_filesystem_test.rb test/unit/repository_git_test.rb test/unit/repository_subversion_test.rb test/unit/repository_test.rb test/unit/role_test.rb test/unit/search_test.rb test/unit/status_test.rb test/unit/time_entry_activity_test.rb test/unit/time_entry_test.rb test/unit/token_test.rb test/unit/type_test.rb test/unit/user_preference_test.rb test/unit/user_test.rb test/unit/version_test.rb test/unit/watcher_test.rb test/unit/wiki_content_test.rb test/unit/wiki_page_test.rb test/unit/wiki_redirect_test.rb test/unit/wiki_test.rb * 180 conversions from: it { should ... } to: it { is_expected.to ... } * 12 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 4 conversions from: Klass.any_instance.should_receive(:message) to: expect_any_instance_of(Klass).to receive(:message) * 4 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 2 conversions from: Klass.any_instance.stub(:message) to: allow_any_instance_of(Klass).to receive(:message) For more details: https://github.com/yujinakayama/transpec#supported-conversions
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 } } }
end
end
end
context 'GET :date_index' do
before do
get :date_index, params: { project_id: 'ecookbook' }
end
Convert specs to RSpec 3.2.0 syntax with Transpec This conversion is done by Transpec 3.1.0 with the following command: transpec -f -c "bundle exec rspec -Itest" test/functional/account_controller_test.rb test/functional/activities_controller_test.rb test/functional/admin_controller_test.rb test/functional/application_controller_test.rb test/functional/attachments_controller_test.rb test/functional/boards_controller_test.rb test/functional/custom_fields_controller_test.rb test/functional/enumerations_controller_test.rb test/functional/groups_controller_test.rb test/functional/help_controller_test.rb test/functional/journals_controller_test.rb test/functional/mail_handler_controller_test.rb test/functional/messages_controller_test.rb test/functional/my_controller_test.rb test/functional/project_enumerations_controller_test.rb test/functional/projects_controller_test.rb test/functional/repositories_controller_test.rb test/functional/repositories_filesystem_controller_test.rb test/functional/repositories_git_controller_test.rb test/functional/repositories_subversion_controller_test.rb test/functional/roles_controller_test.rb test/functional/search_controller_test.rb test/functional/settings_controller_test.rb test/functional/sys_controller_test.rb test/functional/time_entries/reports_controller_test.rb test/functional/timelog_controller_test.rb test/functional/types_controller_test.rb test/functional/user_mailer_test.rb test/functional/users_controller_test.rb test/functional/watchers_controller_test.rb test/functional/welcome_controller_test.rb test/functional/wiki_controller_test.rb test/functional/wikis_controller_test.rb test/functional/workflows_controller_test.rb test/integration/api_test/disabled_rest_api_test.rb test/integration/api_test/http_accept_auth_test.rb test/integration/api_test/http_basic_login_test.rb test/integration/api_test/http_basic_login_with_api_token_test.rb test/integration/api_test/token_authentication_test.rb test/integration/application_test.rb test/integration/layout_test.rb test/integration/lib/redmine/menu_manager_test.rb test/integration/lib/redmine/themes_test.rb test/integration/routing_test.rb test/unit/activity_test.rb test/unit/attachment_test.rb test/unit/board_test.rb test/unit/category_test.rb test/unit/changeset_test.rb test/unit/comment_test.rb test/unit/custom_field_test.rb test/unit/custom_field_user_format_test.rb test/unit/custom_value_test.rb test/unit/default_data_test.rb test/unit/enabled_module_test.rb test/unit/enumeration_test.rb test/unit/group_test.rb test/unit/helpers/application_helper_test.rb test/unit/helpers/custom_fields_helper_test.rb test/unit/helpers/sort_helper_test.rb test/unit/helpers/timelog_helper_test.rb test/unit/issue_nested_set_test.rb test/unit/issue_priority_test.rb test/unit/journal_observer_test.rb test/unit/journal_test.rb test/unit/ldap_auth_source_test.rb test/unit/lib/open_project/database_test.rb test/unit/lib/redmine/access_control_test.rb test/unit/lib/redmine/ciphering_test.rb test/unit/lib/redmine/codeset_util_test.rb test/unit/lib/redmine/helpers/calendar_test.rb test/unit/lib/redmine/hook_test.rb test/unit/lib/redmine/i18n_test.rb test/unit/lib/redmine/menu_manager/mapper_test.rb test/unit/lib/redmine/menu_manager/menu_helper_test.rb test/unit/lib/redmine/menu_manager/menu_item_test.rb test/unit/lib/redmine/menu_manager_test.rb test/unit/lib/redmine/mime_type_test.rb test/unit/lib/redmine/notifiable_test.rb test/unit/lib/redmine/plugin_test.rb test/unit/lib/redmine/safe_attributes_test.rb test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb test/unit/lib/redmine/scm/adapters/git_adapter_test.rb test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb test/unit/lib/redmine/unified_diff_test.rb test/unit/lib/redmine/wiki_formatting/macros_test.rb test/unit/lib/redmine/wiki_formatting/null_formatter_test.rb test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb test/unit/lib/redmine/wiki_formatting_test.rb test/unit/lib/redmine_test.rb test/unit/mail_handler_test.rb test/unit/member_test.rb test/unit/message_test.rb test/unit/principal_test.rb test/unit/project_nested_set_test.rb test/unit/project_test.rb test/unit/query_test.rb test/unit/relation_test.rb test/unit/repository_filesystem_test.rb test/unit/repository_git_test.rb test/unit/repository_subversion_test.rb test/unit/repository_test.rb test/unit/role_test.rb test/unit/search_test.rb test/unit/status_test.rb test/unit/time_entry_activity_test.rb test/unit/time_entry_test.rb test/unit/token_test.rb test/unit/type_test.rb test/unit/user_preference_test.rb test/unit/user_test.rb test/unit/version_test.rb test/unit/watcher_test.rb test/unit/wiki_content_test.rb test/unit/wiki_page_test.rb test/unit/wiki_redirect_test.rb test/unit/wiki_test.rb * 180 conversions from: it { should ... } to: it { is_expected.to ... } * 12 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 4 conversions from: Klass.any_instance.should_receive(:message) to: expect_any_instance_of(Klass).to receive(:message) * 4 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 2 conversions from: Klass.any_instance.stub(:message) to: allow_any_instance_of(Klass).to receive(:message) For more details: https://github.com/yujinakayama/transpec#supported-conversions
10 years ago
it { is_expected.to respond_with :success }
it { should_assign_to :pages }
it { should_assign_to :pages_by_date }
Convert specs to RSpec 3.2.0 syntax with Transpec This conversion is done by Transpec 3.1.0 with the following command: transpec -f -c "bundle exec rspec -Itest" test/functional/account_controller_test.rb test/functional/activities_controller_test.rb test/functional/admin_controller_test.rb test/functional/application_controller_test.rb test/functional/attachments_controller_test.rb test/functional/boards_controller_test.rb test/functional/custom_fields_controller_test.rb test/functional/enumerations_controller_test.rb test/functional/groups_controller_test.rb test/functional/help_controller_test.rb test/functional/journals_controller_test.rb test/functional/mail_handler_controller_test.rb test/functional/messages_controller_test.rb test/functional/my_controller_test.rb test/functional/project_enumerations_controller_test.rb test/functional/projects_controller_test.rb test/functional/repositories_controller_test.rb test/functional/repositories_filesystem_controller_test.rb test/functional/repositories_git_controller_test.rb test/functional/repositories_subversion_controller_test.rb test/functional/roles_controller_test.rb test/functional/search_controller_test.rb test/functional/settings_controller_test.rb test/functional/sys_controller_test.rb test/functional/time_entries/reports_controller_test.rb test/functional/timelog_controller_test.rb test/functional/types_controller_test.rb test/functional/user_mailer_test.rb test/functional/users_controller_test.rb test/functional/watchers_controller_test.rb test/functional/welcome_controller_test.rb test/functional/wiki_controller_test.rb test/functional/wikis_controller_test.rb test/functional/workflows_controller_test.rb test/integration/api_test/disabled_rest_api_test.rb test/integration/api_test/http_accept_auth_test.rb test/integration/api_test/http_basic_login_test.rb test/integration/api_test/http_basic_login_with_api_token_test.rb test/integration/api_test/token_authentication_test.rb test/integration/application_test.rb test/integration/layout_test.rb test/integration/lib/redmine/menu_manager_test.rb test/integration/lib/redmine/themes_test.rb test/integration/routing_test.rb test/unit/activity_test.rb test/unit/attachment_test.rb test/unit/board_test.rb test/unit/category_test.rb test/unit/changeset_test.rb test/unit/comment_test.rb test/unit/custom_field_test.rb test/unit/custom_field_user_format_test.rb test/unit/custom_value_test.rb test/unit/default_data_test.rb test/unit/enabled_module_test.rb test/unit/enumeration_test.rb test/unit/group_test.rb test/unit/helpers/application_helper_test.rb test/unit/helpers/custom_fields_helper_test.rb test/unit/helpers/sort_helper_test.rb test/unit/helpers/timelog_helper_test.rb test/unit/issue_nested_set_test.rb test/unit/issue_priority_test.rb test/unit/journal_observer_test.rb test/unit/journal_test.rb test/unit/ldap_auth_source_test.rb test/unit/lib/open_project/database_test.rb test/unit/lib/redmine/access_control_test.rb test/unit/lib/redmine/ciphering_test.rb test/unit/lib/redmine/codeset_util_test.rb test/unit/lib/redmine/helpers/calendar_test.rb test/unit/lib/redmine/hook_test.rb test/unit/lib/redmine/i18n_test.rb test/unit/lib/redmine/menu_manager/mapper_test.rb test/unit/lib/redmine/menu_manager/menu_helper_test.rb test/unit/lib/redmine/menu_manager/menu_item_test.rb test/unit/lib/redmine/menu_manager_test.rb test/unit/lib/redmine/mime_type_test.rb test/unit/lib/redmine/notifiable_test.rb test/unit/lib/redmine/plugin_test.rb test/unit/lib/redmine/safe_attributes_test.rb test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb test/unit/lib/redmine/scm/adapters/git_adapter_test.rb test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb test/unit/lib/redmine/unified_diff_test.rb test/unit/lib/redmine/wiki_formatting/macros_test.rb test/unit/lib/redmine/wiki_formatting/null_formatter_test.rb test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb test/unit/lib/redmine/wiki_formatting_test.rb test/unit/lib/redmine_test.rb test/unit/mail_handler_test.rb test/unit/member_test.rb test/unit/message_test.rb test/unit/principal_test.rb test/unit/project_nested_set_test.rb test/unit/project_test.rb test/unit/query_test.rb test/unit/relation_test.rb test/unit/repository_filesystem_test.rb test/unit/repository_git_test.rb test/unit/repository_subversion_test.rb test/unit/repository_test.rb test/unit/role_test.rb test/unit/search_test.rb test/unit/status_test.rb test/unit/time_entry_activity_test.rb test/unit/time_entry_test.rb test/unit/token_test.rb test/unit/type_test.rb test/unit/user_preference_test.rb test/unit/user_test.rb test/unit/version_test.rb test/unit/watcher_test.rb test/unit/wiki_content_test.rb test/unit/wiki_page_test.rb test/unit/wiki_redirect_test.rb test/unit/wiki_test.rb * 180 conversions from: it { should ... } to: it { is_expected.to ... } * 12 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 4 conversions from: Klass.any_instance.should_receive(:message) to: expect_any_instance_of(Klass).to receive(:message) * 4 conversions from: obj.should_receive(:message) to: expect(obj).to receive(:message) * 2 conversions from: Klass.any_instance.stub(:message) to: allow_any_instance_of(Klass).to receive(:message) For more details: https://github.com/yujinakayama/transpec#supported-conversions
10 years ago
it { is_expected.to render_template 'wiki/date_index' }
it 'should include atom link' do
assert_select 'a', attributes: { href: '/projects/ecookbook/activity.atom?show_wiki_edits=1' }
end
end
it 'should not found' do
get :show, params: { project_id: 999 }
assert_response 404
end
it 'should protect page' do
page = WikiPage.find_by(wiki_id: 1, title: 'Another page')
assert !page.protected?
session[:user_id] = 2
post :protect, params: { project_id: 1, id: page.title, protected: '1' }
8 years ago
assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'another-page'
assert page.reload.protected?
end
it 'should unprotect page' do
page = WikiPage.find_by(wiki_id: 1, title: 'CookBook documentation')
assert page.protected?
session[:user_id] = 2
post :protect, params: { project_id: 1, id: page.title, protected: '0' }
8 years ago
assert_redirected_to action: 'show', project_id: 'ecookbook', id: 'cookbook-documentation'
assert !page.reload.protected?
end
it 'should show page with edit link' do
session[:user_id] = 2
get :show, params: { project_id: 1 }
assert_response :success
assert_template 'show'
assert_select 'a', attributes: { href: '/projects/1/wiki/CookBook+documentation/edit' }
end
it 'should show page without edit link' do
session[:user_id] = 4
get :show, params: { project_id: 1 }
assert_response :success
assert_template 'show'
assert_select('a', { attributes: { href: '/projects/1/wiki/CookBook+documentation/edit' } }, false)
end
it 'should edit unprotected page' do
# Non members can edit unprotected wiki pages
session[:user_id] = 4
get :edit, params: { project_id: 1, id: 'Another page' }
assert_response :success
assert_template 'edit'
end
it 'should edit protected page by nonmember' do
# Non members can't edit protected wiki pages
session[:user_id] = 4
get :edit, params: { project_id: 1, id: 'CookBook documentation' }
assert_response 403
end
it 'should edit protected page by member' do
session[:user_id] = 2
get :edit, params: { project_id: 1, id: 'CookBook documentation' }
assert_response :success
assert_template 'edit'
end
it 'should history of non existing page should return 404' do
get :history, params: { project_id: 1, id: 'Unknown page' }
assert_response 404
end
end