Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-22 09:09:47 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-22 09:09:47 +0300
commitd17c58402b28c7eabe74df21b57ae31beec56b1f (patch)
tree5508b8bc06c882dc2aa567d1bd0df2fd491617c7 /spec
parenta6cfee85e9a1fd544ffe0b985a5a2ecb642e6ab3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/services.rb6
-rw-r--r--spec/features/merge_request/user_creates_merge_request_spec.rb1
-rw-r--r--spec/features/merge_request/user_posts_notes_spec.rb1
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml1
-rw-r--r--spec/migrations/remove_hipchat_service_records_spec.rb23
-rw-r--r--spec/models/project_services/hipchat_service_spec.rb94
-rw-r--r--spec/models/project_spec.rb1
7 files changed, 44 insertions, 83 deletions
diff --git a/spec/factories/services.rb b/spec/factories/services.rb
index 25ef75880bb..51d9898dbe4 100644
--- a/spec/factories/services.rb
+++ b/spec/factories/services.rb
@@ -159,12 +159,6 @@ FactoryBot.define do
password { 'my-secret-password' }
end
- factory :hipchat_service do
- project
- type { 'HipchatService' }
- token { 'test_token' }
- end
-
factory :slack_service do
project
active { true }
diff --git a/spec/features/merge_request/user_creates_merge_request_spec.rb b/spec/features/merge_request/user_creates_merge_request_spec.rb
index 119cf31098c..617aceae54c 100644
--- a/spec/features/merge_request/user_creates_merge_request_spec.rb
+++ b/spec/features/merge_request/user_creates_merge_request_spec.rb
@@ -7,6 +7,7 @@ RSpec.describe "User creates a merge request", :js do
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
+
let(:title) { "Some feature" }
before do
diff --git a/spec/features/merge_request/user_posts_notes_spec.rb b/spec/features/merge_request/user_posts_notes_spec.rb
index a6dfae72912..83d9388914b 100644
--- a/spec/features/merge_request/user_posts_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_notes_spec.rb
@@ -6,6 +6,7 @@ RSpec.describe 'Merge request > User posts notes', :js do
include NoteInteractionHelpers
let_it_be(:project) { create(:project, :repository) }
+
let(:user) { project.creator }
let(:merge_request) do
create(:merge_request, source_project: project, target_project: project)
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index 5d1e3c79474..817c3769b80 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -369,7 +369,6 @@ project:
- packagist_service
- pivotaltracker_service
- prometheus_service
-- hipchat_service
- flowdock_service
- assembla_service
- asana_service
diff --git a/spec/migrations/remove_hipchat_service_records_spec.rb b/spec/migrations/remove_hipchat_service_records_spec.rb
new file mode 100644
index 00000000000..bc76d7933d8
--- /dev/null
+++ b/spec/migrations/remove_hipchat_service_records_spec.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20210420103955_remove_hipchat_service_records.rb')
+
+RSpec.describe RemoveHipchatServiceRecords do
+ let(:services) { table(:services) }
+
+ before do
+ services.create!(type: 'HipchatService')
+ services.create!(type: 'SomeOtherType')
+ end
+
+ it 'removes services records of type HipchatService' do
+ expect(services.count).to eq(2)
+
+ migrate!
+
+ expect(services.count).to eq(1)
+ expect(services.first.type).to eq('SomeOtherType')
+ expect(services.where(type: 'HipchatService')).to be_empty
+ end
+end
diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb
index 82a4cde752b..42368c31ba0 100644
--- a/spec/models/project_services/hipchat_service_spec.rb
+++ b/spec/models/project_services/hipchat_service_spec.rb
@@ -2,91 +2,35 @@
require 'spec_helper'
+# HipchatService is partially removed and it will be remove completely
+# after the deletion of all the database records.
+# https://gitlab.com/gitlab-org/gitlab/-/issues/27954
RSpec.describe HipchatService do
- describe "Associations" do
- it { is_expected.to belong_to :project }
- it { is_expected.to have_one :service_hook }
- end
+ let_it_be(:project) { create(:project) }
- describe 'Validations' do
- context 'when service is active' do
- before do
- subject.active = true
- end
+ subject(:service) { described_class.new(project: project) }
- it { is_expected.to validate_presence_of(:token) }
- end
+ it { is_expected.to be_valid }
- context 'when service is inactive' do
- before do
- subject.active = false
- end
+ describe '#to_param' do
+ subject { service.to_param }
- it { is_expected.not_to validate_presence_of(:token) }
- end
+ it { is_expected.to eq('hipchat') }
end
- describe "Execute" do
- let(:hipchat) { described_class.new }
- let(:user) { create(:user) }
- let(:project) { create(:project, :repository) }
- let(:api_url) { 'https://hipchat.example.com/v2/room/123456/notification?auth_token=verySecret' }
- let(:project_name) { project.full_name.gsub(/\s/, '') }
- let(:token) { 'verySecret' }
- let(:server_url) { 'https://hipchat.example.com'}
- let(:push_sample_data) do
- Gitlab::DataBuilder::Push.build_sample(project, user)
- end
-
- before do
- allow(hipchat).to receive_messages(
- project_id: project.id,
- project: project,
- room: 123456,
- server: server_url,
- token: token
- )
- WebMock.stub_request(:post, api_url)
- end
-
- it 'does nothing' do
- expect { hipchat.execute(push_sample_data) }.not_to raise_error
- end
+ describe '#supported_events' do
+ subject { service.supported_events }
- describe "#message_options" do
- it "is set to the defaults" do
- expect(hipchat.__send__(:message_options)).to eq({ notify: false, color: 'yellow' })
- end
-
- it "sets notify to true" do
- allow(hipchat).to receive(:notify).and_return('1')
-
- expect(hipchat.__send__(:message_options)).to eq({ notify: true, color: 'yellow' })
- end
-
- it "sets the color" do
- allow(hipchat).to receive(:color).and_return('red')
-
- expect(hipchat.__send__(:message_options)).to eq({ notify: false, color: 'red' })
- end
-
- context 'with a successful build' do
- it 'uses the green color' do
- data = { object_kind: 'pipeline',
- object_attributes: { status: 'success' } }
-
- expect(hipchat.__send__(:message_options, data)).to eq({ notify: false, color: 'green' })
- end
- end
+ it { is_expected.to be_empty }
+ end
- context 'with a failed build' do
- it 'uses the red color' do
- data = { object_kind: 'pipeline',
- object_attributes: { status: 'failed' } }
+ describe '#save' do
+ it 'prevents records from being created or updated' do
+ expect(service.save).to be_falsey
- expect(hipchat.__send__(:message_options, data)).to eq({ notify: false, color: 'red' })
- end
- end
+ expect(service.errors.full_messages).to include(
+ 'HipChat endpoint is deprecated and should not be created or modified.'
+ )
end
end
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 12c17e699e3..8c21b227ad3 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -52,7 +52,6 @@ RSpec.describe Project, factory_default: :keep do
it { is_expected.to have_one(:pipelines_email_service) }
it { is_expected.to have_one(:irker_service) }
it { is_expected.to have_one(:pivotaltracker_service) }
- it { is_expected.to have_one(:hipchat_service) }
it { is_expected.to have_one(:flowdock_service) }
it { is_expected.to have_one(:assembla_service) }
it { is_expected.to have_one(:slack_slash_commands_service) }