update lint service, update spec
This commit is contained in:
parent
f940bffe3f
commit
6b145e6f06
|
@ -2,11 +2,11 @@ require 'travis/yaml'
|
||||||
|
|
||||||
module Travis::API::V3
|
module Travis::API::V3
|
||||||
class Services::Lint::Lint < Service
|
class Services::Lint::Lint < Service
|
||||||
params "content"
|
params 'content'
|
||||||
def run!
|
def run!
|
||||||
request_body.rewind
|
request_body.rewind
|
||||||
content = params[:content] || request_body.read
|
content = params['content'.freeze] || request_body.read
|
||||||
parsed = Travis::Yaml.parse(content)
|
Travis::Yaml.parse(content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,15 +3,13 @@ require 'spec_helper'
|
||||||
describe Travis::API::V3::Services::Lint::Lint do
|
describe Travis::API::V3::Services::Lint::Lint do
|
||||||
let(:content) { "foo: bar" }
|
let(:content) { "foo: bar" }
|
||||||
let(:parsed_body) { JSON.load(last_response.body) }
|
let(:parsed_body) { JSON.load(last_response.body) }
|
||||||
|
let(:headers) {{ 'CONTENT_TYPE' => 'text/yaml'}}
|
||||||
|
|
||||||
|
|
||||||
describe "accepts content in parameter" do
|
describe "accepts content in parameter" do
|
||||||
before { post("v3/lint", content: content ) }
|
before { post("v3/lint", content: content ) }
|
||||||
example { expect(last_response).to be_ok }
|
example { expect(last_response).to be_ok }
|
||||||
example { expect(parsed_body).to be == {
|
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",
|
"@type" => "lint",
|
||||||
"warnings" => [{
|
"warnings" => [{
|
||||||
"key" => [],
|
"key" => [],
|
||||||
|
@ -22,13 +20,9 @@ describe Travis::API::V3::Services::Lint::Lint do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "accepts content as body" do
|
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(last_response).to be_ok }
|
||||||
example { expect(parsed_body).to be == {
|
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",
|
"@type" => "lint",
|
||||||
"warnings" => [{
|
"warnings" => [{
|
||||||
"key" => [],
|
"key" => [],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user