Don't overwrite existing data when If-None-Match is "*" (refs #26)
This commit is contained in:
parent
67435157ed
commit
f61eef717e
@ -95,6 +95,8 @@ module RemoteStorage
|
|||||||
object_exists = !object.raw_data.nil?
|
object_exists = !object.raw_data.nil?
|
||||||
existing_object_size = object_size(object)
|
existing_object_size = object_size(object)
|
||||||
|
|
||||||
|
server.halt 412 if object_exists && server.env["HTTP_IF_NONE_MATCH"] == "*"
|
||||||
|
|
||||||
timestamp = (Time.now.to_f * 1000).to_i
|
timestamp = (Time.now.to_f * 1000).to_i
|
||||||
object.meta["timestamp"] = timestamp
|
object.meta["timestamp"] = timestamp
|
||||||
|
|
||||||
|
@ -262,6 +262,27 @@ describe "App with Riak backend" do
|
|||||||
last_response.body.must_equal "lorem ipsum"
|
last_response.body.must_equal "lorem ipsum"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "when If-None-Match header is set" do
|
||||||
|
before do
|
||||||
|
header "If-None-Match", "*"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "fails when the document already exists" do
|
||||||
|
put "/jimmy/documents/archive/foo", "some awesome content"
|
||||||
|
|
||||||
|
last_response.status.must_equal 412
|
||||||
|
|
||||||
|
get "/jimmy/documents/archive/foo"
|
||||||
|
last_response.body.must_equal "lorem ipsum"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "succeeds when the document does not exist" do
|
||||||
|
put "/jimmy/documents/archive/bar", "my little content"
|
||||||
|
|
||||||
|
last_response.status.must_equal 200
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "exsting content without serializer registered for the given content-type" do
|
describe "exsting content without serializer registered for the given content-type" do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user