Commit 4902dca9 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'rs-issue-2152' into 'master'

Render a 404 when RefsController#logs_tree gets an HTML request

Fixes #2152

See merge request !1748
parents 584fa0bd 167a6b9e
......@@ -55,5 +55,10 @@ class Projects::RefsController < Projects::ApplicationController
commit: last_commit
}
end
respond_to do |format|
format.html { render_404 }
format.js
end
end
end
require 'spec_helper'
describe Projects::RefsController do
let(:project) { create(:project) }
let(:user) { create(:user) }
before do
sign_in(user)
project.team << [user, :developer]
end
describe 'GET #logs_tree' do
def default_get(format = :html)
get :logs_tree, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: 'master',
path: 'foo/bar/baz.html', format: format
end
def xhr_get(format = :html)
xhr :get, :logs_tree, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: 'master',
path: 'foo/bar/baz.html', format: format
end
it 'never throws MissingTemplate' do
expect { default_get }.not_to raise_error
expect { xhr_get }.not_to raise_error
end
it 'renders 404 for non-JS requests' do
xhr_get
expect(response).to be_not_found
end
it 'renders JS' do
xhr_get(:js)
expect(response).to be_success
end
end
end
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