updates specs to new keyword styles
This commit is contained in:
committed by
Julian Herrero
parent
b62eff841c
commit
0f34cae2ad
@@ -13,14 +13,14 @@ 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", params: { 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)
|
||||
end
|
||||
|
||||
specify "with malformed query string" do
|
||||
get "/graphql", query: "Malformed query string"
|
||||
get "/graphql", params: { query: "Malformed query string" }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(parser_error_raised?(response)).to be_truthy
|
||||
@@ -38,7 +38,7 @@ 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", params: { query: "{ proposal(id: #{proposal.id}) { title } }" }.to_json, headers: json_headers
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(JSON.parse(response.body)["data"]["proposal"]["title"]).to eq(proposal.title)
|
||||
@@ -46,21 +46,21 @@ describe GraphqlController, type: :request do
|
||||
|
||||
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", params: "{ proposal(id: #{proposal.id}) { title } }", headers: graphql_headers
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
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", params: { query: "Malformed query string" }.to_json, headers: 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", headers: json_headers
|
||||
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
expect(JSON.parse(response.body)["message"]).to eq("Query string not present")
|
||||
@@ -71,19 +71,19 @@ describe GraphqlController, type: :request do
|
||||
let(:query_string) { "{ proposal(id: #{proposal.id}) { title } }" }
|
||||
|
||||
specify "when absent" do
|
||||
get "/graphql", query: query_string
|
||||
get "/graphql", params: { query: query_string }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
|
||||
specify "when specified as the 'null' string" do
|
||||
get "/graphql", query: query_string, variables: "null"
|
||||
get "/graphql", params: { query: query_string, variables: "null" }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
|
||||
specify "when specified as an empty string" do
|
||||
get "/graphql", query: query_string, variables: ""
|
||||
get "/graphql", params: { query: query_string, variables: "" }
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user