Commit 9c239405 authored by Fatih Acet's avatar Fatih Acet

Merge branch 'merge-request-enrvironments-link' into 'master'

Fixed merge request environment not displaying

Closes gitlab-ce#27080

See merge request !1154
parents 7cd9b800 0bf21d6a
......@@ -41,7 +41,6 @@
// ci_status_url - String, URL to use to check CI status
//
this.opts = opts;
this.$widgetBody = $('.mr-widget-body');
$('#modal_merge_info').modal({
show: false
});
......@@ -106,7 +105,7 @@
urlSuffix = deleteSourceBranch ? '?deleted_source_branch=true' : '';
return window.location.href = window.location.pathname + urlSuffix;
} else if (data.merge_error) {
return _this.$widgetBody.html("<h4>" + data.merge_error + "</h4>");
return $('.mr-widget-body').html("<h4>" + data.merge_error + "</h4>");
} else {
callback = function() {
return merge_request_widget.mergeInProgress(deleteSourceBranch);
......@@ -226,7 +225,7 @@
environment.ci_success_icon = this.$ciSuccessIcon;
const templateString = _.unescape($template[0].outerHTML);
const template = _.template(templateString)(environment);
this.$widgetBody.before(template);
$('.mr-widget-body').before(template);
}
};
......
---
title: Fixed merge request environment link not displaying
merge_request:
author:
require 'rails_helper'
describe 'Merge request', :feature, :js do
include WaitForAjax
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, source_project: project) }
before do
project.team << [user, :master]
login_as(user)
end
context 'new merge request' do
before do
visit new_namespace_project_merge_request_path(
project.namespace,
project,
merge_request: {
source_project_id: project.id,
target_project_id: project.id,
source_branch: 'feature',
target_branch: 'master'
}
)
end
it 'shows widget status after creating new merge request' do
click_button 'Submit merge request'
expect(find('.mr-state-widget')).to have_content('Checking ability to merge automatically')
wait_for_ajax
expect(page).to have_selector('.accept_merge_request')
end
end
context 'view merge request' do
let!(:environment) { create(:environment, project: project) }
let!(:deployment) { create(:deployment, environment: environment, ref: 'feature', sha: merge_request.diff_head_sha) }
before do
visit namespace_project_merge_request_path(project.namespace, project, merge_request)
end
it 'shows environments link' do
wait_for_ajax
page.within('.mr-widget-heading') do
expect(page).to have_content("Deployed to #{environment.name}")
expect(find('.js-environment-link')[:href]).to include(environment.formatted_external_url)
end
end
end
end
/* eslint-disable space-before-function-paren, quotes, comma-dangle, dot-notation, quote-props, no-var, max-len */
/*= require smart_interval */
/*= require merge_request_widget */
/*= require lib/utils/datetime_utility */
......@@ -73,7 +74,7 @@
}
it('should render less than a minute ago text', function() {
spyOn(this.class.$widgetBody, 'before').and.callFake(function(template) {
spyOn($('.mr-widget-body'), 'before').and.callFake(function(template) {
expect(getTimeagoText(template)).toBe('less than a minute ago.');
});
......@@ -85,7 +86,7 @@
oneHourAgo.setHours(oneHourAgo.getHours() - 1);
this.environments[0].deployed_at = oneHourAgo.toISOString();
spyOn(this.class.$widgetBody, 'before').and.callFake(function(template) {
spyOn($('.mr-widget-body'), 'before').and.callFake(function(template) {
expect(getTimeagoText(template)).toBe('about an hour ago.');
});
......@@ -97,7 +98,7 @@
twoHoursAgo.setHours(twoHoursAgo.getHours() - 2);
this.environments[0].deployed_at = twoHoursAgo.toISOString();
spyOn(this.class.$widgetBody, 'before').and.callFake(function(template) {
spyOn($('.mr-widget-body'), 'before').and.callFake(function(template) {
expect(getTimeagoText(template)).toBe('about 2 hours ago.');
});
......@@ -108,7 +109,7 @@
describe('mergeInProgress', function() {
it('should display error with h4 tag', function() {
spyOn(this.class.$widgetBody, 'html').and.callFake(function(html) {
spyOn($('.mr-widget-body'), 'html').and.callFake(function(html) {
expect(html).toBe('<h4>Sorry, something went wrong.</h4>');
});
spyOn($, 'ajax').and.callFake(function(e) {
......
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