diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-10 15:06:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-10 15:06:07 +0000 |
commit | d96abbee0b394ac40eb67253214fb9c41a31bd41 (patch) | |
tree | 4887c6f08cc902c79e2a31d21a85ce7909cf88bc /spec | |
parent | 69849c280c5525d132ebaddb1200c390a42ecc06 (diff) | |
download | gitlab-ce-d96abbee0b394ac40eb67253214fb9c41a31bd41.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
5 files changed, 70 insertions, 69 deletions
diff --git a/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb b/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb index a1585fd2eb3..6a31c57a73d 100644 --- a/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb @@ -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 diff --git a/spec/lib/gitlab/legacy_github_import/release_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/release_formatter_spec.rb index 2cf4b367c0b..554be57fbec 100644 --- a/spec/lib/gitlab/legacy_github_import/release_formatter_spec.rb +++ b/spec/lib/gitlab/legacy_github_import/release_formatter_spec.rb @@ -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 diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb index 7161d6f0a10..01a2e33c0d9 100644 --- a/spec/requests/api/internal/base_spec.rb +++ b/spec/requests/api/internal/base_spec.rb @@ -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'), diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index efc259babdc..83101add724 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -271,26 +271,22 @@ describe SystemNoteService do end describe '.zoom_link_added' do - subject { described_class.zoom_link_added(issue, project, author) } - - it_behaves_like 'a system note' do - let(:action) { 'pinned_embed' } - end + it 'calls ZoomService' do + expect_next_instance_of(::SystemNotes::ZoomService) do |service| + expect(service).to receive(:zoom_link_added) + 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_behaves_like 'a system note' do - let(:action) { 'pinned_embed' } - end + it 'calls ZoomService' do + expect_next_instance_of(::SystemNotes::ZoomService) do |service| + expect(service).to receive(:zoom_link_removed) + 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 diff --git a/spec/services/system_notes/zoom_service_spec.rb b/spec/services/system_notes/zoom_service_spec.rb new file mode 100644 index 00000000000..435cdb5748e --- /dev/null +++ b/spec/services/system_notes/zoom_service_spec.rb @@ -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 |