Skip to content
Snippets Groups Projects
Commit e66d6781 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 4e9f718e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -18,10 +18,12 @@ module API
params do
optional :with_counts, type: Boolean, default: false,
desc: 'Include issue and merge request counts'
optional :include_ancestor_groups, type: Boolean, default: true,
desc: 'Include ancestor groups'
use :pagination
end
get ':id/labels' do
get_labels(user_group, Entities::GroupLabel)
get_labels(user_group, Entities::GroupLabel, include_ancestor_groups: params[:include_ancestor_groups])
end
 
desc 'Create a new label' do
Loading
Loading
Loading
Loading
@@ -10,8 +10,6 @@ module API
optional :description, type: String, desc: 'The description of the group'
optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
default: Gitlab::VisibilityLevel.string_level(
Gitlab::CurrentSettings.current_application_settings.default_group_visibility),
desc: 'The visibility of the group'
optional :lfs_enabled, type: Boolean, desc: 'Enable/disable LFS for the projects in this group'
optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access'
Loading
Loading
Loading
Loading
@@ -18,8 +18,8 @@ module API
label || not_found!('Label')
end
 
def get_labels(parent, entity)
present paginate(available_labels_for(parent)),
def get_labels(parent, entity, include_ancestor_groups: true)
present paginate(available_labels_for(parent, include_ancestor_groups: include_ancestor_groups)),
with: entity,
current_user: current_user,
parent: parent,
Loading
Loading
Loading
Loading
@@ -17,10 +17,12 @@ module API
params do
optional :with_counts, type: Boolean, default: false,
desc: 'Include issue and merge request counts'
optional :include_ancestor_groups, type: Boolean, default: true,
desc: 'Include ancestor groups'
use :pagination
end
get ':id/labels' do
get_labels(user_project, Entities::ProjectLabel)
get_labels(user_project, Entities::ProjectLabel, include_ancestor_groups: params[:include_ancestor_groups])
end
 
desc 'Create a new label' do
Loading
Loading
Loading
Loading
@@ -38,8 +38,10 @@ module Bitbucket
Representation::Repo.new(parsed_response)
end
 
def repos
def repos(filter: nil)
path = "/repositories?role=member"
path += "&q=name~\"#{filter}\"" if filter
get_collection(path, :repo)
end
 
Loading
Loading
Loading
Loading
@@ -31,7 +31,6 @@ namespace :gitlab do
terminate_all_connections unless Rails.env.production?
 
Rake::Task["db:reset"].invoke
Rake::Task["setup_postgresql"].invoke
Rake::Task["db:seed_fu"].invoke
rescue Gitlab::TaskAbortedByUserError
puts "Quitting...".color(:red)
Loading
Loading
desc 'GitLab | Sets up PostgreSQL'
task setup_postgresql: :environment do
require Rails.root.join('db/migrate/20180215181245_users_name_lower_index.rb')
require Rails.root.join('db/migrate/20180504195842_project_name_lower_index.rb')
require Rails.root.join('db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb')
UsersNameLowerIndex.new.up
ProjectNameLowerIndex.new.up
AddPathIndexToRedirectRoutes.new.up
end
desc 'GitLab | Generate PostgreSQL Password Hash'
task :postgresql_md5_hash do
require 'digest'
Loading
Loading
Loading
Loading
@@ -6795,6 +6795,9 @@ msgstr ""
msgid "Filter by two-factor authentication"
msgstr ""
 
msgid "Filter projects"
msgstr ""
msgid "Filter results by group"
msgstr ""
 
Loading
Loading
@@ -13602,6 +13605,9 @@ msgstr ""
msgid "Search"
msgstr ""
 
msgid "Search Button"
msgstr ""
msgid "Search an environment spec"
msgstr ""
 
Loading
Loading
Loading
Loading
@@ -26,8 +26,16 @@ module QA::Page
end
 
# Reminder: You may wish to wait for a particular job status before checking output
def output
find_element(:build_trace).text
def output(wait: 5)
result = ''
wait(reload: false, max: wait, interval: 1) do
result = find_element(:build_trace).text
!result.empty?
end
result
end
 
private
Loading
Loading
Loading
Loading
@@ -80,6 +80,21 @@ describe Import::BitbucketController do
expect(assigns(:already_added_projects)).to eq([@project])
expect(assigns(:repos)).to eq([])
end
context 'when filtering' do
let(:filter) { '<html>test</html>' }
let(:expected_filter) { 'test' }
subject { get :status, params: { filter: filter }, as: :json }
it 'passes sanitized filter param to bitbucket client' do
expect_next_instance_of(Bitbucket::Client) do |client|
expect(client).to receive(:repos).with(filter: expected_filter).and_return([@repo])
end
subject
end
end
end
 
