Rename metadata => annotations
This commit is contained in:
parent
d92c4a0fdd
commit
be2c538d9e
|
@ -28,15 +28,15 @@ class Travis::Api::App
|
|||
end
|
||||
end
|
||||
|
||||
get "/:job_id/metadata" do
|
||||
respond_with service(:find_metadata, params)
|
||||
get "/:job_id/annotations" do
|
||||
respond_with service(:find_annotations, params)
|
||||
end
|
||||
|
||||
put "/:job_id/metadata" do
|
||||
post "/:job_id/annotations" do
|
||||
if params[:description]
|
||||
metadata = service(:update_metadata, params).run
|
||||
annotation = service(:update_annotation, params).run
|
||||
|
||||
status metadata ? 204 : 401
|
||||
status annotation ? 204 : 401
|
||||
else
|
||||
status 422
|
||||
|
||||
|
|
|
@ -76,33 +76,33 @@ describe 'Jobs' do
|
|||
end
|
||||
end
|
||||
|
||||
it "GET /jobs/:id/metadata" do
|
||||
metadata_provider = Factory(:metadata_provider)
|
||||
metadata = metadata_provider.metadata.create(job_id: job.id, description: "Foobar")
|
||||
response = get "/jobs/#{job.id}/metadata", {}, headers
|
||||
response.should deliver_json_for(Metadata.where(id: metadata.id), version: 'v2')
|
||||
it "GET /jobs/:id/annotations" do
|
||||
annotation_provider = Factory(:annotation_provider)
|
||||
annotation = annotation_provider.annotations.create(job_id: job.id, description: "Foobar")
|
||||
response = get "/jobs/#{job.id}/annotations", {}, headers
|
||||
response.should deliver_json_for(Annotation.where(id: annotation.id), version: 'v2')
|
||||
end
|
||||
|
||||
describe "PUT /jobs/:id/metadata" do
|
||||
describe "POST /jobs/:id/annotations" do
|
||||
context "with valid credentials" do
|
||||
it "responds with a 204" do
|
||||
metadata_provider = Factory(:metadata_provider)
|
||||
response = put "/jobs/#{job.id}/metadata", { username: metadata_provider.api_username, key: metadata_provider.api_key, description: "Foobar" }, headers
|
||||
annotation_provider = Factory(:annotation_provider)
|
||||
response = post "/jobs/#{job.id}/annotations", { username: annotation_provider.api_username, key: annotation_provider.api_key, description: "Foobar" }, headers
|
||||
response.status.should eq(204)
|
||||
end
|
||||
end
|
||||
|
||||
context "without a description" do
|
||||
it "responds with a 422" do
|
||||
metadata_provider = Factory(:metadata_provider)
|
||||
response = put "/jobs/#{job.id}/metadata", { username: metadata_provider.api_username, key: metadata_provider.api_key }, headers
|
||||
annotation_provider = Factory(:annotation_provider)
|
||||
response = post "/jobs/#{job.id}/annotations", { username: annotation_provider.api_username, key: annotation_provider.api_key }, headers
|
||||
response.status.should eq(422)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid credentials" 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)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,13 +2,13 @@ require 'spec_helper'
|
|||
|
||||
describe Travis::Api::App::Endpoint::Jobs do
|
||||
let(:job) { Factory(:test) }
|
||||
let(:provider) { Factory(:metadata_provider) }
|
||||
let(:provider) { Factory(:annotation_provider) }
|
||||
|
||||
it "GET /jobs/:id/metadata" do
|
||||
get("/jobs/#{job.id}/metadata", {}, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_ok
|
||||
it "GET /jobs/:id/annotations" do
|
||||
get("/jobs/#{job.id}/annotations", {}, "HTTP_ACCEPT" => "application/vnd.travis-ci.2+json, */*; q=0.01").should be_ok
|
||||
end
|
||||
|
||||
it "PUT /jobs/:id/metadata" 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
|
||||
it "POST /jobs/:id/annotations" do
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user