Commit 699a30f0 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch...

Merge branch '35695-comment-appears-in-a-wrong-place-after-changing-diff-view-to-inline' into 'master'

Resolve "Comment appears in a wrong place after changing diff view to inline"

Closes #35695

See merge request !13156
parents 6e3eec16 fdfb4bbe
...@@ -15,7 +15,7 @@ module DiffHelper ...@@ -15,7 +15,7 @@ module DiffHelper
def diff_view def diff_view
@diff_view ||= begin @diff_view ||= begin
diff_views = %w(inline parallel) diff_views = %w(inline parallel)
diff_view = cookies[:diff_view] diff_view = params[:view] || cookies[:diff_view]
diff_view = diff_views.first unless diff_views.include?(diff_view) diff_view = diff_views.first unless diff_views.include?(diff_view)
diff_view.to_sym diff_view.to_sym
end end
......
---
title: Fix display of new diff comments after changing b between diff views
merge_request:
author:
...@@ -12,19 +12,32 @@ describe DiffHelper do ...@@ -12,19 +12,32 @@ describe DiffHelper do
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: diff_refs, repository: repository) } let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: diff_refs, repository: repository) }
describe 'diff_view' do describe 'diff_view' do
it 'uses the view param over the cookie' do
controller.params[:view] = 'parallel'
helper.request.cookies[:diff_view] = 'inline'
expect(helper.diff_view).to eq :parallel
end
it 'returns the default value when the view param is invalid' do
controller.params[:view] = 'invalid'
expect(helper.diff_view).to eq :inline
end
it 'returns a valid value when cookie is set' do it 'returns a valid value when cookie is set' do
helper.request.cookies[:diff_view] = 'parallel' helper.request.cookies[:diff_view] = 'parallel'
expect(helper.diff_view).to eq :parallel expect(helper.diff_view).to eq :parallel
end end
it 'returns a default value when cookie is invalid' do it 'returns the default value when cookie is invalid' do
helper.request.cookies[:diff_view] = 'invalid' helper.request.cookies[:diff_view] = 'invalid'
expect(helper.diff_view).to eq :inline expect(helper.diff_view).to eq :inline
end end
it 'returns a default value when cookie is nil' do it 'returns the default value when cookie is nil' do
expect(helper.request.cookies).to be_empty expect(helper.request.cookies).to be_empty
expect(helper.diff_view).to eq :inline expect(helper.diff_view).to eq :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