Set charset explicitly in Riak objects' content type

This commit is contained in:
2012-03-17 14:49:31 +01:00
parent 202508ca95
commit 1d81e06d41
2 changed files with 8 additions and 2 deletions

View File

@@ -26,7 +26,7 @@ module RemoteStorage
def put_data(user, category, key, data) def put_data(user, category, key, data)
object = client.bucket("user_data").new("#{user}:#{category}:#{key}") 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.data = data
object.store object.store
rescue ::Riak::HTTPFailedRequest rescue ::Riak::HTTPFailedRequest

View File

@@ -69,13 +69,19 @@ describe "App with Riak backend" do
end end
describe "PUT" do describe "PUT" do
it "saves the value" do before do
header "Authorization", "Bearer 123" header "Authorization", "Bearer 123"
put "/jimmy/documents/bar", "another text" put "/jimmy/documents/bar", "another text"
end
it "saves the value" do
last_response.status.must_equal 200 last_response.status.must_equal 200
storage_client.bucket("user_data").get("jimmy:documents:bar").data.must_equal "another text" storage_client.bucket("user_data").get("jimmy:documents:bar").data.must_equal "another text"
end 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 end
describe "DELETE" do describe "DELETE" do