BigW Consortium Gitlab

Commit 6b4da27e by Nick Thomas

Fix dashboard labels dropdown

parent de2d5ce6
class Dashboard::LabelsController < Dashboard::ApplicationController class Dashboard::LabelsController < Dashboard::ApplicationController
def index def index
labels = LabelsFinder.new(current_user).execute
respond_to do |format| respond_to do |format|
format.json { render json: LabelSerializer.new.represent_appearance(labels) } format.json { render json: LabelSerializer.new.represent_appearance(labels) }
end end
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 end
...@@ -2,7 +2,7 @@ class GlobalLabel ...@@ -2,7 +2,7 @@ class GlobalLabel
attr_accessor :title, :labels attr_accessor :title, :labels
alias_attribute :name, :title alias_attribute :name, :title
delegate :color, :description, to: :@first_label delegate :color, :text_color, :description, to: :@first_label
def for_display def for_display
@first_label @first_label
......
class LabelEntity < Grape::Entity class LabelEntity < Grape::Entity
expose :id expose :id, if: ->(label, _) { !label.is_a?(GlobalLabel) }
expose :title expose :title
expose :color expose :color
expose :description 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