debian-mirror-gitlab/spec/controllers/projects/refs_controller_spec.rb

57 lines
1.2 KiB
Ruby
Raw Normal View History

2015-04-26 12:48:37 +05:30
require 'spec_helper'
describe Projects::RefsController do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
2015-04-26 12:48:37 +05:30
let(:user) { create(:user) }
before do
sign_in(user)
2018-03-17 18:26:18 +05:30
project.add_developer(user)
2015-04-26 12:48:37 +05:30
end
describe 'GET #logs_tree' do
def default_get(format = :html)
2015-09-11 14:41:01 +05:30
get :logs_tree,
namespace_id: project.namespace.to_param,
2017-08-17 22:00:37 +05:30
project_id: project,
2015-09-11 14:41:01 +05:30
id: 'master',
path: 'foo/bar/baz.html',
format: format
2015-04-26 12:48:37 +05:30
end
def xhr_get(format = :html)
2015-09-11 14:41:01 +05:30
xhr :get,
:logs_tree,
namespace_id: project.namespace.to_param,
2018-03-17 18:26:18 +05:30
project_id: project,
id: 'master',
path: 'foo/bar/baz.html',
format: format
2015-04-26 12:48:37 +05:30
end
it 'never throws MissingTemplate' do
expect { default_get }.not_to raise_error
2018-03-17 18:26:18 +05:30
expect { xhr_get(:json) }.not_to raise_error
2015-04-26 12:48:37 +05:30
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
2018-03-17 18:26:18 +05:30
it 'renders JSON' do
xhr_get(:json)
expect(response).to be_success
expect(json_response).to be_kind_of(Array)
end
2015-04-26 12:48:37 +05:30
end
end