2015-04-06 23:02:06 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::RefsController do
|
2017-01-25 16:44:33 -05:00
|
|
|
let(:project) { create(:project, :repository) }
|
2015-04-06 23:02:06 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
project.team << [user, :developer]
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #logs_tree' do
|
|
|
|
def default_get(format = :html)
|
2015-06-23 01:24:39 -04:00
|
|
|
get :logs_tree,
|
|
|
|
namespace_id: project.namespace.to_param,
|
2017-02-23 18:55:01 -05:00
|
|
|
project_id: project,
|
2015-06-23 01:24:39 -04:00
|
|
|
id: 'master',
|
|
|
|
path: 'foo/bar/baz.html',
|
|
|
|
format: format
|
2015-04-06 23:02:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def xhr_get(format = :html)
|
2015-06-23 01:24:39 -04:00
|
|
|
xhr :get,
|
|
|
|
:logs_tree,
|
|
|
|
namespace_id: project.namespace.to_param,
|
2017-02-23 18:55:01 -05:00
|
|
|
project_id: project, id: 'master',
|
2015-06-23 01:24:39 -04:00
|
|
|
path: 'foo/bar/baz.html', format: format
|
2015-04-06 23:02:06 -04:00
|
|
|
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
|