Merge pull request #1492 from basecamp/land-bug
Don't choke when no collections
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user