Commit 22ce76d4 authored by Ruben Davila's avatar Ruben Davila

Refactor to mark Changes tab as active on new MR page.

parent bac19f4c
......@@ -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
......
......@@ -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
......@@ -54,6 +54,6 @@
});
:javascript
var merge_request = new MergeRequest({
action: "#{(@show_diff_tab ? 'diffs' : 'new')}",
action: "#{(@show_changes_tab ? 'diffs' : 'new')}",
setUrl: false
});
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')
......
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