Commit 9ba72378 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Refactor CI API specs for creating runner

parent b253aa32
......@@ -12,44 +12,56 @@ describe Ci::API::API do
end
describe "POST /runners/register" do
describe "should create a runner if token provided" do
context 'when runner token is provided' do
before { post ci_api("/runners/register"), token: registration_token }
it { expect(response.status).to eq(201) }
it 'creates runner' do
expect(response.status).to eq(201)
end
end
describe "should create a runner with description" do
context 'when runner description is provided' do
before { post ci_api("/runners/register"), token: registration_token, description: "server.hostname" }
it { expect(response.status).to eq(201) }
it { expect(Ci::Runner.first.description).to eq("server.hostname") }
it 'creates runner' do
expect(response.status).to eq(201)
expect(Ci::Runner.first.description).to eq("server.hostname")
end
end
describe "should create a runner with tags" do
context 'when runner tags are provided' do
before { post ci_api("/runners/register"), token: registration_token, tag_list: "tag1, tag2" }
it { expect(response.status).to eq(201) }
it { expect(Ci::Runner.first.tag_list.sort).to eq(["tag1", "tag2"]) }
it 'creates runner' do
expect(response.status).to eq(201)
expect(Ci::Runner.first.tag_list.sort).to eq(["tag1", "tag2"])
end
end
describe "should create a runner if project token provided" do
context 'when project token is provided' do
let(:project) { FactoryGirl.create(:empty_project) }
before { post ci_api("/runners/register"), token: project.runners_token }
it { expect(response.status).to eq(201) }
it { expect(project.runners.size).to eq(1) }
it 'creates runner' do
expect(response.status).to eq(201)
expect(project.runners.size).to eq(1)
end
end
it "should return 403 error if token is invalid" do
post ci_api("/runners/register"), token: 'invalid'
context 'when token is invalid' do
it 'returns 403 error' do
post ci_api("/runners/register"), token: 'invalid'
expect(response.status).to eq(403)
expect(response.status).to eq(403)
end
end
it "should return 400 error if no token" do
post ci_api("/runners/register")
context 'when no token provided' do
it 'returns 400 error' do
post ci_api("/runners/register")
expect(response.status).to eq(400)
expect(response.status).to eq(400)
end
end
%w(name version revision platform architecture).each do |param|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment