Merge pull request #1492 from basecamp/land-bug

Don't choke when no collections
This commit is contained in:
Jorge Manrubia
2025-11-05 08:32:28 +01:00
committed by GitHub
2 changed files with 9 additions and 3 deletions
+3 -3
View File
@@ -1,9 +1,9 @@
class LandingsController < ApplicationController
def show
if Current.user.collections.many?
redirect_to events_path
else
if Current.user.collections.one?
redirect_to collection_path(Current.user.collections.first)
else
redirect_to events_path
end
end
end
@@ -10,6 +10,12 @@ class LandingsControllerTest < ActionDispatch::IntegrationTest
assert_redirected_to events_path
end
test "redirects to the timeline when no collections" do
Collection.destroy_all
get landing_path
assert_redirected_to events_path
end
test "redirects to collections when only one collection" do
sole_collection, *collections_to_delete = users(:kevin).collections.to_a
collections_to_delete.each(&:destroy)