diff --git a/lib/remote_storage/riak.rb b/lib/remote_storage/riak.rb index b0dee5f..8689ede 100644 --- a/lib/remote_storage/riak.rb +++ b/lib/remote_storage/riak.rb @@ -90,7 +90,7 @@ module RemoteStorage def put_data(user, directory, key, data, content_type=nil) object = build_data_object(user, directory, key, data, content_type) - object_exists = !object.data.nil? + object_exists = !object.raw_data.nil? existing_object_size = object_size(object) timestamp = (Time.now.to_f * 1000).to_i diff --git a/spec/riak_spec.rb b/spec/riak_spec.rb index c4967f6..fd7c7d3 100644 --- a/spec/riak_spec.rb +++ b/spec/riak_spec.rb @@ -219,6 +219,23 @@ describe "App with Riak backend" do update_entry.data["category"].must_equal "documents" update_entry.indexes["user_id_bin"].must_include "jimmy" end + + describe "when no serializer is registered for the given content-type" do + before do + header "Content-Type", "text/html; charset=UTF-8" + put "/jimmy/documents/html", '' + put "/jimmy/documents/html", '' + end + + it "saves the value" do + last_response.status.must_equal 200 + data_bucket.get("jimmy:documents:html").raw_data.must_equal "" + end + + it "uses the requested content type" do + data_bucket.get("jimmy:documents:html").content_type.must_equal "text/html; charset=UTF-8" + end + end end describe "public data" do