diff options
4 files changed, 56 insertions, 8 deletions
diff --git a/app/assets/javascripts/mirrors/mirror_repos.js b/app/assets/javascripts/mirrors/mirror_repos.js index 0d8f31d6bfc..196b84621b6 100644 --- a/app/assets/javascripts/mirrors/mirror_repos.js +++ b/app/assets/javascripts/mirrors/mirror_repos.js @@ -30,6 +30,7 @@ export default class MirrorRepos { this.$password.on('input.updateUrl', () => this.debouncedUpdateUrl()); this.initMirrorSSH(); + this.updateProtectedBranches(); } initMirrorSSH() { diff --git a/app/views/projects/mirrors/_mirror_repos.html.haml b/app/views/projects/mirrors/_mirror_repos.html.haml index 2f9bd5b04b6..dde0fae740b 100644 --- a/app/views/projects/mirrors/_mirror_repos.html.haml +++ b/app/views/projects/mirrors/_mirror_repos.html.haml @@ -32,7 +32,7 @@ = link_to icon('question-circle'), help_page_path('user/project/protected_branches') .panel-footer - = f.submit _('Mirror repository'), class: 'btn btn-success', name: :update_remote_mirror + = f.submit _('Mirror repository'), class: 'btn btn-success js-mirror-submit', name: :update_remote_mirror .panel.panel-default .table-responsive diff --git a/changelogs/unreleased/sh-fix-mirrors-protected-branches.yml b/changelogs/unreleased/sh-fix-mirrors-protected-branches.yml new file mode 100644 index 00000000000..627de25650d --- /dev/null +++ b/changelogs/unreleased/sh-fix-mirrors-protected-branches.yml @@ -0,0 +1,5 @@ +--- +title: Fix "protected branches only" checkbox not set properly at init +merge_request: 23409 +author: +type: fixed diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb index 401aac9478d..b7a22316d26 100644 --- a/spec/features/projects/settings/repository_settings_spec.rb +++ b/spec/features/projects/settings/repository_settings_spec.rb @@ -133,19 +133,50 @@ describe 'Projects > Settings > Repository settings' do expect(page).to have_selector('#mirror_direction') end - it 'generates an SSH public key on submission', :js do + it 'creates a push mirror that mirrors all branches', :js do + expect(find('.js-mirror-protected-hidden', visible: false).value).to eq('0') + fill_in 'url', with: 'ssh://user@localhost/project.git' select 'SSH public key', from: 'Authentication method' - direction_select = find('#mirror_direction') + select_direction - # In CE, this select box is disabled, but in EE, it is enabled - if direction_select.disabled? - expect(direction_select.value).to eq('push') - else - direction_select.select('Push') + Sidekiq::Testing.fake! do + click_button 'Mirror repository' end + project.reload + + expect(page).to have_content('Mirroring settings were successfully updated') + expect(project.remote_mirrors.first.only_protected_branches).to eq(false) + end + + it 'creates a push mirror that only mirrors protected branches', :js do + find('#only_protected_branches').click + + expect(find('.js-mirror-protected-hidden', visible: false).value).to eq('1') + + fill_in 'url', with: 'ssh://user@localhost/project.git' + select 'SSH public key', from: 'Authentication method' + + select_direction + + Sidekiq::Testing.fake! do + click_button 'Mirror repository' + end + + project.reload + + expect(page).to have_content('Mirroring settings were successfully updated') + expect(project.remote_mirrors.first.only_protected_branches).to eq(true) + end + + it 'generates an SSH public key on submission', :js do + fill_in 'url', with: 'ssh://user@localhost/project.git' + select 'SSH public key', from: 'Authentication method' + + select_direction + Sidekiq::Testing.fake! do click_button 'Mirror repository' end @@ -153,6 +184,17 @@ describe 'Projects > Settings > Repository settings' do expect(page).to have_content('Mirroring settings were successfully updated') expect(page).to have_selector('[title="Copy SSH public key"]') end + + def select_direction(direction = 'push') + direction_select = find('#mirror_direction') + + # In CE, this select box is disabled, but in EE, it is enabled + if direction_select.disabled? + expect(direction_select.value).to eq(direction) + else + direction_select.select(direction.capitalize) + end + end end end end |