gitlab-org--gitlab-foss/spec/controllers/projects/refs_controller_spec.rb

57 lines
1.2 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe Projects::RefsController do
let(:project) { create(:project, :repository) }
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,
project_id: project,
2015-06-23 01:24:39 -04:00
id: 'master',
path: 'foo/bar/baz.html',
format: format
end
2017-11-03 07:27:02 -04:00
def xhr_get(format = :html)
2015-06-23 01:24:39 -04:00
xhr :get,
:logs_tree,
namespace_id: project.namespace.to_param,
2017-11-01 12:48:47 -04:00
project_id: project,
id: 'master',
2017-11-03 07:27:02 -04:00
path: 'foo/bar/baz.html',
2017-11-01 12:48:47 -04:00
format: format
end
it 'never throws MissingTemplate' do
expect { default_get }.not_to raise_error
2017-11-01 12:48:47 -04:00
expect { xhr_get(:json) }.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
2017-11-01 12:48:47 -04:00
it 'renders JSON' do
2017-11-03 07:27:02 -04:00
xhr_get(:json)
2017-11-01 12:48:47 -04:00
expect(response).to be_success
expect(json_response).to be_kind_of(Array)
end
end
end