Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Fixes Ruby 2.7 arguments warnings (shrinerb#494)
Browse files Browse the repository at this point in the history
Related to shrinerb#437
  • Loading branch information
renchap authored Oct 2, 2020
1 parent 74687de commit 429f404
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions lib/shrine/plugins/backgrounding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def destroy_block(&block)

module AttacherMethods
# Inherits global hooks if defined.
def initialize(*args)
super
def initialize(**args)
super(**args)
@destroy_block = self.class.destroy_block
@promote_block = self.class.promote_block
end
Expand Down
14 changes: 7 additions & 7 deletions test/plugin/upload_endpoint_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def endpoint
end

it "doesn't accept more than one file" do
response = app.post "/", multipart: HTTP::FormData.create("files[]": [
response = app.post "/", multipart: HTTP::FormData.create({ "files[]": [
HTTP::FormData::File.new(image.path),
HTTP::FormData::File.new(image.path),
])
] })
assert_equal 400, response.status
assert_equal "Too Many Files", response.body_binary
end
Expand Down Expand Up @@ -84,7 +84,7 @@ def endpoint

it "handles filenames with UTF-8 characters" do
filename = "über_pdf_with_1337%_leetness.pdf"
form = HTTP::FormData.create(file: HTTP::FormData::Part.new("", filename: filename))
form = HTTP::FormData.create({ file: HTTP::FormData::Part.new("", filename: filename) })
response = app.post "/", multipart: { input: form.to_s }, headers: {"Content-Type" => form.content_type}
assert_equal 200, response.status
uploaded_file = @shrine.uploaded_file(response.body_json)
Expand Down Expand Up @@ -183,9 +183,9 @@ def endpoint

describe "Shrine.upload_response" do
it "returns the Rack response triple" do
form_data = HTTP::FormData.create(
form_data = HTTP::FormData.create({
file: HTTP::FormData::Part.new("content", filename: "foo.txt")
)
})

env = {
"REQUEST_METHOD" => "POST",
Expand All @@ -204,9 +204,9 @@ def endpoint
end

it "accepts additional upload endpoint options" do
form_data = HTTP::FormData.create(
form_data = HTTP::FormData.create({
file: HTTP::FormData::Part.new("content", filename: "foo.txt")
)
})

env = {
"REQUEST_METHOD" => "POST",
Expand Down
2 changes: 1 addition & 1 deletion test/shrine_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def generate_location(io, **options)
end

it "doesn't error when storage already closed the file" do
@uploader.storage.instance_eval { def upload(io, *); super; io.close; end }
@uploader.storage.instance_eval { def upload(io, id, **); super; io.close; end }
@uploader.upload(fakeio)
end

Expand Down
8 changes: 4 additions & 4 deletions test/storage/linter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
end

it "takes into account that storage can modify location" do
@storage.instance_eval { def upload(io, id, *); id << "-modified"; super; end }
@storage.instance_eval { def upload(io, id, **); id << "-modified"; super; end }
@linter.call
end
end
Expand Down Expand Up @@ -145,13 +145,13 @@
end

it "works for storages that close files on upload" do
@storage.instance_eval { def upload(io, id, *); super; io.close; end }
@storage.instance_eval { def upload(io, id, **); super; io.close; end }
@linter.call
end

it "accounts for storages which cannot write immediately to previously used location" do
@storage.instance_eval do
def upload(io, id, *)
def upload(io, id, **)
@uploaded ||= []
raise if @uploaded.include?(id)
super
Expand All @@ -168,7 +168,7 @@ def upload(io, id, *)
end

it "doesn't pass any file extensions" do
@storage.instance_eval { def upload(io, id, *); raise if id.include?("."); super; end }
@storage.instance_eval { def upload(io, id, **); raise if id.include?("."); super; end }
@linter.call
end
end

0 comments on commit 429f404

Please sign in to comment.