Skip to content

Commit 1556d0b

Browse files
Fix Ruby 4 compatibility
1 parent 95776d1 commit 1556d0b

File tree

9 files changed

+46
-39
lines changed

9 files changed

+46
-39
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [ master ]
66
pull_request:
77
branches: [ master ]
8+
workflow_dispatch:
89

910
jobs:
1011
test:
@@ -14,10 +15,10 @@ jobs:
1415
matrix:
1516
ruby-version:
1617
- '3.1.7'
17-
- '3.2.8'
18-
- '3.3.8'
19-
- '3.4.4'
20-
- '4.0.0-preview3'
18+
- '3.2.9'
19+
- '3.3.10'
20+
- '3.4.8'
21+
- '4.0.0'
2122

2223
runs-on: ubuntu-22.04
2324

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ the [Ruby on Rails SDK Guide](https://cloudinary.com/documentation/rails_integra
3838

3939
## Version Support
4040

41-
| SDK Version | Ruby 1.9.3 | Ruby 2.x | Ruby 3.x |
42-
|-------------|------------|----------|----------|
43-
| 1.x | |||
44-
| 2.x | | ||
45-
46-
| SDK Version | Rails 5.x | Rails 6.x | Rails 7.x |
47-
|-------------|-----------|-----------|-----------|
48-
| 1.x ||||
49-
| 2.x | |||
41+
| SDK Version | Ruby 1.9.3 | Ruby 2.x | Ruby 3.x | Ruby 4.x |
42+
|-------------|------------|----------|----------|----------|
43+
| 2.x | | |||
44+
| 1.x | | | | |
45+
46+
| SDK Version | Rails 5.x | Rails 6.x | Rails 7.x | Rails 8.x |
47+
|-------------|-----------|-----------|-----------|-----------|
48+
| 2.x | ||||
49+
| 1.x | || | |
5050

5151
## Installation
5252

cloudinary.gemspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ Gem::Specification.new do |s|
2929
s.add_dependency "faraday-follow_redirects", "~> 0.5"
3030
s.add_dependency "ostruct"
3131

32-
s.add_development_dependency "rails", ">= 6.1.7", "< 8.0.0"
32+
s.add_development_dependency "rails", ">= 6.1.7", "< 9.0.0"
3333
s.add_development_dependency "rexml", ">= 3.2.5", "< 4.0.0"
34-
s.add_development_dependency "actionpack", ">= 6.1.7", "< 8.0.0"
34+
s.add_development_dependency "actionpack", ">= 6.1.7", "< 9.0.0"
3535
s.add_development_dependency "nokogiri", ">= 1.12.5", "< 2.0.0"
3636
s.add_development_dependency "rake", ">= 13.0.6", "< 14.0.0"
37-
s.add_development_dependency "sqlite3", ">= 1.4.2", "< 2.0.0"
37+
s.add_development_dependency "sqlite3", ">= 1.4.2", "< 3.0.0"
3838
s.add_development_dependency "rspec", ">= 3.11.2", "< 4.0.0"
3939
s.add_development_dependency "rspec-retry", ">= 0.6.2", "< 1.0.0"
40-
s.add_development_dependency "railties", ">= 6.0.4", "< 8.0.0"
41-
s.add_development_dependency "rspec-rails", ">= 6.0.4", "< 7.0.0"
40+
s.add_development_dependency "railties", ">= 6.0.4", "< 9.0.0"
41+
s.add_development_dependency "rspec-rails", ">= 6.0.4", "< 9.0.0"
4242
s.add_development_dependency "rubyzip", ">= 2.3.0", "< 3.0.0"
4343
s.add_development_dependency "simplecov", ">= 0.21.2", "< 1.0.0"
4444
end

samples/basic-rails/.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.0
1+
4.0.0

samples/basic/.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.0
1+
4.0.0

samples/photo_album/.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.0
1+
4.0.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.3.0
1+
4.0.0

spec/spec_helper.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
require 'active_storage/test_helper'
1111
require 'cloudinary'
1212

13+
# Replacement for CGI.parse
14+
def parse_query_params(query_string)
15+
URI.decode_www_form(query_string.to_s).each_with_object(Hash.new { |h, k| h[k] = [] }) do |(k, v), h|
16+
h[k] << v
17+
end
18+
end
19+
1320
Cloudinary.config.enhance_image_tag = true
1421

1522
DUMMY_CLOUD = "test123"
@@ -551,4 +558,3 @@ def execute(options = {})
551558
MockedApi.call_api(:post, uri, to_h, options)
552559
end
553560
end
554-

spec/utils_spec.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,23 +1307,23 @@
13071307

13081308
it "should use signature version 1 (without parameter encoding) for backward compatibility" do
13091309
public_id_with_ampersand = 'tests/logo&version=2'
1310-
1310+
13111311
expected_signature_v1 = Cloudinary::Utils.api_sign_request(
13121312
{ :public_id => public_id_with_ampersand, :version => test_version },
13131313
SIGNATURE_VERIFICATION_API_SECRET,
13141314
nil,
13151315
1
13161316
)
1317-
1317+
13181318
expected_signature_v2 = Cloudinary::Utils.api_sign_request(
13191319
{ :public_id => public_id_with_ampersand, :version => test_version },
13201320
SIGNATURE_VERIFICATION_API_SECRET,
13211321
nil,
13221322
2
13231323
)
1324-
1324+
13251325
expect(expected_signature_v1).not_to eq(expected_signature_v2)
1326-
1326+
13271327
# verify_api_response_signature should use version 1 for backward compatibility
13281328
expect(
13291329
Cloudinary::Utils.verify_api_response_signature(
@@ -1332,7 +1332,7 @@
13321332
expected_signature_v1
13331333
)
13341334
).to be true
1335-
1335+
13361336
expect(
13371337
Cloudinary::Utils.verify_api_response_signature(
13381338
public_id_with_ampersand,
@@ -1457,13 +1457,13 @@
14571457
expect(url_from_urls).to include("urls[]=#{url1}")
14581458
expect(url_from_urls).to include("urls[]=#{url2}")
14591459

1460-
parameters = CGI::parse(url_from_tag)
1460+
parameters = parse_query_params(URI(url_from_tag).query)
14611461
expect(parameters["tag"]).to eq([sprite_test_tag])
14621462
expect(parameters["mode"]).to eq([Cloudinary::Utils::MODE_DOWNLOAD])
14631463
expect(parameters["timestamp"]).not_to be_nil
14641464
expect(parameters["signature"]).not_to be_nil
14651465

1466-
parameters = CGI::parse(url_from_urls)
1466+
parameters = parse_query_params(URI(url_from_urls).query)
14671467
expect(parameters["mode"]).to eq([Cloudinary::Utils::MODE_DOWNLOAD])
14681468
expect(parameters["timestamp"]).not_to be_nil
14691469
expect(parameters["signature"]).not_to be_nil
@@ -1473,18 +1473,18 @@
14731473
let(:public_id) { 'tests/logo.png' }
14741474
let(:test_version) { 1234 }
14751475
let(:test_api_secret) { SIGNATURE_VERIFICATION_API_SECRET }
1476-
1476+
14771477
before do
14781478
Cloudinary.config.update(:api_secret => test_api_secret)
14791479
end
14801480

14811481
describe "api_sign_request signature_version parameter support" do
14821482
it "should support signature_version parameter in api_sign_request" do
14831483
params = { :public_id => public_id, :version => test_version }
1484-
1484+
14851485
signature_v1 = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, 1)
14861486
signature_v2 = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, 2)
1487-
1487+
14881488
expect(signature_v1).to be_a(String)
14891489
expect(signature_v2).to be_a(String)
14901490
expect(signature_v1).to eq(signature_v2) # No & in values, so should be the same
@@ -1493,20 +1493,20 @@
14931493
it "should use default signature_version from config" do
14941494
Cloudinary.config.signature_version = 2
14951495
params = { :public_id => public_id, :version => test_version }
1496-
1496+
14971497
signature_with_nil = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, nil)
14981498
signature_with_v2 = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, 2)
1499-
1499+
15001500
expect(signature_with_nil).to eq(signature_with_v2)
15011501
end
15021502

