update lint service, update spec

This commit is contained in:
carlad 2016-03-21 15:39:14 +01:00
parent f940bffe3f
commit 6b145e6f06
2 changed files with 6 additions and 12 deletions

View File

@ -2,11 +2,11 @@ require 'travis/yaml'
module Travis::API::V3
class Services::Lint::Lint < Service
params "content"
params 'content'
def run!
request_body.rewind
content = params[:content] || request_body.read
parsed = Travis::Yaml.parse(content)
content = params['content'.freeze] || request_body.read
Travis::Yaml.parse(content)
end
end
end

View File

@ -3,15 +3,13 @@ require 'spec_helper'
describe Travis::API::V3::Services::Lint::Lint do
let(:content) { "foo: bar" }
let(:parsed_body) { JSON.load(last_response.body) }
let(:headers) {{ 'CONTENT_TYPE' => 'text/yaml'}}
describe "accepts content in parameter" do
before { post("v3/lint", content: content ) }
example { expect(last_response).to be_ok }
example { expect(parsed_body).to be == {
"@warnings" => [{
"@type" => "warning",
"message" => "query parameter foo: bar not whitelisted, ignored",
"warning_type" => "ignored_parameter", "parameter"=>"foo: bar"}],
"@type" => "lint",
"warnings" => [{
"key" => [],
@ -22,13 +20,9 @@ describe Travis::API::V3::Services::Lint::Lint do
end
describe "accepts content as body" do
before { post("/v3/lint", content) }
before { post("/v3/lint", content, headers) }
example { expect(last_response).to be_ok }
example { expect(parsed_body).to be == {
"@warnings" => [{
"@type" => "warning",
"message" => "query parameter foo: bar not whitelisted, ignored",
"warning_type" => "ignored_parameter", "parameter"=>"foo: bar"}],
"@type" => "lint",
"warnings" => [{
"key" => [],