-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into task/50684-migrate-to-httpx-http-ruby-client
- Loading branch information
Showing
16 changed files
with
243 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# -- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2010-2023 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. | ||
# ++ | ||
|
||
module Projects::Scopes | ||
module Visible | ||
extend ActiveSupport::Concern | ||
|
||
class_methods do | ||
# Returns all projects the user is allowed to see. | ||
# Those include projects where the user has the permission: | ||
# * :view_project via a project role (which might also be the non member/anonymous role) or by being administrator | ||
# * :view_work_packages via a work package role | ||
def visible(user = User.current) | ||
# Use a shortcut for admins and anonymous where | ||
# we don't need to calculate for work package roles which is more expensive | ||
if user.admin? || user.anonymous? | ||
Project.allowed_to(user, :view_project) | ||
else | ||
Project.allowed_to(user, :view_project) | ||
.or(where(id: WorkPackage.allowed_to(user, :view_work_packages).select(:project_id))) | ||
end | ||
end | ||
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
7 changes: 4 additions & 3 deletions
7
modules/meeting/app/components/meetings/sidebar/participants_form_component.html.erb
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
5 changes: 3 additions & 2 deletions
5
.../components/work_package_meetings_tab/add_work_package_to_meeting_form_component.html.erb
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 |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# -- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2010-2023 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' | ||
|
||
RSpec.describe Projects::Scopes::Visible do | ||
shared_let(:activity) { create(:time_entry_activity) } | ||
shared_let(:project) { create(:project) } | ||
shared_let(:public_project) { create(:public_project) } | ||
shared_let(:work_package) { create(:work_package, project:) } | ||
shared_let(:shared_in_project) { create(:project) } | ||
shared_let(:shared_work_package) { create(:work_package, project: shared_in_project) } | ||
shared_let(:view_work_package_role) { create(:view_work_package_role) } | ||
shared_let(:non_member_role) { create(:non_member) } | ||
shared_let(:anonymous_role) { create(:anonymous_role) } | ||
shared_let(:shared_user) do | ||
create(:user).tap do |u| | ||
create(:member, | ||
project:, | ||
principal: u, | ||
roles: [create(:project_role)]) | ||
|
||
create(:work_package_member, | ||
entity: shared_work_package, | ||
principal: u, | ||
roles: [view_work_package_role]) | ||
end | ||
end | ||
shared_let(:admin_user) { create(:admin) } | ||
shared_let(:only_project_user) do | ||
create(:user).tap do |u| | ||
create(:member, | ||
project:, | ||
principal: u, | ||
roles: [create(:project_role)]) | ||
end | ||
end | ||
shared_let(:only_shared_user) do | ||
create(:user).tap do |u| | ||
create(:work_package_member, | ||
entity: shared_work_package, | ||
principal: u, | ||
roles: [view_work_package_role]) | ||
end | ||
end | ||
shared_let(:no_membership_user) do | ||
create(:user) | ||
end | ||
|
||
subject { Project.visible(current_user) } | ||
|
||
context 'for an admin user' do | ||
let(:current_user) { admin_user } | ||
|
||
it 'list all projects' do | ||
expect(subject) | ||
.to contain_exactly(shared_in_project, project, public_project) | ||
end | ||
end | ||
|
||
context 'for a user a work package is shared with and who has a memberships' do | ||
let(:current_user) { shared_user } | ||
|
||
it 'list all projects' do | ||
expect(subject) | ||
.to contain_exactly(shared_in_project, project, public_project) | ||
end | ||
end | ||
|
||
context 'for a user having only a project membership' do | ||
let(:current_user) { only_project_user } | ||
|
||
it 'list only the project in which the user has the membership and the public project' do | ||
expect(subject) | ||
.to contain_exactly(project, public_project) | ||
end | ||
end | ||
|
||
context 'for a user only having a share' do | ||
let(:current_user) { only_shared_user } | ||
|
||
it 'list only the project in which the shared work package is and the public project' do | ||
expect(subject) | ||
.to contain_exactly(shared_in_project, public_project) | ||
end | ||
end | ||
|
||
context 'for a user without any permission' do | ||
let(:current_user) { no_membership_user } | ||
|
||
it 'list only the public project' do | ||
expect(subject) | ||
.to contain_exactly(public_project) | ||
end | ||
end | ||
|
||
context 'for an anonymous user' do | ||
let(:current_user) { create(:anonymous) } | ||
|
||
it 'list only the public project' do | ||
expect(subject) | ||
.to contain_exactly(public_project) | ||
end | ||
end | ||
end |
Oops, something went wrong.