Skip to content

Commit

Permalink
NoMethodError for intersect if running on Ruby 2.7.6 #1500
Browse files Browse the repository at this point in the history
  • Loading branch information
picman committed Jan 9, 2024
1 parent 94a654f commit 0adcc62
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/models/dmsf_folder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,21 @@ def self.permissions?(folder, allow_system: true, file: false)
if folder.dmsf_folder_permissions.any?
role_ids = User.current.roles_for_project(folder.project).map(&:id)
role_permission_ids = folder.dmsf_folder_permissions.roles.map(&:object_id)
return true if role_ids.intersection(role_permission_ids).any?
if RUBY_VERSION < '3.1' # intersect? method added in Ruby 3.1, though we support 2.7 too
return true if role_ids.intersection(role_permission_ids).any?
elsif role_ids.intersect?(role_permission_ids)
return true
end

principal_ids = folder.dmsf_folder_permissions.users.map(&:object_id)
return true if principal_ids.include?(User.current.id)

user_group_ids = User.current.groups.map(&:id)
principal_ids.intersection(user_group_ids).any?
if RUBY_VERSION < '3.1' # intersect? method added in Ruby 3.1, though we support 2.7 too
principal_ids.intersection(user_group_ids).any?
else
principal_ids.intersect?(user_group_ids)
end
else
DmsfFolder.permissions? folder.dmsf_folder, allow_system: allow_system, file: file
end
Expand Down

0 comments on commit 0adcc62

Please sign in to comment.