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

studio.code.org: redirect to /home if signed in, otherwise /courses #17500

Merged
merged 2 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 2 additions & 9 deletions dashboard/app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,11 @@ def health_check

GALLERY_PER_PAGE = 5

# Signed in student with assigned course: redirect to current_lesson
# Signed in, not student with assigned course: redirect to /home
# Signed in: redirect to /home
# Signed out: redirect to /courses
def index
if current_user
# We skip the redirect if the user does not have an age set, because we
# pop up the age interstitial on /home
if current_user.student? && current_user.primary_script && current_user.age.present?
redirect_to script_next_path(current_user.primary_script)
else
redirect_to '/home'
end
redirect_to '/home'
else
redirect_to '/courses'
end
Expand Down
25 changes: 1 addition & 24 deletions dashboard/test/controllers/home_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,14 @@ class HomeControllerTest < ActionController::TestCase
Properties.stubs(:get).returns nil
end

test "redirect to /home when signed in and not a student with course progress" do
test "redirect index when signed in" do
user = create(:user)
sign_in user
get :index

assert_redirected_to '/home'
end

test "student with course progress is redirected to next lesson" do
student = create :student
script = create :script
sign_in student
User.any_instance.expects(:primary_script).returns(script).twice
get :index

assert_redirected_to script_next_path(script)
end

test "student with course progress and no age is not redirected to next lesson" do
student = create :student
student.birthday = nil
student.age = nil
student.save(validate: false)
script = create :script
sign_in student
User.any_instance.expects(:primary_script).returns(script)
get :index

assert_redirected_to '/home'
end

test "redirect index when signed out" do
get :index

Expand Down