Skip to content
Snippets Groups Projects
Commit 88a08249 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 7d19df2d
No related branches found
No related tags found
No related merge requests found
Showing
with 496 additions and 131 deletions
Loading
Loading
@@ -58,32 +58,4 @@ describe ClustersHelper do
it { is_expected.to eq('Create new cluster') }
end
end
describe '#render_new_provider_form' do
subject { helper.new_cluster_partial(provider: provider) }
context 'GCP provider' do
let(:provider) { 'gcp' }
it { is_expected.to eq('clusters/clusters/gcp/new') }
end
context 'AWS provider' do
let(:provider) { 'aws' }
it { is_expected.to eq('clusters/clusters/aws/new') }
end
context 'other provider' do
let(:provider) { 'other' }
it { is_expected.to eq('clusters/clusters/cloud_providers/cloud_provider_selector') }
end
context 'no provider' do
let(:provider) { nil }
it { is_expected.to eq('clusters/clusters/cloud_providers/cloud_provider_selector') }
end
end
end
Loading
Loading
@@ -6,7 +6,6 @@ import axios from '~/lib/utils/axios_utils';
import jobApp from '~/jobs/components/job_app.vue';
import createStore from '~/jobs/store';
import * as types from '~/jobs/store/mutation_types';
import { resetStore } from '../store/helpers';
import job from '../mock_data';
 
