summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-17 12:06:48 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-17 12:06:48 +0000
commitbd860c22f6a4b9473cbddd34a53eead8235a7ea1 (patch)
tree3f955a56c2ac90497863da26902a42dba49f3466 /spec
parente567b4c2df7dc4085d213db029eff6b6fcde0152 (diff)
downloadgitlab-ce-bd860c22f6a4b9473cbddd34a53eead8235a7ea1.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/application_controller_spec.rb1
-rw-r--r--spec/controllers/concerns/send_file_upload_spec.rb1
-rw-r--r--spec/controllers/projects/jobs_controller_spec.rb1
-rw-r--r--spec/finders/issues_finder_spec.rb202
-rw-r--r--spec/helpers/application_helper_spec.rb1
-rw-r--r--spec/helpers/defer_script_tag_helper_spec.rb1
-rw-r--r--spec/lib/container_registry/client_spec.rb1
-rw-r--r--spec/lib/gitlab/encoding_helper_spec.rb1
-rw-r--r--spec/lib/gitlab/git/blame_spec.rb1
-rw-r--r--spec/lib/gitlab/git/blob_spec.rb2
-rw-r--r--spec/lib/gitlab/git/conflict/file_spec.rb1
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb1
-rw-r--r--spec/lib/gitlab/git_spec.rb1
-rw-r--r--spec/lib/gitlab/json_logger_spec.rb1
-rw-r--r--spec/lib/gitlab/path_regex_spec.rb1
-rw-r--r--spec/lib/gitlab/project_search_results_spec.rb1
-rw-r--r--spec/lib/gitlab/regex_spec.rb1
-rw-r--r--spec/lib/gitlab/search/found_blob_spec.rb1
-rw-r--r--spec/lib/gitlab/url_blocker_spec.rb1
-rw-r--r--spec/models/blob_spec.rb1
-rw-r--r--spec/models/project_spec.rb37
-rw-r--r--spec/requests/api/groups_spec.rb44
-rw-r--r--spec/requests/api/issues/get_group_issues_spec.rb4
-rw-r--r--spec/requests/api/issues/get_project_issues_spec.rb3
-rw-r--r--spec/requests/api/issues/issues_spec.rb85
-rw-r--r--spec/requests/api/pipelines_spec.rb48
-rw-r--r--spec/requests/api/projects_spec.rb1
-rw-r--r--spec/services/git/branch_push_service_spec.rb2
-rw-r--r--spec/services/issues/update_service_spec.rb1
-rw-r--r--spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb2
-rw-r--r--spec/support/shared_examples/finders/assignees_filter_shared_examples.rb12
-rw-r--r--spec/support/shared_examples/models/cluster_application_core_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/requests/api/issues_shared_examples.rb21
33 files changed, 421 insertions, 65 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 52a68e987f0..d7134d3d25a 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/controllers/concerns/send_file_upload_spec.rb b/spec/controllers/concerns/send_file_upload_spec.rb
index 3bf0ec799c7..4110be721ad 100644
--- a/spec/controllers/concerns/send_file_upload_spec.rb
+++ b/spec/controllers/concerns/send_file_upload_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb
index b455b55bd11..53d32665b0c 100644
--- a/spec/controllers/projects/jobs_controller_spec.rb
+++ b/spec/controllers/projects/jobs_controller_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb
index ef8749be0be..a17ff1ad50d 100644
--- a/spec/finders/issues_finder_spec.rb
+++ b/spec/finders/issues_finder_spec.rb
@@ -21,15 +21,28 @@ describe IssuesFinder do
let(:expected_issuables) { [issue1, issue2] }
end
- it_behaves_like 'assignee username filter' do
+ it_behaves_like 'assignee NOT ID filter' do
+ let(:params) { { not: { assignee_id: user.id } } }
+ let(:expected_issuables) { [issue3, issue4] }
+ end
+
+ context 'filter by username' do
+ set(:user3) { create(:user) }
+
before do
project2.add_developer(user3)
issue3.assignees = [user2, user3]
end
- set(:user3) { create(:user) }
- let(:params) { { assignee_username: [user2.username, user3.username] } }
- let(:expected_issuables) { [issue3] }
+ it_behaves_like 'assignee username filter' do
+ let(:params) { { assignee_username: [user2.username, user3.username] } }
+ let(:expected_issuables) { [issue3] }
+ end
+
+ it_behaves_like 'assignee NOT username filter' do
+ let(:params) { { not: { assignee_username: [user2.username, user3.username] } } }
+ let(:expected_issuables) { [issue1, issue2, issue4] }
+ end
end
it_behaves_like 'no assignee filter' do
@@ -112,6 +125,26 @@ describe IssuesFinder do
end
end
+ context 'filtering by NOT group_id' do
+ let(:params) { { not: { group_id: group.id } } }
+
+ context 'when include_subgroup param not set' do
+ it 'returns all other group issues' do
+ expect(issues).to contain_exactly(issue2, issue3, issue4)
+ end
+ end
+
+ context 'when include_subgroup param is true', :nested_groups do
+ before do
+ params[:include_subgroups] = true
+ end
+
+ it 'returns all other group and subgroup issues' do
+ expect(issues).to contain_exactly(issue2, issue3)
+ end
+ end
+ end
+
context 'filtering by author ID' do
let(:params) { { author_id: user2.id } }
@@ -120,6 +153,14 @@ describe IssuesFinder do
end
end
+ context 'filtering by not author ID' do
+ let(:params) { { not: { author_id: user2.id } } }
+
+ it 'returns issues not created by that user' do
+ expect(issues).to contain_exactly(issue1, issue2, issue4)
+ end
+ end
+
context 'filtering by milestone' do
let(:params) { { milestone_title: milestone.title } }
@@ -128,6 +169,14 @@ describe IssuesFinder do
end
end
+ context 'filtering by not milestone' do
+ let(:params) { { not: { milestone_title: milestone.title } } }
+
+ it 'returns issues not assigned to that milestone' do
+ expect(issues).to contain_exactly(issue2, issue3, issue4)
+ end
+ end
+
context 'filtering by group milestone' do
let!(:group) { create(:group, :public) }
let(:group_milestone) { create(:milestone, group: group) }
@@ -143,6 +192,14 @@ describe IssuesFinder do
it 'returns issues assigned to that group milestone' do
expect(issues).to contain_exactly(issue2, issue3)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { milestone_title: group_milestone.title } } }
+
+ it 'returns issues not assigned to that group milestone' do
+ expect(issues).to contain_exactly(issue1, issue4)
+ end
+ end
end
context 'filtering by no milestone' do
@@ -184,10 +241,10 @@ describe IssuesFinder do
let(:project_next_8_8) { create(:project, :public) }
let(:project_in_group) { create(:project, :public, namespace: group) }
- let(:yesterday) { Date.today - 1.day }
- let(:tomorrow) { Date.today + 1.day }
- let(:two_days_from_now) { Date.today + 2.days }
- let(:ten_days_from_now) { Date.today + 10.days }
+ let(:yesterday) { Date.current - 1.day }
+ let(:tomorrow) { Date.current + 1.day }
+ let(:two_days_from_now) { Date.current + 2.days }
+ let(:ten_days_from_now) { Date.current + 10.days }
let(:milestones) do
[
@@ -201,7 +258,7 @@ describe IssuesFinder do
end
before do
- milestones.each do |milestone|
+ @created_issues = milestones.map do |milestone|
create(:issue, project: milestone.project || project_in_group, milestone: milestone, author: user, assignees: [user])
end
end
@@ -210,6 +267,18 @@ describe IssuesFinder do
expect(issues.map { |issue| issue.milestone.title }).to contain_exactly('1.1', '8.8', '9.9')
expect(issues.map { |issue| issue.milestone.due_date }).to contain_exactly(tomorrow, two_days_from_now, tomorrow)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { milestone_title: Milestone::Upcoming.name } } }
+
+ it 'returns issues not in upcoming milestones for each project or group' do
+ target_issues = @created_issues.reject do |issue|
+ issue.milestone&.due_date && issue.milestone.due_date > Date.current
+ end + @created_issues.select { |issue| issue.milestone&.title == '8.9' }
+
+ expect(issues).to contain_exactly(issue1, issue2, issue3, issue4, *target_issues)
+ end
+ end
end
context 'filtering by started milestone' do
@@ -219,10 +288,10 @@ describe IssuesFinder do
let(:project_started_1_and_2) { create(:project, :public) }
let(:project_started_8) { create(:project, :public) }
- let(:yesterday) { Date.today - 1.day }
- let(:tomorrow) { Date.today + 1.day }
- let(:two_days_ago) { Date.today - 2.days }
- let(:three_days_ago) { Date.today - 3.days }
+ let(:yesterday) { Date.current - 1.day }
+ let(:tomorrow) { Date.current + 1.day }
+ let(:two_days_ago) { Date.current - 2.days }
+ let(:three_days_ago) { Date.current - 3.days }
let(:milestones) do
[
@@ -248,6 +317,16 @@ describe IssuesFinder do
expect(issues.map { |issue| issue.milestone.title }).to contain_exactly('1.0', '2.0', '8.0')
expect(issues.map { |issue| issue.milestone.start_date }).to contain_exactly(two_days_ago, yesterday, yesterday)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { milestone_title: Milestone::Started.name } } }
+
+ it 'returns issues not in the started milestones for each project' do
+ target_issues = Issue.where.not(milestone: Milestone.started)
+
+ expect(issues).to contain_exactly(issue2, issue3, issue4, *target_issues)
+ end
+ end
end
context 'filtering by label' do
@@ -256,6 +335,33 @@ describe IssuesFinder do
it 'returns issues with that label' do
expect(issues).to contain_exactly(issue2)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { label_name: label.title } } }
+
+ it 'returns issues that do not have that label' do
+ expect(issues).to contain_exactly(issue1, issue3, issue4)
+ end
+
+ # IssuableFinder first filters using the outer params (the ones not inside the `not` key.)
+ # Afterwards, it applies the `not` params to that resultset. This means that things inside the `not` param
+ # do not take precedence over the outer params with the same name.
+ context 'shadowing the same outside param' do
+ let(:params) { { label_name: label2.title, not: { label_name: label.title } } }
+
+ it 'does not take precedence over labels outside NOT' do
+ expect(issues).to contain_exactly(issue3)
+ end
+ end
+
+ context 'further filtering outside params' do
+ let(:params) { { label_name: label2.title, not: { assignee_username: user2.username } } }
+
+ it 'further filters on the returned resultset' do
+ expect(issues).to be_empty
+ end
+ end
+ end
end
context 'filtering by multiple labels' do
@@ -269,6 +375,14 @@ describe IssuesFinder do
it 'returns the unique issues with all those labels' do
expect(issues).to contain_exactly(issue2)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { label_name: [label.title, label2.title].join(',') } } }
+
+ it 'returns issues that do not have ALL labels provided' do
+ expect(issues).to contain_exactly(issue1, issue3, issue4)
+ end
+ end
end
context 'filtering by a label that includes any or none in the title' do
@@ -276,18 +390,28 @@ describe IssuesFinder do
let(:label) { create(:label, title: 'any foo', project: project2) }
let(:label2) { create(:label, title: 'bar none', project: project2) }
- it 'returns the unique issues with all those labels' do
+ before do
create(:label_link, label: label2, target: issue2)
+ end
+ it 'returns the unique issues with all those labels' do
expect(issues).to contain_exactly(issue2)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { label_name: [label.title, label2.title].join(',') } } }
+
+ it 'returns issues that do not have ALL labels provided' do
+ expect(issues).to contain_exactly(issue1, issue3, issue4)
+ end
+ end
end
context 'filtering by no label' do
let(:params) { { label_name: described_class::FILTER_NONE } }
it 'returns issues with no labels' do
- expect(issues).to contain_exactly(issue1, issue3, issue4)
+ expect(issues).to contain_exactly(issue1, issue4)
end
end
@@ -309,6 +433,14 @@ describe IssuesFinder do
it 'returns issues with title and description match for search term' do
expect(issues).to contain_exactly(issue1, issue2)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { search: 'git' } } }
+
+ it 'returns issues with no title and description match for search term' do
+ expect(issues).to contain_exactly(issue3, issue4)
+ end
+ end
end
context 'filtering by issue term in title' do
@@ -317,6 +449,14 @@ describe IssuesFinder do
it 'returns issues with title match for search term' do
expect(issues).to contain_exactly(issue1)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { search: 'git', in: 'title' } } }
+
+ it 'returns issues with no title match for search term' do
+ expect(issues).to contain_exactly(issue2, issue3, issue4)
+ end
+ end
end
context 'filtering by issues iids' do
@@ -325,6 +465,14 @@ describe IssuesFinder do
it 'returns issues with iids match' do
expect(issues).to contain_exactly(issue3)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { iids: issue3.iid } } }
+
+ it 'returns issues with no iids match' do
+ expect(issues).to contain_exactly(issue1, issue2, issue4)
+ end
+ end
end
context 'filtering by state' do
@@ -466,6 +614,14 @@ describe IssuesFinder do
it 'returns issues that the user thumbsup to' do
expect(issues).to contain_exactly(issue1)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { my_reaction_emoji: 'thumbsup' } } }
+
+ it 'returns issues that the user did not thumbsup to' do
+ expect(issues).to contain_exactly(issue2, issue3, issue4)
+ end
+ end
end
context 'user2 searches by "thumbsup" reaction' do
@@ -476,6 +632,14 @@ describe IssuesFinder do
it 'returns issues that the user2 thumbsup to' do
expect(issues).to contain_exactly(issue2)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { my_reaction_emoji: 'thumbsup' } } }
+
+ it 'returns issues that the user2 thumbsup to' do
+ expect(issues).to contain_exactly(issue3)
+ end
+ end
end
context 'user searches by "thumbsdown" reaction' do
@@ -484,6 +648,14 @@ describe IssuesFinder do
it 'returns issues that the user thumbsdown to' do
expect(issues).to contain_exactly(issue3)
end
+
+ context 'using NOT' do
+ let(:params) { { not: { my_reaction_emoji: 'thumbsdown' } } }
+
+ it 'returns issues that the user thumbsdown to' do
+ expect(issues).to contain_exactly(issue1, issue2, issue4)
+ end
+ end
end
end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 4a3ff7e0095..2f481e237a7 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
require 'spec_helper'
describe ApplicationHelper do
diff --git a/spec/helpers/defer_script_tag_helper_spec.rb b/spec/helpers/defer_script_tag_helper_spec.rb
index d10b6f134e4..9ada3ae75ba 100644
--- a/spec/helpers/defer_script_tag_helper_spec.rb
+++ b/spec/helpers/defer_script_tag_helper_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
require 'spec_helper'
describe DeferScriptTagHelper do
diff --git a/spec/lib/container_registry/client_spec.rb b/spec/lib/container_registry/client_spec.rb
index bc5fddd12ba..6c2b338bfcd 100644
--- a/spec/lib/container_registry/client_spec.rb
+++ b/spec/lib/container_registry/client_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb
index b24b71522ec..fc08719fb33 100644
--- a/spec/lib/gitlab/encoding_helper_spec.rb
+++ b/spec/lib/gitlab/encoding_helper_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
require "spec_helper"
diff --git a/spec/lib/gitlab/git/blame_spec.rb b/spec/lib/gitlab/git/blame_spec.rb
index 0010c0304eb..ac085e2c266 100644
--- a/spec/lib/gitlab/git/blame_spec.rb
+++ b/spec/lib/gitlab/git/blame_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
require "spec_helper"
describe Gitlab::Git::Blame, :seed_helper do
diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb
index 1c24244c3a6..7f680071969 100644
--- a/spec/lib/gitlab/git/blob_spec.rb
+++ b/spec/lib/gitlab/git/blob_spec.rb
@@ -1,5 +1,3 @@
-# encoding: utf-8
-
require "spec_helper"
describe Gitlab::Git::Blob, :seed_helper do
diff --git a/spec/lib/gitlab/git/conflict/file_spec.rb b/spec/lib/gitlab/git/conflict/file_spec.rb
index afed6c32af6..a6cabd4966a 100644
--- a/spec/lib/gitlab/git/conflict/file_spec.rb
+++ b/spec/lib/gitlab/git/conflict/file_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
require 'spec_helper'
describe Gitlab::Git::Conflict::File do
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index dccd50bc472..e455c4c99ab 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
require "spec_helper"
describe Gitlab::Git::Repository, :seed_helper do
diff --git a/spec/lib/gitlab/git_spec.rb b/spec/lib/gitlab/git_spec.rb
index 6515be85ae3..505bc470644 100644
--- a/spec/lib/gitlab/git_spec.rb
+++ b/spec/lib/gitlab/git_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
require 'spec_helper'
describe Gitlab::Git do
diff --git a/spec/lib/gitlab/json_logger_spec.rb b/spec/lib/gitlab/json_logger_spec.rb
index d3d9fe9948a..3d4f9b5db86 100644
--- a/spec/lib/gitlab/json_logger_spec.rb
+++ b/spec/lib/gitlab/json_logger_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
require 'spec_helper'
describe Gitlab::JsonLogger do
diff --git a/spec/lib/gitlab/path_regex_spec.rb b/spec/lib/gitlab/path_regex_spec.rb
index 7dcdad7ff92..0829a2b4334 100644
--- a/spec/lib/gitlab/path_regex_spec.rb
+++ b/spec/lib/gitlab/path_regex_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb
index e0b9581c75c..d6e50c672e6 100644
--- a/spec/lib/gitlab/project_search_results_spec.rb
+++ b/spec/lib/gitlab/project_search_results_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb
index e19210d8fbf..3036e3a9754 100644
--- a/spec/lib/gitlab/regex_spec.rb
+++ b/spec/lib/gitlab/regex_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/lib/gitlab/search/found_blob_spec.rb b/spec/lib/gitlab/search/found_blob_spec.rb
index 3496fb29836..a575f6e2f11 100644
--- a/spec/lib/gitlab/search/found_blob_spec.rb
+++ b/spec/lib/gitlab/search/found_blob_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb
index 6ce002ad70e..0e66e959b24 100644
--- a/spec/lib/gitlab/url_blocker_spec.rb
+++ b/spec/lib/gitlab/url_blocker_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/models/blob_spec.rb b/spec/models/blob_spec.rb
index 62a75bde63b..2efab3076d8 100644
--- a/spec/models/blob_spec.rb
+++ b/spec/models/blob_spec.rb
@@ -1,4 +1,3 @@
-# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 5b4b9c516a0..67f64822184 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -2027,6 +2027,43 @@ describe Project do
end
end
+ describe '#latest_pipeline_for_ref' do
+ let(:project) { create(:project, :repository) }
+ let(:second_branch) { project.repository.branches[2] }
+
+ let!(:pipeline_for_default_branch) do
+ create(:ci_empty_pipeline, project: project, sha: project.commit.id,
+ ref: project.default_branch)
+ end
+ let!(:pipeline_for_second_branch) do
+ create(:ci_empty_pipeline, project: project, sha: second_branch.target,
+ ref: second_branch.name)
+ end
+
+ before do
+ create(:ci_empty_pipeline, project: project, sha: project.commit.parent.id,
+ ref: project.default_branch)
+ end
+
+ context 'default repository branch' do
+ subject { project.latest_pipeline_for_ref(project.default_branch) }
+
+ it { is_expected.to eq(pipeline_for_default_branch) }
+ end
+
+ context 'provided ref' do
+ subject { project.latest_pipeline_for_ref(second_branch.name) }
+
+ it { is_expected.to eq(pipeline_for_second_branch) }
+ end
+
+ context 'bad ref' do
+ subject { project.latest_pipeline_for_ref(SecureRandom.uuid) }
+
+ it { is_expected.to be_nil }
+ end
+ end
+
describe '#latest_successful_build_for_sha' do
let(:project) { create(:project, :repository) }
let(:pipeline) { create_pipeline(project) }
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index 0893dcb39b6..b3acf531ccb 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -59,6 +59,16 @@ describe API::Groups do
.to satisfy_one { |group| group['name'] == group1.name }
end
+ it "does not include runners_token information" do
+ get api("/groups", user1)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to include_pagination_headers
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(1)
+ expect(json_response.first).not_to include('runners_token')
+ end
+
it "does not include statistics" do
get api("/groups", user1), params: { statistics: true }
@@ -79,6 +89,16 @@ describe API::Groups do
expect(json_response.length).to eq(2)
end
+ it "does not include runners_token information" do
+ get api("/groups", admin)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to include_pagination_headers
+ expect(json_response).to be_an Array
+ expect(json_response.length).to eq(2)
+ expect(json_response.first).not_to include('runners_token')
+ end
+
it "does not include statistics by default" do
get api("/groups", admin)
@@ -292,6 +312,7 @@ describe API::Groups do
get api("/groups/#{group1.id}")
expect(response).to have_gitlab_http_status(200)
+ expect(json_response).not_to include('runners_token')
end
it 'returns only public projects in the group' do
@@ -350,6 +371,22 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(200)
expect(json_response['projects']).to be_nil
expect(json_response['shared_projects']).to be_nil
+ expect(json_response).not_to include('runners_token')
+ end
+
+ it "doesn't return runners_token if the user is not the owner of the group" do
+ get api("/groups/#{group1.id}", user3)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response).not_to include('runners_token')
+ end
+
+ it "returns runners_token if the user is the owner of the group" do
+ group1.add_owner(user3)
+ get api("/groups/#{group1.id}", user3)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response).to include('runners_token')
end
it "does not return a non existing group" do
@@ -407,6 +444,13 @@ describe API::Groups do
expect(json_response['name']).to eq(group2.name)
end
+ it "returns information of the runners_token for the group" do
+ get api("/groups/#{group2.id}", admin)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(json_response).to include('runners_token')
+ end
+
it "does not return a non existing group" do
get api("/groups/1328", admin)
diff --git a/spec/requests/api/issues/get_group_issues_spec.rb b/spec/requests/api/issues/get_group_issues_spec.rb
index c487471e4a1..3ee08758f99 100644
--- a/spec/requests/api/issues/get_group_issues_spec.rb
+++ b/spec/requests/api/issues/get_group_issues_spec.rb
@@ -437,17 +437,21 @@ describe API::Issues do
end
context 'with labeled issues' do
+ let(:group_issue2) { create :issue, project: group_project }
let(:label_b) { create(:label, title: 'foo', project: group_project) }
let(:label_c) { create(:label, title: 'bar', project: group_project) }
before do
+ create(:label_link, label: group_label, target: group_issue2)
create(:label_link, label: label_b, target: group_issue)
+ create(:label_link, label: label_b, target: group_issue2)
create(:label_link, label: label_c, target: group_issue)
get api(base_url, user), params: params
end
let(:issue) { group_issue }
+ let(:issue2) { group_issue2 }
let(:label) { group_label }
it_behaves_like 'labeled issues with labels and label_name params'
diff --git a/spec/requests/api/issues/get_project_issues_spec.rb b/spec/requests/api/issues/get_project_issues_spec.rb
index b7aa3f93451..c10f5b2bd58 100644
--- a/spec/requests/api/issues/get_project_issues_spec.rb
+++ b/spec/requests/api/issues/get_project_issues_spec.rb
@@ -283,11 +283,14 @@ describe API::Issues do
end
context 'with labeled issues' do
+ let(:issue2) { create :issue, project: project }
let(:label_b) { create(:label, title: 'foo', project: project) }
let(:label_c) { create(:label, title: 'bar', project: project) }
before do
+ create(:label_link, label: label, target: issue2)
create(:label_link, label: label_b, target: issue)
+ create(:label_link, label: label_b, target: issue2)
create(:label_link, label: label_c, target: issue)
get api('/issues', user), params: params
diff --git a/spec/requests/api/issues/issues_spec.rb b/spec/requests/api/issues/issues_spec.rb
index f19c2dcc6fe..61a94b682be 100644
--- a/spec/requests/api/issues/issues_spec.rb
+++ b/spec/requests/api/issues/issues_spec.rb
@@ -427,9 +427,12 @@ describe API::Issues do
context 'with labeled issues' do
let(:label_b) { create(:label, title: 'foo', project: project) }
let(:label_c) { create(:label, title: 'bar', project: project) }
+ let(:issue2) { create(:issue, author: user, project: project) }
before do
+ create(:label_link, label: label, target: issue2)
create(:label_link, label: label_b, target: issue)
+ create(:label_link, label: label_b, target: issue2)
create(:label_link, label: label_c, target: issue)
get api('/issues', user), params: params
@@ -497,46 +500,74 @@ describe API::Issues do
end
end
- it 'returns an empty array if no issue matches milestone' do
- get api("/issues?milestone=#{empty_milestone.title}", user)
+ context 'filter by milestone' do
+ it 'returns an empty array if no issue matches milestone' do
+ get api("/issues?milestone=#{empty_milestone.title}", user)
- expect_paginated_array_response([])
- end
+ expect_paginated_array_response([])
+ end
- it 'returns an empty array if milestone does not exist' do
- get api('/issues?milestone=foo', user)
+ it 'returns an empty array if milestone does not exist' do
+ get api('/issues?milestone=foo', user)
- expect_paginated_array_response([])
- end
+ expect_paginated_array_response([])
+ end
- it 'returns an array of issues in given milestone' do
- get api("/issues?milestone=#{milestone.title}", user)
+ it 'returns an array of issues in given milestone' do
+ get api("/issues?milestone=#{milestone.title}", user)
- expect_paginated_array_response([issue.id, closed_issue.id])
- end
+ expect_paginated_array_response([issue.id, closed_issue.id])
+ end
- it 'returns an array of issues in given milestone_title param' do
- get api("/issues?milestone_title=#{milestone.title}", user)
+ it 'returns an array of issues in given milestone_title param' do
+ get api("/issues?milestone_title=#{milestone.title}", user)
- expect_paginated_array_response([issue.id, closed_issue.id])
- end
+ expect_paginated_array_response([issue.id, closed_issue.id])
+ end
- it 'returns an array of issues matching state in milestone' do
- get api("/issues?milestone=#{milestone.title}&state=closed", user)
+ it 'returns an array of issues matching state in milestone' do
+ get api("/issues?milestone=#{milestone.title}&state=closed", user)
- expect_paginated_array_response(closed_issue.id)
- end
+ expect_paginated_array_response(closed_issue.id)
+ end
- it 'returns an array of issues with no milestone' do
- get api("/issues?milestone=#{no_milestone_title}", author)
+ it 'returns an array of issues with no milestone' do
+ get api("/issues?milestone=#{no_milestone_title}", author)
- expect_paginated_array_response(confidential_issue.id)
- end
+ expect_paginated_array_response(confidential_issue.id)
+ end
- it 'returns an array of issues with no milestone using milestone_title param' do
- get api("/issues?milestone_title=#{no_milestone_title}", author)
+ it 'returns an array of issues with no milestone using milestone_title param' do
+ get api("/issues?milestone_title=#{no_milestone_title}", author)
- expect_paginated_array_response(confidential_issue.id)
+ expect_paginated_array_response(confidential_issue.id)
+ end
+
+ context 'negated' do
+ it 'returns all issues if milestone does not exist' do
+ get api('/issues?not[milestone]=foo', user)
+
+ expect_paginated_array_response([issue.id, closed_issue.id])
+ end
+
+ it 'returns all issues that do not belong to a milestone but have a milestone' do
+ get api("/issues?not[milestone]=#{empty_milestone.title}", user)
+
+ expect_paginated_array_response([issue.id, closed_issue.id])
+ end
+
+ it 'returns an array of issues with any milestone' do
+ get api("/issues?not[milestone]=#{no_milestone_title}", user)
+
+ expect_paginated_array_response([issue.id, closed_issue.id])
+ end
+
+ it 'returns an array of issues matching state not in milestone' do
+ get api("/issues?not[milestone]=#{empty_milestone.title}&state=closed", user)
+
+ expect_paginated_array_response(closed_issue.id)
+ end
+ end
end
it 'returns an array of issues found by iids' do
diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb
index 174b3214d13..3a3f0e970a4 100644
--- a/spec/requests/api/pipelines_spec.rb
+++ b/spec/requests/api/pipelines_spec.rb
@@ -459,6 +459,54 @@ describe API::Pipelines do
end
end
+ describe 'GET /projects/:id/pipelines/latest' do
+ context 'authorized user' do
+ let(:second_branch) { project.repository.branches[2] }
+
+ let!(:second_pipeline) do
+ create(:ci_empty_pipeline, project: project, sha: second_branch.target,
+ ref: second_branch.name, user: user)
+ end
+
+ before do
+ create(:ci_empty_pipeline, project: project, sha: project.commit.parent.id,
+ ref: project.default_branch, user: user)
+ end
+
+ context 'default repository branch' do
+ it 'gets the latest pipleine' do
+ get api("/projects/#{project.id}/pipelines/latest", user)
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to match_response_schema('public_api/v4/pipeline/detail')
+ expect(json_response['ref']).to eq(project.default_branch)
+ expect(json_response['sha']).to eq(project.commit.id)
+ end
+ end
+
+ context 'ref parameter' do
+ it 'gets the latest pipleine' do
+ get api("/projects/#{project.id}/pipelines/latest", user), params: { ref: second_branch.name }
+
+ expect(response).to have_gitlab_http_status(200)
+ expect(response).to match_response_schema('public_api/v4/pipeline/detail')
+ expect(json_response['ref']).to eq(second_branch.name)
+ expect(json_response['sha']).to eq(second_branch.target)
+ end
+ end
+ end
+
+ context 'unauthorized user' do
+ it 'does not return a project pipeline' do
+ get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member)
+
+ expect(response).to have_gitlab_http_status(404)
+ expect(json_response['message']).to eq '404 Project Not Found'
+ expect(json_response['id']).to be nil
+ end
+ end
+ end
+
describe 'GET /projects/:id/pipelines/:pipeline_id/variables' do
subject { get api("/projects/#{project.id}/pipelines/#{pipeline.id}/variables", api_user) }
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index f52e36e6bcd..2d8ef9c06dc 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
require 'spec_helper'
shared_examples 'languages and percentages JSON response' do
diff --git a/spec/services/git/branch_push_service_spec.rb b/spec/services/git/branch_push_service_spec.rb
index c3a4f3dbe3f..f4d1a1e34cd 100644
--- a/spec/services/git/branch_push_service_spec.rb
+++ b/spec/services/git/branch_push_service_spec.rb
@@ -197,7 +197,7 @@ describe Git::BranchPushService, services: true do
create(:protected_branch, :no_one_can_push, :developers_can_merge, project: project, name: 'master')
expect(project).to receive(:execute_hooks)
expect(project.default_branch).to eq("master")
- expect_any_instance_of(ProtectedBranches::CreateService).not_to receive(:execute)
+ expect(ProtectedBranches::CreateService).not_to receive(:new)
execute_service(project, user, blankrev, 'newrev', ref)
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index fd9a63b79cc..55254b61ac8 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
require 'spec_helper'
diff --git a/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb b/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb
index 26ab6fbd400..6c96b18d834 100644
--- a/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb
+++ b/spec/support/shared_contexts/finders/issues_finder_shared_contexts.rb
@@ -12,6 +12,7 @@ RSpec.shared_context 'IssuesFinder context' do
set(:project3) { create(:project, group: subgroup) }
set(:milestone) { create(:milestone, project: project1) }
set(:label) { create(:label, project: project2) }
+ set(:label2) { create(:label, project: project2) }
set(:issue1) { create(:issue, author: user, assignees: [user], project: project1, milestone: milestone, title: 'gitlab', created_at: 1.week.ago, updated_at: 1.week.ago) }
set(:issue2) { create(:issue, author: user, assignees: [user], project: project2, description: 'gitlab', created_at: 1.week.from_now, updated_at: 1.week.from_now) }
set(:issue3) { create(:issue, author: user2, assignees: [user2], project: project2, title: 'tanuki', description: 'tanuki', created_at: 2.weeks.from_now, updated_at: 2.weeks.from_now) }
@@ -24,6 +25,7 @@ end
RSpec.shared_context 'IssuesFinder#execute context' do
let!(:closed_issue) { create(:issue, author: user2, assignees: [user2], project: project2, state: 'closed') }
let!(:label_link) { create(:label_link, label: label, target: issue2) }
+ let!(:label_link2) { create(:label_link, label: label2, target: issue3) }
let(:search_user) { user }
let(:params) { {} }
let(:issues) { described_class.new(search_user, params.reverse_merge(scope: scope, state: 'opened')).execute }
diff --git a/spec/support/shared_examples/finders/assignees_filter_shared_examples.rb b/spec/support/shared_examples/finders/assignees_filter_shared_examples.rb
index a931c4df99f..f1df1052ef2 100644
--- a/spec/support/shared_examples/finders/assignees_filter_shared_examples.rb
+++ b/spec/support/shared_examples/finders/assignees_filter_shared_examples.rb
@@ -6,12 +6,24 @@ shared_examples 'assignee ID filter' do
end
end
+shared_examples 'assignee NOT ID filter' do
+ it 'returns issuables not assigned to that user' do
+ expect(issuables).to contain_exactly(*expected_issuables)
+ end
+end
+
shared_examples 'assignee username filter' do
it 'returns issuables assigned to those users' do
expect(issuables).to contain_exactly(*expected_issuables)
end
end
+shared_examples 'assignee NOT username filter' do
+ it 'returns issuables not assigned to those users' do
+ expect(issuables).to contain_exactly(*expected_issuables)
+ end
+end
+
shared_examples 'no assignee filter' do
let(:params) { { assignee_id: 'None' } }
diff --git a/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb b/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb
index 8e58cc7ba22..affe88be475 100644
--- a/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb
+++ b/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb
@@ -21,4 +21,8 @@ shared_examples 'cluster application core specs' do |application_name|
expect(Clusters::Cluster::APPLICATIONS[subject.name]).to eq(described_class)
end
end
+
+ describe '.association_name' do
+ it { expect(described_class.association_name).to eq(:"application_#{subject.name}") }
+ end
end
diff --git a/spec/support/shared_examples/requests/api/issues_shared_examples.rb b/spec/support/shared_examples/requests/api/issues_shared_examples.rb
index 1133e95e44e..d22210edf99 100644
--- a/spec/support/shared_examples/requests/api/issues_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/issues_shared_examples.rb
@@ -8,6 +8,13 @@ shared_examples 'labeled issues with labels and label_name params' do
end
end
+ shared_examples 'returns negated label names' do
+ it 'returns label names' do
+ expect_paginated_array_response(issue2.id)
+ expect(json_response.first['labels']).to eq([label_b.title, label.title])
+ end
+ end
+
shared_examples 'returns basic label entity' do
it 'returns basic label entity' do
expect_paginated_array_response(issue.id)
@@ -28,6 +35,20 @@ shared_examples 'labeled issues with labels and label_name params' do
it_behaves_like 'returns label names'
end
+ context 'negation' do
+ context 'array of labeled issues when all labels match with negation' do
+ let(:params) { { labels: "#{label.title},#{label_b.title}", not: { labels: "#{label_c.title}" } } }
+
+ it_behaves_like 'returns negated label names'
+ end
+
+ context 'array of labeled issues when all labels match with negation with label params as array' do
+ let(:params) { { labels: [label.title, label_b.title], not: { labels: [label_c.title] } } }
+
+ it_behaves_like 'returns negated label names'
+ end
+ end
+
context 'when with_labels_details provided' do
context 'array of labeled issues when all labels match' do
let(:params) { { labels: "#{label.title},#{label_b.title},#{label_c.title}", with_labels_details: true } }