Skip to content

Commit dbffc2e

Browse files
authored
Merge branch 'transloadit:main' into main
2 parents 88dc744 + 9372cf4 commit dbffc2e

5 files changed

Lines changed: 40 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ jobs:
1313
strategy:
1414
matrix:
1515
ruby:
16-
- 3.0
1716
- 3.1
1817
- 3.2
1918
- 3.3
20-
- jruby
21-
- truffleruby
2219
fail-fast: false
2320
steps:
24-
- uses: actions/checkout@v3
21+
- uses: actions/checkout@v4
22+
with:
23+
lfs: true
2524
- uses: actions/setup-node@v4
2625
with:
2726
node-version: 20
@@ -53,7 +52,9 @@ jobs:
5352
TRANSLOADIT_KEY: ${{ secrets.TRANSLOADIT_KEY }}
5453
TRANSLOADIT_SECRET: ${{ secrets.TRANSLOADIT_SECRET }}
5554
steps:
56-
- uses: actions/checkout@v3
55+
- uses: actions/checkout@v4
56+
with:
57+
lfs: true
5758
- uses: ruby/setup-ruby@v1
5859
with:
5960
ruby-version: 3.3

test/test_helper.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,29 @@ def run_transloadit_sig(payload, key:, secret:, algorithm: nil)
7272
end
7373

7474
Minitest::Test.include(TransloaditCliHelpers)
75+
76+
module SingletonMethodOverrideHelpers
77+
def with_singleton_method(target, name, implementation)
78+
eigenclass = target.singleton_class
79+
80+
backup = "__orig_#{name}_for_test__"
81+
had_method = eigenclass.method_defined?(name) || eigenclass.private_method_defined?(name)
82+
eigenclass.send(:alias_method, backup, name) if had_method
83+
84+
target.define_singleton_method(name, &implementation)
85+
yield
86+
ensure
87+
eigenclass = target.singleton_class
88+
if eigenclass.method_defined?(name) || eigenclass.private_method_defined?(name)
89+
eigenclass.send(:remove_method, name)
90+
end
91+
if had_method
92+
eigenclass.send(:alias_method, name, backup)
93+
if eigenclass.method_defined?(backup) || eigenclass.private_method_defined?(backup)
94+
eigenclass.send(:remove_method, backup)
95+
end
96+
end
97+
end
98+
end
99+
100+
Minitest::Test.include(SingletonMethodOverrideHelpers)

test/unit/test_transloadit.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109

110110
it "must produce Transloadit-compatible JSON output" do
111111
fixed_time = Time.utc(2025, 10, 28, 0, 0, 0)
112-
Time.stub :now, fixed_time do
112+
with_singleton_method(Time, :now, proc { fixed_time }) do
113113
_(@transloadit.to_json).must_equal MultiJson.dump(@transloadit.to_hash)
114114
end
115115
end

test/unit/transloadit/test_assembly.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,14 @@
146146
it "must call the create! method with the same parameters" do
147147
VCR.use_cassette "submit_assembly" do
148148
file = open("lib/transloadit/version.rb")
149-
mocker = Minitest::Mock.new
150-
mocker.expect :call, nil, [file]
151-
@assembly.stub :create!, mocker do
149+
create_arg = nil
150+
with_singleton_method(@assembly, :create!, proc { |arg|
151+
create_arg = arg
152+
nil
153+
}) do
152154
@assembly.submit!(file)
153155
end
154-
mocker.verify
156+
_(create_arg).must_equal file
155157
end
156158
end
157159
end

transloadit.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
1616
gem.description = "The transloadit gem allows you to automate uploading files through the Transloadit REST API"
1717

1818
gem.required_rubygems_version = ">= 2.2.0"
19-
gem.required_ruby_version = ">= 3.0.0"
19+
gem.required_ruby_version = ">= 3.1.0"
2020

2121
gem.files = `git ls-files`.split("\n")
2222
gem.require_paths = %w[lib]

0 commit comments

Comments
 (0)