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
fix check for permission without module
ulfertsfe0adb915124
diff --git a/app/models/projects/scopes/allowed_to.rb b/app/models/projects/scopes/allowed_to.rbindex d7b60276558..a2118d15982 100644--- a/app/models/projects/scopes/allowed_to.rb+++ b/app/models/projects/scopes/allowed_to.rb@@ -51,7 +51,7 @@ module Projects::Scopesdef allowed_to_admin_relation(permissions)joins(allowed_to_enabled_module_join(permissions))- .where(active: true)+ .where(arel_table[:active].eq(true))enddef allowed_to_non_member_relation(user, permissions)@@ -93,7 +93,7 @@ module Projects::Scopescondition = permissions.inject(Arel::Nodes::False.new) do |or_condition, permission|permission_condition = role_permissions_table[:permission].eq(permission.name)- unless permission.public?+ if permission.project_module.present?permission_condition = permission_condition.and(enabled_modules_table[:name].eq(permission.project_module))enddiff --git a/spec/models/projects/allowed_to_scope_spec.rb b/spec/models/projects/allowed_to_scope_spec.rbindex 68b0ce94c08..90bcff1c9c0 100644--- a/spec/models/projects/allowed_to_scope_spec.rb+++ b/spec/models/projects/allowed_to_scope_spec.rb@@ -63,6 +63,7 @@ RSpec.describe Project, 'allowed to' dolet(:action) { :view_work_packages }let(:public_action) { :view_news }let(:public_non_module_action) { :view_project }+ let(:non_module_action) { :edit_project }let(:member) dobuild(:member,user:,@@ -163,7 +164,7 @@ RSpec.describe Project, 'allowed to' docontext 'with the user being memberwith the permission being public and not module bound- with no module bing active' do+ with no module being active' dobefore domember.save!project.enabled_modules = []@@ -173,6 +174,36 @@ RSpec.describe Project, 'allowed to' doexpect(described_class.allowed_to(user, public_non_module_action)).to contain_exactly(project)endend++ context 'with the user being member+ with the permission being module bound+ with the role having the permission+ with no module active' do+ let(:permissions) { [non_module_action] }++ before do+ member.save!+ end++ it 'includes the project' do+ expect(described_class.allowed_to(user, non_module_action)).to contain_exactly(project)+ end+ end++ context 'with the user being member+ with the permission being module bound+ without the role having the permission+ with no module active' do+ let(:permissions) { [] }++ before do+ member.save!+ end++ it 'is empty' do+ expect(described_class.allowed_to(user, non_module_action)).to be_empty+ end+ endendshared_examples_for 'with an admin user' do