From d4d15ac6cbb8fc9bcf4aff98141b6f5299c36d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Wed, 25 Jul 2018 09:10:33 +0200 Subject: [PATCH] [28091] Fix project responsible and add spec https://community.openproject.com/wp/28091 --- app/assets/stylesheets/vendor/_select2.scss | 4 -- app/models/user.rb | 2 +- .../projects/project_responsible_spec.rb | 62 +++++++++++++++++++ 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 spec/features/projects/project_responsible_spec.rb diff --git a/app/assets/stylesheets/vendor/_select2.scss b/app/assets/stylesheets/vendor/_select2.scss index c609d086e2..045136c60b 100644 --- a/app/assets/stylesheets/vendor/_select2.scss +++ b/app/assets/stylesheets/vendor/_select2.scss @@ -132,10 +132,6 @@ $se2-width: 100%; height: $se2-element-height; line-height: $se2-line-height; - .select2-chosen { - line-height: $se2-line-height; - } - .select2-arrow { @include varprop(background, se2-theme-selectable-color); border-radius: 0; diff --git a/app/models/user.rb b/app/models/user.rb index 1efb41b76e..51e90cfc53 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -189,7 +189,7 @@ class User < Principal end def self.search_in_project(query, options) - Project.find(options.fetch(:project)).users.like(query) + options.fetch(:project).users.like(query) end # Returns the user that matches provided login and password, or nil diff --git a/spec/features/projects/project_responsible_spec.rb b/spec/features/projects/project_responsible_spec.rb new file mode 100644 index 0000000000..fcbdefcc84 --- /dev/null +++ b/spec/features/projects/project_responsible_spec.rb @@ -0,0 +1,62 @@ +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2018 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-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 'spec_helper' +require 'features/projects/project_settings_page' + +describe 'Projects responsible setting', + type: :feature, + with_settings: { user_format: :firstname_lastname }, + js: true do + include Capybara::Select2 + let!(:admin) { FactoryBot.create :admin } + let!(:user) { FactoryBot.create(:user, firstname: 'Foo', lastname: 'Bar', member_in_project: project) } + + let!(:project) do + FactoryBot.create(:project, + name: 'Plain project', + identifier: 'plain-project') + end + let(:settings_page) { ProjectSettingsPage.new(project) } + + before do + login_as admin + end + + it 'can set the responsible (Regression test #28091)' do + settings_page.visit_settings + expect(page).to have_selector('.form--label', text: 'Responsible') + + select2('Foo Bar', css: '#s2id_project_responsible_id') + click_on 'Save' + + expect(page).to have_selector('.select2-chosen', text: 'Foo Bar') + project.reload + expect(project.responsible).to eq(user) + end +end