# frozen_string_literal: true

class Groups::IterationsController < Groups::ApplicationController
  before_action :check_iterations_available!
  before_action :authorize_show_iteration!, only: [:index, :show]
  before_action :authorize_create_iteration!, only: :new

  def index; end

  def show; end

  def new; end

  private

  def check_iterations_available!
    return render_404 unless group.feature_available?(:iterations)
  end

  def authorize_create_iteration!
    return render_404 unless can?(current_user, :create_iteration, group)
  end

  def authorize_show_iteration!
    return render_404 unless can?(current_user, :read_iteration, group)
  end
end
