diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/finders/base_finder.rb | 2 | ||||
-rw-r--r-- | app/helpers/labels_helper.rb | 6 | ||||
-rw-r--r-- | app/models/concerns/issuable.rb | 2 | ||||
-rw-r--r-- | app/models/issue.rb | 3 | ||||
-rw-r--r-- | app/models/label.rb | 5 | ||||
-rw-r--r-- | app/models/merge_request.rb | 3 | ||||
-rw-r--r-- | app/models/project.rb | 11 |
7 files changed, 13 insertions, 19 deletions
diff --git a/app/finders/base_finder.rb b/app/finders/base_finder.rb index 7150bb2e31b..4be74a1ff8c 100644 --- a/app/finders/base_finder.rb +++ b/app/finders/base_finder.rb @@ -125,7 +125,7 @@ class BaseFinder def by_label(items) if params[:label_name].present? - items = items.tagged_with(params[:label_name]) + items = items.joins(:labels).where("labels.title = ?", params[:label_name]) end items diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index 4d20b827a0d..7d72989cb3b 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -1,11 +1,11 @@ module LabelsHelper def issue_label_names - @project.issues_labels.map(&:name) + @project.labels.pluck(:title) end def labels_autocomplete_source - labels = @project.issues_labels - labels = labels.map{ |l| { label: l.name, value: l.name } } + labels = @project.labels + labels = labels.map { |l| { label: l.name, value: l.name } } labels.to_json end diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 9a227fcef59..f260198547e 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -13,6 +13,8 @@ module Issuable belongs_to :assignee, class_name: "User" belongs_to :milestone has_many :notes, as: :noteable, dependent: :destroy + has_many :label_links, as: :target, dependent: :destroy + has_many :labels, through: :label_links validates :author, presence: true validates :title, presence: true, length: { within: 0..255 } diff --git a/app/models/issue.rb b/app/models/issue.rb index b5a72d535d9..92a8ff9b677 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -32,9 +32,6 @@ class Issue < ActiveRecord::Base scope :of_group, ->(group) { where(project_id: group.project_ids) } scope :of_user_team, ->(team) { where(project_id: team.project_ids, assignee_id: team.member_ids) } - - acts_as_taggable_on :labels - scope :cared, ->(user) { where(assignee_id: user) } scope :open_for, ->(user) { opened.assigned_to(user) } diff --git a/app/models/label.rb b/app/models/label.rb index 17f293b698f..31f68c31e5c 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -4,4 +4,9 @@ class Label < ActiveRecord::Base validates :color, format: { with: /\A\#[0-9A-Fa-f]{3}{1,2}+\Z/ }, allow_blank: true validates :project, presence: true + validates :title, presence: true + + def name + title + end end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 83dafe93233..b5705ef151d 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -47,9 +47,6 @@ class MergeRequest < ActiveRecord::Base attr_accessor :can_be_created, :compare_failed, :compare_commits, :compare_diffs - ActsAsTaggableOn.strict_case_match = true - acts_as_taggable_on :labels - state_machine :state, initial: :opened do event :close do transition [:reopened, :opened] => :closed diff --git a/app/models/project.rb b/app/models/project.rb index a4627d6d4d1..0e93e32162d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -41,8 +41,7 @@ class Project < ActiveRecord::Base default_value_for :snippets_enabled, gitlab_config_features.snippets ActsAsTaggableOn.strict_case_match = true - - acts_as_taggable_on :tags, :issues_default_labels + acts_as_taggable_on :tags attr_accessor :new_default_branch @@ -71,6 +70,7 @@ class Project < ActiveRecord::Base # Merge requests from source project should be kept when source project was removed has_many :fork_merge_requests, foreign_key: "source_project_id", class_name: MergeRequest has_many :issues, -> { order "state DESC, created_at DESC" }, dependent: :destroy + has_many :labels, dependent: :destroy has_many :services, dependent: :destroy has_many :events, dependent: :destroy has_many :milestones, dependent: :destroy @@ -282,13 +282,6 @@ class Project < ActiveRecord::Base self.id end - # Tags are shared by issues and merge requests - def issues_labels - @issues_labels ||= (issues_default_labels + - merge_requests.tags_on(:labels) + - issues.tags_on(:labels)).uniq.sort_by(&:name) - end - def issue_exists?(issue_id) if used_default_issues_tracker? self.issues.where(iid: issue_id).first.present? |