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
Remove TimeEntries visible scope as this is already implemented by cost scope
Klaus Zanders3d26a24dbd51
diff --git a/modules/costs/app/models/time_entries/scopes/visible.rb b/modules/costs/app/models/time_entries/scopes/visible.rbdeleted file mode 100644index cc4d39d51b9..00000000000--- a/modules/costs/app/models/time_entries/scopes/visible.rb+++ /dev/null@@ -1,46 +0,0 @@-#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) 2012-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 TimeEntries::Scopes- module Visible- extend ActiveSupport::Concern-- class_methods do- def visible(user = User.current)- all_scope = TimeEntry- .where(project_id: Project.allowed_to(user, :view_time_entries))-- own_scope = TimeEntry- .where(work_package_id: WorkPackage.allowed_to(user, :view_own_time_entries))- .where(user:)-- all_scope.or(own_scope)- end- end- end-enddiff --git a/modules/costs/app/models/time_entry.rb b/modules/costs/app/models/time_entry.rbindex c745e6df00c..e317762078f 100644--- a/modules/costs/app/models/time_entry.rb+++ b/modules/costs/app/models/time_entry.rb@@ -52,7 +52,6 @@ class TimeEntry < ApplicationRecordinclude Entry::SplashedDatesscopes :of_user_and_day,- :visible,:ongoing# TODO: move into servicediff --git a/modules/costs/spec/models/time_entries/scopes/visible_spec.rb b/modules/costs/spec/models/time_entries/scopes/visible_spec.rbindex 1311e537157..b1305c96ee2 100644--- a/modules/costs/spec/models/time_entries/scopes/visible_spec.rb+++ b/modules/costs/spec/models/time_entries/scopes/visible_spec.rb@@ -28,13 +28,8 @@require 'spec_helper'-RSpec.describe TimeEntries::Scopes::Visible do+RSpec.describe TimeEntry, "visible scope" dolet(:project) { create(:project) }- let(:user) do- create(:user,- member_with_permissions: { project => permissions })- end- let(:permissions) { [:view_time_entries] }let(:work_package) docreate(:work_package,@@ -68,18 +63,20 @@ RSpec.describe TimeEntries::Scopes::Visible dosubject { TimeEntry.visible(user) }context 'for a user having the view_time_entries permission' do+ let(:user) { create(:user, member_with_permissions: { project => [:view_time_entries] }) }+it 'retrieves all the time entries of projects the user has the permissions in' doexpect(subject)- .to match_array([own_project_time_entry, project_time_entry])+ .to contain_exactly(own_project_time_entry, project_time_entry)endend- context 'for a user having the view_own_time_entries permission' do- let(:permissions) { [:view_own_time_entries] }+ context 'for a user having the view_own_time_entries permission on a work package' do+ let(:user) { create(:user, member_with_permissions: { work_package => [:view_own_time_entries] }) }it 'retrieves all the time entries of the user in projects the user has the permissions in' doexpect(subject)- .to match_array([own_project_time_entry])+ .to contain_exactly(own_project_time_entry)endendenddiff --git a/spec/factories/principal_factory.rb b/spec/factories/principal_factory.rbindex d9d821674fe..c9e683c9938 100644--- a/spec/factories/principal_factory.rb+++ b/spec/factories/principal_factory.rb@@ -77,7 +77,7 @@ FactoryBot.define docreate(:member, principal:, project: object, roles: [role])elsif Member.can_be_member_of?(object)role = create(:work_package_role, permissions:)- create(:member, principal:, entity: object, project: entity.project, roles: [role])+ create(:member, principal:, entity: object, project: object.project, roles: [role])endend