debian-mirror-gitlab/spec/requests/api/templates_spec.rb

56 lines
1.6 KiB
Ruby
Raw Normal View History

2016-06-22 15:30:34 +05:30
require 'spec_helper'
describe API::Templates, api: true do
include ApiHelpers
2016-09-13 17:45:13 +05:30
context 'global templates' do
describe 'the Template Entity' do
before { get api('/gitignores/Ruby') }
2016-06-22 15:30:34 +05:30
2016-09-13 17:45:13 +05:30
it { expect(json_response['name']).to eq('Ruby') }
it { expect(json_response['content']).to include('*.gem') }
end
2016-06-22 15:30:34 +05:30
2016-09-13 17:45:13 +05:30
describe 'the TemplateList Entity' do
before { get api('/gitignores') }
2016-06-22 15:30:34 +05:30
2016-09-13 17:45:13 +05:30
it { expect(json_response.first['name']).not_to be_nil }
it { expect(json_response.first['content']).to be_nil }
end
2016-06-22 15:30:34 +05:30
2016-09-13 17:45:13 +05:30
context 'requesting gitignores' do
describe 'GET /gitignores' do
it 'returns a list of available gitignore templates' do
get api('/gitignores')
2016-06-22 15:30:34 +05:30
2016-09-13 17:45:13 +05:30
expect(response.status).to eq(200)
expect(json_response).to be_an Array
expect(json_response.size).to be > 15
end
2016-06-22 15:30:34 +05:30
end
end
2016-09-13 17:45:13 +05:30
context 'requesting gitlab-ci-ymls' do
describe 'GET /gitlab_ci_ymls' do
it 'returns a list of available gitlab_ci_ymls' do
get api('/gitlab_ci_ymls')
2016-06-22 15:30:34 +05:30
2016-09-13 17:45:13 +05:30
expect(response.status).to eq(200)
expect(json_response).to be_an Array
expect(json_response.first['name']).not_to be_nil
end
2016-06-22 15:30:34 +05:30
end
end
2016-09-13 17:45:13 +05:30
describe 'GET /gitlab_ci_ymls/Ruby' do
it 'adds a disclaimer on the top' do
get api('/gitlab_ci_ymls/Ruby')
2016-06-22 15:30:34 +05:30
2016-09-13 17:45:13 +05:30
expect(response).to have_http_status(200)
expect(json_response['name']).not_to be_nil
expect(json_response['content']).to start_with("# This file is a template,")
end
2016-06-22 15:30:34 +05:30
end
end
end