forked from OpenNeo/impress
Auto log in as test user in development mode
I want to test some logged-in stuff, but the whole openneo_id app is a mess to integrate with (and I want to eliminate it down the line anyway), so here's a simple hacky thing that just gets you into a test user for development!
This commit is contained in:
parent
23b84cba26
commit
cff393f014
1 changed files with 6 additions and 0 deletions
|
@ -8,6 +8,7 @@ class ApplicationController < ActionController::Base
|
||||||
helper_method :can_use_image_mode?, :user_is?
|
helper_method :can_use_image_mode?, :user_is?
|
||||||
|
|
||||||
before_filter :set_locale
|
before_filter :set_locale
|
||||||
|
before_filter :login_as_test_user if Rails.env.development?
|
||||||
|
|
||||||
def authenticate_user! # too lazy to change references to login_path
|
def authenticate_user! # too lazy to change references to login_path
|
||||||
redirect_to(login_path) unless user_signed_in?
|
redirect_to(login_path) unless user_signed_in?
|
||||||
|
@ -66,5 +67,10 @@ class ApplicationController < ActionController::Base
|
||||||
def valid_locale?(locale)
|
def valid_locale?(locale)
|
||||||
locale && I18n.usable_locales.include?(locale.to_sym)
|
locale && I18n.usable_locales.include?(locale.to_sym)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def login_as_test_user
|
||||||
|
test_user = User.find_by_name('test')
|
||||||
|
sign_in(:user, test_user, bypass: true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue