Redirect users in homepage to homepage after login
For reasons I'm not sure about, the homepage (and the welcome pages) were an exception in our "redirect users to the same page they were" policy. I'm not sure about the welcome pages (no test was present indicating they should behave in a special way), but in the case of the home page, it was a bit annoying to be redirected to a different place after signing in.
This commit is contained in:
@@ -107,7 +107,7 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def set_return_url
|
||||
if !devise_controller? && controller_name != "welcome" && is_navigational_format?
|
||||
if !devise_controller? && is_navigational_format?
|
||||
store_location_for(:user, request.fullpath)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,8 +6,10 @@ describe "Sessions" do
|
||||
debate = create(:debate)
|
||||
|
||||
visit debate_path(debate)
|
||||
|
||||
login_through_form_as(user)
|
||||
click_link "Sign in"
|
||||
fill_in "user_login", with: user.email
|
||||
fill_in "user_password", with: user.password
|
||||
click_button "Enter"
|
||||
|
||||
expect(page).to have_content("You have been signed in successfully")
|
||||
expect(page).to have_current_path(debate_path(debate))
|
||||
@@ -30,4 +32,17 @@ describe "Sessions" do
|
||||
|
||||
expect(page).to have_current_path budget_investments_path(heading.budget, heading_id: "outskirts")
|
||||
end
|
||||
|
||||
scenario "Sign in redirects to the homepage if the user was there" do
|
||||
user = create(:user, :level_two)
|
||||
|
||||
visit debates_path
|
||||
visit "/"
|
||||
click_link "Sign in"
|
||||
fill_in "user_login", with: user.email
|
||||
fill_in "user_password", with: user.password
|
||||
click_button "Enter"
|
||||
|
||||
expect(page).to have_current_path "/"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user