Skip to content

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

adapt specs

ulfertsc6a638c79ff0
diff --git a/spec/controllers/settings_controller_spec.rb b/spec/controllers/settings_controller_spec.rb
index 1d4413a3b6e..5c1e12e2390 100644
--- a/spec/controllers/settings_controller_spec.rb
+++ b/spec/controllers/settings_controller_spec.rb
@@ -37,82 +37,106 @@ describe SettingsController, type: :controller do
allow(User).to receive(:current).and_return @user
end
- describe 'edit' do
+ describe 'show' do
render_views
- before do
- @previous_projects_modules = Setting.default_projects_modules
- end
-
- after do
- Setting.default_projects_modules = @previous_projects_modules
- end
+ context 'default project modules' do
+ before do
+ @previous_projects_modules = Setting.default_projects_modules
+ end
- it 'contains a check box for the activity module on the projects tab' do
- get 'edit', params: { tab: 'projects' }
+ after do
+ Setting.default_projects_modules = @previous_projects_modules
+ end
- expect(response).to be_successful
- expect(response).to render_template 'edit'
- expect(response.body).to have_selector "input[@name='settings[default_projects_modules][]'][@value='activity']"
- end
+ it 'contains a check box for the activity module on the projects tab' do
+ get 'show', params: { tab: 'projects' }
- it 'does not store the activity in the default_projects_modules if unchecked' do
- post 'edit',
- params: {
- tab: 'projects',
- settings: {
- default_projects_modules: ['wiki']
- }
- }
+ expect(response).to be_successful
+ expect(response).to render_template 'show'
+ expect(response.body).to have_selector "input[@name='settings[default_projects_modules][]'][@value='activity']"
+ end
- expect(response).to be_redirect
- expect(response).to redirect_to action: 'edit', tab: 'projects'
+ it 'contains a check box for the activity module on the projects tab' do
+ get 'show', params: { tab: 'projects' }
- expect(Setting.default_projects_modules).to eq(['wiki'])
- end
+ expect(response).to be_successful
+ expect(response).to render_template 'show'
+ expect(response.body).to have_selector "input[@name='settings[default_projects_modules][]'][@value='activity']"
+ end
- it 'stores the activity in the default_projects_modules if checked' do
- post 'edit',
- params: {
- tab: 'projects',
- settings: {
- default_projects_modules: ['activity', 'wiki']
- }
- }
+ describe 'without activated activity module' do
+ before do
+ Setting.default_projects_modules = %w[wiki]
+ end
- expect(response).to be_redirect
- expect(response).to redirect_to action: 'edit', tab: 'projects'
+ it 'contains an unchecked checkbox for activity' do
+ get 'show', params: { tab: 'projects' }
- expect(Setting.default_projects_modules).to eq(['activity', 'wiki'])
- end
+ expect(response).to be_successful
+ expect(response).to render_template 'show'
- describe 'with activity in Setting.default_projects_modules' do
- before do
- Setting.default_projects_modules = %w[activity wiki]
+ expect(response.body).not_to have_selector "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']"
+ end
end
- it 'contains a checked checkbox for activity' do
- get 'edit', params: { tab: 'projects' }
+ describe 'with activity in Setting.default_projects_modules' do
+ before do
+ Setting.default_projects_modules = %w[activity wiki]
+ end
- expect(response).to be_successful
- expect(response).to render_template 'edit'
+ it 'contains a checked checkbox for activity' do
+ get 'show', params: { tab: 'projects' }
+
+ expect(response).to be_successful
+ expect(response).to render_template 'show'
- expect(response.body).to have_selector "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']"
+ expect(response.body).to have_selector "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']"
+ end
end
end
+ end
+
+ describe 'update' do
+ render_views
- describe 'without activated activity module' do
+ context 'default project modules' do
before do
- Setting.default_projects_modules = %w[wiki]
+ @previous_projects_modules = Setting.default_projects_modules
end
- it 'contains an unchecked checkbox for activity' do
- get 'edit', params: { tab: 'projects' }
+ after do
+ Setting.default_projects_modules = @previous_projects_modules
+ end
- expect(response).to be_successful
- expect(response).to render_template 'edit'
+ it 'does not store the activity in the default_projects_modules if unchecked' do
+ patch 'update',
+ params: {
+ tab: 'projects',
+ settings: {
+ default_projects_modules: ['wiki']
+ }
+ }
+
+ expect(response).to be_redirect
+ expect(response).to redirect_to action: 'show', tab: 'projects'
+
+ expect(Setting.default_projects_modules).to eq(['wiki'])
+ end
+
+ it 'stores the activity in the default_projects_modules if checked' do
+ patch 'update',
+ params: {
+ tab: 'projects',
+ settings: {
+ default_projects_modules: ['activity', 'wiki']
+ }
+ }
+
+ expect(response).to be_redirect
+ expect(response).to redirect_to action: 'show', tab: 'projects'
- expect(response.body).not_to have_selector "input[@name='settings[default_projects_modules][]'][@value='activity'][@checked='checked']"
+ expect(Setting.default_projects_modules).to eq(['activity', 'wiki'])
end
end
@@ -158,11 +182,11 @@ describe SettingsController, type: :controller do
end
end
- describe 'POST #edit with password login enabled' do
+ describe 'PATCH #update with password login enabled' do
before do
allow(OpenProject::Configuration).to receive(:disable_password_login?).and_return(false)
- post 'edit', params: { tab: 'authentication', settings: new_settings }
+ patch 'update', params: { tab: 'authentication', settings: new_settings }
end
it 'is successful' do
@@ -194,11 +218,11 @@ describe SettingsController, type: :controller do
end
end
- describe 'POST #edit with password login disabled' do
+ describe 'PATCH #update with password login disabled' do
before do
allow(OpenProject::Configuration).to receive(:disable_password_login?).and_return(true)
- post 'edit', params: { tab: 'authentication', settings: new_settings }
+ patch 'update', params: { tab: 'authentication', settings: new_settings }
end
it 'is successful' do
diff --git a/spec/features/admin/test_mail_notification_spec.rb b/spec/features/admin/test_mail_notification_spec.rb
index 4ddecd9f407..4c8eec11158 100644
--- a/spec/features/admin/test_mail_notification_spec.rb
+++ b/spec/features/admin/test_mail_notification_spec.rb
@@ -29,13 +29,11 @@
require 'spec_helper'
describe 'Test mail notification', type: :feature do
- include Redmine::I18n
-
let(:admin) { FactoryBot.create(:admin) }
before do
login_as(admin)
- visit general_settings_path(tab: :notifications)
+ visit admin_mail_notifications_path(tab: :notifications)
end
it 'shows the correct message on errors in test notification (Regression #28226)' do
diff --git a/spec_legacy/functional/settings_controller_spec.rb b/spec_legacy/functional/settings_controller_spec.rb
deleted file mode 100644
index dacc306a7a4..00000000000
--- a/spec_legacy/functional/settings_controller_spec.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-#-- encoding: UTF-8
-
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2020 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-2017 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 'settings_controller'
-
-describe SettingsController, type: :controller do
- fixtures :all
-
- before do
- User.current = nil
- session[:user_id] = 1 # admin
- end
-
- it 'should index' do
- get :index
- assert_response :success
- assert_template 'edit'
- end
-
- it 'should get edit' do
- get :edit
- assert_response :success
- assert_template 'edit'
- end
-
- it 'should post edit notifications' do
- post :edit,
- params: {
- settings: {
- mail_from: '[email protected]',
- bcc_recipients: '0',
- notified_events: %w(work_package_added work_package_updated news_added),
- emails_footer: 'Test footer'
- }
- }
- assert_redirected_to '/settings/edit'
- assert_equal '[email protected]', Setting.mail_from
- assert !Setting.bcc_recipients?
- assert_equal %w(work_package_added work_package_updated news_added), Setting.notified_events
- assert_equal 'Test footer', Setting.emails_footer
- end
-end