diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-01-23 22:54:06 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-01-23 22:54:06 +0100 |
commit | c4613f09e24371b0d06641aff9746701e3f590c3 (patch) | |
tree | d7bde780836b54c533a265cd198a80f22280f756 | |
parent | c26c1b6c054d5c55795c683658612e0f14ccfa43 (diff) | |
download | gitlab-ci-c4613f09e24371b0d06641aff9746701e3f590c3.tar.gz |
Use hostname as default runner's description
-rw-r--r-- | lib/api/runners.rb | 4 | ||||
-rw-r--r-- | spec/requests/api/runners_spec.rb | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/api/runners.rb b/lib/api/runners.rb index f8239a1..79d0b56 100644 --- a/lib/api/runners.rb +++ b/lib/api/runners.rb @@ -33,10 +33,10 @@ module API runner = if params[:token] == GitlabCi::REGISTRATION_TOKEN # Create shared runner. Requires admin access - Runner.create + Runner.create(description: params[:hostname]) elsif project = Project.find_by(token: params[:token]) # Create a specific runner for project. - project.runners.create + project.runners.create(description: params[:hostname]) end return forbidden! unless runner diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index 7e35e5b..eb5e0ae 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -45,6 +45,13 @@ describe API::API do it { response.status.should == 201 } end + describe "should create a runner with description" do + before { post api("/runners/register"), token: GitlabCi::REGISTRATION_TOKEN, hostname: "server.hostname" } + + it { response.status.should == 201 } + it { Runner.first.description.should == "server.hostname" } + end + describe "should create a runner if project token provided" do let(:project) { FactoryGirl.create(:project) } before { post api("/runners/register"), token: project.token } |