2019-04-15 06:17:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-07-07 08:54:49 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 23:08:05 -04:00
|
|
|
RSpec.describe Dashboard::LabelsController do
|
2020-10-14 08:08:58 -04:00
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let_it_be(:project_2) { create(:project) }
|
|
|
|
|
|
|
|
let_it_be(:label) { create(:label, project: project, title: 'some_label') }
|
|
|
|
let_it_be(:label_with_same_title) { create(:label, project: project_2, title: 'some_label') }
|
|
|
|
let_it_be(:unrelated_label) { create(:label, project: create(:project, :public)) }
|
|
|
|
|
|
|
|
before_all do
|
|
|
|
project.add_reporter(user)
|
|
|
|
project_2.add_reporter(user)
|
|
|
|
end
|
2017-07-07 08:54:49 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#index" do
|
2019-04-09 11:38:58 -04:00
|
|
|
subject { get :index, format: :json }
|
|
|
|
|
2020-10-14 08:08:58 -04:00
|
|
|
it 'returns labels with unique titles for projects the user has a relationship with' do
|
2019-04-09 11:38:58 -04:00
|
|
|
subject
|
2017-07-07 08:54:49 -04:00
|
|
|
|
|
|
|
expect(json_response).to be_kind_of(Array)
|
|
|
|
expect(json_response.size).to eq(1)
|
2020-10-14 08:08:58 -04:00
|
|
|
expect(json_response[0]['title']).to eq(label.title)
|
2017-07-07 08:54:49 -04:00
|
|
|
end
|
2019-04-09 11:38:58 -04:00
|
|
|
|
|
|
|
it_behaves_like 'disabled when using an external authorization service'
|
2017-07-07 08:54:49 -04:00
|
|
|
end
|
|
|
|
end
|