Skip to content

Commit

Permalink
fix: user.project_admin_of? with nil project
Browse files Browse the repository at this point in the history
This was returning nil instead of false which then caused nothing to be output in the glossary edit html javascript section breaking the glossary view link when the user was not a an admin or project admin.
  • Loading branch information
dougmartin committed Dec 6, 2023
1 parent fd12ef3 commit e8d6c4c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def is_project_admin?()
end

def project_admin_of?(project)
project && admined_projects.any? {|ap| ap.id == project.id }
!!(project && admined_projects.any? {|ap| ap.id == project.id })
end

def most_recent_authentication
Expand Down
1 change: 1 addition & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@
expect(user.project_admins.length).to be(0)
expect(user.admined_projects.length).to be(0)

expect(user.project_admin_of?(nil)).to be(false)
expect(user.project_admin_of?(project1)).to be(false)
expect(user.project_admin_of?(project2)).to be(false)
end
Expand Down

0 comments on commit e8d6c4c

Please sign in to comment.