diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index 996909a28c6805156e19f26705843fad413b39a1..91315a07debcff03bba0db8f7e0578847fac0dd0 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -83,6 +83,7 @@ class Projects::ApplicationController < ApplicationController end def apply_diff_view_cookie! + @show_changes_tab = params[:view].present? cookies.permanent[:diff_view] = params.delete(:view) if params[:view].present? end diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 696f71921314c4f6b37c784e67db6b64a9920da3..4c1f38be9f393cbc701ab6e6f7a7ee23840909af 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -216,7 +216,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController @base_commit = @merge_request.diff_base_commit @diffs = @merge_request.diffs(diff_options) if @merge_request.compare @diff_notes_disabled = true - @show_diff_tab = check_diff_tab @pipeline = @merge_request.pipeline @statuses = @pipeline.statuses.relevant if @pipeline @@ -520,10 +519,4 @@ class Projects::MergeRequestsController < Projects::ApplicationController params[:merge_request] ||= ActionController::Parameters.new(source_project: @project) @merge_request = MergeRequests::BuildService.new(project, current_user, merge_request_params).execute end - - private - - def check_diff_tab - request.query_parameters[:view].present? - end end diff --git a/app/views/projects/merge_requests/_new_submit.html.haml b/app/views/projects/merge_requests/_new_submit.html.haml index 0b05a2693a6c11c55de050e34a9dfe4dc5459464..00bd4e143dff1ad3d0a1a6a944867815c5e433a1 100644 --- a/app/views/projects/merge_requests/_new_submit.html.haml +++ b/app/views/projects/merge_requests/_new_submit.html.haml @@ -54,6 +54,6 @@ }); :javascript var merge_request = new MergeRequest({ - action: "#{(@show_diff_tab ? 'diffs' : 'new')}", - setUrl: false + action: "#{(@show_changes_tab ? 'diffs' : 'new')}", + setUrl: false }); diff --git a/spec/features/merge_requests/create_new_mr_spec.rb b/spec/features/merge_requests/create_new_mr_spec.rb index 775b38814eb0abaec2ec1c015f0d5e6ca2fb2d60..b963d1305b5315314ff50e6a1f2f869f776bbc6e 100644 --- a/spec/features/merge_requests/create_new_mr_spec.rb +++ b/spec/features/merge_requests/create_new_mr_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' feature 'Create New Merge Request', feature: true, js: true do - include WaitForAjax - let(:user) { create(:user) } let(:project) { create(:project, :public) } @@ -51,11 +49,10 @@ feature 'Create New Merge Request', feature: true, js: true do click_link 'Changes' - expect(page.find_link('Inline')[:class]).to match(/\bactive\b/) - expect(page.find_link('Side-by-side')[:class]).not_to match(/\bactive\b/) + expect(page).to have_css('a.btn.active', text: 'Inline') + expect(page).not_to have_css('a.btn.active', text: 'Side-by-side') click_link 'Side-by-side' - wait_for_ajax within '.merge-request' do expect(page).not_to have_css('a.btn.active', text: 'Inline')