From 1d81e06d4124d432af5bbff58cef2b8523b6eb89 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sat, 17 Mar 2012 14:49:31 +0100 Subject: [PATCH] Set charset explicitly in Riak objects' content type --- lib/remote_storage/riak.rb | 2 +- spec/riak_spec.rb | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/remote_storage/riak.rb b/lib/remote_storage/riak.rb index 37f68c1..ada51ae 100644 --- a/lib/remote_storage/riak.rb +++ b/lib/remote_storage/riak.rb @@ -26,7 +26,7 @@ module RemoteStorage def put_data(user, category, key, data) object = client.bucket("user_data").new("#{user}:#{category}:#{key}") - object.content_type = "text/plain" + object.content_type = "text/plain; charset=utf-8" object.data = data object.store rescue ::Riak::HTTPFailedRequest diff --git a/spec/riak_spec.rb b/spec/riak_spec.rb index 54d42ac..138963a 100644 --- a/spec/riak_spec.rb +++ b/spec/riak_spec.rb @@ -69,13 +69,19 @@ describe "App with Riak backend" do end describe "PUT" do - it "saves the value" do + before do header "Authorization", "Bearer 123" put "/jimmy/documents/bar", "another text" + end + it "saves the value" do last_response.status.must_equal 200 storage_client.bucket("user_data").get("jimmy:documents:bar").data.must_equal "another text" end + + it "stores the data as plain text with utf-8 encoding" do + storage_client.bucket("user_data").get("jimmy:documents:bar").content_type.must_equal "text/plain; charset=utf-8" + end end describe "DELETE" do