Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass CI for [email protected] #415

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions test/cases/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,11 @@ def test_collection_path
def test_collection_path_with_parameters
assert_equal "/people.json?gender=male", Person.collection_path(gender: "male")
assert_equal "/people.json?gender=false", Person.collection_path(gender: false)
assert_equal "/people.json?gender=", Person.collection_path(gender: nil)
if ActiveSupport::VERSION::MAJOR < 8 || ActiveSupport::VERSION::MINOR < 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an alternative to version checking, I also considered an explicit { key: nil }.to_query == "key", but felt that was too verbose and harder to grep for in the future when these branches are no longer necessary.

assert_equal "/people.json?gender=", Person.collection_path(gender: nil)
else
assert_equal "/people.json?gender", Person.collection_path(gender: nil)
end

assert_equal "/people.json?gender=male", Person.collection_path("gender" => "male")

Expand All @@ -785,7 +789,11 @@ def test_collection_path_with_parameters
assert Person.collection_path(gender: "male", student: true).include?("gender=male")
assert Person.collection_path(gender: "male", student: true).include?("student=true")

assert_equal "/people.json?name%5B%5D=bob&name%5B%5D=your+uncle%2Bme&name%5B%5D=&name%5B%5D=false", Person.collection_path(name: ["bob", "your uncle+me", nil, false])
if ActiveSupport::VERSION::MAJOR < 8 || ActiveSupport::VERSION::MINOR < 1
assert_equal "/people.json?name%5B%5D=bob&name%5B%5D=your+uncle%2Bme&name%5B%5D=&name%5B%5D=false", Person.collection_path(name: ["bob", "your uncle+me", nil, false])
else
assert_equal "/people.json?name%5B%5D=bob&name%5B%5D=your+uncle%2Bme&name%5B%5D&name%5B%5D=false", Person.collection_path(name: ["bob", "your uncle+me", nil, false])
end
assert_equal "/people.json?struct%5Ba%5D%5B%5D=2&struct%5Ba%5D%5B%5D=1&struct%5Bb%5D=fred", Person.collection_path(struct: { :a => [2, 1], "b" => "fred" })
end

Expand Down
12 changes: 10 additions & 2 deletions test/singleton_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def test_singleton_path
def test_singleton_path_with_parameters
assert_equal "/weather.json?degrees=fahrenheit", Weather.singleton_path(degrees: "fahrenheit")
assert_equal "/weather.json?degrees=false", Weather.singleton_path(degrees: false)
assert_equal "/weather.json?degrees=", Weather.singleton_path(degrees: nil)
if ActiveSupport::VERSION::MAJOR < 8 || ActiveSupport::VERSION::MINOR < 1
assert_equal "/weather.json?degrees=", Weather.singleton_path(degrees: nil)
else
assert_equal "/weather.json?degrees", Weather.singleton_path(degrees: nil)
end

assert_equal "/weather.json?degrees=fahrenheit", Weather.singleton_path("degrees" => "fahrenheit")

Expand All @@ -52,7 +56,11 @@ def test_singleton_path_with_parameters
assert path.include?("lunar=true")

path = Weather.singleton_path(days: ["monday", "saturday and sunday", nil, false])
assert_equal "/weather.json?days%5B%5D=monday&days%5B%5D=saturday+and+sunday&days%5B%5D=&days%5B%5D=false", path
if ActiveSupport::VERSION::MAJOR < 8 || ActiveSupport::VERSION::MINOR < 1
assert_equal "/weather.json?days%5B%5D=monday&days%5B%5D=saturday+and+sunday&days%5B%5D=&days%5B%5D=false", path
else
assert_equal "/weather.json?days%5B%5D=monday&days%5B%5D=saturday+and+sunday&days%5B%5D&days%5B%5D=false", path
end

path = Inventory.singleton_path(product_id: 5)
assert_equal "/products/5/inventory.json", path
Expand Down
Loading