describe "POST create" do
Loading
Loading
Loading
Loading
@@ -5,6 +5,7 @@ import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import IssuableContext from '~/issuable_context';
import LabelsSelect from '~/labels_select';
import _ from 'underscore';
 
import '~/gl_dropdown';
import 'select2';
Loading
Loading
@@ -15,6 +16,35 @@ import '~/users_select';
let saveLabelCount = 0;
let mock;
 
function testLabelClicks(labelOrder, done) {
$('.edit-link')
.get(0)
.click();
setTimeout(() => {
const labelsInDropdown = $('.dropdown-content a');
expect(labelsInDropdown.length).toBe(10);
const arrayOfLabels = labelsInDropdown.get();
const randomArrayOfLabels = _.shuffle(arrayOfLabels);
randomArrayOfLabels.forEach((label, i) => {
if (i < saveLabelCount) {
$(label).click();
}
});
$('.edit-link')
.get(0)
.click();
setTimeout(() => {
expect($('.sidebar-collapsed-icon').attr('data-original-title')).toBe(labelOrder);
done();
}, 0);
}, 0);
}
describe('Issue dropdown sidebar', () => {
preloadFixtures('static/issue_sidebar_label.html');
 
Loading
Loading
@@ -29,7 +59,7 @@ describe('Issue dropdown sidebar', () => {
mock.onGet('/root/test/labels.json').reply(() => {
const labels = Array(10)
.fill()
.map((_, i) => ({
.map((_val, i) => ({
id: i,
title: `test ${i}`,
color: '#5CB85C',
Loading
Loading
@@ -41,7 +71,7 @@ describe('Issue dropdown sidebar', () => {
mock.onPut('/root/test/issues/2.json').reply(() => {
const labels = Array(saveLabelCount)
.fill()
.map((_, i) => ({
.map((_val, i) => ({
id: i,
title: `test ${i}`,
color: '#5CB85C',
Loading
Loading
@@ -57,61 +87,11 @@ describe('Issue dropdown sidebar', () => {
 
it('changes collapsed tooltip when changing labels when less than 5', done => {
saveLabelCount = 5;
$('.edit-link')
.get(0)
.click();
setTimeout(() => {
expect($('.dropdown-content a').length).toBe(10);
$('.dropdown-content a').each(function(i) {
if (i < saveLabelCount) {
$(this)
.get(0)
.click();
}
});
$('.edit-link')
.get(0)
.click();
setTimeout(() => {
expect($('.sidebar-collapsed-icon').attr('data-original-title')).toBe(
'test 0, test 1, test 2, test 3, test 4',
);
done();
}, 0);
}, 0);
testLabelClicks('test 0, test 1, test 2, test 3, test 4', done);
});
 
it('changes collapsed tooltip when changing labels when more than 5', done => {
saveLabelCount = 6;
$('.edit-link')
.get(0)
.click();
setTimeout(() => {
expect($('.dropdown-content a').length).toBe(10);
$('.dropdown-content a').each(function(i) {
if (i < saveLabelCount) {
$(this)
.get(0)
.click();
}
});
$('.edit-link')
.get(0)
.click();
setTimeout(() => {
expect($('.sidebar-collapsed-icon').attr('data-original-title')).toBe(
'test 0, test 1, test 2, test 3, test 4, and 1 more',
);
done();
}, 0);
}, 0);
testLabelClicks('test 0, test 1, test 2, test 3, test 4, and 1 more', done);
});
});
Loading
Loading
@@ -5,9 +5,11 @@ require 'spec_helper'
describe API::GroupLabels do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:subgroup) { create(:group, parent: group) }
let!(:group_member) { create(:group_member, group: group, user: user) }
let!(:label1) { create(:group_label, title: 'feature', group: group) }
let!(:label2) { create(:group_label, title: 'bug', group: group) }
let!(:group_label1) { create(:group_label, title: 'feature', group: group) }
let!(:group_label2) { create(:group_label, title: 'bug', group: group) }
let!(:subgroup_label) { create(:group_label, title: 'support', group: subgroup) }
 
describe 'GET :id/labels' do
it 'returns all available labels for the group' do
Loading
Loading
@@ -35,6 +37,34 @@ describe API::GroupLabels do
end
end
 
describe 'GET :subgroup_id/labels' do
context 'when the include_ancestor_groups parameter is not set' do
it 'returns all available labels for the group and ancestor groups' do
get api("/groups/#{subgroup.id}/labels", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response).to all(match_schema('public_api/v4/labels/label'))
expect(json_response.size).to eq(3)
expect(json_response.map {|r| r['name'] }).to contain_exactly('feature', 'bug', 'support')
end
end
context 'when the include_ancestor_groups parameter is set to false' do
it 'returns all available labels for the group but not for ancestor groups' do
get api("/groups/#{subgroup.id}/labels", user), params: { include_ancestor_groups: false }
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response).to all(match_schema('public_api/v4/labels/label'))
expect(json_response.size).to eq(1)
expect(json_response.map {|r| r['name'] }).to contain_exactly('support')
end
end
end
describe 'POST /groups/:id/labels' do
it 'returns created label when all params are given' do
post api("/groups/#{group.id}/labels", user),
Loading
Loading
@@ -78,7 +108,7 @@ describe API::GroupLabels do
it 'returns 409 if label already exists' do
post api("/groups/#{group.id}/labels", user),
params: {
name: label1.name,
name: group_label1.name,
color: '#FFAABB'
}
 
Loading
Loading
@@ -89,13 +119,13 @@ describe API::GroupLabels do
 
describe 'DELETE /groups/:id/labels' do
it 'returns 204 for existing label' do
delete api("/groups/#{group.id}/labels", user), params: { name: label1.name }
delete api("/groups/#{group.id}/labels", user), params: { name: group_label1.name }
 
expect(response).to have_gitlab_http_status(204)
end
 
it 'returns 404 for non existing label' do
delete api("/groups/#{group.id}/labels", user), params: { name: 'label2' }
delete api("/groups/#{group.id}/labels", user), params: { name: 'not_exists' }
 
expect(response).to have_gitlab_http_status(404)
expect(json_response['message']).to eq('404 Label Not Found')
Loading
Loading
@@ -115,12 +145,12 @@ describe API::GroupLabels do
 
expect(response).to have_gitlab_http_status(204)
expect(subgroup.labels.size).to eq(0)
expect(group.labels).to include(label1)
expect(group.labels).to include(group_label1)
end
 
it_behaves_like '412 response' do
let(:request) { api("/groups/#{group.id}/labels", user) }
let(:params) { { name: label1.name } }
let(:params) { { name: group_label1.name } }
end
end
 
Loading
Loading
@@ -128,7 +158,7 @@ describe API::GroupLabels do
it 'returns 200 if name and colors and description are changed' do
put api("/groups/#{group.id}/labels", user),
params: {
name: label1.name,
name: group_label1.name,
new_name: 'New Label',
color: '#FFFFFF',
description: 'test'
Loading
Loading
@@ -152,13 +182,13 @@ describe API::GroupLabels do
 
expect(response).to have_gitlab_http_status(200)
expect(subgroup.labels[0].name).to eq('New Label')
expect(label1.name).to eq('feature')
expect(group_label1.name).to eq('feature')
end
 
it 'returns 404 if label does not exist' do
put api("/groups/#{group.id}/labels", user),
params: {
name: 'label2',
name: 'not_exists',
new_name: 'label3'
}
 
Loading
Loading
@@ -166,14 +196,14 @@ describe API::GroupLabels do
end
 
it 'returns 400 if no label name given' do
put api("/groups/#{group.id}/labels", user), params: { new_name: label1.name }
put api("/groups/#{group.id}/labels", user), params: { new_name: group_label1.name }
 
expect(response).to have_gitlab_http_status(400)
expect(json_response['error']).to eq('name is missing')
end
 
it 'returns 400 if no new parameters given' do
put api("/groups/#{group.id}/labels", user), params: { name: label1.name }
put api("/groups/#{group.id}/labels", user), params: { name: group_label1.name }
 
expect(response).to have_gitlab_http_status(400)
expect(json_response['error']).to eq('new_name, color, description are missing, '\
Loading
Loading
@@ -184,31 +214,31 @@ describe API::GroupLabels do
describe 'POST /groups/:id/labels/:label_id/subscribe' do
context 'when label_id is a label title' do
it 'subscribes to the label' do
post api("/groups/#{group.id}/labels/#{label1.title}/subscribe", user)
post api("/groups/#{group.id}/labels/#{group_label1.title}/subscribe", user)
 
expect(response).to have_gitlab_http_status(201)
expect(json_response['name']).to eq(label1.title)
expect(json_response['name']).to eq(group_label1.title)
expect(json_response['subscribed']).to be_truthy
end
end
 
context 'when label_id is a label ID' do
it 'subscribes to the label' do
post api("/groups/#{group.id}/labels/#{label1.id}/subscribe", user)
post api("/groups/#{group.id}/labels/#{group_label1.id}/subscribe", user)
 
expect(response).to have_gitlab_http_status(201)
expect(json_response['name']).to eq(label1.title)
expect(json_response['name']).to eq(group_label1.title)
expect(json_response['subscribed']).to be_truthy
end
end
 
context 'when user is already subscribed to label' do
before do
label1.subscribe(user)
group_label1.subscribe(user)
end
 
it 'returns 304' do
post api("/groups/#{group.id}/labels/#{label1.id}/subscribe", user)
post api("/groups/#{group.id}/labels/#{group_label1.id}/subscribe", user)
 
expect(response).to have_gitlab_http_status(304)
end
Loading
Loading
@@ -225,36 +255,36 @@ describe API::GroupLabels do
 
describe 'POST /groups/:id/labels/:label_id/unsubscribe' do
before do
label1.subscribe(user)
group_label1.subscribe(user)
end
 
context 'when label_id is a label title' do
it 'unsubscribes from the label' do
post api("/groups/#{group.id}/labels/#{label1.title}/unsubscribe", user)
post api("/groups/#{group.id}/labels/#{group_label1.title}/unsubscribe", user)
 
expect(response).to have_gitlab_http_status(201)
expect(json_response['name']).to eq(label1.title)
expect(json_response['name']).to eq(group_label1.title)
expect(json_response['subscribed']).to be_falsey
end
end
 
context 'when label_id is a label ID' do
it 'unsubscribes from the label' do
post api("/groups/#{group.id}/labels/#{label1.id}/unsubscribe", user)
post api("/groups/#{group.id}/labels/#{group_label1.id}/unsubscribe", user)
 
expect(response).to have_gitlab_http_status(201)
expect(json_response['name']).to eq(label1.title)
expect(json_response['name']).to eq(group_label1.title)
expect(json_response['subscribed']).to be_falsey
end
end
 
context 'when user is already unsubscribed from label' do
before do
label1.unsubscribe(user)
group_label1.unsubscribe(user)
end
 
it 'returns 304' do
post api("/groups/#{group.id}/labels/#{label1.id}/unsubscribe", user)
post api("/groups/#{group.id}/labels/#{group_label1.id}/unsubscribe", user)
 
expect(response).to have_gitlab_http_status(304)
end
Loading
Loading
Loading
Loading
@@ -497,6 +497,29 @@ describe API::Groups do
 
expect(response).to have_gitlab_http_status(404)
end
context 'within a subgroup' do
let(:group3) { create(:group, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let!(:subgroup) { create(:group, parent: group3, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
before do
group3.add_owner(user3)
end
it 'does not change visibility when not requested' do
put api("/groups/#{group3.id}", user3), params: { description: 'Bug #23083' }
expect(response).to have_gitlab_http_status(200)
expect(json_response['visibility']).to eq('public')
end
it 'prevents making private a group containing public subgroups' do
put api("/groups/#{group3.id}", user3), params: { visibility: 'private' }
expect(response).to have_gitlab_http_status(400)
expect(json_response['message']['visibility_level']).to contain_exactly('private is not allowed since there are sub-groups with higher visibility.')
end
end
end
 
context 'when authenticated as the admin' do
Loading
Loading
Loading
Loading
@@ -256,6 +256,52 @@ describe API::Labels do
'is_project_label' => true)
end
end
context 'when the include_ancestor_groups parameter is not set' do
let(:group) { create(:group) }
let!(:group_label) { create(:group_label, title: 'feature', group: group) }
let(:subgroup) { create(:group, parent: group) }
let!(:subgroup_label) { create(:group_label, title: 'support', group: subgroup) }
before do
subgroup.add_owner(user)
project.update!(group: subgroup)
end
it 'returns all available labels for the project, parent group and ancestor groups' do
get api("/projects/#{project.id}/labels", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response).to all(match_schema('public_api/v4/labels/label'))
expect(json_response.size).to eq(4)
expect(json_response.map {|r| r['name'] }).to contain_exactly(group_label.name, subgroup_label.name, priority_label.name, label1.name)
end
end
context 'when the include_ancestor_groups parameter is set to false' do
let(:group) { create(:group) }
let!(:group_label) { create(:group_label, title: 'feature', group: group) }
let(:subgroup) { create(:group, parent: group) }
let!(:subgroup_label) { create(:group_label, title: 'support', group: subgroup) }
before do
subgroup.add_owner(user)
project.update!(group: subgroup)
end
it 'returns all available labels for the project and the parent group only' do
get api("/projects/#{project.id}/labels", user), params: { include_ancestor_groups: false }
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response).to all(match_schema('public_api/v4/labels/label'))
expect(json_response.size).to eq(3)
expect(json_response.map {|r| r['name'] }).to contain_exactly(subgroup_label.name, priority_label.name, label1.name)
end
end
end
 
describe 'POST /projects/:id/labels' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment