summaryrefslogtreecommitdiff
path: root/lib/learn_gitlab.rb
blob: abceb80bd30d5d9651dbc7a414578f6a4643c32d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# frozen_string_literal: true

class LearnGitlab
  PROJECT_NAME = 'Learn GitLab'
  BOARD_NAME = 'GitLab onboarding'
  LABEL_NAME = 'Novice'

  def initialize(current_user)
    @current_user = current_user
  end

  def available?
    project && board && label
  end

  def project
    @project ||= current_user.projects.find_by_name(PROJECT_NAME)
  end

  def board
    return unless project

    @board ||= project.boards.find_by_name(BOARD_NAME)
  end

  def label
    return unless project

    @label ||= project.labels.find_by_name(LABEL_NAME)
  end

  private

  attr_reader :current_user
end