Specs for If-None-Match on GET requests
This commit is contained in:
@@ -65,6 +65,30 @@ describe "Directories" do
|
|||||||
last_response.headers["Access-Control-Allow-Headers"].must_equal "Authorization, Content-Type, Origin"
|
last_response.headers["Access-Control-Allow-Headers"].must_equal "Authorization, Content-Type, Origin"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when If-None-Match header is set" do
|
||||||
|
before do
|
||||||
|
get "/jimmy/tasks/"
|
||||||
|
|
||||||
|
@etag = last_response.headers["ETag"]
|
||||||
|
end
|
||||||
|
|
||||||
|
it "responds with 'not modified' when it matches the current ETag" do
|
||||||
|
header "If-None-Match", @etag
|
||||||
|
get "/jimmy/tasks/"
|
||||||
|
|
||||||
|
last_response.status.must_equal 304
|
||||||
|
last_response.body.must_be_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
it "responds normally when it does not match the current ETag" do
|
||||||
|
header "If-None-Match", "FOO"
|
||||||
|
get "/jimmy/tasks/"
|
||||||
|
|
||||||
|
last_response.status.must_equal 200
|
||||||
|
last_response.body.wont_be_empty
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "with sub-directories" do
|
context "with sub-directories" do
|
||||||
before do
|
before do
|
||||||
get "/jimmy/tasks/"
|
get "/jimmy/tasks/"
|
||||||
|
|||||||
+24
-1
@@ -63,19 +63,42 @@ describe "App with Riak backend" do
|
|||||||
object.data = "some private text data"
|
object.data = "some private text data"
|
||||||
object.store
|
object.store
|
||||||
|
|
||||||
|
@etag = object.etag
|
||||||
|
|
||||||
auth = auth_bucket.new("jimmy:123")
|
auth = auth_bucket.new("jimmy:123")
|
||||||
auth.data = ["documents", "public"]
|
auth.data = ["documents", "public"]
|
||||||
auth.store
|
auth.store
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET" do
|
describe "GET" do
|
||||||
it "returns the value" do
|
before do
|
||||||
header "Authorization", "Bearer 123"
|
header "Authorization", "Bearer 123"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns the value" do
|
||||||
get "/jimmy/documents/foo"
|
get "/jimmy/documents/foo"
|
||||||
|
|
||||||
last_response.status.must_equal 200
|
last_response.status.must_equal 200
|
||||||
last_response.body.must_equal "some private text data"
|
last_response.body.must_equal "some private text data"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "when If-None-Match header is set" do
|
||||||
|
it "responds with 'not modified' when it matches the current ETag" do
|
||||||
|
header "If-None-Match", @etag
|
||||||
|
get "/jimmy/documents/foo"
|
||||||
|
|
||||||
|
last_response.status.must_equal 304
|
||||||
|
last_response.body.must_be_empty
|
||||||
|
end
|
||||||
|
|
||||||
|
it "responds normally when it does not match the current ETag" do
|
||||||
|
header "If-None-Match", "FOO"
|
||||||
|
get "/jimmy/documents/foo"
|
||||||
|
|
||||||
|
last_response.status.must_equal 200
|
||||||
|
last_response.body.must_equal "some private text data"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET nonexisting key" do
|
describe "GET nonexisting key" do
|
||||||
|
|||||||
Reference in New Issue
Block a user