describe('Job App ', () => {
Loading
Loading
@@ -16,24 +15,29 @@ describe('Job App ', () => {
let vm;
let mock;
 
const props = {
const initSettings = {
endpoint: `${gl.TEST_HOST}jobs/123.json`,
pagePath: `${gl.TEST_HOST}jobs/123`,
logState:
'eyJvZmZzZXQiOjE3NDUxLCJuX29wZW5fdGFncyI6MCwiZmdfY29sb3IiOm51bGwsImJnX2NvbG9yIjpudWxsLCJzdHlsZV9tYXNrIjowfQ%3D%3D',
};
const props = {
runnerHelpUrl: 'help/runner',
deploymentHelpUrl: 'help/deployment',
runnerSettingsUrl: 'settings/ci-cd/runners',
variablesSettingsUrl: 'settings/ci-cd/variables',
terminalPath: 'jobs/123/terminal',
pagePath: `${gl.TEST_HOST}jobs/123`,
projectPath: 'user-name/project-name',
subscriptionsMoreMinutesUrl: 'https://customers.gitlab.com/buy_pipeline_minutes',
logState:
'eyJvZmZzZXQiOjE3NDUxLCJuX29wZW5fdGFncyI6MCwiZmdfY29sb3IiOm51bGwsImJnX2NvbG9yIjpudWxsLCJzdHlsZV9tYXNrIjowfQ%3D%3D',
};
 
const waitForJobReceived = () => waitForMutation(store, types.RECEIVE_JOB_SUCCESS);
const setupAndMount = ({ jobData = {}, traceData = {} } = {}) => {
mock.onGet(props.endpoint).replyOnce(200, { ...job, ...jobData });
mock.onGet(`${props.pagePath}/trace.json`).reply(200, traceData);
mock.onGet(initSettings.endpoint).replyOnce(200, { ...job, ...jobData });
mock.onGet(`${initSettings.pagePath}/trace.json`).reply(200, traceData);
store.dispatch('init', initSettings);
 
vm = mountComponentWithStore(Component, { props, store });
 
Loading
Loading
@@ -46,7 +50,6 @@ describe('Job App ', () => {
});
 
afterEach(() => {
resetStore(store);
vm.$destroy();
mock.restore();
});
Loading
Loading
@@ -384,7 +387,6 @@ describe('Job App ', () => {
})
.then(done)
.catch(done.fail);
done();
});
 
it('displays remaining time for a delayed job', done => {
Loading
Loading
Loading
Loading
@@ -15,6 +15,7 @@ import {
scrollBottom,
requestTrace,
fetchTrace,
startPollingTrace,
stopPollingTrace,
receiveTraceSuccess,
receiveTraceError,
Loading
Loading
@@ -241,6 +242,50 @@ describe('Job State actions', () => {
done,
);
});
describe('when job is incomplete', () => {
let tracePayload;
beforeEach(() => {
tracePayload = {
html: 'I, [2018-08-17T22:57:45.707325 #1841] INFO -- :',
complete: false,
};
mock.onGet(`${TEST_HOST}/endpoint/trace.json`).replyOnce(200, tracePayload);
});
it('dispatches startPollingTrace', done => {
testAction(
fetchTrace,
null,
mockedState,
[],
[
{ type: 'toggleScrollisInBottom', payload: true },
{ type: 'receiveTraceSuccess', payload: tracePayload },
{ type: 'startPollingTrace' },
],
done,
);
});
it('does not dispatch startPollingTrace when timeout is non-empty', done => {
mockedState.traceTimeout = 1;
testAction(
fetchTrace,
null,
mockedState,
[],
[
{ type: 'toggleScrollisInBottom', payload: true },
{ type: 'receiveTraceSuccess', payload: tracePayload },
],
done,
);
});
});
});
 
describe('error', () => {
Loading
Loading
@@ -265,16 +310,69 @@ describe('Job State actions', () => {
});
});
 
describe('startPollingTrace', () => {
let dispatch;
let commit;
beforeEach(() => {
jasmine.clock().install();
dispatch = jasmine.createSpy();
commit = jasmine.createSpy();
startPollingTrace({ dispatch, commit });
});
afterEach(() => {
jasmine.clock().uninstall();
});
it('should save the timeout id but not call fetchTrace', () => {
expect(commit).toHaveBeenCalledWith(types.SET_TRACE_TIMEOUT, 1);
expect(dispatch).not.toHaveBeenCalledWith('fetchTrace');
});
describe('after timeout has passed', () => {
beforeEach(() => {
jasmine.clock().tick(4000);
});
it('should clear the timeout id and fetchTrace', () => {
expect(commit).toHaveBeenCalledWith(types.SET_TRACE_TIMEOUT, 0);
expect(dispatch).toHaveBeenCalledWith('fetchTrace');
});
});
});
describe('stopPollingTrace', () => {
let origTimeout;
beforeEach(() => {
// Can't use spyOn(window, 'clearTimeout') because this caused unrelated specs to timeout
// https://gitlab.com/gitlab-org/gitlab/-/merge_requests/23838#note_280277727
origTimeout = window.clearTimeout;
window.clearTimeout = jasmine.createSpy();
});
afterEach(() => {
window.clearTimeout = origTimeout;
});
it('should commit STOP_POLLING_TRACE mutation ', done => {
const traceTimeout = 7;
testAction(
stopPollingTrace,
null,
mockedState,
[{ type: types.STOP_POLLING_TRACE }],
{ ...mockedState, traceTimeout },
[{ type: types.SET_TRACE_TIMEOUT, payload: 0 }, { type: types.STOP_POLLING_TRACE }],
[],
done,
);
)
.then(() => {
expect(window.clearTimeout).toHaveBeenCalledWith(traceTimeout);
})
.then(done)
.catch(done.fail);
});
});
 
Loading
Loading
@@ -292,15 +390,8 @@ describe('Job State actions', () => {
});
 
describe('receiveTraceError', () => {
it('should commit RECEIVE_TRACE_ERROR mutation ', done => {
testAction(
receiveTraceError,
null,
mockedState,
[{ type: types.RECEIVE_TRACE_ERROR }],
[],
done,
);
it('should commit stop polling trace', done => {
testAction(receiveTraceError, null, mockedState, [], [{ type: 'stopPollingTrace' }], done);
});
});
 
Loading
Loading
Loading
Loading
@@ -2,10 +2,10 @@
 
require 'spec_helper'
 
describe Gitlab::Auth::CurrentUserMode, :do_not_mock_admin_mode do
describe Gitlab::Auth::CurrentUserMode, :do_not_mock_admin_mode, :request_store do
include_context 'custom session'
 
let(:user) { build(:user) }
let(:user) { build_stubbed(:user) }
 
subject { described_class.new(user) }
 
Loading
Loading
@@ -13,54 +13,66 @@ describe Gitlab::Auth::CurrentUserMode, :do_not_mock_admin_mode do
allow(ActiveSession).to receive(:list_sessions).with(user).and_return([session])
end
 
describe '#admin_mode?', :request_store do
context 'when the user is a regular user' do
it 'is false by default' do
expect(subject.admin_mode?).to be(false)
end
shared_examples 'admin mode cannot be enabled' do
it 'is false by default' do
expect(subject.admin_mode?).to be(false)
end
 
it 'cannot be enabled with a valid password' do
subject.enable_admin_mode!(password: user.password)
it 'cannot be enabled with a valid password' do
subject.enable_admin_mode!(password: user.password)
 
expect(subject.admin_mode?).to be(false)
end
expect(subject.admin_mode?).to be(false)
end
 
it 'cannot be enabled with an invalid password' do
subject.enable_admin_mode!(password: nil)
it 'cannot be enabled with an invalid password' do
subject.enable_admin_mode!(password: nil)
 
expect(subject.admin_mode?).to be(false)
end
expect(subject.admin_mode?).to be(false)
end
 
it 'cannot be enabled with empty params' do
subject.enable_admin_mode!
it 'cannot be enabled with empty params' do
subject.enable_admin_mode!
 
expect(subject.admin_mode?).to be(false)
end
expect(subject.admin_mode?).to be(false)
end
 
it 'disable has no effect' do
subject.enable_admin_mode!
subject.disable_admin_mode!
it 'disable has no effect' do
subject.enable_admin_mode!
subject.disable_admin_mode!
expect(subject.admin_mode?).to be(false)
end
context 'skipping password validation' do
it 'cannot be enabled with a valid password' do
subject.enable_admin_mode!(password: user.password, skip_password_validation: true)
 
expect(subject.admin_mode?).to be(false)
end
 
context 'skipping password validation' do
it 'cannot be enabled with a valid password' do
subject.enable_admin_mode!(password: user.password, skip_password_validation: true)
it 'cannot be enabled with an invalid password' do
subject.enable_admin_mode!(skip_password_validation: true)
 
expect(subject.admin_mode?).to be(false)
end
expect(subject.admin_mode?).to be(false)
end
end
end
 
it 'cannot be enabled with an invalid password' do
subject.enable_admin_mode!(skip_password_validation: true)
describe '#admin_mode?' do
context 'when the user is a regular user' do
it_behaves_like 'admin mode cannot be enabled'
 
expect(subject.admin_mode?).to be(false)
context 'bypassing session' do
it_behaves_like 'admin mode cannot be enabled' do
around do |example|
described_class.bypass_session!(user.id) { example.run }
end
end
end
end
 
context 'when the user is an admin' do
let(:user) { build(:user, :admin) }
let(:user) { build_stubbed(:user, :admin) }
 
context 'when admin mode not requested' do
it 'is false by default' do
Loading
Loading
@@ -148,11 +160,36 @@ describe Gitlab::Auth::CurrentUserMode, :do_not_mock_admin_mode do
end
end
end
context 'bypassing session' do
it 'is active by default' do
described_class.bypass_session!(user.id) do
expect(subject.admin_mode?).to be(true)
end
end
it 'enable has no effect' do
described_class.bypass_session!(user.id) do
subject.request_admin_mode!
subject.enable_admin_mode!(password: user.password)
expect(subject.admin_mode?).to be(true)
end
end
it 'disable has no effect' do
described_class.bypass_session!(user.id) do
subject.disable_admin_mode!
expect(subject.admin_mode?).to be(true)
end
end
end
end
end
 
describe '#enable_admin_mode!' do
let(:user) { build(:user, :admin) }
let(:user) { build_stubbed(:user, :admin) }
 
it 'creates a timestamp in the session' do
subject.request_admin_mode!
Loading
Loading
@@ -163,7 +200,7 @@ describe Gitlab::Auth::CurrentUserMode, :do_not_mock_admin_mode do
end
 
describe '#enable_sessionless_admin_mode!' do
let(:user) { build(:user, :admin) }
let(:user) { build_stubbed(:user, :admin) }
 
it 'enabled admin mode without password' do
subject.enable_sessionless_admin_mode!
Loading
Loading
@@ -173,7 +210,7 @@ describe Gitlab::Auth::CurrentUserMode, :do_not_mock_admin_mode do
end
 
describe '#disable_admin_mode!' do
let(:user) { build(:user, :admin) }
let(:user) { build_stubbed(:user, :admin) }
 
it 'sets the session timestamp to nil' do
subject.request_admin_mode!
Loading
Loading
@@ -183,6 +220,73 @@ describe Gitlab::Auth::CurrentUserMode, :do_not_mock_admin_mode do
end
end
 
describe '.bypass_session!' do
context 'with a regular user' do
it 'admin mode is false' do
described_class.bypass_session!(user.id) do
expect(subject.admin_mode?).to be(false)
expect(described_class.bypass_session_admin_id).to be(user.id)
end
expect(described_class.bypass_session_admin_id).to be_nil
end
end
context 'with an admin user' do
let(:user) { build_stubbed(:user, :admin) }
it 'admin mode is true' do
described_class.bypass_session!(user.id) do
expect(subject.admin_mode?).to be(true)
expect(described_class.bypass_session_admin_id).to be(user.id)
end
expect(described_class.bypass_session_admin_id).to be_nil
end
end
end
describe '.with_current_request_admin_mode' do
context 'with a regular user' do
it 'user is not available inside nor outside the yielded block' do
described_class.with_current_admin(user) do
expect(described_class.current_admin).to be_nil
end
expect(described_class.bypass_session_admin_id).to be_nil
end
end
context 'with an admin user' do
let(:user) { build_stubbed(:user, :admin) }
context 'admin mode is disabled' do
it 'user is not available inside nor outside the yielded block' do
described_class.with_current_admin(user) do
expect(described_class.current_admin).to be_nil
end
expect(described_class.bypass_session_admin_id).to be_nil
end
end
context 'admin mode is enabled' do
before do
subject.request_admin_mode!
subject.enable_admin_mode!(password: user.password)
end
it 'user is available only inside the yielded block' do
described_class.with_current_admin(user) do
expect(described_class.current_admin).to be(user)
end
expect(described_class.current_admin).to be_nil
end
end
end
end
def expected_session_entry(value_matcher)
{
Gitlab::Auth::CurrentUserMode::SESSION_STORE_KEY => a_hash_including(
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, :migr
let(:group) { namespaces.create!(name: 'foo', path: 'foo') }
let(:subgroup) { namespaces.create!(name: 'bar', path: 'bar', parent_id: group.id) }
 
describe described_class::Storage::HashedProject do
describe described_class::Storage::Hashed do
let(:project) { double(id: 555) }
 
subject(:project_storage) { described_class.new(project) }
Loading
Loading
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::SidekiqMiddleware::AdminMode::Client, :do_not_mock_admin_mode, :request_store do
include AdminModeHelper
let(:worker) do
Class.new do
def perform; end
end
end
let(:job) { {} }
let(:queue) { :test }
it 'yields block' do
expect do |b|
subject.call(worker, job, queue, nil, &b)
end.to yield_control.once
end
context 'user is a regular user' do
it 'no admin mode field in payload' do
subject.call(worker, job, queue, nil) { nil }
expect(job).not_to include('admin_mode_user_id')
end
end
context 'user is an administrator' do
let(:admin) { create(:admin) }
context 'admin mode disabled' do
it 'no admin mode field in payload' do
subject.call(worker, job, queue, nil) { nil }
expect(job).not_to include('admin_mode_user_id')
end
end
context 'admin mode enabled' do
before do
enable_admin_mode!(admin)
end
context 'when sidekiq required context not set' do
it 'no admin mode field in payload' do
subject.call(worker, job, queue, nil) { nil }
expect(job).not_to include('admin_mode_user_id')
end
end
context 'when user stored in current request' do
it 'has admin mode field in payload' do
Gitlab::Auth::CurrentUserMode.with_current_admin(admin) do
subject.call(worker, job, queue, nil) { nil }
expect(job).to include('admin_mode_user_id' => admin.id)
end
end
end
context 'when bypassing session' do
it 'has admin mode field in payload' do
Gitlab::Auth::CurrentUserMode.bypass_session!(admin.id) do
subject.call(worker, job, queue, nil) { nil }
expect(job).to include('admin_mode_user_id' => admin.id)
end
end
end
end
end
context 'admin mode feature disabled' do
before do
stub_feature_flags(user_mode_in_session: false)
end
it 'yields block' do
expect do |b|
subject.call(worker, job, queue, nil, &b)
end.to yield_control.once
end
it 'no admin mode field in payload' do
subject.call(worker, job, queue, nil) { nil }
expect(job).not_to include('admin_mode_user_id')
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::SidekiqMiddleware::AdminMode::Server, :do_not_mock_admin_mode, :request_store do
include AdminModeHelper
let(:worker) do
Class.new do
def perform; end
end
end
let(:job) { {} }
let(:queue) { :test }
it 'yields block' do
expect do |b|
subject.call(worker, job, queue, &b)
end.to yield_control.once
end
context 'job has no admin mode field' do
it 'session is not bypassed' do
subject.call(worker, job, queue) do
expect(Gitlab::Auth::CurrentUserMode.bypass_session_admin_id).to be_nil
end
end
end
context 'job has admin mode field' do
let(:admin) { create(:admin) }
context 'nil admin mode id' do
let(:job) { { 'admin_mode_user_id' => nil } }
it 'session is not bypassed' do
subject.call(worker, job, queue) do
expect(Gitlab::Auth::CurrentUserMode.bypass_session_admin_id).to be_nil
end
end
end
context 'valid admin mode id' do
let(:job) { { 'admin_mode_user_id' => admin.id } }
it 'session is bypassed' do
subject.call(worker, job, queue) do
expect(Gitlab::Auth::CurrentUserMode.bypass_session_admin_id).to be(admin.id)
end
end
end
end
context 'admin mode feature disabled' do
before do
stub_feature_flags(user_mode_in_session: false)
end
it 'yields block' do
expect do |b|
subject.call(worker, job, queue, &b)
end.to yield_control.once
end
it 'session is not bypassed' do
subject.call(worker, job, queue) do
expect(Gitlab::Auth::CurrentUserMode.bypass_session_admin_id).to be_nil
end
end
end
end
Loading
Loading
@@ -45,7 +45,8 @@ describe Gitlab::SidekiqMiddleware do
Gitlab::SidekiqMiddleware::ArgumentsLogger,
Gitlab::SidekiqMiddleware::MemoryKiller,
Gitlab::SidekiqMiddleware::RequestStoreMiddleware,
Gitlab::SidekiqMiddleware::WorkerContext::Server
Gitlab::SidekiqMiddleware::WorkerContext::Server,
Gitlab::SidekiqMiddleware::AdminMode::Server
]
end
let(:enabled_sidekiq_middlewares) { all_sidekiq_middlewares - disabled_sidekiq_middlewares }
Loading
Loading
@@ -115,7 +116,8 @@ describe Gitlab::SidekiqMiddleware do
Gitlab::SidekiqStatus::ClientMiddleware,
Gitlab::SidekiqMiddleware::ClientMetrics,
Gitlab::SidekiqMiddleware::WorkerContext::Client,
Labkit::Middleware::Sidekiq::Client
Labkit::Middleware::Sidekiq::Client,
Gitlab::SidekiqMiddleware::AdminMode::Client
]
end
 
Loading
Loading
Loading
Loading
@@ -17,7 +17,7 @@ describe MicrosoftTeams::Notifier do
text: '[#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1)',
image: 'http://someimage.com'
},
attachments: 'please fix'
attachments: "[GitLab](https://gitlab.com)\n\n- _Ruby_\n- **Go**\n"
}
end
 
Loading
Loading
@@ -31,13 +31,7 @@ describe MicrosoftTeams::Notifier do
'activityImage' => 'http://someimage.com'
},
{
'title' => 'Details',
'facts' => [
{
'name' => 'Attachments',
'value' => 'please fix'
}
]
text: "[GitLab](https://gitlab.com)\n\n- _Ruby_\n- **Go**\n"
}
],
'title' => 'JohnDoe4/project2',
Loading
Loading
@@ -54,4 +48,14 @@ describe MicrosoftTeams::Notifier do
expect(subject.ping(options)).to be true
end
end
describe '#body' do
it 'returns Markdown-based body when HTML was passed' do
expect(subject.send(:body, options)).to eq(body.to_json)
end
it 'fails when empty Hash was passed' do
expect { subject.send(:body, {}) }.to raise_error(ArgumentError)
end
end
end
Loading
Loading
@@ -84,6 +84,16 @@ describe Issue do
end
end
 
describe '.simple_sorts' do
it 'includes all keys' do
expect(described_class.simple_sorts.keys).to include(
*%w(created_asc created_at_asc created_date created_desc created_at_desc
closest_future_date closest_future_date_asc due_date due_date_asc due_date_desc
id_asc id_desc relative_position relative_position_asc
updated_desc updated_asc updated_at_asc updated_at_desc))
end
end
describe '#order_by_position_and_priority' do
let(:project) { create :project }
let(:p1) { create(:label, title: 'P1', project: project, priority: 1) }
Loading
Loading
Loading
Loading
@@ -2985,9 +2985,9 @@ describe User, :do_not_mock_admin_mode do
end
end
 
describe '#can_read_all_resources?' do
describe '#can_read_all_resources?', :request_store do
it 'returns false for regular user' do
user = build(:user)
user = build_stubbed(:user)
 
expect(user.can_read_all_resources?).to be_falsy
end
Loading
Loading
@@ -2995,7 +2995,7 @@ describe User, :do_not_mock_admin_mode do
context 'for admin user' do
include_context 'custom session'
 
let(:user) { build(:user, :admin) }
let(:user) { build_stubbed(:user, :admin) }
 
context 'when admin mode is disabled' do
it 'returns false' do
Loading
Loading
Loading
Loading
@@ -23,8 +23,8 @@ describe BasePolicy, :do_not_mock_admin_mode do
end
 
describe 'read cross project' do
let(:current_user) { create(:user) }
let(:user) { create(:user) }
let(:current_user) { build_stubbed(:user) }
let(:user) { build_stubbed(:user) }
 
subject { described_class.new(current_user, [user]) }
 
Loading
Loading
@@ -38,7 +38,7 @@ describe BasePolicy, :do_not_mock_admin_mode do
it { is_expected.not_to be_allowed(:read_cross_project) }
 
context 'for admins' do
let(:current_user) { build(:admin) }
let(:current_user) { build_stubbed(:admin) }
 
subject { described_class.new(current_user, nil) }
 
Loading
Loading
@@ -56,14 +56,14 @@ describe BasePolicy, :do_not_mock_admin_mode do
end
 
describe 'full private access' do
let(:current_user) { create(:user) }
let(:current_user) { build_stubbed(:user) }
 
subject { described_class.new(current_user, nil) }
 
it { is_expected.not_to be_allowed(:read_all_resources) }
 
context 'for admins' do
let(:current_user) { build(:admin) }
let(:current_user) { build_stubbed(:admin) }
 
it 'allowed when in admin mode' do
enable_admin_mode!(current_user)
Loading
Loading
Loading
Loading
@@ -5,6 +5,8 @@ require 'spec_helper'
describe ErrorTracking::IssueDetailsService do
include_context 'sentry error tracking context'
 
subject { described_class.new(project, user, params) }
describe '#execute' do
context 'with authorized user' do
context 'when issue_details returns a detailed error' do
Loading
Loading
Loading
Loading
@@ -5,6 +5,8 @@ require 'spec_helper'
describe ErrorTracking::IssueLatestEventService do
include_context 'sentry error tracking context'
 
subject { described_class.new(project, user) }
describe '#execute' do
context 'with authorized user' do
context 'when issue_latest_event returns an error event' do
Loading
Loading
Loading
Loading
@@ -7,16 +7,19 @@ describe ErrorTracking::IssueUpdateService do
 
let(:arguments) { { issue_id: 1234, status: 'resolved' } }
 
subject { described_class.new(project, user, arguments) }
subject(:update_service) { described_class.new(project, user, arguments) }
 
shared_examples 'does not perform close issue flow' do
it 'does not call the close issue service' do
update_service.execute
expect(issue_close_service)
.not_to receive(:execute)
.not_to have_received(:execute)
end
 
it 'does not create system note' do
expect(SystemNoteService).not_to receive(:close_after_error_tracking_resolve)
update_service.execute
end
end
 
Loading
Loading
@@ -31,13 +34,13 @@ describe ErrorTracking::IssueUpdateService do
end
 
it 'returns the response' do
expect(result).to eq(update_issue_response.merge(status: :success, closed_issue_iid: nil))
expect(update_service.execute).to eq(update_issue_response.merge(status: :success, closed_issue_iid: nil))
end
 
it 'updates any related issue' do
expect(subject).to receive(:update_related_issue)
expect(update_service).to receive(:update_related_issue)
 
result
update_service.execute
end
 
context 'related issue and resolving' do
Loading
Loading
@@ -48,39 +51,46 @@ describe ErrorTracking::IssueUpdateService do
let(:issue_close_service) { spy(:issue_close_service) }
 
before do
allow_any_instance_of(SentryIssueFinder)
.to receive(:execute)
.and_return(sentry_issue)
allow_next_instance_of(SentryIssueFinder) do |finder|
allow(finder).to receive(:execute).and_return(sentry_issue)
end
 
allow(Issues::CloseService)
.to receive(:new)
.and_return(issue_close_service)
end
 
after do
result
allow(issue_close_service)
.to receive(:execute)
.and_return(issue)
end
 
it 'closes the issue' do
update_service.execute
expect(issue_close_service)
.to receive(:execute)
.to have_received(:execute)
.with(issue, system_note: false)
.and_return(issue)
end
 
it 'creates a system note' do
expect(SystemNoteService).to receive(:close_after_error_tracking_resolve)
end
context 'issues gets closed' do
let(:closed_issue) { create(:issue, :closed, project: project) }
 
it 'returns a response with closed issue' do
closed_issue = create(:issue, :closed, project: project)
before do
expect(issue_close_service)
.to receive(:execute)
.with(issue, system_note: false)
.and_return(closed_issue)
end
 
expect(issue_close_service)
.to receive(:execute)
.with(issue, system_note: false)
.and_return(closed_issue)
it 'creates a system note' do
expect(SystemNoteService).to receive(:close_after_error_tracking_resolve)
update_service.execute
end
 
expect(result).to eq(status: :success, updated: true, closed_issue_iid: closed_issue.iid)
it 'returns a response with closed issue' do
expect(update_service.execute).to eq(status: :success, updated: true, closed_issue_iid: closed_issue.iid)
end
end
 
context 'issue is already closed' do
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ require 'spec_helper'
describe Projects::AfterRenameService do
let(:rugged_config) { rugged_repo(project.repository).config }
let(:legacy_storage) { Storage::LegacyProject.new(project) }
let(:hashed_storage) { Storage::HashedProject.new(project) }
let(:hashed_storage) { Storage::Hashed.new(project) }
let!(:path_before_rename) { project.path }
let!(:full_path_before_rename) { project.full_path }
let!(:path_after_rename) { "#{project.path}-renamed" }
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
 
let(:project) { create(:project, :repository, storage_version: 1, skip_disk_validation: true) }
let(:legacy_storage) { Storage::LegacyProject.new(project) }
let(:hashed_storage) { Storage::HashedProject.new(project) }
let(:hashed_storage) { Storage::Hashed.new(project) }
 
let!(:upload) { Upload.find_by(path: file_uploader.upload_path) }
let(:file_uploader) { build(:file_uploader, project: project) }
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ describe Projects::HashedStorage::MigrateRepositoryService do
let(:gitlab_shell) { Gitlab::Shell.new }
let(:project) { create(:project, :legacy_storage, :repository, :wiki_repo) }
let(:legacy_storage) { Storage::LegacyProject.new(project) }
let(:hashed_storage) { Storage::HashedProject.new(project) }
let(:hashed_storage) { Storage::Hashed.new(project) }
 
subject(:service) { described_class.new(project: project, old_disk_path: project.disk_path) }
 
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ describe Projects::HashedStorage::RollbackAttachmentsService do
 
let(:project) { create(:project, :repository, skip_disk_validation: true) }
let(:legacy_storage) { Storage::LegacyProject.new(project) }
let(:hashed_storage) { Storage::HashedProject.new(project) }
let(:hashed_storage) { Storage::Hashed.new(project) }
 
let!(:upload) { Upload.find_by(path: file_uploader.upload_path) }
let(:file_uploader) { build(:file_uploader, project: project) }
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ describe Projects::HashedStorage::RollbackRepositoryService, :clean_gitlab_redis
let(:gitlab_shell) { Gitlab::Shell.new }
let(:project) { create(:project, :repository, :wiki_repo, storage_version: ::Project::HASHED_STORAGE_FEATURES[:repository]) }
let(:legacy_storage) { Storage::LegacyProject.new(project) }
let(:hashed_storage) { Storage::HashedProject.new(project) }
let(:hashed_storage) { Storage::Hashed.new(project) }
 
subject(:service) { described_class.new(project: project, old_disk_path: project.disk_path) }
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment