This makes future refactoring easier.
13 files changed:
# Offense count: 487
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
# Offense count: 487
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
# Offense count: 62
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
# Offense count: 62
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
def require_user
unless current_user
if request.get?
def require_user
unless current_user
if request.get?
- redirect_to :controller => "users", :action => "login", :referer => request.fullpath
+ redirect_to login_path(:referer => request.fullpath)
end
elsif request.get?
respond_to do |format|
end
elsif request.get?
respond_to do |format|
- format.html { redirect_to :controller => "users", :action => "login", :referer => request.fullpath }
+ format.html { redirect_to login_path(:referer => request.fullpath) }
format.any { head :forbidden }
end
else
format.any { head :forbidden }
end
else
render :action => "new"
else
flash[:notice] = t ".wrong_user", :user => current_user.display_name
render :action => "new"
else
flash[:notice] = t ".wrong_user", :user => current_user.display_name
- redirect_to :controller => "users", :action => "login", :referer => request.fullpath
+ redirect_to login_path(:referer => request.fullpath)
end
rescue ActiveRecord::RecordNotFound
@title = t "messages.no_such_message.title"
end
rescue ActiveRecord::RecordNotFound
@title = t "messages.no_such_message.title"
@message.save
else
flash[:notice] = t ".wrong_user", :user => current_user.display_name
@message.save
else
flash[:notice] = t ".wrong_user", :user => current_user.display_name
- redirect_to :controller => "users", :action => "login", :referer => request.fullpath
+ redirect_to login_path(:referer => request.fullpath)
end
rescue ActiveRecord::RecordNotFound
@title = t "messages.no_such_message.title"
end
rescue ActiveRecord::RecordNotFound
@title = t "messages.no_such_message.title"
token = user.tokens.create
UserMailer.lost_password(user, token).deliver_later
flash[:notice] = t "users.lost_password.notice email on way"
token = user.tokens.create
UserMailer.lost_password(user, token).deliver_later
flash[:notice] = t "users.lost_password.notice email on way"
- redirect_to :action => "login"
else
flash.now[:error] = t "users.lost_password.notice email cannot find"
end
else
flash.now[:error] = t "users.lost_password.notice email cannot find"
end
token = UserToken.find_by(:token => params[:confirm_string])
if token&.user&.active?
flash[:error] = t("users.confirm.already active")
token = UserToken.find_by(:token => params[:confirm_string])
if token&.user&.active?
flash[:error] = t("users.confirm.already active")
- redirect_to :action => "login"
elsif !token || token.expired?
flash[:error] = t("users.confirm.unknown token")
redirect_to :action => "confirm"
elsif !token || token.expired?
flash[:error] = t("users.confirm.unknown token")
redirect_to :action => "confirm"
if token.nil? || token.user != user
flash[:notice] = t("users.confirm.success")
if token.nil? || token.user != user
flash[:notice] = t("users.confirm.success")
- redirect_to :action => :login, :referer => referer
+ redirect_to login_path(:referer => referer)
flash[:notice] = t "users.confirm_resend.success_html", :email => user.email, :sender => Settings.support_email
end
flash[:notice] = t "users.confirm_resend.success_html", :email => user.email, :sender => Settings.support_email
end
- redirect_to :action => "login"
<% unless current_user %>
<div class="notice">
<% unless current_user %>
<div class="notice">
- <%= link_to(t(".join_discussion"), :controller => "users", :action => "login", :referer => request.fullpath) %>
+ <%= link_to(t(".join_discussion"), login_path(:referer => request.fullpath)) %>
<% end %>
<% end %>
<% else %>
<% end %>
<% end %>
<% else %>
- <h3 id="newcomment"><%= t(".login_to_leave_a_comment_html", :login_link => link_to(t(".login"), :controller => "users", :action => "login", :referer => request.fullpath)) %></h3>
+ <h3 id="newcomment"><%= t(".login_to_leave_a_comment_html", :login_link => link_to(t(".login"), login_path(:referer => request.fullpath))) %></h3>
get friend_changesets_path
assert_response :redirect
get friend_changesets_path
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => friend_changesets_path
+ assert_redirected_to login_path(:referer => friend_changesets_path)
session_for(private_user)
session_for(private_user)
get nearby_changesets_path
assert_response :redirect
get nearby_changesets_path
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => nearby_changesets_path
+ assert_redirected_to login_path(:referer => nearby_changesets_path)
session_for(private_user)
session_for(private_user)
# are not logged in
get new_diary_entry_path
assert_response :redirect
# are not logged in
get new_diary_entry_path
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => "/diary/new"
+ assert_redirected_to login_path(:referer => "/diary/new")
# not logged in, without and with the id of the entry you want to edit
get edit_diary_entry_path(:display_name => entry.user.display_name, :id => entry)
assert_response :redirect
# not logged in, without and with the id of the entry you want to edit
get edit_diary_entry_path(:display_name => entry.user.display_name, :id => entry)
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit"
+ assert_redirected_to login_path(:referer => "/user/#{ERB::Util.u(entry.user.display_name)}/diary/#{entry.id}/edit")
# Try a list of diary entries for your friends when not logged in
get friends_diary_entries_path
assert_response :redirect
# Try a list of diary entries for your friends when not logged in
get friends_diary_entries_path
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => "/diary/friends"
+ assert_redirected_to login_path(:referer => "/diary/friends")
# Try a list of diary entries for your friends when logged in
session_for(user)
# Try a list of diary entries for your friends when logged in
session_for(user)
# Try a list of diary entries for nearby users when not logged in
get nearby_diary_entries_path
assert_response :redirect
# Try a list of diary entries for nearby users when not logged in
get nearby_diary_entries_path
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => "/diary/nearby"
+ assert_redirected_to login_path(:referer => "/diary/nearby")
# Try a list of diary entries for nearby users when logged in
session_for(nearby_user)
# Try a list of diary entries for nearby users when logged in
session_for(nearby_user)
get edit_path
assert_response :redirect
get edit_path
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => "/edit"
+ assert_redirected_to login_path(:referer => "/edit")
end
# Test the error when trying to edit without public edits
end
# Test the error when trying to edit without public edits
def test_welcome
get welcome_path
assert_response :redirect
def test_welcome
get welcome_path
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => "/welcome"
+ assert_redirected_to login_path(:referer => "/welcome")
session_for(create(:user))
get welcome_path
session_for(create(:user))
get welcome_path
# First try to get it when not logged in
get traces_mine_path
# First try to get it when not logged in
get traces_mine_path
- assert_redirected_to :controller => "users", :action => "login", :referer => "/traces/mine"
+ assert_redirected_to login_path(:referer => "/traces/mine")
# First with no auth
get new_trace_path
assert_response :redirect
# First with no auth
get new_trace_path
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => new_trace_path
+ assert_redirected_to login_path(:referer => new_trace_path)
# Now authenticated as a user with gps.trace.visibility set
user = create(:user)
# Now authenticated as a user with gps.trace.visibility set
user = create(:user)
# First with no auth
get edit_trace_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file)
assert_response :redirect
# First with no auth
get edit_trace_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file)
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :referer => edit_trace_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file.id)
+ assert_redirected_to login_path(:referer => edit_trace_path(:display_name => public_trace_file.user.display_name, :id => public_trace_file.id))
# Now with some other user, which should fail
session_for(create(:user))
# Now with some other user, which should fail
session_for(create(:user))
confirm_string = User.find_by(:email => user.email).tokens.create(:referer => new_diary_entry_path).token
post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
confirm_string = User.find_by(:email => user.email).tokens.create(:referer => new_diary_entry_path).token
post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
- assert_redirected_to :action => "login"
+ assert_redirected_to login_path
assert_match(/already been confirmed/, flash[:error])
end
assert_match(/already been confirmed/, flash[:error])
end
end
end
assert_response :redirect
end
end
assert_response :redirect
- assert_redirected_to :action => :login
+ assert_redirected_to login_path
assert_match(/^Sorry you lost it/, flash[:notice])
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_match(/^Sorry you lost it/, flash[:notice])
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
end
end
assert_response :redirect
end
end
assert_response :redirect
- assert_redirected_to :action => :login
+ assert_redirected_to login_path
assert_match(/^Sorry you lost it/, flash[:notice])
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_match(/^Sorry you lost it/, flash[:notice])
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
end
end
assert_response :redirect
end
end
assert_response :redirect
- assert_redirected_to :action => :login
+ assert_redirected_to login_path
assert_match(/^Sorry you lost it/, flash[:notice])
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_match(/^Sorry you lost it/, flash[:notice])
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
end
end
assert_response :redirect
end
end
assert_response :redirect
- assert_redirected_to :action => :login
+ assert_redirected_to login_path
assert_match(/^Sorry you lost it/, flash[:notice])
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_match(/^Sorry you lost it/, flash[:notice])
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
# you are not logged in
get user_account_path(user)
assert_response :redirect
# you are not logged in
get user_account_path(user)
assert_response :redirect
- assert_redirected_to :action => "login", :referer => "/user/#{ERB::Util.u(user.display_name)}/account"
+ assert_redirected_to login_path(:referer => "/user/#{ERB::Util.u(user.display_name)}/account")
# Make sure that you are blocked when not logged in as the right user
session_for(create(:user))
# Make sure that you are blocked when not logged in as the right user
session_for(create(:user))
# Shouldn't work when not logged in
get users_path
assert_response :redirect
# Shouldn't work when not logged in
get users_path
assert_response :redirect
- assert_redirected_to :action => :login, :referer => users_path
+ assert_redirected_to login_path(:referer => users_path)
get "/login"
assert_response :redirect
get "/login"
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true"
+ assert_redirected_to login_path(:cookie_test => "true")
follow_redirect!
assert_response :success
post "/login", :params => { "username" => user.email, "password" => "test", :referer => "/user/#{ERB::Util.u(user.display_name)}" }
follow_redirect!
assert_response :success
post "/login", :params => { "username" => user.email, "password" => "test", :referer => "/user/#{ERB::Util.u(user.display_name)}" }
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :cookie_test => true, :referer => "/history"
+ assert_redirected_to login_path(:cookie_test => true, :referer => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :cookie_test => true, :referer => "/history"
+ assert_redirected_to login_path(:cookie_test => true, :referer => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :cookie_test => true, :referer => "/history"
+ assert_redirected_to login_path(:cookie_test => true, :referer => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :cookie_test => true, :referer => "/history"
+ assert_redirected_to login_path(:cookie_test => true, :referer => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
get "/login", :params => { :referer => "/history" }
assert_response :redirect
get "/login", :params => { :referer => "/history" }
assert_response :redirect
- assert_redirected_to "controller" => "users", "action" => "login", "cookie_test" => "true", "referer" => "/history"
+ assert_redirected_to login_path("cookie_test" => "true", "referer" => "/history")
follow_redirect!
assert_response :success
assert_template "users/login"
follow_redirect!
assert_response :success
assert_template "users/login"
def try_password_login(username, password, remember_me = nil)
get "/login"
assert_response :redirect
def try_password_login(username, password, remember_me = nil)
get "/login"
assert_response :redirect
- assert_redirected_to :controller => :users, :action => :login, :cookie_test => true
+ assert_redirected_to login_path(:cookie_test => true)
follow_redirect!
assert_response :success
assert_template "login"
follow_redirect!
assert_response :success
assert_template "login"