Add spec to expose a bug finding manager logged in
I've moved the method to the User model in order to make it easier to test. I'm not sure where it belongs, though. There was already a failing spec in `spec/features/management_spec.rb`, but it passed if run standalone because it only failed if previous tests had already created nine users or more.
This commit is contained in:
@@ -56,7 +56,7 @@ class Management::BaseController < ActionController::Base
|
||||
|
||||
def manager_logged_in
|
||||
if current_manager
|
||||
@manager_logged_in = User.find_by(id: session[:manager]["login"].last(1))
|
||||
@manager_logged_in = User.find_by_manager_login(session[:manager]["login"])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -329,6 +329,10 @@ class User < ActiveRecord::Base
|
||||
where(conditions.to_hash).where(["username = ?", login]).first
|
||||
end
|
||||
|
||||
def self.find_by_manager_login(manager_login)
|
||||
find_by(id: manager_login.last(1))
|
||||
end
|
||||
|
||||
def interests
|
||||
followables = follows.map(&:followable)
|
||||
followables.compact.map { |followable| followable.tags.map(&:name) }.flatten.compact.uniq
|
||||
|
||||
Reference in New Issue
Block a user