Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2019-10-10 15:06:07 +00:00
parent 69849c280c
commit d96abbee0b
14 changed files with 99 additions and 103 deletions

View file

@ -317,11 +317,11 @@ module SystemNoteService
end
def zoom_link_added(issue, project, author)
create_note(NoteSummary.new(issue, project, author, _('added a Zoom call to this issue'), action: 'pinned_embed'))
::SystemNotes::ZoomService.new(noteable: issue, project: project, author: author).zoom_link_added
end
def zoom_link_removed(issue, project, author)
create_note(NoteSummary.new(issue, project, author, _('removed a Zoom call from this issue'), action: 'pinned_embed'))
::SystemNotes::ZoomService.new(noteable: issue, project: project, author: author).zoom_link_removed
end
private

View file

@ -0,0 +1,13 @@
# frozen_string_literal: true
module SystemNotes
class ZoomService < ::SystemNotes::BaseService
def zoom_link_added
create_note(NoteSummary.new(noteable, project, author, _('added a Zoom call to this issue'), action: 'pinned_embed'))
end
def zoom_link_removed
create_note(NoteSummary.new(noteable, project, author, _('removed a Zoom call from this issue'), action: 'pinned_embed'))
end
end
end

View file

@ -0,0 +1,5 @@
---
title: 'GitHub import: Handle nil published_at dates'
merge_request: 18355
author:
type: fixed

View file

@ -379,6 +379,8 @@ This functionality is only available:
## Most Recent Pipeline
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/issues/50499) in GitLab 12.3.
There's a link to the latest pipeline for the last commit of a given branch at `/project/pipelines/[branch]/latest`. Also, `/project/pipelines/latest` will redirect you to the latest pipeline for the last commit on the project's default branch.
## Security on protected branches

View file

@ -215,17 +215,6 @@ Example response:
- GitLab Geo
- GitLab-shell's `bin/check`
## Broadcast message(s) [NOT USED]
```
GET /internal/broadcast_message
GET /internal/broadcast_messages
```
**Deprecated:** This used to be used by GitLab-shell to print out broadcast
messages. But this is now included in the `post_receive` call. Other
clients can use the public BroadcastMessages API.
## Get new 2FA recovery codes using an SSH key
This is called from GitLab-shell and allows users to get new 2FA

View file

@ -148,22 +148,6 @@ module API
}
end
get "/broadcast_messages" do
if messages = BroadcastMessage.current
present messages, with: Entities::BroadcastMessage
else
[]
end
end
get "/broadcast_message" do
if message = BroadcastMessage.current&.last
present message, with: Entities::BroadcastMessage
else
{}
end
end
# rubocop: disable CodeReuse/ActiveRecord
post '/two_factor_recovery_codes' do
status 200

View file

@ -37,7 +37,8 @@ module Gitlab
description: description_for(release),
created_at: release.created_at,
updated_at: release.created_at,
released_at: release.published_at,
# Draft releases will have a null published_at
released_at: release.published_at || Time.current,
project_id: project.id
}
end

View file

@ -10,7 +10,8 @@ module Gitlab
name: raw_data.name,
description: raw_data.body,
created_at: raw_data.created_at,
released_at: raw_data.published_at,
# Draft releases will have a null published_at
released_at: raw_data.published_at || Time.current,
updated_at: raw_data.created_at
}
end

View file

