releases_finder.rb 398 Bytes
Newer Older
Alessio Caiazza's avatar
Alessio Caiazza committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# frozen_string_literal: true

class ReleasesFinder
  def initialize(project, current_user = nil)
    @project = project
    @current_user = current_user
  end

  # rubocop: disable CodeReuse/ActiveRecord
  def execute
    return [] unless Ability.allowed?(@current_user, :read_release, @project)

    @project.releases.order('created_at DESC')
  end
  # rubocop: enable CodeReuse/ActiveRecord
end