diff options
-rw-r--r-- | app/views/projects/branches/_branch.html.haml | 3 | ||||
-rw-r--r-- | changelogs/unreleased/9841-geo-unable-to-compare-branches-on-secondary.yml | 5 | ||||
-rw-r--r-- | spec/features/projects/branches_spec.rb | 32 |
3 files changed, 38 insertions, 2 deletions
diff --git a/app/views/projects/branches/_branch.html.haml b/app/views/projects/branches/_branch.html.haml index c64ad1c8147..91c51d5e091 100644 --- a/app/views/projects/branches/_branch.html.haml +++ b/app/views/projects/branches/_branch.html.haml @@ -53,9 +53,8 @@ = _('Merge request') - if branch.name != @repository.root_ref - = link_to project_compare_index_path(@project, from: @repository.root_ref, to: branch.name), + = link_to project_compare_path(@project, @repository.root_ref, branch.name), class: "btn btn-default #{'prepend-left-10' unless merge_project}", - method: :post, title: s_('Branches|Compare') do = s_('Branches|Compare') diff --git a/changelogs/unreleased/9841-geo-unable-to-compare-branches-on-secondary.yml b/changelogs/unreleased/9841-geo-unable-to-compare-branches-on-secondary.yml new file mode 100644 index 00000000000..c014edf9c09 --- /dev/null +++ b/changelogs/unreleased/9841-geo-unable-to-compare-branches-on-secondary.yml @@ -0,0 +1,5 @@ +--- +title: Allow users to compare branches on a read-only instance +merge_request: 25414 +author: +type: fixed diff --git a/spec/features/projects/branches_spec.rb b/spec/features/projects/branches_spec.rb index 97757e8da92..ee71c843b80 100644 --- a/spec/features/projects/branches_spec.rb +++ b/spec/features/projects/branches_spec.rb @@ -229,6 +229,38 @@ describe 'Branches' do end end + describe 'comparing branches' do + before do + sign_in(user) + project.add_developer(user) + end + + shared_examples 'compares branches' do + it 'compares branches' do + visit project_branches_path(project) + + page.within first('.all-branches li') do + click_link 'Compare' + end + + expect(page).to have_content 'Commits' + expect(page).to have_link 'Create merge request' + end + end + + context 'on a read-only instance' do + before do + allow(Gitlab::Database).to receive(:read_only?).and_return(true) + end + + it_behaves_like 'compares branches' + end + + context 'on a read-write instance' do + it_behaves_like 'compares branches' + end + end + def sorted_branches(repository, count:, sort_by:, state: nil) branches = repository.branches_sorted_by(sort_by) branches = branches.select { |b| state == 'active' ? b.active? : b.stale? } if state |