-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14120 from virgo47/feature/50849_change_work_pack…
…ages_status Feature/50849 change work packages status
- Loading branch information
Showing
18 changed files
with
197 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
spec/features/work_packages/edit_on_change_work_package_status_permission_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2024 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 'spec_helper' | ||
require 'features/page_objects/notification' | ||
|
||
RSpec.describe 'edit work package', :js do | ||
let(:current_user) do | ||
create(:user, | ||
firstname: 'Dev', | ||
lastname: 'Guy', | ||
member_with_roles: { project => role }) | ||
end | ||
let(:permissions) { %i[view_work_packages change_work_package_status] } | ||
let(:role) { create(:project_role, permissions: permissions) } | ||
|
||
let(:type) { create(:type) } | ||
let(:project) { create(:project, types: [type]) } | ||
let(:status_new) { create(:status, name: 'New') } | ||
let(:status_done) { create(:status, name: 'Done') } | ||
let(:workflow) do | ||
create(:workflow, | ||
type_id: type.id, | ||
old_status: status_new, | ||
new_status: status_done, | ||
role: role) | ||
end | ||
let(:work_package) do | ||
create(:work_package, | ||
author: current_user, | ||
status: status_new, | ||
project:, | ||
type:, | ||
created_at: 5.days.ago.to_date.to_fs(:db)) | ||
end | ||
|
||
let(:wp_page) { Pages::FullWorkPackage.new(work_package) } | ||
|
||
before do | ||
workflow | ||
|
||
login_as(current_user) | ||
wp_page.visit! | ||
wp_page.ensure_page_loaded | ||
end | ||
|
||
context 'as a user having only the change_work_package_status permission' do | ||
it 'can only change the status' do | ||
status_field = wp_page.edit_field :status | ||
status_field.expect_state_text status_new.name | ||
status_field.update status_done.name | ||
|
||
wp_page.expect_toast(message: 'Successful update') | ||
status_field.expect_state_text status_done.name | ||
|
||
subject_field = wp_page.work_package_field('subject') | ||
subject_field.expect_read_only | ||
end | ||
end | ||
|
||
context 'as a user having only the edit_work_packages permission' do | ||
let(:permissions) { %i[view_work_packages edit_work_packages] } | ||
|
||
it 'can change the status' do | ||
status_field = wp_page.edit_field :status | ||
status_field.expect_state_text status_new.name | ||
status_field.update status_done.name | ||
|
||
wp_page.expect_toast(message: 'Successful update') | ||
status_field.expect_state_text status_done.name | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,9 +324,8 @@ | |
end | ||
|
||
shared_context 'with a new work package with attachment' do | ||
# The edit_work_packages is currently wrongfully needed as the work package | ||
# is created first and only then the attachment is added. | ||
let(:permissions) { %i[add_work_packages edit_work_packages] } | ||
# The work package is created first and only then the attachment is added. | ||
let(:permissions) { %i[add_work_packages add_work_package_attachments] } | ||
let!(:user) do | ||
create(:user, | ||
mail: '[email protected]', | ||
|
@@ -342,9 +341,8 @@ | |
end | ||
|
||
shared_context 'with a new work package with attachment in apple format' do | ||
# The edit_work_packages is currently wrongfully needed as the work package | ||
# is created first and only then the attachment is added. | ||
let(:permissions) { %i[add_work_packages edit_work_packages] } | ||
# The work package is created first and only then the attachment is added. | ||
let(:permissions) { %i[add_work_packages add_work_package_attachments] } | ||
let!(:user) do | ||
create(:user, | ||
mail: '[email protected]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters