Rename metadata => annotations

This commit is contained in:
Henrik Hodne 2013-07-10 16:55:03 -07:00
parent d92c4a0fdd
commit be2c538d9e
3 changed files with 21 additions and 21 deletions

View File

@ -28,15 +28,15 @@ class Travis::Api::App
end end
end end
get "/:job_id/metadata" do get "/:job_id/annotations" do
respond_with service(:find_metadata, params) respond_with service(:find_annotations, params)
end end
put "/:job_id/metadata" do post "/:job_id/annotations" do
if params[:description] if params[:description]
metadata = service(:update_metadata, params).run annotation = service(:update_annotation, params).run
status metadata ? 204 : 401 status annotation ? 204 : 401
else else
status 422 status 422

View File

@ -76,33 +76,33 @@ describe 'Jobs' do
end end
end end
it "GET /jobs/:id/metadata" do it "GET /jobs/:id/annotations" do
metadata_provider = Factory(:metadata_provider) annotation_provider = Factory(:annotation_provider)
metadata = metadata_provider.metadata.create(job_id: job.id, description: "Foobar") annotation = annotation_provider.annotations.create(job_id: job.id, description: "Foobar")
response = get "/jobs/#{job.id}/metadata", {}, headers response = get "/jobs/#{job.id}/annotations", {}, headers
response.should deliver_json_for(Metadata.where(id: metadata.id), version: 'v2') response.should deliver_json_for(Annotation.where(id: annotation.id), version: 'v2')
end end
describe "PUT /jobs/:id/metadata" do describe "POST /jobs/:id/annotations" do
context "with valid credentials" do context "with valid credentials" do
it "responds with a 204" do it "responds with a 204" do
metadata_provider = Factory(:metadata_provider) annotation_provider = Factory(:annotation_provider)
response = put "/jobs/#{job.id}/metadata", { username: metadata_provider.api_username, key: metadata_provider.api_key, description: "Foobar" }, headers response = post "/jobs/#{job.id}/annotations", { username: annotation_provider.api_username, key: annotation_provider.api_key, description: "Foobar" }, headers
response.status.should eq(204) response.status.should eq(204)
end end
end end
context "without a description" do context "without a description" do
it "responds with a 422" do it "responds with a 422" do
metadata_provider = Factory(:metadata_provider) annotation_provider = Factory(:annotation_provider)
response = put "/jobs/#{job.id}/metadata", { username: metadata_provider.api_username, key: metadata_provider.api_key }, headers response = post "/jobs/#{job.id}/annotations", { username: annotation_provider.api_username, key: annotation_provider.api_key }, headers
response.status.should eq(422) response.status.should eq(422)
end end
end end
context "with invalid credentials" do context "with invalid credentials" do
it "responds with a 401" do it "responds with a 401" do
response = put "/jobs/#{job.id}/metadata", { username: "invalid-username", key: "invalid-key", description: "Foobar" }, headers response = post "/jobs/#{job.id}/annotations", { username: "invalid-username", key: "invalid-key", description: "Foobar" }, headers
response.status.should eq(401) response.status.should eq(401)
end end
end end

View File

@ -2,13 +2,13 @@ require 'spec_helper'
describe Travis::Api::App::Endpoint::Jobs do describe Travis::Api::App::Endpoint::Jobs do
let(:job) { Factory(:test) } let(:job) { Factory(:test) }
let(:provider) { Factory(:metadata_provider) } let(:provider) { Factory(:annotation_provider) }
it "GET /jobs/:id/metadata" do it "GET /jobs/:id/annotations" do
get("/jobs/#{job.id}/metadata", {}, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_ok get("/jobs/#{job.id}/annotations", {}, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_ok
end end
it "PUT /jobs/:id/metadata" do it "POST /jobs/:id/annotations" do
response = put("/jobs/#{job.id}/metadata", { "username" => provider.api_username, "key" => provider.api_key, "description" => "Foobar" }, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_successful response = post("/jobs/#{job.id}/annotations", { "username" => provider.api_username, "key" => provider.api_key, "description" => "Foobar" }, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_successful
end end
end end