# HG changeset patch # User nanaya # Date 1638097278 -32400 # Node ID 84ca55a0568e0a5a2c77d27418628ec6997e0215 # Parent 02d043b1967d99c0461c7b7dfef45d7af9e33bac Fix pasting base64 gzip and fix tests diff -r 02d043b1967d -r 84ca55a0568e app/models/paste.rb --- a/app/models/paste.rb Sun Nov 28 19:54:08 2021 +0900 +++ b/app/models/paste.rb Sun Nov 28 20:01:18 2021 +0900 @@ -36,7 +36,9 @@ end def paste_gzip=(paste) - self.paste = ActiveSupport::Gzip.decompress paste.read + paste = paste.read if paste.is_a? ActionDispatch::Http::UploadedFile + + self.paste = ActiveSupport::Gzip.decompress paste end def paste_gzip_base64=(paste) diff -r 02d043b1967d -r 84ca55a0568e test/controllers/pastes_controller_test.rb --- a/test/controllers/pastes_controller_test.rb Sun Nov 28 19:54:08 2021 +0900 +++ b/test/controllers/pastes_controller_test.rb Sun Nov 28 20:01:18 2021 +0900 @@ -11,7 +11,7 @@ test "creates paste from gzip" do assert_difference("Paste.count", 1) do - post :create, :params => { "paste" => { "paste_gzip" => ActiveSupport::Gzip.compress("here be paste") } } + post :create, :params => { "paste" => { "paste_gzip" => fixture_file_upload('hello_world.txt.gz') } } end assert_response :redirect diff -r 02d043b1967d -r 84ca55a0568e test/fixtures/files/hello_world.txt.gz Binary file test/fixtures/files/hello_world.txt.gz has changed