Commit 89724028 authored by Sean McGivern's avatar Sean McGivern

Merge branch '34590-fix-dashboard-labels-dropdown' into 'master'

Fix dashboard labels dropdown

Closes #34590

See merge request !12708
parents 59f4fb7a 6b4da27e
class Dashboard::LabelsController < Dashboard::ApplicationController
def index
labels = LabelsFinder.new(current_user).execute
respond_to do |format|
format.json { render json: LabelSerializer.new.represent_appearance(labels) }
end
end
def labels
finder_params = { project_ids: projects.select(:id) }
labels = LabelsFinder.new(current_user, finder_params).execute
GlobalLabel.build_collection(labels)
end
end
......@@ -2,7 +2,7 @@ class GlobalLabel
attr_accessor :title, :labels
alias_attribute :name, :title
delegate :color, :description, to: :@first_label
delegate :color, :text_color, :description, to: :@first_label
def for_display
@first_label
......
class LabelEntity < Grape::Entity
expose :id
expose :id, if: ->(label, _) { !label.is_a?(GlobalLabel) }
expose :title
expose :color
expose :description
......
---
title: Fix dashboard labels dropdown
merge_request: 12708
author:
require 'spec_helper'
describe Dashboard::LabelsController do
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
let!(:label) { create(:label, project: project) }
before do
sign_in(user)
project.add_reporter(user)
end
describe "#index" do
let!(:unrelated_label) { create(:label, project: create(:empty_project, :public)) }
it 'returns global labels for projects the user has a relationship with' do
get :index, format: :json
expect(json_response).to be_kind_of(Array)
expect(json_response.size).to eq(1)
expect(json_response[0]["id"]).to be_nil
expect(json_response[0]["title"]).to eq(label.title)
end
end
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