@ -255,9 +255,9 @@ EOF
}
function display_deployment_debug() {
# Get all pods that are not ready (this will return completed pods for minio and migrations jobs)
echoinfo "Unready Pods for release ${CI_ENVIRONMENT_SLUG}"
kubectl get pods -n "$KUBE_NAMESPACE" -lrelease=${CI_ENVIRONMENT_SLUG} --field-selector=status.phase!=Running
# Get all pods for this release
echoinfo "Pods for release ${CI_ENVIRONMENT_SLUG}"
kubectl get pods -n "$KUBE_NAMESPACE" -lrelease=${CI_ENVIRONMENT_SLUG}
# Get all non-completed jobs
echoinfo "Unsuccessful Jobs for release ${CI_ENVIRONMENT_SLUG}"

View file

@ -34,6 +34,22 @@ describe Gitlab::GithubImport::Importer::ReleasesImporter do
importer.execute
end
it 'imports draft releases' do
release_double = double(
name: 'Test',
body: 'This is description',
tag_name: '1.0',
description: 'This is my release',
created_at: created_at,
updated_at: created_at,
published_at: nil
)
expect(importer).to receive(:each_release).and_return([release_double])
expect { importer.execute }.to change { Release.count }.by(1)
end
end
describe '#build_releases' do

View file

@ -37,6 +37,14 @@ describe Gitlab::LegacyGithubImport::ReleaseFormatter do
expect(release.attributes).to eq(expected)
end
context 'with a nil published_at date' do
let(:published_at) { nil }
it 'inserts a timestamp for released_at' do
expect(release.attributes[:released_at]).to be_a(Time)
end
end
end
describe '#valid' do

View file

@ -43,61 +43,6 @@ describe API::Internal::Base do
end
end
describe 'GET /internal/broadcast_message' do
context 'broadcast message exists' do
let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now ) }
it 'returns one broadcast message' do
get api('/internal/broadcast_message'), params: { secret_token: secret_token }
expect(response).to have_gitlab_http_status(200)
expect(json_response['message']).to eq(broadcast_message.message)
end
end
context 'broadcast message does not exist' do
it 'returns nothing' do
get api('/internal/broadcast_message'), params: { secret_token: secret_token }
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_empty
end
end
context 'nil broadcast message' do
it 'returns nothing' do
allow(BroadcastMessage).to receive(:current).and_return(nil)
get api('/internal/broadcast_message'), params: { secret_token: secret_token }
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_empty
end
end
end
describe 'GET /internal/broadcast_messages' do
context 'broadcast message(s) exist' do
let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now ) }
it 'returns active broadcast message(s)' do
get api('/internal/broadcast_messages'), params: { secret_token: secret_token }
expect(response).to have_gitlab_http_status(200)
expect(json_response[0]['message']).to eq(broadcast_message.message)
end
end
context 'broadcast message does not exist' do
it 'returns nothing' do
get api('/internal/broadcast_messages'), params: { secret_token: secret_token }
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_empty
end
end
end
describe 'GET /internal/two_factor_recovery_codes' do
it 'returns an error message when the key does not exist' do
post api('/internal/two_factor_recovery_codes'),

View file

@ -271,26 +271,22 @@ describe SystemNoteService do
end
describe '.zoom_link_added' do
subject { described_class.zoom_link_added(issue, project, author) }
it 'calls ZoomService' do
expect_next_instance_of(::SystemNotes::ZoomService) do |service|
expect(service).to receive(:zoom_link_added)
end
it_behaves_like 'a system note' do
let(:action) { 'pinned_embed' }
end
it 'sets the zoom link added note text' do
expect(subject.note).to eq('added a Zoom call to this issue')
described_class.zoom_link_added(noteable, project, author)
end
end
describe '.zoom_link_removed' do
subject { described_class.zoom_link_removed(issue, project, author) }
it 'calls ZoomService' do
expect_next_instance_of(::SystemNotes::ZoomService) do |service|
expect(service).to receive(:zoom_link_removed)
end
it_behaves_like 'a system note' do
let(:action) { 'pinned_embed' }
end
it 'sets the zoom link removed note text' do
expect(subject.note).to eq('removed a Zoom call from this issue')
described_class.zoom_link_removed(noteable, project, author)
end
end

View file

@ -0,0 +1,36 @@
# frozen_string_literal: true
require 'spec_helper'
describe ::SystemNotes::ZoomService do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:author) { create(:user) }
let(:noteable) { create(:issue, project: project) }
let(:service) { described_class.new(noteable: noteable, project: project, author: author) }
describe '#zoom_link_added' do
subject { service.zoom_link_added }
it_behaves_like 'a system note' do
let(:action) { 'pinned_embed' }
end
it 'sets the zoom link added note text' do
expect(subject.note).to eq('added a Zoom call to this issue')
end
end
describe '#zoom_link_removed' do
subject { service.zoom_link_removed }
it_behaves_like 'a system note' do
let(:action) { 'pinned_embed' }
end
it 'sets the zoom link removed note text' do
expect(subject.note).to eq('removed a Zoom call from this issue')
end
end
end