summaryrefslogtreecommitdiff
path: root/app/models/repository_language.rb
blob: e468d7162391ad7e3147e3ec290cb4a605cd85f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

class RepositoryLanguage < ApplicationRecord
  belongs_to :project
  belongs_to :programming_language

  default_scope { includes(:programming_language) }

  validates :project, presence: true
  validates :share, inclusion: { in: 0..100, message: "The share of a language is between 0 and 100" }
  validates :programming_language, uniqueness: { scope: :project_id }

  delegate :name, :color, to: :programming_language
end