Change single quotes to double quotes

This commit is contained in:
Julian Herrero
2019-02-01 16:48:49 +01:00
parent 4a12425987
commit 31ac8b7f55
302 changed files with 6403 additions and 6403 deletions

View File

@@ -1,10 +1,10 @@
require 'rails_helper'
require "rails_helper"
# Useful resource: http://graphql.org/learn/serving-over-http/
def parser_error_raised?(response)
data_is_empty = response['data'].nil?
error_is_present = (JSON.parse(response.body)['errors'].first['message'] =~ /^Parse error on/)
data_is_empty = response["data"].nil?
error_is_present = (JSON.parse(response.body)["errors"].first["message"] =~ /^Parse error on/)
data_is_empty && error_is_present
end
@@ -13,24 +13,24 @@ describe GraphqlController, type: :request do
describe "handles GET request" do
specify "with query string inside query params" do
get '/graphql', query: "{ proposal(id: #{proposal.id}) { title } }"
get "/graphql", query: "{ proposal(id: #{proposal.id}) { title } }"
expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']['proposal']['title']).to eq(proposal.title)
expect(JSON.parse(response.body)["data"]["proposal"]["title"]).to eq(proposal.title)
end
specify "with malformed query string" do
get '/graphql', query: 'Malformed query string'
get "/graphql", query: "Malformed query string"
expect(response).to have_http_status(:ok)
expect(parser_error_raised?(response)).to be_truthy
end
specify "without query string" do
get '/graphql'
get "/graphql"
expect(response).to have_http_status(:bad_request)
expect(JSON.parse(response.body)['message']).to eq('Query string not present')
expect(JSON.parse(response.body)["message"]).to eq("Query string not present")
end
end
@@ -38,32 +38,32 @@ describe GraphqlController, type: :request do
let(:json_headers) { { "CONTENT_TYPE" => "application/json" } }
specify "with json-encoded query string inside body" do
post '/graphql', { query: "{ proposal(id: #{proposal.id}) { title } }" }.to_json, json_headers
post "/graphql", { query: "{ proposal(id: #{proposal.id}) { title } }" }.to_json, json_headers
expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']['proposal']['title']).to eq(proposal.title)
expect(JSON.parse(response.body)["data"]["proposal"]["title"]).to eq(proposal.title)
end
specify "with raw query string inside body" do
graphql_headers = { "CONTENT_TYPE" => "application/graphql" }
post '/graphql', "{ proposal(id: #{proposal.id}) { title } }", graphql_headers
post "/graphql", "{ proposal(id: #{proposal.id}) { title } }", graphql_headers
expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']['proposal']['title']).to eq(proposal.title)
expect(JSON.parse(response.body)["data"]["proposal"]["title"]).to eq(proposal.title)
end
specify "with malformed query string" do
post '/graphql', { query: "Malformed query string" }.to_json, json_headers
post "/graphql", { query: "Malformed query string" }.to_json, json_headers
expect(response).to have_http_status(:ok)
expect(parser_error_raised?(response)).to be_truthy
end
it "without query string" do
post '/graphql', json_headers
post "/graphql", json_headers
expect(response).to have_http_status(:bad_request)
expect(JSON.parse(response.body)['message']).to eq('Query string not present')
expect(JSON.parse(response.body)["message"]).to eq("Query string not present")
end
end