Commit 78be4f8c authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'ce-to-ee-2018-08-22' into 'master'

CE upstream - 2018-08-22 12:21 UTC

Closes gitlab-ce#50549 and gitlab-qa#317

See merge request gitlab-org/gitlab-ee!6968
parents 22706acf e112b98c
...@@ -8,11 +8,11 @@ entry. ...@@ -8,11 +8,11 @@ entry.
- Bump Gitaly to 0.117.1 for Rouge update. !21277 - Bump Gitaly to 0.117.1 for Rouge update. !21277
- Fix symlink vulnerability in project import. - Fix symlink vulnerability in project import.
- Bump rugged to 0.27.4 for security fixes.
- Fixed XSS in branch name in Web IDE.
- Adding CSRF protection to Hooks test action. - Adding CSRF protection to Hooks test action.
- Don't expose project names in GitHub counters. - Don't expose project names in GitHub counters.
- Bump rugged to 0.27.4 for security fixes.
- Don't expose project names in various counters. - Don't expose project names in various counters.
- Fixed XSS in branch name in Web IDE.
### Removed (1 change) ### Removed (1 change)
...@@ -72,9 +72,9 @@ entry. ...@@ -72,9 +72,9 @@ entry.
- Fix bug setting http headers in Files API. !20938 - Fix bug setting http headers in Files API. !20938
- Rails5: fix flaky spec. !20953 (Jasper Maes) - Rails5: fix flaky spec. !20953 (Jasper Maes)
- Fixed list of projects not loading in group boards. !20955 - Fixed list of projects not loading in group boards. !20955
- Fix rendering of the context lines in MR diffs page. !20968
- Fix navigation to First and Next discussion on MR Changes tab. !20968
- Fix autosave and ESC confirmation issues for MR discussions. !20968 - Fix autosave and ESC confirmation issues for MR discussions. !20968
- Fix navigation to First and Next discussion on MR Changes tab. !20968
- Fix rendering of the context lines in MR diffs page. !20968
- fix error caused when using the search bar while unauthenticated. !20970 - fix error caused when using the search bar while unauthenticated. !20970
- Fix GPG status badge loading regressions. !20987 - Fix GPG status badge loading regressions. !20987
- Ensure links in notifications footer are not escaped. !21000 - Ensure links in notifications footer are not escaped. !21000
...@@ -88,18 +88,18 @@ entry. ...@@ -88,18 +88,18 @@ entry.
- Fix issue stopping Instance Statistics javascript to be executed. !21211 - Fix issue stopping Instance Statistics javascript to be executed. !21211
- Fix broken JavaScript in IE11. !21214 - Fix broken JavaScript in IE11. !21214
- Improve JUnit test reports in merge request widgets. !49966 - Improve JUnit test reports in merge request widgets. !49966
- Fix handling of annotated tags when Gitaly is not in use.
- Properly handle colons in URL passwords. - Properly handle colons in URL passwords.
- Renders test reports for resolved failures and resets error state. - Renders test reports for resolved failures and resets error state.
- Sanitize git URL in import errors. (Jamie Schembri) - Fix handling of annotated tags when Gitaly is not in use.
- Fix updated_at if created_at is set for Note API.
- Allow to toggle notifications for issues due soon.
- Fix serialization of LegacyDiffNote. - Fix serialization of LegacyDiffNote.
- Update hamlit to fix ruby 2.5 incompatibilities, fixes #42045. (Matthew Dawson)
- Escapes milestone and label's names on flash notice when promoting them. - Escapes milestone and label's names on flash notice when promoting them.
- Allow to toggle notifications for issues due soon.
- Sanitize git URL in import errors. (Jamie Schembri)
- Add missing predefined variable and fix docs. - Add missing predefined variable and fix docs.
- Allow updating a project's avatar without other params. (Jamie Schembri) - Allow updating a project's avatar without other params. (Jamie Schembri)
- Fix the UI for listing system-level labels. - Fix the UI for listing system-level labels.
- Update hamlit to fix ruby 2.5 incompatibilities, fixes #42045. (Matthew Dawson)
- Fix updated_at if created_at is set for Note API.
- Fix search bar text input alignment. - Fix search bar text input alignment.
### Changed (32 changes, 7 of them are from the community) ### Changed (32 changes, 7 of them are from the community)
...@@ -133,9 +133,9 @@ entry. ...@@ -133,9 +133,9 @@ entry.
- Update to Rouge 3.2.0, including Terraform and Crystal lexer and bug fixes. !20991 - Update to Rouge 3.2.0, including Terraform and Crystal lexer and bug fixes. !20991
- Update design of project templates. !21012 - Update design of project templates. !21012
- Update to Rouge 3.2.1, which includes a critical fix to the Perl Lexer. !21263 - Update to Rouge 3.2.1, which includes a critical fix to the Perl Lexer. !21263
- Redesign GCP offer banner.
- Add a 10 ms bucket for SQL timings. - Add a 10 ms bucket for SQL timings.
- Show one digit after dot in commit_per_day value in charts page. (msdundar) - Show one digit after dot in commit_per_day value in charts page. (msdundar)
- Redesign GCP offer banner.
### Performance (30 changes, 10 of them are from the community) ### Performance (30 changes, 10 of them are from the community)
...@@ -206,13 +206,13 @@ entry. ...@@ -206,13 +206,13 @@ entry.
- Clean orphaned files in object storage. !20918 - Clean orphaned files in object storage. !20918
- Adds frontend support to render test reports on the MR widget. !20936 - Adds frontend support to render test reports on the MR widget. !20936
- Trigger system hooks when project is archived/unarchived. !20995 - Trigger system hooks when project is archived/unarchived. !20995
- Custom Wiki Sidebar Support Issue 14995. (Josh Sooter)
- Emails on push recipients now accepts formats like John Doe <johndoe@example.com>. (George Thomas) - Emails on push recipients now accepts formats like John Doe <johndoe@example.com>. (George Thomas)
- Added button to regenerate 2FA codes. (Luke Picciau)
- Improve danger confirmation modals by focusing input field. (Jamie Schembri)
- Add new model for tracking label events. - Add new model for tracking label events.
- Custom Wiki Sidebar Support Issue 14995. (Josh Sooter) - Improve danger confirmation modals by focusing input field. (Jamie Schembri)
- Clicking CI icon in Web IDE now opens up pipelines panel. - Clicking CI icon in Web IDE now opens up pipelines panel.
- Enabled deletion of files in the Web IDE. - Enabled deletion of files in the Web IDE.
- Added button to regenerate 2FA codes. (Luke Picciau)
### Other (26 changes, 7 of them are from the community) ### Other (26 changes, 7 of them are from the community)
...@@ -238,9 +238,9 @@ entry. ...@@ -238,9 +238,9 @@ entry.
- Update git rerere link in docs. !21060 (gfyoung) - Update git rerere link in docs. !21060 (gfyoung)
- Add 'tabindex' attribute support on Icon component to show BS4 popover on trigger type 'focus'. !21066 - Add 'tabindex' attribute support on Icon component to show BS4 popover on trigger type 'focus'. !21066
- Add a Gitlab::Profiler.print_by_total_time convenience method for profiling from a Rails console. - Add a Gitlab::Profiler.print_by_total_time convenience method for profiling from a Rails console.
- Disables toggle comments button if diff has no discussions.
- Automatically expand runner's settings block when linking to the runner's settings page. - Automatically expand runner's settings block when linking to the runner's settings page.
- Increases title column on modal for reports. - Increases title column on modal for reports.
- Disables toggle comments button if diff has no discussions.
- Moves help_popover component to a common location. - Moves help_popover component to a common location.
......
...@@ -119,14 +119,14 @@ gem 'dropzonejs-rails', '~> 0.7.1' ...@@ -119,14 +119,14 @@ gem 'dropzonejs-rails', '~> 0.7.1'
# for backups # for backups
gem 'fog-aws', '~> 2.0.1' gem 'fog-aws', '~> 2.0.1'
gem 'fog-core', '~> 1.44' gem 'fog-core', '~> 1.44'
gem 'fog-google', '~> 1.3.3' gem 'fog-google', '~> 1.7.1'
gem 'fog-local', '~> 0.3' gem 'fog-local', '~> 0.3'
gem 'fog-openstack', '~> 0.1' gem 'fog-openstack', '~> 0.1'
gem 'fog-rackspace', '~> 0.1.1' gem 'fog-rackspace', '~> 0.1.1'
gem 'fog-aliyun', '~> 0.2.0' gem 'fog-aliyun', '~> 0.2.0'
# for Google storage # for Google storage
gem 'google-api-client', '~> 0.19.8' gem 'google-api-client', '~> 0.23'
# for aws storage # for aws storage
gem 'unf', '~> 0.1.4' gem 'unf', '~> 0.1.4'
......
...@@ -263,11 +263,11 @@ GEM ...@@ -263,11 +263,11 @@ GEM
builder builder
excon (~> 0.58) excon (~> 0.58)
formatador (~> 0.2) formatador (~> 0.2)
fog-google (1.3.3) fog-google (1.7.1)
fog-core fog-core
fog-json fog-json
fog-xml fog-xml
google-api-client (~> 0.19.1) google-api-client (~> 0.23.0)
fog-json (1.0.2) fog-json (1.0.2)
fog-core (~> 1.0) fog-core (~> 1.0)
multi_json (~> 1.10) multi_json (~> 1.10)
...@@ -354,7 +354,7 @@ GEM ...@@ -354,7 +354,7 @@ GEM
actionpack (>= 3.0) actionpack (>= 3.0)
multi_json multi_json
request_store (>= 1.0) request_store (>= 1.0)
google-api-client (0.19.8) google-api-client (0.23.4)
addressable (~> 2.5, >= 2.5.1) addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.5, < 0.7.0) googleauth (>= 0.5, < 0.7.0)
httpclient (>= 2.8.1, < 3.0) httpclient (>= 2.8.1, < 3.0)
...@@ -767,7 +767,7 @@ GEM ...@@ -767,7 +767,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0) http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0) mime-types (>= 1.16, < 4.0)
netrc (~> 0.8) netrc (~> 0.8)
retriable (3.1.1) retriable (3.1.2)
rinku (2.0.0) rinku (2.0.0)
rotp (2.1.2) rotp (2.1.2)
rouge (3.2.1) rouge (3.2.1)
...@@ -1065,7 +1065,7 @@ DEPENDENCIES ...@@ -1065,7 +1065,7 @@ DEPENDENCIES
fog-aliyun (~> 0.2.0) fog-aliyun (~> 0.2.0)
fog-aws (~> 2.0.1) fog-aws (~> 2.0.1)
fog-core (~> 1.44) fog-core (~> 1.44)
fog-google (~> 1.3.3) fog-google (~> 1.7.1)
fog-local (~> 0.3) fog-local (~> 0.3)
fog-openstack (~> 0.1) fog-openstack (~> 0.1)
fog-rackspace (~> 0.1.1) fog-rackspace (~> 0.1.1)
...@@ -1086,7 +1086,7 @@ DEPENDENCIES ...@@ -1086,7 +1086,7 @@ DEPENDENCIES
gitlab-styles (~> 2.4) gitlab-styles (~> 2.4)
gitlab_omniauth-ldap (~> 2.0.4) gitlab_omniauth-ldap (~> 2.0.4)
gon (~> 6.2) gon (~> 6.2)
google-api-client (~> 0.19.8) google-api-client (~> 0.23)
google-protobuf (= 3.5.1) google-protobuf (= 3.5.1)
gpgme gpgme
grape (~> 1.0) grape (~> 1.0)
......
...@@ -266,11 +266,11 @@ GEM ...@@ -266,11 +266,11 @@ GEM
builder builder
excon (~> 0.58) excon (~> 0.58)
formatador (~> 0.2) formatador (~> 0.2)
fog-google (1.3.3) fog-google (1.7.1)
fog-core fog-core
fog-json fog-json
fog-xml fog-xml
google-api-client (~> 0.19.1) google-api-client (~> 0.23.0)
fog-json (1.0.2) fog-json (1.0.2)
fog-core (~> 1.0) fog-core (~> 1.0)
multi_json (~> 1.10) multi_json (~> 1.10)
...@@ -357,7 +357,7 @@ GEM ...@@ -357,7 +357,7 @@ GEM
actionpack (>= 3.0) actionpack (>= 3.0)
multi_json multi_json
request_store (>= 1.0) request_store (>= 1.0)
google-api-client (0.19.8) google-api-client (0.23.4)
addressable (~> 2.5, >= 2.5.1) addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.5, < 0.7.0) googleauth (>= 0.5, < 0.7.0)
httpclient (>= 2.8.1, < 3.0) httpclient (>= 2.8.1, < 3.0)
...@@ -777,7 +777,7 @@ GEM ...@@ -777,7 +777,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0) http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0) mime-types (>= 1.16, < 4.0)
netrc (~> 0.8) netrc (~> 0.8)
retriable (3.1.1) retriable (3.1.2)
rinku (2.0.0) rinku (2.0.0)
rotp (2.1.2) rotp (2.1.2)
rouge (3.2.0) rouge (3.2.0)
...@@ -1077,7 +1077,7 @@ DEPENDENCIES ...@@ -1077,7 +1077,7 @@ DEPENDENCIES
fog-aliyun (~> 0.2.0) fog-aliyun (~> 0.2.0)
fog-aws (~> 2.0.1) fog-aws (~> 2.0.1)
fog-core (~> 1.44) fog-core (~> 1.44)
fog-google (~> 1.3.3) fog-google (~> 1.7.1)
fog-local (~> 0.3) fog-local (~> 0.3)
fog-openstack (~> 0.1) fog-openstack (~> 0.1)
fog-rackspace (~> 0.1.1) fog-rackspace (~> 0.1.1)
...@@ -1098,7 +1098,7 @@ DEPENDENCIES ...@@ -1098,7 +1098,7 @@ DEPENDENCIES
gitlab-styles (~> 2.4) gitlab-styles (~> 2.4)
gitlab_omniauth-ldap (~> 2.0.4) gitlab_omniauth-ldap (~> 2.0.4)
gon (~> 6.2) gon (~> 6.2)
google-api-client (~> 0.19.8) google-api-client (~> 0.23)
google-protobuf (= 3.5.1) google-protobuf (= 3.5.1)
gpgme gpgme
grape (~> 1.0) grape (~> 1.0)
......
11.2.0-pre 11.3.0-pre
...@@ -330,7 +330,6 @@ $line-select-yellow-dark: #f0e2bd; ...@@ -330,7 +330,6 @@ $line-select-yellow-dark: #f0e2bd;
$dark-diff-match-bg: rgba(255, 255, 255, 0.3); $dark-diff-match-bg: rgba(255, 255, 255, 0.3);
$dark-diff-match-color: rgba(255, 255, 255, 0.1); $dark-diff-match-color: rgba(255, 255, 255, 0.1);
$file-mode-changed: #777; $file-mode-changed: #777;
$file-mode-changed: #777;
$diff-image-info-color: gray; $diff-image-info-color: gray;
$diff-swipe-border: #999; $diff-swipe-border: #999;
$diff-view-modes-color: gray; $diff-view-modes-color: gray;
......
...@@ -101,7 +101,7 @@ class Projects::CommitController < Projects::ApplicationController ...@@ -101,7 +101,7 @@ class Projects::CommitController < Projects::ApplicationController
@branch_name = create_new_branch? ? @commit.cherry_pick_branch_name : @start_branch @branch_name = create_new_branch? ? @commit.cherry_pick_branch_name : @start_branch
create_commit(Commits::CherryPickService, success_notice: "The #{@commit.change_type_title(current_user)} has been successfully cherry-picked.", create_commit(Commits::CherryPickService, success_notice: "The #{@commit.change_type_title(current_user)} has been successfully cherry-picked into #{@branch_name}.",
success_path: -> { successful_change_path }, failure_path: failed_change_path) success_path: -> { successful_change_path }, failure_path: failed_change_path)
end end
......
...@@ -193,6 +193,7 @@ class Commit ...@@ -193,6 +193,7 @@ class Commit
# otherwise returns commit message without first line # otherwise returns commit message without first line
def description def description
return safe_message if full_title.length >= 100 return safe_message if full_title.length >= 100
return no_commit_message if safe_message.blank?
safe_message.split("\n", 2)[1].try(:chomp) safe_message.split("\n", 2)[1].try(:chomp)
end end
......
...@@ -104,7 +104,7 @@ class Member < ActiveRecord::Base ...@@ -104,7 +104,7 @@ class Member < ActiveRecord::Base
def filter_by_2fa(value) def filter_by_2fa(value)
case value case value
when 'enabled' when 'enabled'
left_join_users.merge(User.with_two_factor_indistinct) left_join_users.merge(User.with_two_factor)
when 'disabled' when 'disabled'
left_join_users.merge(User.without_two_factor) left_join_users.merge(User.without_two_factor)
else else
......
...@@ -298,13 +298,16 @@ class User < ActiveRecord::Base ...@@ -298,13 +298,16 @@ class User < ActiveRecord::Base
end end
end end
def self.with_two_factor_indistinct
joins("LEFT OUTER JOIN u2f_registrations AS u2f ON u2f.user_id = users.id")
.where("u2f.id IS NOT NULL OR users.otp_required_for_login = ?", true)
end
def self.with_two_factor def self.with_two_factor
with_two_factor_indistinct.distinct(arel_table[:id]) with_u2f_registrations = <<-SQL
EXISTS (
SELECT *
FROM u2f_registrations AS u2f
WHERE u2f.user_id = users.id
) OR users.otp_required_for_login = ?
SQL
where(with_u2f_registrations, true)
end end
def self.without_two_factor def self.without_two_factor
......
...@@ -146,7 +146,6 @@ class GitPushService < BaseService ...@@ -146,7 +146,6 @@ class GitPushService < BaseService
EventCreateService.new.push(project, current_user, build_push_data) EventCreateService.new.push(project, current_user, build_push_data)
Ci::CreatePipelineService.new(project, current_user, build_push_data).execute(:push, mirror_update: mirror_update) Ci::CreatePipelineService.new(project, current_user, build_push_data).execute(:push, mirror_update: mirror_update)
SystemHookPushWorker.perform_async(build_push_data.dup, :push_hooks)
project.execute_hooks(build_push_data.dup, :push_hooks) project.execute_hooks(build_push_data.dup, :push_hooks)
project.execute_services(build_push_data.dup, :push_hooks) project.execute_services(build_push_data.dup, :push_hooks)
......
---
title: "Avoid nil safe message"
merge_request: 21326
author: Yi Siliang
type: fixed
---
title: Add target branch name to cherrypick confirmation message
merge_request: 20846
author: George Andrinopoulos
type: other
---
title: 'API: Catch empty commit messages'
merge_request: 21322
author: Robert Schilling
type: fixed
---
title: 'API: Catch empty code content for project snippets'
merge_request: 21325
author: Robert Schilling
type: fixed
---
title: 'API: Add expiration date for shared projects to the project entity'
merge_request: 21104
author: Robert Schilling
type: added
---
title: Fix SQL error when sorting 2FA-enabled users by name in admin area
merge_request: 21324
author:
type: fixed
---
title: Bump fog-google to 1.7.0 and google-api-client to 0.23.0
merge_request: 21295
author:
type: fixed
---
title: Eliminate unnecessary and duplicate system hook fires
merge_request: 21337
author:
type: performance
...@@ -7,7 +7,7 @@ module Fog ...@@ -7,7 +7,7 @@ module Fog
class GoogleXML class GoogleXML
class File < Fog::Model class File < Fog::Model
module MonkeyPatch module MonkeyPatch
def url(expires) def url(expires, options = {})
requires :key requires :key
collection.get_https_url(key, expires) collection.get_https_url(key, expires)
end end
......
...@@ -352,12 +352,14 @@ Example response: ...@@ -352,12 +352,14 @@ Example response:
{ {
"group_id": 4, "group_id": 4,
"group_name": "Twitter", "group_name": "Twitter",
"group_access_level": 30 "group_access_level": 30,
"expires_at": null
}, },
{ {
"group_id": 3, "group_id": 3,
"group_name": "Gitlab Org", "group_name": "Gitlab Org",
"group_access_level": 10 "group_access_level": 10,
"expires_at": "2018-08-14"
} }
] ]
} }
......
...@@ -91,6 +91,7 @@ module API ...@@ -91,6 +91,7 @@ module API
group_link.group.name group_link.group.name
end end
expose :group_access, as: :group_access_level expose :group_access, as: :group_access_level
expose :expires_at
end end
class ProjectIdentity < Grape::Entity class ProjectIdentity < Grape::Entity
......
...@@ -59,7 +59,7 @@ module API ...@@ -59,7 +59,7 @@ module API
params :simple_file_params do params :simple_file_params do
requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb' requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.' requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.'
requires :commit_message, type: String, desc: 'Commit message' requires :commit_message, type: String, allow_blank: false, desc: 'Commit message'
optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from' optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from'
optional :author_email, type: String, desc: 'The email of the author' optional :author_email, type: String, desc: 'The email of the author'
optional :author_name, type: String, desc: 'The name of the author' optional :author_name, type: String, desc: 'The name of the author'
......
...@@ -49,7 +49,7 @@ module API ...@@ -49,7 +49,7 @@ module API
params do params do
requires :title, type: String, desc: 'The title of the snippet' requires :title, type: String, desc: 'The title of the snippet'
requires :file_name, type: String, desc: 'The file name of the snippet' requires :file_name, type: String, desc: 'The file name of the snippet'
requires :code, type: String, desc: 'The content of the snippet' requires :code, type: String, allow_blank: false, desc: 'The content of the snippet'
optional :description, type: String, desc: 'The description of a snippet' optional :description, type: String, desc: 'The description of a snippet'
requires :visibility, type: String, requires :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values, values: Gitlab::VisibilityLevel.string_values,
...@@ -78,7 +78,7 @@ module API ...@@ -78,7 +78,7 @@ module API
requires :snippet_id, type: Integer, desc: 'The ID of a project snippet' requires :snippet_id, type: Integer, desc: 'The ID of a project snippet'
optional :title, type: String, desc: 'The title of the snippet' optional :title, type: String, desc: 'The title of the snippet'
optional :file_name, type: String, desc: 'The file name of the snippet' optional :file_name, type: String, desc: 'The file name of the snippet'
optional :code, type: String, desc: 'The content of the snippet' optional :code, type: String, allow_blank: false, desc: 'The content of the snippet'
optional :description, type: String, desc: 'The description of a snippet' optional :description, type: String, desc: 'The description of a snippet'
optional :visibility, type: String, optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values, values: Gitlab::VisibilityLevel.string_values,
......
...@@ -2,7 +2,7 @@ module QA ...@@ -2,7 +2,7 @@ module QA
module Scenario module Scenario
module Test module Test
module Integration module Integration
class Github < Test::Instance class Github < Test::Instance::All
tags :github tags :github
def perform(address, *rspec_options) def perform(address, *rspec_options)
......
...@@ -2,7 +2,7 @@ module QA ...@@ -2,7 +2,7 @@ module QA
module Scenario module Scenario
module Test module Test
module Integration module Integration
class Kubernetes < Test::Instance class Kubernetes < Test::Instance::All
tags :kubernetes tags :kubernetes
end end
end end
......
...@@ -2,7 +2,7 @@ module QA ...@@ -2,7 +2,7 @@ module QA
module Scenario module Scenario
module Test module Test
module Integration module Integration
class LDAP < Test::Instance class LDAP < Test::Instance::All
tags :ldap tags :ldap
end end
end end
......
...@@ -6,7 +6,7 @@ module QA ...@@ -6,7 +6,7 @@ module QA
# Run test suite against any GitLab instance where mattermost is enabled, # Run test suite against any GitLab instance where mattermost is enabled,
# including staging and on-premises installation. # including staging and on-premises installation.
# #
class Mattermost < Test::Instance class Mattermost < Test::Instance::All
tags :core, :mattermost tags :core, :mattermost
def perform(address, mattermost, *rspec_options) def perform(address, mattermost, *rspec_options)
......
...@@ -230,7 +230,7 @@ describe Projects::CommitController do ...@@ -230,7 +230,7 @@ describe Projects::CommitController do
id: master_pickable_commit.id) id: master_pickable_commit.id)
expect(response).to redirect_to project_commits_path(project, 'master') expect(response).to redirect_to project_commits_path(project, 'master')
expect(flash[:notice]).to eq('The commit has been successfully cherry-picked.') expect(flash[:notice]).to eq('The commit has been successfully cherry-picked into master.')
end end
end end
......
...@@ -2,5 +2,6 @@ FactoryBot.define do ...@@ -2,5 +2,6 @@ FactoryBot.define do
factory :project_group_link do factory :project_group_link do
project project
group group
expires_at nil
end end
end end
...@@ -21,7 +21,7 @@ describe 'Cherry-pick Commits' do ...@@ -21,7 +21,7 @@ describe 'Cherry-pick Commits' do
uncheck 'create_merge_request' uncheck 'create_merge_request'
click_button 'Cherry-pick' click_button 'Cherry-pick'
end end
expect(page).to have_content('The commit has been successfully cherry-picked.') expect(page).to have_content('The commit has been successfully cherry-picked into master.')
end end
end end
...@@ -32,7 +32,7 @@ describe 'Cherry-pick Commits' do ...@@ -32,7 +32,7 @@ describe 'Cherry-pick Commits' do
uncheck 'create_merge_request' uncheck 'create_merge_request'
click_button 'Cherry-pick' click_button 'Cherry-pick'
end end
expect(page).to have_content('The commit has been successfully cherry-picked.') expect(page).to have_content('The commit has been successfully cherry-picked into master.')
end end
end end
...@@ -59,7 +59,7 @@ describe 'Cherry-pick Commits' do ...@@ -59,7 +59,7 @@ describe 'Cherry-pick Commits' do
page.within('#modal-cherry-pick-commit') do page.within('#modal-cherry-pick-commit') do
click_button 'Cherry-pick' click_button 'Cherry-pick'
end end
expect(page).to have_content('The commit has been successfully cherry-picked. You can now submit a merge request to get this change into the original branch.') expect(page).to have_content("The commit has been successfully cherry-picked into cherry-pick-#{master_pickable_commit.short_id}. You can now submit a merge request to get this change into the original branch.")
expect(page).to have_content("From cherry-pick-#{master_pickable_commit.short_id} into master") expect(page).to have_content("From cherry-pick-#{master_pickable_commit.short_id} into master")
end end
end end
...@@ -86,7 +86,7 @@ describe 'Cherry-pick Commits' do ...@@ -86,7 +86,7 @@ describe 'Cherry-pick Commits' do
click_button 'Cherry-pick' click_button 'Cherry-pick'
end end
expect(page).to have_content('The commit has been successfully cherry-picked.') expect(page).to have_content('The commit has been successfully cherry-picked into feature.')
end end
end end
......
...@@ -225,6 +225,12 @@ eos ...@@ -225,6 +225,12 @@ eos
end end
describe 'description' do describe 'description' do
it 'returns no_commit_message when safe_message is blank' do
allow(commit).to receive(:safe_message).and_return(nil)
expect(commit.description).to eq('--no commit message')
end
it 'returns description of commit message if title less than 100 characters' do it 'returns description of commit message if title less than 100 characters' do
message = <<eos message = <<eos
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit.
......
...@@ -343,6 +343,14 @@ describe User do ...@@ -343,6 +343,14 @@ describe User do
expect(users_with_two_factor).to eq([user_with_2fa.id]) expect(users_with_two_factor).to eq([user_with_2fa.id])
expect(users_with_two_factor).not_to include(user_without_2fa.id) expect(users_with_two_factor).not_to include(user_without_2fa.id)
end end
it 'works with ORDER BY' do
user_with_2fa = create(:user, :two_factor_via_otp, :two_factor_via_u2f)
expect(described_class
.with_two_factor
.reorder_by_name).to eq([user_with_2fa])
end
end end
describe ".without_two_factor" do describe ".without_two_factor" do
......
...@@ -313,7 +313,7 @@ describe API::Files do ...@@ -313,7 +313,7 @@ describe API::Files do
describe "POST /projects/:id/repository/files/:file_path" do describe "POST /projects/:id/repository/files/:file_path" do
let!(:file_path) { "new_subfolder%2Fnewfile%2Erb" } let!(:file_path) { "new_subfolder%2Fnewfile%2Erb" }
let(:valid_params) do let(:params) do
{ {
branch: "master", branch: "master",
content: "puts 8", content: "puts 8",
...@@ -322,7 +322,7 @@ describe API::Files do ...@@ -322,7 +322,7 @@ describe API::Files do
end end
it "creates a new file in project repo" do it "creates a new file in project repo" do
post api(route(file_path), user), valid_params post api(route(file_path), user), params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(201)
expect(json_response["file_path"]).to eq(CGI.unescape(file_path)) expect(json_response["file_path"]).to eq(CGI.unescape(file_path))
...@@ -337,20 +337,28 @@ describe API::Files do ...@@ -337,20 +337,28 @@ describe API::Files do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(400)
end end
it 'returns a 400 bad request if the commit message is empty' do
params[:commit_message] = ''
post api(route(file_path), user), params
expect(response).to have_gitlab_http_status(400)
end
it "returns a 400 if editor fails to create file" do it "returns a 400 if editor fails to create file" do
allow_any_instance_of(Repository).to receive(:create_file) allow_any_instance_of(Repository).to receive(:create_file)
.and_raise(Gitlab::Git::CommitError, 'Cannot create file') .and_raise(Gitlab::Git::CommitError, 'Cannot create file')
post api(route("any%2Etxt"), user), valid_params post api(route("any%2Etxt"), user), params
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(400)
end end
context "when specifying an author" do context "when specifying an author" do
it "creates a new file with the specified author" do it "creates a new file with the specified author" do
valid_params.merge!(author_email: author_email, author_name: author_name) params.merge!(author_email: author_email, author_name: author_name)
post api(route("new_file_with_author%2Etxt"), user), valid_params post api(route("new_file_with_author%2Etxt"), user), params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(201)
expect(response.content_type).to eq('application/json') expect(response.content_type).to eq('application/json')
...@@ -364,7 +372,7 @@ describe API::Files do ...@@ -364,7 +372,7 @@ describe API::Files do
let!(:project) { create(:project_empty_repo, namespace: user.namespace ) } let!(:project) { create(:project_empty_repo, namespace: user.namespace ) }
it "creates a new file in project repo" do it "creates a new file in project repo" do
post api(route("newfile%2Erb"), user), valid_params post api(route("newfile%2Erb"), user), params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(201)
expect(json_response['file_path']).to eq('newfile.rb') expect(json_response['file_path']).to eq('newfile.rb')
...@@ -376,7 +384,7 @@ describe API::Files do ...@@ -376,7 +384,7 @@ describe API::Files do
end end
describe "PUT /projects/:id/repository/files" do describe "PUT /projects/:id/repository/files" do
let(:valid_params) do let(:params) do
{ {
branch: 'master', branch: 'master',
content: 'puts 8', content: 'puts 8',
...@@ -385,7 +393,7 @@ describe API::Files do ...@@ -385,7 +393,7 @@ describe API::Files do
end end
it "updates existing file in project repo" do it "updates existing file in project repo" do
put api(route(file_path), user), valid_params put api(route(file_path), user), params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(json_response['file_path']).to eq(CGI.unescape(file_path)) expect(json_response['file_path']).to eq(CGI.unescape(file_path))
...@@ -394,8 +402,16 @@ describe API::Files do ...@@ -394,8 +402,16 @@ describe API::Files do
expect(last_commit.author_name).to eq(user.name) expect(last_commit.author_name).to eq(user.name)
end end
it 'returns a 400 bad request if the commit message is empty' do
params[:commit_message] = ''
put api(route(file_path), user), params
expect(response).to have_gitlab_http_status(400)
end
it "returns a 400 bad request if update existing file with stale last commit id" do it "returns a 400 bad request if update existing file with stale last commit id" do
params_with_stale_id = valid_params.merge(last_commit_id: 'stale') params_with_stale_id = params.merge(last_commit_id: 'stale')
put api(route(file_path), user), params_with_stale_id put api(route(file_path), user), params_with_stale_id
...@@ -406,7 +422,7 @@ describe API::Files do ...@@ -406,7 +422,7 @@ describe API::Files do
it "updates existing file in project repo with accepts correct last commit id" do it "updates existing file in project repo with accepts correct last commit id" do
last_commit = Gitlab::Git::Commit last_commit = Gitlab::Git::Commit
.last_for_path(project.repository, 'master', URI.unescape(file_path)) .last_for_path(project.repository, 'master', URI.unescape(file_path))
params_with_correct_id = valid_params.merge(last_commit_id: last_commit.id) params_with_correct_id = params.merge(last_commit_id: last_commit.id)
put api(route(file_path), user), params_with_correct_id put api(route(file_path), user), params_with_correct_id
...@@ -421,9 +437,9 @@ describe API::Files do ...@@ -421,9 +437,9 @@ describe API::Files do
context "when specifying an author" do context "when specifying an author" do
it "updates a file with the specified author" do it "updates a file with the specified author" do
valid_params.merge!(author_email: author_email, author_name: author_name, content: "New content") params.merge!(author_email: author_email, author_name: author_name, content: "New content")
put api(route(file_path), user), valid_params put api(route(file_path), user), params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
last_commit = project.repository.commit.raw last_commit = project.repository.commit.raw
...@@ -434,7 +450,7 @@ describe API::Files do ...@@ -434,7 +450,7 @@ describe API::Files do
end end
describe "DELETE /projects/:id/repository/files" do describe "DELETE /projects/:id/repository/files" do
let(:valid_params) do let(:params) do
{ {
branch: 'master', branch: 'master',
commit_message: 'Changed file' commit_message: 'Changed file'
...@@ -442,7 +458,7 @@ describe API::Files do ...@@ -442,7 +458,7 @@ describe API::Files do
end end
it "deletes existing file in project repo" do it "deletes existing file in project repo" do
delete api(route(file_path), user), valid_params delete api(route(file_path), user), params
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(204)
end end
...@@ -453,19 +469,27 @@ describe API::Files do ...@@ -453,19 +469,27 @@ describe API::Files do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(400)
end end
it 'returns a 400 bad request if the commit message is empty' do
params[:commit_message] = ''
delete api(route(file_path), user), params
expect(response).to have_gitlab_http_status(400)
end
it "returns a 400 if fails to delete file" do it "returns a 400 if fails to delete file" do
allow_any_instance_of(Repository).to receive(:delete_file).and_raise(Gitlab::Git::CommitError, 'Cannot delete file') allow_any_instance_of(Repository).to receive(:delete_file).and_raise(Gitlab::Git::CommitError, 'Cannot delete file')
delete api(route(file_path), user), valid_params delete api(route(file_path), user), params
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(400)
end end
context "when specifying an author" do context "when specifying an author" do
it "removes a file with the specified author" do it "removes a file with the specified author" do
valid_params.merge!(author_email: author_email, author_name: author_name) params.merge!(author_email: author_email, author_name: author_name)
delete api(route(file_path), user), valid_params delete api(route(file_path), user), params
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(204)
end end
......
...@@ -116,6 +116,14 @@ describe API::ProjectSnippets do ...@@ -116,6 +116,14 @@ describe API::ProjectSnippets do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(400)
end end
it 'returns 400 for empty code field' do
params[:code] = ''
post api("/projects/#{project.id}/snippets/", admin), params
expect(response).to have_gitlab_http_status(400)
end
context 'when the snippet is spam' do context 'when the snippet is spam' do
def create_snippet(project, snippet_params = {}) def create_snippet(project, snippet_params = {})
project.add_developer(user) project.add_developer(user)
...@@ -180,6 +188,14 @@ describe API::ProjectSnippets do ...@@ -180,6 +188,14 @@ describe API::ProjectSnippets do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(400)
end end
it 'returns 400 for empty code field' do
new_content = ''
put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), code: new_content
expect(response).to have_gitlab_http_status(400)
end
context 'when the snippet is spam' do context 'when the snippet is spam' do
def update_snippet(snippet_params = {}) def update_snippet(snippet_params = {})
put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}", admin), snippet_params put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}", admin), snippet_params
......
...@@ -962,6 +962,7 @@ describe API::Projects do ...@@ -962,6 +962,7 @@ describe API::Projects do
expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id) expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id)
expect(json_response['shared_with_groups'][0]['group_name']).to eq(group.name) expect(json_response['shared_with_groups'][0]['group_name']).to eq(group.name)
expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access) expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access)
expect(json_response['shared_with_groups'][0]['expires_at']).to be_nil
expect(json_response['only_allow_merge_if_pipeline_succeeds']).to eq(project.only_allow_merge_if_pipeline_succeeds) expect(json_response['only_allow_merge_if_pipeline_succeeds']).to eq(project.only_allow_merge_if_pipeline_succeeds)
expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to eq(project.only_allow_merge_if_all_discussions_are_resolved) expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to eq(project.only_allow_merge_if_all_discussions_are_resolved)
expect(json_response['merge_method']).to eq(project.merge_method.to_s) expect(json_response['merge_method']).to eq(project.merge_method.to_s)
...@@ -969,6 +970,21 @@ describe API::Projects do ...@@ -969,6 +970,21 @@ describe API::Projects do
expect(json_response).not_to have_key('repository_storage') expect(json_response).not_to have_key('repository_storage')
end end
it 'returns a group link with expiration date' do
group = create(:group)
expires_at = 5.days.from_now.to_date
link = create(:project_group_link, project: project, group: group, expires_at: expires_at)
get api("/projects/#{project.id}", user)
expect(json_response['shared_with_groups']).to be_an Array
expect(json_response['shared_with_groups'].length).to eq(1)
expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id)
expect(json_response['shared_with_groups'][0]['group_name']).to eq(group.name)
expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access)
expect(json_response['shared_with_groups'][0]['expires_at']).to eq(expires_at.to_s)
end
it 'returns a project by path name' do it 'returns a project by path name' do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
......
...@@ -245,9 +245,13 @@ describe GitPushService do ...@@ -245,9 +245,13 @@ describe GitPushService do
end end
end end
context "Sends System Push data" do describe 'system hooks' do
it "when pushing on a branch" do let(:system_hook_service) { double() }
expect(SystemHookPushWorker).to receive(:perform_async).with(push_data, :push_hooks)
it "sends a system hook after pushing a branch" do
expect(SystemHooksService).to receive(:new).and_return(system_hook_service)
expect(system_hook_service).to receive(:execute_hooks).with(push_data, :push_hooks)
execute_service(project, user, oldrev, newrev, ref) execute_service(project, user, oldrev, newrev, ref)
end 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