This commit is contained in:
Sdogruyol 2016-07-17 14:31:45 +03:00
parent 6ffa4af0e1
commit 4edebcf8eb
6 changed files with 12 additions and 13 deletions

View File

@ -51,10 +51,10 @@ describe "Context" do
get "/" do |env| get "/" do |env|
env.set "key", "value" env.set "key", "value"
{ {
key: env.get("key"), key: env.get("key"),
before_get: env.get("before_get"), before_get: env.get("before_get"),
before_get_int: env.get("before_get_int"), before_get_int: env.get("before_get_int"),
before_get_float: env.get("before_get_float") before_get_float: env.get("before_get_float"),
} }
end end
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
@ -68,4 +68,4 @@ describe "Context" do
context.store["before_get_int"].should eq 123 context.store["before_get_int"].should eq 123
context.store["before_get_float"].should eq 3.5 context.store["before_get_float"].should eq 3.5
end end
end end

View File

@ -74,7 +74,7 @@ describe "Macros" do
env.response.headers.add "Content-Type", "image/png" env.response.headers.add "Content-Type", "image/png"
headers env, { headers env, {
"Access-Control-Allow-Origin" => "*", "Access-Control-Allow-Origin" => "*",
"Content-Type" => "text/plain" "Content-Type" => "text/plain",
} }
end end

View File

@ -1,7 +1,6 @@
require "../spec_helper" require "../spec_helper"
describe "Kemal::Middleware::CSRF" do describe "Kemal::Middleware::CSRF" do
it "sends GETs to next handler" do it "sends GETs to next handler" do
handler = Kemal::Middleware::CSRF.new handler = Kemal::Middleware::CSRF.new
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
@ -33,7 +32,7 @@ describe "Kemal::Middleware::CSRF" do
request = HTTP::Request.new("POST", "/", request = HTTP::Request.new("POST", "/",
body: "authenticity_token=#{current_token}&hasan=lamec", body: "authenticity_token=#{current_token}&hasan=lamec",
headers: HTTP::Headers{"Content-Type" => "application/x-www-form-urlencoded", headers: HTTP::Headers{"Content-Type" => "application/x-www-form-urlencoded",
"Set-Cookie" => client_response.headers["Set-Cookie"]}) "Set-Cookie" => client_response.headers["Set-Cookie"]})
io, context = process_request(handler, request) io, context = process_request(handler, request)
client_response = HTTP::Client::Response.from_io(io, decompress: false) client_response = HTTP::Client::Response.from_io(io, decompress: false)
client_response.status_code.should eq 404 client_response.status_code.should eq 404
@ -54,8 +53,8 @@ describe "Kemal::Middleware::CSRF" do
request = HTTP::Request.new("POST", "/", request = HTTP::Request.new("POST", "/",
body: "hasan=lamec", body: "hasan=lamec",
headers: HTTP::Headers{"Content-Type" => "application/x-www-form-urlencoded", headers: HTTP::Headers{"Content-Type" => "application/x-www-form-urlencoded",
"Set-Cookie" => client_response.headers["Set-Cookie"], "Set-Cookie" => client_response.headers["Set-Cookie"],
"x-csrf-token" => current_token }) "x-csrf-token" => current_token})
io, context = process_request(handler, request) io, context = process_request(handler, request)
client_response = HTTP::Client::Response.from_io(io, decompress: false) client_response = HTTP::Client::Response.from_io(io, decompress: false)
client_response.status_code.should eq 404 client_response.status_code.should eq 404

View File

@ -166,7 +166,7 @@ describe "Kemal::RouteHandler" do
end end
it "sets X-Powered-By to Kemal" do it "sets X-Powered-By to Kemal" do
get "/" {} get "/" { }
request = HTTP::Request.new("GET", "/") request = HTTP::Request.new("GET", "/")
client_response = call_request_on_app(request) client_response = call_request_on_app(request)
client_response.headers["X-Powered-By"].should eq("Kemal") client_response.headers["X-Powered-By"].should eq("Kemal")

View File

@ -46,7 +46,7 @@ describe "Views" do
client_response = call_request_on_app(request) client_response = call_request_on_app(request)
client_response.body.should contain("Hello world") client_response.body.should contain("Hello world")
client_response.body.should contain("serdar") client_response.body.should contain("serdar")
client_response.body.should contain("kemal") client_response.body.should contain("kemal")
end end
it "renders layout with content_for" do it "renders layout with content_for" do

View File

@ -19,7 +19,7 @@ module Kemal
# I hate websites which require daily login so the default # I hate websites which require daily login so the default
# inactivity timeout is 48 hours. # inactivity timeout is 48 hours.
TTL = 48.hours TTL = 48.hours
# In-memory, ephemeral datastore only. # In-memory, ephemeral datastore only.
# #