Commit d988966c authored by GitLab Bot's avatar GitLab Bot

Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-01-30

parents f9a09067 7f647f9f
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
/* global fuzzaldrinPlus */ /* global fuzzaldrinPlus */
import _ from 'underscore'; import _ from 'underscore';
import fuzzaldrinPlus from 'fuzzaldrin-plus'; import fuzzaldrinPlus from 'fuzzaldrin-plus';
import axios from './lib/utils/axios_utils';
import { visitUrl } from './lib/utils/url_utility'; import { visitUrl } from './lib/utils/url_utility';
import { isObject } from './lib/utils/type_utility'; import { isObject } from './lib/utils/type_utility';
...@@ -212,25 +213,17 @@ GitLabDropdownRemote = (function() { ...@@ -212,25 +213,17 @@ GitLabDropdownRemote = (function() {
}; };
GitLabDropdownRemote.prototype.fetchData = function() { GitLabDropdownRemote.prototype.fetchData = function() {
return $.ajax({ if (this.options.beforeSend) {
url: this.dataEndpoint, this.options.beforeSend();
dataType: this.options.dataType, }
beforeSend: (function(_this) {
return function() { // Fetch the data through ajax if the data is a string
if (_this.options.beforeSend) { return axios.get(this.dataEndpoint)
return _this.options.beforeSend(); .then(({ data }) => {
} if (this.options.success) {
}; return this.options.success(data);
})(this), }
success: (function(_this) { });
return function(data) {
if (_this.options.success) {
return _this.options.success(data);
}
};
})(this)
});
// Fetch the data through ajax if the data is a string
}; };
return GitLabDropdownRemote; return GitLabDropdownRemote;
......
import flash from '../flash';
import { __ } from '../locale';
import axios from '../lib/utils/axios_utils';
import ContributorsStatGraph from './stat_graph_contributors'; import ContributorsStatGraph from './stat_graph_contributors';
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
$.ajax({ const url = document.querySelector('.js-graphs-show').dataset.projectGraphPath;
type: 'GET',
url: document.querySelector('.js-graphs-show').dataset.projectGraphPath, axios.get(url)
dataType: 'json', .then(({ data }) => {
success(data) {
const graph = new ContributorsStatGraph(); const graph = new ContributorsStatGraph();
graph.init(data); graph.init(data);
...@@ -16,6 +18,6 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -16,6 +18,6 @@ document.addEventListener('DOMContentLoaded', () => {
$('.stat-graph').fadeIn(); $('.stat-graph').fadeIn();
$('.loading-graph').hide(); $('.loading-graph').hide();
}, })
}); .catch(() => flash(__('Error fetching contributors data.')));
}); });
import axios from './lib/utils/axios_utils';
import flash from './flash';
import { __ } from './locale';
export default class GroupLabelSubscription { export default class GroupLabelSubscription {
constructor(container) { constructor(container) {
const $container = $(container); const $container = $(container);
...@@ -13,14 +17,12 @@ export default class GroupLabelSubscription { ...@@ -13,14 +17,12 @@ export default class GroupLabelSubscription {
event.preventDefault(); event.preventDefault();
const url = this.$unsubscribeButtons.attr('data-url'); const url = this.$unsubscribeButtons.attr('data-url');
axios.post(url)
$.ajax({ .then(() => {
type: 'POST', this.toggleSubscriptionButtons();
url, this.$unsubscribeButtons.removeAttr('data-url');
}).done(() => { })
this.toggleSubscriptionButtons(); .catch(() => flash(__('There was an error when unsubscribing from this label.')));
this.$unsubscribeButtons.removeAttr('data-url');
});
} }
subscribe(event) { subscribe(event) {
...@@ -31,12 +33,9 @@ export default class GroupLabelSubscription { ...@@ -31,12 +33,9 @@ export default class GroupLabelSubscription {
this.$unsubscribeButtons.attr('data-url', url); this.$unsubscribeButtons.attr('data-url', url);
$.ajax({ axios.post(url)
type: 'POST', .then(() => this.toggleSubscriptionButtons())
url, .catch(() => flash(__('There was an error when subscribing to this label.')));
}).done(() => {
this.toggleSubscriptionButtons();
});
} }
toggleSubscriptionButtons() { toggleSubscriptionButtons() {
......
import Flash from '../flash'; import axios from '../lib/utils/axios_utils';
import flash from '../flash';
export default class IntegrationSettingsForm { export default class IntegrationSettingsForm {
constructor(formSelector) { constructor(formSelector) {
...@@ -95,29 +96,26 @@ export default class IntegrationSettingsForm { ...@@ -95,29 +96,26 @@ export default class IntegrationSettingsForm {
*/ */
testSettings(formData) { testSettings(formData) {
this.toggleSubmitBtnState(true); this.toggleSubmitBtnState(true);
$.ajax({
type: 'PUT', return axios.put(this.testEndPoint, formData)
url: this.testEndPoint, .then(({ data }) => {
data: formData, if (data.error) {
}) flash(`${data.message} ${data.service_response}`, 'alert', document, {
.done((res) => { title: 'Save anyway',
if (res.error) { clickHandler: (e) => {
new Flash(`${res.message} ${res.service_response}`, 'alert', document, { e.preventDefault();
title: 'Save anyway', this.$form.submit();
clickHandler: (e) => { },
e.preventDefault(); });
this.$form.submit(); } else {
}, this.$form.submit();
}); }
} else {
this.$form.submit(); this.toggleSubmitBtnState(false);
} })
}) .catch(() => {
.fail(() => { flash('Something went wrong on our end.');
new Flash('Something went wrong on our end.'); this.toggleSubmitBtnState(false);
}) });
.always(() => {
this.toggleSubmitBtnState(false);
});
} }
} }
/* eslint-disable comma-dangle, quotes, consistent-return, func-names, array-callback-return, space-before-function-paren, prefer-arrow-callback, max-len, no-unused-expressions, no-sequences, no-underscore-dangle, no-unused-vars, no-param-reassign */ /* eslint-disable comma-dangle, quotes, consistent-return, func-names, array-callback-return, space-before-function-paren, prefer-arrow-callback, max-len, no-unused-expressions, no-sequences, no-underscore-dangle, no-unused-vars, no-param-reassign */
import _ from 'underscore'; import _ from 'underscore';
import axios from './lib/utils/axios_utils';
import Flash from './flash'; import Flash from './flash';
export default { export default {
...@@ -22,15 +23,9 @@ export default { ...@@ -22,15 +23,9 @@ export default {
}, },
submit() { submit() {
const _this = this; axios[this.form.attr('method')](this.form.attr('action'), this.getFormDataAsObject())
const xhr = $.ajax({ .then(() => window.location.reload())
url: this.form.attr('action'), .catch(() => this.onFormSubmitFailure());
method: this.form.attr('method'),
dataType: 'JSON',
data: this.getFormDataAsObject()
});
xhr.done(() => window.location.reload());
xhr.fail(() => this.onFormSubmitFailure());
}, },
onFormSubmitFailure() { onFormSubmitFailure() {
......
import axios from './lib/utils/axios_utils';
import flash from './flash';
import { __ } from './locale';
import IssuableBulkUpdateSidebar from './issuable_bulk_update_sidebar'; import IssuableBulkUpdateSidebar from './issuable_bulk_update_sidebar';
import IssuableBulkUpdateActions from './issuable_bulk_update_actions'; import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
...@@ -20,23 +23,24 @@ export default class IssuableIndex { ...@@ -20,23 +23,24 @@ export default class IssuableIndex {
} }
static resetIncomingEmailToken() { static resetIncomingEmailToken() {
$('.incoming-email-token-reset').on('click', (e) => { const $resetToken = $('.incoming-email-token-reset');
$resetToken.on('click', (e) => {
e.preventDefault(); e.preventDefault();
$.ajax({ $resetToken.text('resetting...');
type: 'PUT',
url: $('.incoming-email-token-reset').attr('href'), axios.put($resetToken.attr('href'))
dataType: 'json', .then(({ data }) => {
success(response) { $('#issuable_email').val(data.new_address).focus();
$('#issuable_email').val(response.new_address).focus();
}, $resetToken.text('reset it');
beforeSend() { })
$('.incoming-email-token-reset').text('resetting...'); .catch(() => {
}, flash(__('There was an error when reseting email token.'));
complete() {
$('.incoming-email-token-reset').text('reset it'); $resetToken.text('reset it');
}, });
});
}); });
} }
} }
/* eslint-disable comma-dangle, class-methods-use-this, no-underscore-dangle, no-param-reassign, no-unused-vars, consistent-return, func-names, space-before-function-paren, max-len */ /* eslint-disable comma-dangle, class-methods-use-this, no-underscore-dangle, no-param-reassign, no-unused-vars, consistent-return, func-names, space-before-function-paren, max-len */
import Sortable from 'vendor/Sortable'; import Sortable from 'vendor/Sortable';
import Flash from './flash'; import flash from './flash';
import axios from './lib/utils/axios_utils';
export default class LabelManager { export default class LabelManager {
constructor({ togglePriorityButton, prioritizedLabels, otherLabels } = {}) { constructor({ togglePriorityButton, prioritizedLabels, otherLabels } = {}) {
...@@ -50,11 +51,12 @@ export default class LabelManager { ...@@ -50,11 +51,12 @@ export default class LabelManager {
if (persistState == null) { if (persistState == null) {
persistState = true; persistState = true;
} }
let xhr;
const _this = this; const _this = this;
const url = $label.find('.js-toggle-priority').data('url'); const url = $label.find('.js-toggle-priority').data('url');
let $target = this.prioritizedLabels; let $target = this.prioritizedLabels;
let $from = this.otherLabels; let $from = this.otherLabels;
const rollbackLabelPosition = this.rollbackLabelPosition.bind(this, $label, action);
if (action === 'remove') { if (action === 'remove') {
$target = this.otherLabels; $target = this.otherLabels;
$from = this.prioritizedLabels; $from = this.prioritizedLabels;
...@@ -71,40 +73,34 @@ export default class LabelManager { ...@@ -71,40 +73,34 @@ export default class LabelManager {
return; return;
} }
if (action === 'remove') { if (action === 'remove') {
xhr = $.ajax({ axios.delete(url)
url, .catch(rollbackLabelPosition);
type: 'DELETE'
});
// Restore empty message // Restore empty message
if (!$from.find('li').length) { if (!$from.find('li').length) {
$from.find('.empty-message').removeClass('hidden'); $from.find('.empty-message').removeClass('hidden');
} }
} else { } else {
xhr = this.savePrioritySort($label, action); this.savePrioritySort($label, action)
.catch(rollbackLabelPosition);
} }
return xhr.fail(this.rollbackLabelPosition.bind(this, $label, action));
} }
onPrioritySortUpdate() { onPrioritySortUpdate() {
const xhr = this.savePrioritySort(); this.savePrioritySort()
return xhr.fail(function() { .catch(() => flash(this.errorMessage));
return new Flash(this.errorMessage, 'alert');
});
} }
savePrioritySort() { savePrioritySort() {
return $.post({ return axios.post(this.prioritizedLabels.data('url'), {
url: this.prioritizedLabels.data('url'), label_ids: this.getSortedLabelsIds(),
data: {
label_ids: this.getSortedLabelsIds()
}
}); });
} }
rollbackLabelPosition($label, originalAction) { rollbackLabelPosition($label, originalAction) {
const action = originalAction === 'remove' ? 'add' : 'remove'; const action = originalAction === 'remove' ? 'add' : 'remove';
this.toggleLabelPriority($label, action, false); this.toggleLabelPriority($label, action, false);
return new Flash(this.errorMessage, 'alert'); flash(this.errorMessage);
} }
getSortedLabelsIds() { getSortedLabelsIds() {
......
/* eslint-disable func-names, prefer-arrow-callback, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, one-var, one-var-declaration-per-line, consistent-return, no-param-reassign, max-len */ /* eslint-disable func-names, prefer-arrow-callback, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, one-var, one-var-declaration-per-line, consistent-return, no-param-reassign, max-len */
import { __ } from './locale';
import axios from './lib/utils/axios_utils';
import createFlash from './flash';
import FilesCommentButton from './files_comment_button'; import FilesCommentButton from './files_comment_button';
import imageDiffHelper from './image_diff/helpers/index'; import imageDiffHelper from './image_diff/helpers/index';
import syntaxHighlight from './syntax_highlight'; import syntaxHighlight from './syntax_highlight';
...@@ -60,30 +63,31 @@ export default class SingleFileDiff { ...@@ -60,30 +63,31 @@ export default class SingleFileDiff {
getContentHTML(cb) { getContentHTML(cb) {
this.collapsedContent.hide(); this.collapsedContent.hide();
this.loadingContent.show(); this.loadingContent.show();
$.get(this.diffForPath, (function(_this) {
return function(data) { axios.get(this.diffForPath)
_this.loadingContent.hide(); .then(({ data }) => {
this.loadingContent.hide();
if (data.html) { if (data.html) {
_this.content = $(data.html); this.content = $(data.html);
syntaxHighlight(_this.content); syntaxHighlight(this.content);
} else { } else {
_this.hasError = true; this.hasError = true;
_this.content = $(ERROR_HTML); this.content = $(ERROR_HTML);
} }
_this.collapsedContent.after(_this.content); this.collapsedContent.after(this.content);
if (typeof gl.diffNotesCompileComponents !== 'undefined') { if (typeof gl.diffNotesCompileComponents !== 'undefined') {
gl.diffNotesCompileComponents(); gl.diffNotesCompileComponents();
} }
const $file = $(_this.file); const $file = $(this.file);
FilesCommentButton.init($file); FilesCommentButton.init($file);
const canCreateNote = $file.closest('.files').is('[data-can-create-note]'); const canCreateNote = $file.closest('.files').is('[data-can-create-note]');
imageDiffHelper.initImageDiff($file[0], canCreateNote); imageDiffHelper.initImageDiff($file[0], canCreateNote);
if (cb) cb(); if (cb) cb();
}; })
})(this)); .catch(createFlash(__('An error occurred while retrieving diff')));
} }
} }
...@@ -645,12 +645,12 @@ class MergeRequest < ActiveRecord::Base ...@@ -645,12 +645,12 @@ class MergeRequest < ActiveRecord::Base
can_be_merged? && !should_be_rebased? can_be_merged? && !should_be_rebased?
end end
def mergeable_state?(skip_ci_check: false) def mergeable_state?(skip_ci_check: false, skip_discussions_check: false)
return false unless open? return false unless open?
return false if work_in_progress? return false if work_in_progress?
return false if broken? return false if broken?
return false unless skip_ci_check || mergeable_ci_state? return false unless skip_ci_check || mergeable_ci_state?
return false unless mergeable_discussions_state? return false unless skip_discussions_check || mergeable_discussions_state?
true true
end end
......
...@@ -67,7 +67,18 @@ class MergeRequestWidgetEntity < IssuableEntity ...@@ -67,7 +67,18 @@ class MergeRequestWidgetEntity < IssuableEntity
expose :merge_ongoing?, as: :merge_ongoing expose :merge_ongoing?, as: :merge_ongoing
expose :work_in_progress?, as: :work_in_progress expose :work_in_progress?, as: :work_in_progress
expose :source_branch_exists?, as: :source_branch_exists expose :source_branch_exists?, as: :source_branch_exists
expose :mergeable_discussions_state?, as: :mergeable_discussions_state
expose :mergeable_discussions_state?, as: :mergeable_discussions_state do |merge_request|
# This avoids calling MergeRequest#mergeable_discussions_state without
# considering the state of the MR first. If a MR isn't mergeable, we can
# safely short-circuit it.
if merge_request.mergeable_state?(skip_ci_check: true, skip_discussions_check: true)
merge_request.mergeable_discussions_state?
else
false
end
end
expose :branch_missing?, as: :branch_missing expose :branch_missing?, as: :branch_missing
expose :commits_count expose :commits_count
expose :cannot_be_merged?, as: :has_conflicts expose :cannot_be_merged?, as: :has_conflicts
......
---
title: Stop checking if discussions are in a mergeable state if the MR isn't
merge_request:
author:
type: performance
...@@ -35,7 +35,6 @@ tasks = [ ...@@ -35,7 +35,6 @@ tasks = [
%w[bundle exec rubocop --parallel], %w[bundle exec rubocop --parallel],
%w[bundle exec rake gettext:lint], %w[bundle exec rake gettext:lint],
%w[bundle exec rake lint:static_verification], %w[bundle exec rake lint:static_verification],
%w[scripts/lint-changelog-yaml],
%w[scripts/lint-conflicts.sh], %w[scripts/lint-conflicts.sh],
%w[scripts/lint-rugged] %w[scripts/lint-rugged]
] ]
......
...@@ -112,13 +112,6 @@ feature 'Expand and collapse diffs', :js do ...@@ -112,13 +112,6 @@ feature 'Expand and collapse diffs', :js do
wait_for_requests wait_for_requests
end end
it 'makes a request to get the content' do
ajax_uris = evaluate_script('ajaxUris')
expect(ajax_uris).not_to be_empty
expect(ajax_uris.first).to include('large_diff.md')
end
it 'shows the diff content' do it 'shows the diff content' do
expect(large_diff).to have_selector('.code') expect(large_diff).to have_selector('.code')
expect(large_diff).not_to have_selector('.nothing-here-block') expect(large_diff).not_to have_selector('.nothing-here-block')
......
import MockAdaptor from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import IntegrationSettingsForm from '~/integrations/integration_settings_form'; import IntegrationSettingsForm from '~/integrations/integration_settings_form';
describe('IntegrationSettingsForm', () => { describe('IntegrationSettingsForm', () => {
...@@ -109,91 +111,117 @@ describe('IntegrationSettingsForm', () => { ...@@ -109,91 +111,117 @@ describe('IntegrationSettingsForm', () => {
describe('testSettings', () => { describe('testSettings', () => {
let integrationSettingsForm; let integrationSettingsForm;
let formData; let formData;
let mock;
beforeEach(() => { beforeEach(() => {
mock = new MockAdaptor(axios);
spyOn(axios, 'put').and.callThrough();
integrationSettingsForm = new IntegrationSettingsForm('.js-integration-settings-form'); integrationSettingsForm = new IntegrationSettingsForm('.js-integration-settings-form');
formData = integrationSettingsForm.$form.serialize(); formData = integrationSettingsForm.$form.serialize();
}); });
it('should make an ajax request with provided `formData`', () => { afterEach(() => {
const deferred = $.Deferred(); mock.restore();
spyOn($, 'ajax').and.returnValue(deferred.promise()); });
integrationSettingsForm.testSettings(formData); it('should make an ajax request with provided `formData`', (done) => {
integrationSettingsForm.testSettings(formData)
.then(() => {
expect(axios.put).toHaveBeenCalledWith(integrationSettingsForm.testEndPoint, formData);
expect($.ajax).toHaveBeenCalledWith({ done();
type: 'PUT', })
url: integrationSettingsForm.testEndPoint, .catch(done.fail);
data: formData,
});
}); });
it('should show error Flash with `Save anyway` action if ajax request responds with error in test', () => { it('should show error Flash with `Save anyway` action if ajax request responds with error in test', (done) => {
const errorMessage = 'Test failed.'; const errorMessage = 'Test failed.';
const deferred = $.Deferred(); mock.onPut(integrationSettingsForm.testEndPoint).reply(200, {
spyOn($, 'ajax').and.returnValue(deferred.promise()); error: true,
message: errorMessage,
integrationSettingsForm.testSettings(formData); service_response: 'some error',
});
deferred.resolve({ error: true, message: errorMessage, service_response: 'some error' }); integrationSettingsForm.testSettings(formData)
.then(() => {
const $flashContainer = $('.flash-container');
expect($flashContainer.find('.flash-text').text().trim()).toEqual('Test failed. some error');
expect($flashContainer.find('.flash-action')).toBeDefined();
expect($flashContainer.find('.flash-action').text().trim()).toEqual('Save anyway');
const $flashContainer = $('.flash-container'); done();
expect($flashContainer.find('.flash-text').text().trim()).toEqual('Test failed. some error'); })
expect($flashContainer.find('.flash-action')).toBeDefined(); .catch(done.fail);
expect($flashContainer.find('.flash-action').text().trim()).toEqual('Save anyway');
}); });
it('should submit form if ajax request responds without any error in test', () => { it('should submit form if ajax request responds without any error in test', (done) => {
const deferred = $.Deferred(); spyOn(integrationSettingsForm.$form, 'submit');
spyOn($, 'ajax').and.returnValue(deferred.promise());
integrationSettingsForm.testSettings(formData); mock.onPut(integrationSettingsForm.testEndPoint).reply(200, {
error: false,
});
spyOn(integrationSettingsForm.$form, 'submit'); integrationSettingsForm.testSettings(formData)
deferred.resolve({ error: false }); .then(() => {
expect(integrationSettingsForm.$form.submit).toHaveBeenCalled();
expect(integrationSettingsForm.$form.submit).toHaveBeenCalled(); done();
})
.catch(done.fail);
}); });
it('should submit form when clicked on `Save anyway` action of error Flash', () => { it('should submit form when clicked on `Save anyway` action of error Flash', (done) => {
const errorMessage = 'Test failed.'; spyOn(integrationSettingsForm.$form, 'submit');
const deferred = $.Deferred();
spyOn($, 'ajax').and.returnValue(deferred.promise());
integrationSettingsForm.testSettings(formData); const errorMessage = 'Test failed.';
mock.onPut(integrationSettingsForm.testEndPoint).reply(200, {
error: true,
message: errorMessage,
});
deferred.resolve({ error: true, message: errorMessage }); integrationSettingsForm.testSettings(formData)
.then(() => {
const $flashAction = $('.flash-container .flash-action');
expect($flashAction).toBeDefined();
const $flashAction = $('.flash-container .flash-action'); $flashAction.get(0).click();
expect($flashAction).toBeDefined(); })
.then(() => {
expect(integrationSettingsForm.$form.submit).toHaveBeenCalled();
spyOn(integrationSettingsForm.$form, 'submit'); done();
$flashAction.get(0).click(); })
expect(integrationSettingsForm.$form.submit).toHaveBeenCalled(); .catch(done.fail);
}); });
it('should show error Flash if ajax request failed', () => { it('should show error Flash if ajax request failed', (done) => {
const errorMessage = 'Something went wrong on our end.'; const errorMessage = 'Something went wrong on our end.';
const deferred = $.Deferred();
spyOn($, 'ajax').and.returnValue(deferred.promise());
integrationSettingsForm.testSettings(formData); mock.onPut(integrationSettingsForm.testEndPoint).networkError();
deferred.reject(); integrationSettingsForm.testSettings(formData)
.then(() => {
expect($('.flash-container .flash-text').text().trim()).toEqual(errorMessage);
expect($('.flash-container .flash-text').text().trim()).toEqual(errorMessage); done();
})
.catch(done.fail);
}); });
it('should always call `toggleSubmitBtnState` with `false` once request is completed', () => { it('should always call `toggleSubmitBtnState` with `false` once request is completed', (done) => {
const deferred = $.Deferred(); mock.onPut(integrationSettingsForm.testEndPoint).networkError();
spyOn($, 'ajax').and.returnValue(deferred.promise());
integrationSettingsForm.testSettings(formData);
spyOn(integrationSettingsForm, 'toggleSubmitBtnState'); spyOn(integrationSettingsForm, 'toggleSubmitBtnState');
deferred.reject();
expect(integrationSettingsForm.toggleSubmitBtnState).toHaveBeenCalledWith(false); integrationSettingsForm.testSettings(formData)
.then(() => {
expect(integrationSettingsForm.toggleSubmitBtnState).toHaveBeenCalledWith(false);
done();
})
.catch(done.fail);
}); });
}); });
}); });
import MockAdaptor from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils';
import IssuableIndex from '~/issuable_index'; import IssuableIndex from '~/issuable_index';
describe('Issuable', () => { describe('Issuable', () => {
...@@ -19,6 +21,8 @@ describe('Issuable', () => { ...@@ -19,6 +21,8 @@ describe('Issuable', () => {
}); });
describe('resetIncomingEmailToken', () => { describe('resetIncomingEmailToken', () => {
let mock;
beforeEach(() => { beforeEach(() => {
const element = document.createElement('a'); const element = document.createElement('a');
element.classList.add('incoming-email-token-reset'); element.classList.add('incoming-email-token-reset');
...@@ -30,14 +34,28 @@ describe('Issuable', () => { ...@@ -30,14 +34,28 @@ describe('Issuable', () => {
document.body.appendChild(input); document.body.appendChild(input);
Issuable = new IssuableIndex('issue_'); Issuable = new IssuableIndex('issue_');
mock = new MockAdaptor(axios);
mock.onPut('foo').reply(200, {
new_address: 'testing123',
});
}); });
it('should send request to reset email token', () => { afterEach(() => {
spyOn(jQuery, 'ajax').and.callThrough(); mock.restore();
});
it('should send request to reset email token', (done) => {
spyOn(axios, 'put').and.callThrough();
document.querySelector('.incoming-email-token-reset').click(); document.querySelector('.incoming-email-token-reset').click();
expect(jQuery.ajax).toHaveBeenCalled(); setTimeout(() => {
expect(jQuery.ajax.calls.argsFor(0)[0].url).toEqual('foo'); expect(axios.put).toHaveBeenCalledWith('foo');
expect($('#issuable_email').val()).toBe('testing123');
done();
});
}); });
}); });
}); });
......
...@@ -1568,6 +1568,10 @@ describe MergeRequest do ...@@ -1568,6 +1568,10 @@ describe MergeRequest do
it 'returns false' do it 'returns false' do
expect(subject.mergeable_state?).to be_falsey expect(subject.mergeable_state?).to be_falsey
end end
it 'returns true when skipping discussions check' do
expect(subject.mergeable_state?(skip_discussions_check: true)).to be(true)
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment