Hides merge request section in edit project when disabled
This commit is contained in:
parent
fd1741b479
commit
4da474ca92
3 changed files with 75 additions and 15 deletions
|
@ -15,18 +15,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectNew.prototype.toggleSettings = function() {
|
ProjectNew.prototype.toggleSettings = function() {
|
||||||
this._showOrHide('#project_builds_enabled', '.builds-feature');
|
this._showOrHide('#project_project_feature_attributes_builds_access_level', '.builds-feature');
|
||||||
return this._showOrHide('#project_merge_requests_enabled', '.merge-requests-feature');
|
this._showOrHide('#project_project_feature_attributes_merge_requests_access_level', '.merge-requests-feature');
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectNew.prototype.toggleSettingsOnclick = function() {
|
ProjectNew.prototype.toggleSettingsOnclick = function() {
|
||||||
return $('#project_builds_enabled, #project_merge_requests_enabled').on('click', this.toggleSettings);
|
$('#project_project_feature_attributes_builds_access_level, #project_project_feature_attributes_merge_requests_access_level').on('change', this.toggleSettings);
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectNew.prototype._showOrHide = function(checkElement, container) {
|
ProjectNew.prototype._showOrHide = function(checkElement, container) {
|
||||||
var $container;
|
var $container;
|
||||||
$container = $(container);
|
$container = $(container);
|
||||||
if ($(checkElement).prop('checked')) {
|
if ($(checkElement).val() !== '0') {
|
||||||
return $container.show();
|
return $container.show();
|
||||||
} else {
|
} else {
|
||||||
return $container.hide();
|
return $container.hide();
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
%fieldset.builds-feature
|
.merge-requests-feature
|
||||||
|
%fieldset.builds-feature
|
||||||
|
%hr
|
||||||
%h5.prepend-top-0
|
%h5.prepend-top-0
|
||||||
Merge Requests
|
Merge Requests
|
||||||
.form-group
|
.form-group
|
||||||
|
@ -6,6 +8,7 @@
|
||||||
= f.label :only_allow_merge_if_build_succeeds do
|
= f.label :only_allow_merge_if_build_succeeds do
|
||||||
= f.check_box :only_allow_merge_if_build_succeeds
|
= f.check_box :only_allow_merge_if_build_succeeds
|
||||||
%strong Only allow merge requests to be merged if the build succeeds
|
%strong Only allow merge requests to be merged if the build succeeds
|
||||||
.help-block
|
%br
|
||||||
|
%span.descr
|
||||||
Builds need to be configured to enable this feature.
|
Builds need to be configured to enable this feature.
|
||||||
= link_to icon('question-circle'), help_page_path('workflow/merge_requests', anchor: 'only-allow-merge-requests-to-be-merged-if-the-build-succeeds')
|
= link_to icon('question-circle'), help_page_path('workflow/merge_requests', anchor: 'only-allow-merge-requests-to-be-merged-if-the-build-succeeds')
|
||||||
|
|
57
spec/features/projects/edit_spec.rb
Normal file
57
spec/features/projects/edit_spec.rb
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
feature 'Project edit', feature: true, js: true do
|
||||||
|
include WaitForAjax
|
||||||
|
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
let(:project) { create(:project) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
project.team << [user, :master]
|
||||||
|
login_as(user)
|
||||||
|
|
||||||
|
visit edit_namespace_project_path(project.namespace, project)
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'feature visibility' do
|
||||||
|
context 'merge requests select' do
|
||||||
|
it 'hides merge requests section' do
|
||||||
|
select('Disabled', from: 'project_project_feature_attributes_merge_requests_access_level')
|
||||||
|
|
||||||
|
expect(page).to have_selector('.merge-requests-feature', visible: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'hides merge requests section after save' do
|
||||||
|
select('Disabled', from: 'project_project_feature_attributes_merge_requests_access_level')
|
||||||
|
|
||||||
|
expect(page).to have_selector('.merge-requests-feature', visible: false)
|
||||||
|
|
||||||
|
click_button 'Save changes'
|
||||||
|
|
||||||
|
wait_for_ajax
|
||||||
|
|
||||||
|
expect(page).to have_selector('.merge-requests-feature', visible: false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'builds select' do
|
||||||
|
it 'hides merge requests section' do
|
||||||
|
select('Disabled', from: 'project_project_feature_attributes_builds_access_level')
|
||||||
|
|
||||||
|
expect(page).to have_selector('.builds-feature', visible: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'hides merge requests section after save' do
|
||||||
|
select('Disabled', from: 'project_project_feature_attributes_builds_access_level')
|
||||||
|
|
||||||
|
expect(page).to have_selector('.builds-feature', visible: false)
|
||||||
|
|
||||||
|
click_button 'Save changes'
|
||||||
|
|
||||||
|
wait_for_ajax
|
||||||
|
|
||||||
|
expect(page).to have_selector('.builds-feature', visible: false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue