OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
legacy_spec to spec
ulferts293b8935a205
diff --git a/spec/controllers/sys_controller_spec.rb b/spec/controllers/sys_controller_spec.rbindex d46a5878a41..44626dbdff6 100644--- a/spec/controllers/sys_controller_spec.rb+++ b/spec/controllers/sys_controller_spec.rb@@ -28,7 +28,7 @@require 'spec_helper'-describe SysController, type: :controller do+describe SysController, type: :controller, with_settings: { sys_api_enabled: true } dolet(:commit_role) doFactoryBot.create(:role, permissions: %i[commit_access browse_repository])end@@ -46,18 +46,15 @@ describe SysController, type: :controller dolet(:public) { false }let(:project) { FactoryBot.create(:project, public: public) }+ let!(:repository_project) do+ FactoryBot.create(:project, public: false, members: { valid_user => [browse_role] })+ endbefore(:each) doFactoryBot.create(:non_member, permissions: [:browse_repository])DeletedUser.first # creating it first in order to avoid problems with should_receive- random_project = FactoryBot.create(:project, public: false)- FactoryBot.create(:member,- user: valid_user,- roles: [browse_role],- project: random_project)allow(Setting).to receive(:sys_api_key).and_return(api_key)- allow(Setting).to receive(:sys_api_enabled?).and_return(true)allow(Setting).to receive(:repository_authentication_caching_enabled?).and_return(true)Rails.cache.clear@@ -679,4 +676,84 @@ describe SysController, type: :controller doendendend++ describe '#projects' do+ before do+ request.env['HTTP_AUTHORIZATION'] =+ ActionController::HttpAuthentication::Basic.encode_credentials(+ valid_user.login,+ valid_user_password+ )++ get 'projects', params: { key: api_key }+ end++ it 'is successful' do+ expect(response)+ .to have_http_status(:ok)+ end++ it 'returns an xml with the projects having a repository' do+ expect(response.content_type)+ .to eql 'application/xml; charset=utf-8'++ expect(Nokogiri::XML::Document.parse(response.body).xpath('//projects[1]//id').text)+ .to eql repository_project.id.to_s+ end++ context 'when disabled', with_settings: { sys_api_enabled?: false } do+ it 'is 403 forbidden' do+ expect(response)+ .to have_http_status(:forbidden)+ end+ end+ end++ describe '#fetch_changesets' do+ let(:params) { { id: repository_project.identifier } }++ before do+ request.env['HTTP_AUTHORIZATION'] =+ ActionController::HttpAuthentication::Basic.encode_credentials(+ valid_user.login,+ valid_user_password+ )++ allow_any_instance_of(Repository::Subversion).to receive(:fetch_changesets).and_return(true)++ get 'fetch_changesets', params: params.merge({ key: api_key })+ end++ context 'with a project identifier' do+ it 'is successful' do+ expect(response)+ .to have_http_status(:ok)+ end+ end++ context 'without a project identifier' do+ let(:params) { {} }++ it 'is successful' do+ expect(response)+ .to have_http_status(:ok)+ end+ end++ context 'for an unknown project' do+ let(:params) { { id: 0 } }++ it 'returns 404' do+ expect(response)+ .to have_http_status(:not_found)+ end+ end++ context 'when disabled', with_settings: { sys_api_enabled?: false } do+ it 'is 403 forbidden' do+ expect(response)+ .to have_http_status(:forbidden)+ end+ end+ endenddiff --git a/spec_legacy/functional/sys_controller_spec.rb b/spec_legacy/functional/sys_controller_spec.rbdeleted file mode 100644index 1ba8318824f..00000000000--- a/spec_legacy/functional/sys_controller_spec.rb+++ /dev/null@@ -1,74 +0,0 @@-#-- 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 docs/COPYRIGHT.rdoc for more details.-#++--require_relative '../legacy_spec_helper'-require 'sys_controller'--describe SysController, type: :controller do- fixtures :all-- before do- Setting.enabled_scm = %w(subversion git)- end-- describe 'when enabled',- with_settings: { sys_api_enabled?: true } do- it 'should projects with repository enabled' do- get :projects- assert_response :success- assert_equal 'application/xml; charset=utf-8', response.content_type- assert_select 'projects', children: { count: Project.active.has_module(:repository).count }- end-- it 'should fetch changesets' do- 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- expect_any_instance_of(Repository::Subversion).to receive(:fetch_changesets).and_return(true)- get :fetch_changesets, params: { id: 'ecookbook' }- assert_response :success- end-- it 'should fetch changesets unknown project' do- get :fetch_changesets, params: { id: 'unknown' }- assert_response 404- end- end-- describe 'when disabled', with_settings: { sys_api_enabled?: false } do- it 'should disabled ws should respond with 403 error' do- get :fetch_changesets, params: { id: 'unknown' }- assert_response 403- end- end-end