Set response code for newly created objects to 201
This commit is contained in:
parent
5ddde402a8
commit
4ae4865de5
@ -116,7 +116,7 @@ module RemoteStorage
|
||||
update_all_directory_objects(user, directory, timestamp)
|
||||
|
||||
server.headers["ETag"] = object.etag
|
||||
server.halt 200
|
||||
server.halt object_exists ? 200 : 201
|
||||
rescue ::Riak::HTTPFailedRequest
|
||||
server.halt 422
|
||||
end
|
||||
|
@ -101,7 +101,7 @@ describe "Permissions" do
|
||||
it "saves the value when there are write permissions" do
|
||||
put "/jimmy/contacts/1", "John Doe"
|
||||
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:contacts:1").data.must_equal "John Doe"
|
||||
end
|
||||
|
||||
@ -116,14 +116,14 @@ describe "Permissions" do
|
||||
it "saves the value when there are direct write permissions" do
|
||||
put "/jimmy/tasks/home/1", "take out the trash"
|
||||
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:tasks/home:1").data.must_equal "take out the trash"
|
||||
end
|
||||
|
||||
it "saves the value when there are write permissions for a parent directory" do
|
||||
put "/jimmy/contacts/family/1", "Bobby Brother"
|
||||
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:contacts/family:1").data.must_equal "Bobby Brother"
|
||||
end
|
||||
|
||||
@ -139,14 +139,14 @@ describe "Permissions" do
|
||||
it "saves the value" do
|
||||
put "/jimmy/public/contacts/foo", "Foo Bar"
|
||||
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:public/contacts:foo").data.must_equal "Foo Bar"
|
||||
end
|
||||
|
||||
it "saves the value to a sub-directory" do
|
||||
put "/jimmy/public/contacts/family/foo", "Foo Bar"
|
||||
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:public/contacts/family:foo").data.must_equal "Foo Bar"
|
||||
end
|
||||
end
|
||||
@ -289,7 +289,7 @@ describe "Permissions" do
|
||||
it "allows PUT requests" do
|
||||
put "/jimmy/contacts/1", "John Doe"
|
||||
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:contacts:1").data.must_equal "John Doe"
|
||||
end
|
||||
|
||||
@ -320,7 +320,7 @@ describe "Permissions" do
|
||||
it "allows PUT requests" do
|
||||
put "/jimmy/1", "Gonna kick it root down"
|
||||
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy::1").data.must_equal "Gonna kick it root down"
|
||||
end
|
||||
|
||||
@ -351,7 +351,7 @@ describe "Permissions" do
|
||||
it "allows PUT requests" do
|
||||
put "/jimmy/public/1", "Hello World"
|
||||
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:public:1").data.must_equal "Hello World"
|
||||
end
|
||||
|
||||
|
@ -127,7 +127,7 @@ describe "App with Riak backend" do
|
||||
end
|
||||
|
||||
it "saves the value" do
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
last_response.body.must_equal ""
|
||||
data_bucket.get("jimmy:documents:bar").data.must_equal "another text"
|
||||
end
|
||||
@ -166,7 +166,7 @@ describe "App with Riak backend" do
|
||||
end
|
||||
|
||||
it "saves the value (as JSON)" do
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:documents:jason").data.must_be_kind_of Hash
|
||||
data_bucket.get("jimmy:documents:jason").data.must_equal({"foo" => "bar", "unhosted" => 1})
|
||||
end
|
||||
@ -191,7 +191,7 @@ describe "App with Riak backend" do
|
||||
end
|
||||
|
||||
it "saves the value" do
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:documents:magic").raw_data.must_equal "pure magic"
|
||||
end
|
||||
|
||||
@ -215,7 +215,7 @@ describe "App with Riak backend" do
|
||||
end
|
||||
|
||||
it "saves the value (as JSON)" do
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:documents:jason").data.must_be_kind_of Hash
|
||||
data_bucket.get("jimmy:documents:jason").data.must_equal({"foo" => "bar", "unhosted" => 1})
|
||||
end
|
||||
@ -309,7 +309,7 @@ describe "App with Riak backend" do
|
||||
it "succeeds when the document does not exist" do
|
||||
put "/jimmy/documents/archive/bar", "my little content"
|
||||
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -337,7 +337,7 @@ describe "App with Riak backend" do
|
||||
end
|
||||
|
||||
it "saves the value" do
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:public/documents/notes:foo").data.must_equal "note to self"
|
||||
end
|
||||
|
||||
@ -499,7 +499,7 @@ describe "App with Riak backend" do
|
||||
end
|
||||
|
||||
it "saves an empty JSON object" do
|
||||
last_response.status.must_equal 200
|
||||
last_response.status.must_equal 201
|
||||
data_bucket.get("jimmy:documents:jason").data.must_be_kind_of Hash
|
||||
data_bucket.get("jimmy:documents:jason").data.must_equal({})
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user