Commit 8f14f931 authored by Mark Chao's avatar Mark Chao

Remove unnecessary checks; Refactor

parent f36a28e5
......@@ -27,13 +27,13 @@ module Projects
include_ancestor_groups: true
).execute
hashes = available_labels.as_json(only: [:title, :color])
label_hashes = available_labels.as_json(only: [:title, :color])
if target&.respond_to?(:labels)
already_set_labels = available_labels & target.labels
if already_set_labels.present?
titles = already_set_labels.map(&:title)
hashes.each do |hash|
label_hashes.each do |hash|
if titles.include?(hash['title'])
hash[:set] = true
end
......@@ -41,7 +41,7 @@ module Projects
end
end
hashes
label_hashes
end
def commands(noteable, type)
......
......@@ -8,13 +8,13 @@ module Groups
only_group_labels: true
).execute
hashes = available_labels.as_json(only: [:title, :color])
label_hashes = available_labels.as_json(only: [:title, :color])
if target&.respond_to?(:labels)
already_set_labels = available_labels & target.labels
if already_set_labels.present?
titles = already_set_labels.map(&:title)
hashes.each do |hash|
label_hashes.each do |hash|
if titles.include?(hash['title'])
hash[:set] = true
end
......@@ -22,11 +22,12 @@ module Groups
end
end
hashes
label_hashes
end
def epics
# TODO: change to EpicsFinder once frontend supports epics from descendant groups
# TODO: change to EpicsFinder once frontend supports epics from external groups.
# See https://gitlab.com/gitlab-org/gitlab-ee/issues/6837
DeclarativePolicy.user_scope do
if Ability.allowed?(current_user, :read_epic, group)
group.epics
......
......@@ -11,7 +11,6 @@ describe Groups::AutocompleteService do
end
def expect_labels_to_equal(labels, expected_labels)
expect(labels.size).to eq(expected_labels.size)
extract_title = lambda { |label| label['title'] }
expect(labels.map(&extract_title)).to eq(expected_labels.map(&extract_title))
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment