2019-04-15 10:17:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-04-07 03:02:06 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::RefsController do
|
2017-01-25 21:44:33 +00:00
|
|
|
let(:project) { create(:project, :repository) }
|
2015-04-07 03:02:06 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
2017-12-22 08:18:28 +00:00
|
|
|
project.add_developer(user)
|
2015-04-07 03:02:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #logs_tree' do
|
|
|
|
def default_get(format = :html)
|
2015-06-23 05:24:39 +00:00
|
|
|
get :logs_tree,
|
2018-12-17 22:52:17 +00:00
|
|
|
params: {
|
|
|
|
namespace_id: project.namespace.to_param,
|
|
|
|
project_id: project,
|
|
|
|
id: 'master',
|
|
|
|
path: 'foo/bar/baz.html'
|
|
|
|
},
|
2015-06-23 05:24:39 +00:00
|
|
|
format: format
|
2015-04-07 03:02:06 +00:00
|
|
|
end
|
|
|
|
|
2017-11-03 11:27:02 +00:00
|
|
|
def xhr_get(format = :html)
|
2018-12-19 21:57:41 +00:00
|
|
|
get :logs_tree, params: {
|
|
|
|
namespace_id: project.namespace.to_param,
|
|
|
|
project_id: project,
|
|
|
|
id: 'master',
|
|
|
|
path: 'foo/bar/baz.html',
|
|
|
|
format: format
|
|
|
|
}, xhr: true
|
2015-04-07 03:02:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'never throws MissingTemplate' do
|
|
|
|
expect { default_get }.not_to raise_error
|
2017-11-01 16:48:47 +00:00
|
|
|
expect { xhr_get(:json) }.not_to raise_error
|
2015-04-07 03:02:06 +00:00
|
|
|
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
|
2019-04-06 12:04:27 +00:00
|
|
|
expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original
|
|
|
|
|
2015-04-07 03:02:06 +00:00
|
|
|
xhr_get(:js)
|
2019-08-19 09:55:20 +00:00
|
|
|
expect(response).to be_successful
|
2015-04-07 03:02:06 +00:00
|
|
|
end
|
2017-11-01 16:48:47 +00:00
|
|
|
|
|
|
|
it 'renders JSON' do
|
2019-04-06 12:04:27 +00:00
|
|
|
expect(::Gitlab::GitalyClient).to receive(:allow_ref_name_caching).and_call_original
|
|
|
|
|
2017-11-03 11:27:02 +00:00
|
|
|
xhr_get(:json)
|
2017-11-01 16:48:47 +00:00
|
|
|
|
2019-08-19 09:55:20 +00:00
|
|
|
expect(response).to be_successful
|
2017-11-01 16:48:47 +00:00
|
|
|
expect(json_response).to be_kind_of(Array)
|
|
|
|
end
|
2015-04-07 03:02:06 +00:00
|
|
|
end
|
|
|
|
end
|