Commit f6d816f9 authored by Rémy Coutable's avatar Rémy Coutable

Add a controller test for the new 'diff_view' cookie

parent cf1349ad
...@@ -26,15 +26,13 @@ class Projects::ApplicationController < ApplicationController ...@@ -26,15 +26,13 @@ class Projects::ApplicationController < ApplicationController
end end
end end
protected private
def apply_diff_view_cookie! def apply_diff_view_cookie!
view = params[:view] || cookies[:diff_view] view = params[:view] || cookies[:diff_view]
cookies.permanent[:diff_view] = params[:view] = view if view cookies.permanent[:diff_view] = params[:view] = view if view
end end
private
def builds_enabled def builds_enabled
return render_404 unless @project.builds_enabled? return render_404 unless @project.builds_enabled?
end end
......
...@@ -199,6 +199,18 @@ describe Projects::MergeRequestsController do ...@@ -199,6 +199,18 @@ describe Projects::MergeRequestsController do
end end
end end
describe 'GET diffs with view' do
it 'saves the preferred diff view in a cookie' do
get :diffs,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
view: 'parallel'
expect(response.cookies['diff_view']).to eq('parallel')
end
end
describe 'GET commits' do describe 'GET commits' do
def go(format: 'html') def go(format: 'html')
get :commits, get :commits,
......
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