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/sys_controller_spec.rb

102 lines
3.3 KiB

#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
#
# 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 doc/COPYRIGHT.rdoc for more details.
#++
require 'legacy_spec_helper'
require 'sys_controller'
describe SysController, type: :controller do
fixtures :all
before do
Setting.sys_api_enabled = '1'
Setting.enabled_scm = %w(subversion git)
end
it 'should projects with repository enabled' do
get :projects
assert_response :success
assert_equal 'application/xml', response.content_type
with_options tag: 'projects' do |test|
test.assert_tag children: { count: Project.active.has_module(:repository).count }
end
end
it 'should create project repository' do
assert_nil Project.find(4).repository
post :create_project_repository, id: 4,
scm_vendor: 'subversion',
scm_type: 'existing',
repository: { url: 'file:///create/project/repository/subproject2' }
assert_response :created
r = Project.find(4).repository
assert r.is_a?(Repository::Subversion)
assert_equal 'file:///create/project/repository/subproject2', r.url
end
it 'should fetch changesets' do
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
expect_any_instance_of(Repository::Subversion).to receive(:fetch_changesets).and_return(true)
get :fetch_changesets
assert_response :success
end
it 'should fetch changesets one project' do
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
expect_any_instance_of(Repository::Subversion).to receive(:fetch_changesets).and_return(true)
get :fetch_changesets, id: 'ecookbook'
assert_response :success
end
it 'should fetch changesets unknown project' do
get :fetch_changesets, id: 'unknown'
assert_response 404
end
it 'should disabled ws should respond with 403 error' do
with_settings sys_api_enabled: '0' do
get :projects
assert_response 403
end
end
it 'should api key' do
with_settings sys_api_key: 'my_secret_key' do
get :projects, key: 'my_secret_key'
assert_response :success
end
end
it 'should wrong key should respond with 403 error' do
with_settings sys_api_enabled: 'my_secret_key' do
get :projects, key: 'wrong_key'
assert_response 403
end
end
end