Skip to content

Commit

Permalink
fix string freeze issue for ruby 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandru-calinoiu committed Apr 13, 2016
1 parent 2d7a78a commit c2e720e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/fog/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def self.directories
def self.get_body_size(body)
if body.respond_to?(:encoding)
original_encoding = body.encoding
body.force_encoding('BINARY')
body = body.dup.force_encoding('BINARY')
end

size = if body.respond_to?(:bytesize)
Expand Down
12 changes: 11 additions & 1 deletion spec/storage_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module Fog
module Storage
class BothWays
attr_reader :args

def initialize(args)
@args = args
end
Expand Down Expand Up @@ -105,5 +106,14 @@ def initialize(args)
skip
end
end

it "respects frozen strings" do
if RUBY_VERSION >= "2.3.0"
body = "foo".freeze
Fog::Storage.get_body_size(body)
else
skip
end
end
end
end
end

0 comments on commit c2e720e

Please sign in to comment.