15031503
it "should default to version 2 when no config is set" do
15041504
Cloudinary.config.signature_version = nil
15051505
params = { :public_id => public_id, :version => test_version }
1506-
1506+
15071507
signature_with_nil = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, nil)
15081508
signature_with_v2 = Cloudinary::Utils.api_sign_request(params, test_api_secret, nil, 2)
1509-
1509+
15101510
expect(signature_with_nil).to eq(signature_with_v2)
15111511
end
15121512
end
@@ -1527,13 +1527,13 @@
15271527
expect(url_from_urls).to include("urls[]=#{url1}")
15281528
expect(url_from_urls).to include("urls[]=#{url2}")
15291529

1530-
parameters = CGI::parse(url_from_tag)
1530+
parameters = parse_query_params(URI(url_from_tag).query)
15311531
expect(parameters["tag"]).to eq([multi_test_tag])
15321532
expect(parameters["mode"]).to eq([Cloudinary::Utils::MODE_DOWNLOAD])
15331533
expect(parameters["timestamp"]).not_to be_nil
15341534
expect(parameters["signature"]).not_to be_nil
15351535

1536-
parameters = CGI::parse(url_from_urls)
1536+
parameters = parse_query_params(URI(url_from_urls).query)
15371537
expect(parameters["mode"]).to eq([Cloudinary::Utils::MODE_DOWNLOAD])
15381538
expect(parameters["timestamp"]).not_to be_nil
15391539
expect(parameters["signature"]).not_to be_nil

0 commit comments

Comments
 (0)