summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-03 21:07:29 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-03 21:07:29 +0000
commit1da3754b25657f49afdcb0b942506d365b1ee89d (patch)
tree9f4bfa94fdd1762ef99e6a61bf180ac8cd7b5616 /spec
parent25521def84a6987fe9d4265b560e930bfb32c195 (diff)
downloadgitlab-ce-1da3754b25657f49afdcb0b942506d365b1ee89d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/health_controller_spec.rb3
-rw-r--r--spec/controllers/projects/settings/operations_controller_spec.rb15
-rw-r--r--spec/factories/grafana_integrations.rb9
-rw-r--r--spec/features/merge_request/user_sees_merge_widget_spec.rb14
-rw-r--r--spec/frontend/reports/store/utils_spec.js14
-rw-r--r--spec/helpers/projects_helper_spec.rb36
-rw-r--r--spec/javascripts/monitoring/components/dashboard_spec.js4
-rw-r--r--spec/javascripts/monitoring/utils_spec.js53
-rw-r--r--spec/javascripts/reports/components/grouped_test_reports_app_spec.js10
-rw-r--r--spec/lib/backup/repository_spec.rb1
-rw-r--r--spec/lib/gitlab/ci/parsers/test/junit_spec.rb68
-rw-r--r--spec/lib/gitlab/health_checks/gitaly_check_spec.rb4
-rw-r--r--spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb41
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml1
-rw-r--r--spec/lib/gitlab/url_blocker_spec.rb8
-rw-r--r--spec/models/grafana_integration_spec.rb38
-rw-r--r--spec/models/namespace_spec.rb26
-rw-r--r--spec/models/project_spec.rb41
-rw-r--r--spec/services/groups/destroy_service_spec.rb2
-rw-r--r--spec/services/projects/operations/update_service_spec.rb56
-rw-r--r--spec/workers/repository_check/dispatch_worker_spec.rb4
21 files changed, 299 insertions, 149 deletions
diff --git a/spec/controllers/health_controller_spec.rb b/spec/controllers/health_controller_spec.rb
index ae05573af2e..dd6aac4b126 100644
--- a/spec/controllers/health_controller_spec.rb
+++ b/spec/controllers/health_controller_spec.rb
@@ -32,7 +32,8 @@ describe HealthController do
end
it 'responds with readiness checks data when a failure happens' do
- allow(Gitlab::HealthChecks::Redis::RedisCheck).to receive(:readiness).and_return(Gitlab::HealthChecks::Result.new(false, "check error"))
+ allow(Gitlab::HealthChecks::Redis::RedisCheck).to receive(:readiness).and_return(
+ Gitlab::HealthChecks::Result.new('redis_check', false, "check error"))
subject
diff --git a/spec/controllers/projects/settings/operations_controller_spec.rb b/spec/controllers/projects/settings/operations_controller_spec.rb
index 3a56511a8d6..0b34656e9e2 100644
--- a/spec/controllers/projects/settings/operations_controller_spec.rb
+++ b/spec/controllers/projects/settings/operations_controller_spec.rb
@@ -180,6 +180,21 @@ describe Projects::Settings::OperationsController do
end
end
+ context 'grafana integration' do
+ describe 'PATCH #update' do
+ let(:params) do
+ {
+ grafana_integration_attributes: {
+ grafana_url: 'https://grafana.gitlab.com',
+ token: 'eyJrIjoicDRlRTREdjhhOEZ5WjZPWXUzazJOSW0zZHJUejVOd3IiLCJuIjoiVGVzdCBLZXkiLCJpZCI6MX0='
+ }
+ }
+ end
+
+ it_behaves_like 'PATCHable'
+ end
+ end
+
private
def project_params(project, params = {})
diff --git a/spec/factories/grafana_integrations.rb b/spec/factories/grafana_integrations.rb
new file mode 100644
index 00000000000..c19417f5a90
--- /dev/null
+++ b/spec/factories/grafana_integrations.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :grafana_integration, class: GrafanaIntegration do
+ project
+ grafana_url { 'https://grafana.com' }
+ token { SecureRandom.hex(10) }
+ end
+end
diff --git a/spec/features/merge_request/user_sees_merge_widget_spec.rb b/spec/features/merge_request/user_sees_merge_widget_spec.rb
index d19835741e3..6b6226ad1c5 100644
--- a/spec/features/merge_request/user_sees_merge_widget_spec.rb
+++ b/spec/features/merge_request/user_sees_merge_widget_spec.rb
@@ -536,10 +536,10 @@ describe 'Merge request > User sees merge widget', :js do
within(".js-reports-container") do
click_button 'Expand'
- expect(page).to have_content('Test summary contained 1 failed test result out of 2 total tests')
+ expect(page).to have_content('Test summary contained 1 failed/error test result out of 2 total tests')
within(".js-report-section-container") do
expect(page).to have_content('rspec found no changed test results out of 1 total test')
- expect(page).to have_content('junit found 1 failed test result out of 1 total test')
+ expect(page).to have_content('junit found 1 failed/error test result out of 1 total test')
expect(page).to have_content('New')
expect(page).to have_content('addTest')
end
@@ -581,9 +581,9 @@ describe 'Merge request > User sees merge widget', :js do
within(".js-reports-container") do
click_button 'Expand'
- expect(page).to have_content('Test summary contained 1 failed test result out of 2 total tests')
+ expect(page).to have_content('Test summary contained 1 failed/error test result out of 2 total tests')
within(".js-report-section-container") do
- expect(page).to have_content('rspec found 1 failed test result out of 1 total test')
+ expect(page).to have_content('rspec found 1 failed/error test result out of 1 total test')
expect(page).to have_content('junit found no changed test results out of 1 total test')
expect(page).not_to have_content('New')
expect(page).to have_content('Test#sum when a is 1 and b is 3 returns summary')
@@ -677,10 +677,10 @@ describe 'Merge request > User sees merge widget', :js do
within(".js-reports-container") do
click_button 'Expand'
- expect(page).to have_content('Test summary contained 20 failed test results out of 20 total tests')
+ expect(page).to have_content('Test summary contained 20 failed/error test results out of 20 total tests')
within(".js-report-section-container") do
- expect(page).to have_content('rspec found 10 failed test results out of 10 total tests')
- expect(page).to have_content('junit found 10 failed test results out of 10 total tests')
+ expect(page).to have_content('rspec found 10 failed/error test results out of 10 total tests')
+ expect(page).to have_content('junit found 10 failed/error test results out of 10 total tests')
expect(page).to have_content('Test#sum when a is 1 and b is 3 returns summary', count: 2)
end
diff --git a/spec/frontend/reports/store/utils_spec.js b/spec/frontend/reports/store/utils_spec.js
index 1679d120db2..f0141b9e162 100644
--- a/spec/frontend/reports/store/utils_spec.js
+++ b/spec/frontend/reports/store/utils_spec.js
@@ -30,7 +30,9 @@ describe('Reports store utils', () => {
const data = { failed: 3, total: 10 };
const result = utils.summaryTextBuilder(name, data);
- expect(result).toBe('Test summary contained 3 failed test results out of 10 total tests');
+ expect(result).toBe(
+ 'Test summary contained 3 failed/error test results out of 10 total tests',
+ );
});
it('should render text for multiple fixed results', () => {
@@ -47,7 +49,7 @@ describe('Reports store utils', () => {
const result = utils.summaryTextBuilder(name, data);
expect(result).toBe(
- 'Test summary contained 3 failed test results and 4 fixed test results out of 10 total tests',
+ 'Test summary contained 3 failed/error test results and 4 fixed test results out of 10 total tests',
);
});
@@ -57,7 +59,7 @@ describe('Reports store utils', () => {
const result = utils.summaryTextBuilder(name, data);
expect(result).toBe(
- 'Test summary contained 1 failed test result and 1 fixed test result out of 10 total tests',
+ 'Test summary contained 1 failed/error test result and 1 fixed test result out of 10 total tests',
);
});
});
@@ -84,7 +86,7 @@ describe('Reports store utils', () => {
const data = { failed: 3, total: 10 };
const result = utils.reportTextBuilder(name, data);
- expect(result).toBe('Rspec found 3 failed test results out of 10 total tests');
+ expect(result).toBe('Rspec found 3 failed/error test results out of 10 total tests');
});
it('should render text for multiple fixed results', () => {
@@ -101,7 +103,7 @@ describe('Reports store utils', () => {
const result = utils.reportTextBuilder(name, data);
expect(result).toBe(
- 'Rspec found 3 failed test results and 4 fixed test results out of 10 total tests',
+ 'Rspec found 3 failed/error test results and 4 fixed test results out of 10 total tests',
);
});
@@ -111,7 +113,7 @@ describe('Reports store utils', () => {
const result = utils.reportTextBuilder(name, data);
expect(result).toBe(
- 'Rspec found 1 failed test result and 1 fixed test result out of 10 total tests',
+ 'Rspec found 1 failed/error test result and 1 fixed test result out of 10 total tests',
);
});
});
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index d2a4ce6540d..1fa3c639603 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -902,4 +902,40 @@ describe ProjectsHelper do
end
end
end
+
+ describe '#grafana_integration_url' do
+ let(:project) { create(:project) }
+
+ before do
+ helper.instance_variable_set(:@project, project)
+ end
+
+ subject { helper.grafana_integration_url }
+
+ it { is_expected.to eq(nil) }
+
+ context 'grafana integration exists' do
+ let!(:grafana_integration) { create(:grafana_integration, project: project) }
+
+ it { is_expected.to eq(grafana_integration.grafana_url) }
+ end
+ end
+
+ describe '#grafana_integration_token' do
+ let(:project) { create(:project) }
+
+ before do
+ helper.instance_variable_set(:@project, project)
+ end
+
+ subject { helper.grafana_integration_token }
+
+ it { is_expected.to eq(nil) }
+
+ context 'grafana integration exists' do
+ let!(:grafana_integration) { create(:grafana_integration, project: project) }
+
+ it { is_expected.to eq(grafana_integration.token) }
+ end
+ end
end
diff --git a/spec/javascripts/monitoring/components/dashboard_spec.js b/spec/javascripts/monitoring/components/dashboard_spec.js
index 87aa4ba500d..ab3ab477708 100644
--- a/spec/javascripts/monitoring/components/dashboard_spec.js
+++ b/spec/javascripts/monitoring/components/dashboard_spec.js
@@ -333,8 +333,8 @@ describe('Dashboard', () => {
});
it('shows a specific time window selected from the url params', done => {
- const start = 1564439536;
- const end = 1564441336;
+ const start = '2019-10-01T18:27:47.000Z';
+ const end = '2019-10-01T18:57:47.000Z';
spyOnDependency(Dashboard, 'getTimeDiff').and.returnValue({
start,
end,
diff --git a/spec/javascripts/monitoring/utils_spec.js b/spec/javascripts/monitoring/utils_spec.js
index e22e8cdc03d..7030156931f 100644
--- a/spec/javascripts/monitoring/utils_spec.js
+++ b/spec/javascripts/monitoring/utils_spec.js
@@ -1,5 +1,5 @@
-import { getTimeDiff, graphDataValidatorForValues } from '~/monitoring/utils';
-import { timeWindows } from '~/monitoring/constants';
+import { getTimeDiff, getTimeWindow, graphDataValidatorForValues } from '~/monitoring/utils';
+import { timeWindows, timeWindowsKeyNames } from '~/monitoring/constants';
import { graphDataPrometheusQuery, graphDataPrometheusQueryRange } from './mock_data';
describe('getTimeDiff', () => {
@@ -39,6 +39,55 @@ describe('getTimeDiff', () => {
});
});
+describe('getTimeWindow', () => {
+ [
+ {
+ args: [
+ {
+ start: '2019-10-01T18:27:47.000Z',
+ end: '2019-10-01T21:27:47.000Z',
+ },
+ ],
+ expected: timeWindowsKeyNames.threeHours,
+ },
+ {
+ args: [
+ {
+ start: '2019-10-01T28:27:47.000Z',
+ end: '2019-10-01T21:27:47.000Z',
+ },
+ ],
+ expected: timeWindowsKeyNames.eightHours,
+ },
+ {
+ args: [
+ {
+ start: '',
+ end: '',
+ },
+ ],
+ expected: timeWindowsKeyNames.eightHours,
+ },
+ {
+ args: [
+ {
+ start: null,
+ end: null,
+ },
+ ],
+ expected: timeWindowsKeyNames.eightHours,
+ },
+ {
+ args: [{}],
+ expected: timeWindowsKeyNames.eightHours,
+ },
+ ].forEach(({ args, expected }) => {
+ it(`returns "${expected}" with args=${JSON.stringify(args)}`, () => {
+ expect(getTimeWindow(...args)).toEqual(expected);
+ });
+ });
+});
+
describe('graphDataValidatorForValues', () => {
/*
* When dealing with a metric using the query format, e.g.
diff --git a/spec/javascripts/reports/components/grouped_test_reports_app_spec.js b/spec/javascripts/reports/components/grouped_test_reports_app_spec.js
index 1f1e626ed33..1b006cdbd4e 100644
--- a/spec/javascripts/reports/components/grouped_test_reports_app_spec.js
+++ b/spec/javascripts/reports/components/grouped_test_reports_app_spec.js
@@ -83,11 +83,11 @@ describe('Grouped Test Reports App', () => {
setTimeout(() => {
expect(vm.$el.querySelector('.gl-spinner')).toBeNull();
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
- 'Test summary contained 2 failed test results out of 11 total tests',
+ 'Test summary contained 2 failed/error test results out of 11 total tests',
);
expect(vm.$el.textContent).toContain(
- 'rspec:pg found 2 failed test results out of 8 total tests',
+ 'rspec:pg found 2 failed/error test results out of 8 total tests',
);
expect(vm.$el.textContent).toContain('New');
@@ -111,16 +111,16 @@ describe('Grouped Test Reports App', () => {
setTimeout(() => {
expect(vm.$el.querySelector('.gl-spinner')).toBeNull();
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
- 'Test summary contained 2 failed test results and 2 fixed test results out of 11 total tests',
+ 'Test summary contained 2 failed/error test results and 2 fixed test results out of 11 total tests',
);
expect(vm.$el.textContent).toContain(
- 'rspec:pg found 1 failed test result and 2 fixed test results out of 8 total tests',
+ 'rspec:pg found 1 failed/error test result and 2 fixed test results out of 8 total tests',
);
expect(vm.$el.textContent).toContain('New');
expect(vm.$el.textContent).toContain(
- ' java ant found 1 failed test result out of 3 total tests',
+ ' java ant found 1 failed/error test result out of 3 total tests',
);
done();
}, 0);
diff --git a/spec/lib/backup/repository_spec.rb b/spec/lib/backup/repository_spec.rb
index e1d46c25338..582effcc303 100644
--- a/spec/lib/backup/repository_spec.rb
+++ b/spec/lib/backup/repository_spec.rb
@@ -10,7 +10,6 @@ describe Backup::Repository do
before do
allow(progress).to receive(:puts)
allow(progress).to receive(:print)
- allow(FileUtils).to receive(:mkdir_p).and_return(true)
allow(FileUtils).to receive(:mv).and_return(true)
allow_any_instance_of(described_class).to receive(:progress).and_return(progress)
diff --git a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb
index 8ff60710f67..6a7fe7a5927 100644
--- a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb
+++ b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb
@@ -38,12 +38,14 @@ describe Gitlab::Ci::Parsers::Test::Junit do
end
end
- context 'when there is only one <testcase> in <testsuite>' do
+ context 'when there is only one <testsuite> in <testsuites>' do
let(:junit) do
<<-EOF.strip_heredoc
- <testsuite>
- <testcase classname='Calculator' name='sumTest1' time='0.01'></testcase>
- </testsuite>
+ <testsuites>
+ <testsuite>
+ <testcase classname='Calculator' name='sumTest1' time='0.01'></testcase>
+ </testsuite>
+ </testsuites>
EOF
end
@@ -56,23 +58,65 @@ describe Gitlab::Ci::Parsers::Test::Junit do
end
end
- context 'when there is only one <testsuite> in <testsuites>' do
+ context 'when there is <testcase>' do
let(:junit) do
<<-EOF.strip_heredoc
- <testsuites>
<testsuite>
- <testcase classname='Calculator' name='sumTest1' time='0.01'></testcase>
+ <testcase classname='Calculator' name='sumTest1' time='0.01'>
+ #{testcase_content}
+ </testcase>
</testsuite>
- </testsuites>
EOF
end
- it 'parses XML and adds a test case to a suite' do
+ let(:test_case) { test_cases[0] }
+
+ before do
expect { subject }.not_to raise_error
+ end
- expect(test_cases[0].classname).to eq('Calculator')
- expect(test_cases[0].name).to eq('sumTest1')
- expect(test_cases[0].execution_time).to eq(0.01)
+ shared_examples_for '<testcase> XML parser' do |status, output|
+ it 'parses XML and adds a test case to the suite' do
+ aggregate_failures do
+ expect(test_case.classname).to eq('Calculator')
+ expect(test_case.name).to eq('sumTest1')
+ expect(test_case.execution_time).to eq(0.01)
+ expect(test_case.status).to eq(status)
+ expect(test_case.system_output).to eq(output)
+ end
+ end
+ end
+
+ context 'and has failure' do
+ let(:testcase_content) { '<failure>Some failure</failure>' }
+
+ it_behaves_like '<testcase> XML parser',
+ ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED,
+ 'Some failure'
+ end
+
+ context 'and has error' do
+ let(:testcase_content) { '<error>Some error</error>' }
+
+ it_behaves_like '<testcase> XML parser',
+ ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED,
+ 'Some error'
+ end
+
+ context 'and has an unknown type' do
+ let(:testcase_content) { '<foo>Some foo</foo>' }
+
+ it_behaves_like '<testcase> XML parser',
+ ::Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS,
+ nil
+ end
+
+ context 'and has no content' do
+ let(:testcase_content) { '' }
+
+ it_behaves_like '<testcase> XML parser',
+ ::Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS,
+ nil
end
end
diff --git a/spec/lib/gitlab/health_checks/gitaly_check_spec.rb b/spec/lib/gitlab/health_checks/gitaly_check_spec.rb
index 4912cd48761..99d10312c15 100644
--- a/spec/lib/gitlab/health_checks/gitaly_check_spec.rb
+++ b/spec/lib/gitlab/health_checks/gitaly_check_spec.rb
@@ -18,13 +18,13 @@ describe Gitlab::HealthChecks::GitalyCheck do
context 'Gitaly server is up' do
let(:gitaly_check) { double(check: { success: true }) }
- it { is_expected.to eq([result_class.new(true, nil, shard: 'default')]) }
+ it { is_expected.to eq([result_class.new('gitaly_check', true, nil, shard: 'default')]) }
end
context 'Gitaly server is down' do
let(:gitaly_check) { double(check: { success: false, message: 'Connection refused' }) }
- it { is_expected.to eq([result_class.new(false, 'Connection refused', shard: 'default')]) }
+ it { is_expected.to eq([result_class.new('gitaly_check', false, 'Connection refused', shard: 'default')]) }
end
end
diff --git a/spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb b/spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb
deleted file mode 100644
index ed757ed60d8..00000000000
--- a/spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-describe Gitlab::HealthChecks::PrometheusTextFormat do
- let(:metric_class) { Gitlab::HealthChecks::Metric }
- subject { described_class.new }
-
- describe '#marshal' do
- let(:sample_metrics) do
- [metric_class.new('metric1', 1),
- metric_class.new('metric2', 2)]
- end
-
- it 'marshal to text with non repeating type definition' do
- expected = <<-EXPECTED.strip_heredoc
- # TYPE metric1 gauge
- metric1 1
- # TYPE metric2 gauge
- metric2 2
- EXPECTED
-
- expect(subject.marshal(sample_metrics)).to eq(expected)
- end
-
- context 'metrics where name repeats' do
- let(:sample_metrics) do
- [metric_class.new('metric1', 1),
- metric_class.new('metric1', 2),
- metric_class.new('metric2', 3)]
- end
-
- it 'marshal to text with non repeating type definition' do
- expected = <<-EXPECTED.strip_heredoc
- # TYPE metric1 gauge
- metric1 1
- metric1 2
- # TYPE metric2 gauge
- metric2 3
- EXPECTED
- expect(subject.marshal(sample_metrics)).to eq(expected)
- end
- end
- end
-end
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index 16d5da59f1b..36cac12e6bd 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -411,6 +411,7 @@ project:
- external_pull_requests
- pages_metadatum
- alerts_service
+- grafana_integration
award_emoji:
- awardable
- user
diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb
index 0e66e959b24..a68ba489986 100644
--- a/spec/lib/gitlab/url_blocker_spec.rb
+++ b/spec/lib/gitlab/url_blocker_spec.rb
@@ -62,6 +62,14 @@ describe Gitlab::UrlBlocker do
expect { subject }.to raise_error(described_class::BlockedUrlError)
end
end
+
+ context 'when domain is too long' do
+ let(:import_url) { 'https://example' + 'a' * 1024 + '.com' }
+
+ it 'raises an error' do
+ expect { subject }.to raise_error(described_class::BlockedUrlError)
+ end
+ end
end
context 'when the URL hostname is an IP address' do
diff --git a/spec/models/grafana_integration_spec.rb b/spec/models/grafana_integration_spec.rb
new file mode 100644
index 00000000000..f8973097a40
--- /dev/null
+++ b/spec/models/grafana_integration_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe GrafanaIntegration do
+ describe 'associations' do
+ it { is_expected.to belong_to(:project) }
+ end
+
+ describe 'validations' do
+ it { is_expected.to validate_presence_of(:project) }
+ it { is_expected.to validate_presence_of(:token) }
+
+ it 'disallows invalid urls for grafana_url' do
+ unsafe_url = %{https://replaceme.com/'><script>alert(document.cookie)</script>}
+ non_ascii_url = 'http://gitlab.com/api/0/projects/project1/something€'
+ blank_url = ''
+ excessively_long_url = 'https://grafan' + 'a' * 1024 + '.com'
+
+ is_expected.not_to allow_values(
+ unsafe_url,
+ non_ascii_url,
+ blank_url,
+ excessively_long_url
+ ).for(:grafana_url)
+ end
+
+ it 'allows valid urls for grafana_url' do
+ external_url = 'http://grafana.com/'
+ internal_url = 'http://192.168.1.1'
+
+ is_expected.to allow_value(
+ external_url,
+ internal_url
+ ).for(:grafana_url)
+ end
+ end
+end
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index a4d60467071..797be0d1fe2 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -896,32 +896,6 @@ describe Namespace do
end
end
end
-
- context 'when :emails_disabled feature flag is off' do
- before do
- stub_feature_flags(emails_disabled: false)
- end
-
- context 'when not a subgroup' do
- it 'returns false' do
- group = create(:group, emails_disabled: true)
-
- expect(group.emails_disabled?).to be_falsey
- end
- end
-
- context 'when a subgroup and ancestor emails are disabled' do
- let(:grandparent) { create(:group) }
- let(:parent) { create(:group, parent: grandparent) }
- let(:group) { create(:group, parent: parent) }
-
- it 'returns false' do
- grandparent.update_attribute(:emails_disabled, true)
-
- expect(group.emails_disabled?).to be_falsey
- end
- end
- end
end
describe '#pages_virtual_domain' do
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 45812a83c68..c6d1a17c6cb 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -2387,29 +2387,6 @@ describe Project do
expect(project.emails_disabled?).to be_truthy
end
end
-
- context 'when :emails_disabled feature flag is off' do
- before do
- stub_feature_flags(emails_disabled: false)
- end
-
- context 'emails disabled in group' do
- it 'returns false' do
- allow(project.namespace).to receive(:emails_disabled?) { true }
-
- expect(project.emails_disabled?).to be_falsey
- end
- end
-
- context 'emails enabled in group' do
- it 'returns false' do
- allow(project.namespace).to receive(:emails_disabled?) { false }
- project.update_attribute(:emails_disabled, true)
-
- expect(project.emails_disabled?).to be_falsey
- end
- end
- end
end
describe '#lfs_enabled?' do
@@ -3671,14 +3648,6 @@ describe Project do
end
end
- describe '#ensure_storage_path_exists' do
- it 'delegates to gitlab_shell to ensure namespace is created' do
- expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage, project.base_dir)
-
- project.ensure_storage_path_exists
- end
- end
-
describe '#legacy_storage?' do
it 'returns true when storage_version is nil' do
project = build(:project, storage_version: nil)
@@ -3793,16 +3762,6 @@ describe Project do
end
end
- describe '#ensure_storage_path_exists' do
- it 'delegates to gitlab_shell to ensure namespace is created' do
- allow(project).to receive(:gitlab_shell).and_return(gitlab_shell)
-
- expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage, hashed_prefix)
-
- project.ensure_storage_path_exists
- end
- end
-
describe '#pages_path' do
it 'returns a path where pages are stored' do
expect(project.pages_path).to eq(File.join(Settings.pages.path, project.namespace.full_path, project.path))
diff --git a/spec/services/groups/destroy_service_spec.rb b/spec/services/groups/destroy_service_spec.rb
index 1ab2e994b7e..b50a2db8bbe 100644
--- a/spec/services/groups/destroy_service_spec.rb
+++ b/spec/services/groups/destroy_service_spec.rb
@@ -8,7 +8,7 @@ describe Groups::DestroyService do
let!(:user) { create(:user) }
let!(:group) { create(:group) }
let!(:nested_group) { create(:group, parent: group) }
- let!(:project) { create(:project, :legacy_storage, namespace: group) }
+ let!(:project) { create(:project, :repository, :legacy_storage, namespace: group) }
let!(:notification_setting) { create(:notification_setting, source: group)}
let(:gitlab_shell) { Gitlab::Shell.new }
let(:remove_path) { group.path + "+#{group.id}+deleted" }
diff --git a/spec/services/projects/operations/update_service_spec.rb b/spec/services/projects/operations/update_service_spec.rb
index 7e765659b9d..b2f9fd6df79 100644
--- a/spec/services/projects/operations/update_service_spec.rb
+++ b/spec/services/projects/operations/update_service_spec.rb
@@ -170,5 +170,61 @@ describe Projects::Operations::UpdateService do
expect(project.reload.name).to eq(original_name)
end
end
+
+ context 'grafana integration' do
+ let(:params) do
+ {
+ grafana_integration_attributes: {
+ grafana_url: 'http://new.grafana.com',
+ token: 'VerySecureToken='
+ }
+ }
+ end
+
+ context 'without existing grafana integration' do
+ it 'creates an integration' do
+ expect(result[:status]).to eq(:success)
+
+ expected_attrs = params[:grafana_integration_attributes]
+ integration = project.reload.grafana_integration
+
+ expect(integration.grafana_url).to eq(expected_attrs[:grafana_url])
+ expect(integration.token).to eq(expected_attrs[:token])
+ end
+ end
+
+ context 'with an existing grafana integration' do
+ before do
+ create(:grafana_integration, project: project)
+ end
+
+ it 'updates the settings' do
+ expect(result[:status]).to eq(:success)
+
+ expected_attrs = params[:grafana_integration_attributes]
+ integration = project.reload.grafana_integration
+
+ expect(integration.grafana_url).to eq(expected_attrs[:grafana_url])
+ expect(integration.token).to eq(expected_attrs[:token])
+ end
+
+ context 'with all grafana attributes blank in params' do
+ let(:params) do
+ {
+ grafana_integration_attributes: {
+ grafana_url: '',
+ token: ''
+ }
+ }
+ end
+
+ it 'destroys the metrics_setting entry in DB' do
+ expect(result[:status]).to eq(:success)
+
+ expect(project.reload.grafana_integration).to be_nil
+ end
+ end
+ end
+ end
end
end
diff --git a/spec/workers/repository_check/dispatch_worker_spec.rb b/spec/workers/repository_check/dispatch_worker_spec.rb
index 03efb6a0a80..e4bb0bf4046 100644
--- a/spec/workers/repository_check/dispatch_worker_spec.rb
+++ b/spec/workers/repository_check/dispatch_worker_spec.rb
@@ -30,8 +30,8 @@ describe RepositoryCheck::DispatchWorker do
context 'with unhealthy shard' do
let(:default_shard_name) { 'default' }
let(:unhealthy_shard_name) { 'unhealthy' }
- let(:default_shard) { Gitlab::HealthChecks::Result.new(true, nil, shard: default_shard_name) }
- let(:unhealthy_shard) { Gitlab::HealthChecks::Result.new(false, '14:Connect Failed', shard: unhealthy_shard_name) }
+ let(:default_shard) { Gitlab::HealthChecks::Result.new('gitaly_check', true, nil, shard: default_shard_name) }
+ let(:unhealthy_shard) { Gitlab::HealthChecks::Result.new('gitaly_check', false, '14:Connect Failed', shard: unhealthy_shard_name) }
before do
allow(Gitlab::HealthChecks::GitalyCheck).to receive(:readiness).and_return([default_shard, unhealthy_shard])