Skip to content

Commit

Permalink
Don't error when checking user roles on a project
Browse files Browse the repository at this point in the history
Substitute the call to the overwritten `Project.find_by_name` finder
method with plain ActiveRecord finder methods. Make sure the
`user_has_role?` method is always call on a project.
  • Loading branch information
eduardoj committed Dec 12, 2024
1 parent 76c00c9 commit 1bf1fea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,9 @@ def addreview_opts
end

def any_project_maintained_by_current_user?
projects = @actions.select(:target_project).distinct.pluck(:target_project)
projects = Project.where(name: @actions.select(:target_project))
maintainer_role = Role.find_by_title('maintainer')
projects.any? { |project| Project.find_by_name(project).user_has_role?(User.possibly_nobody, maintainer_role) }
projects.any? { |project| project.user_has_role?(User.possibly_nobody, maintainer_role) }
end

def new_state
Expand Down

0 comments on commit 1bf1fea

Please sign in to comment.