Improve code coverage for app/models/user.rb
Related to Improve code coverage for app/models/user.rb (#435160 - closed) which added coverage to app/models/user.rb
relating to [Source Code Backend] FCL for Incident 17213 (gitlab-com&2265 - closed).
This Issue tracks adding coverage to the remaining code that was unrelated.
Fix the test gaps reported for this file on https://gitlab-org.gitlab.io/gitlab/coverage-ruby/
As of 00769538, the current coverage gaps for User
(https://gitlab-org.gitlab.io/gitlab/coverage-ruby/#35c38ceff63c512a6a8b1f4d336518a9b805040d) are:
From line 712:
+ def find_for_database_authentication(warden_conditions)
+ conditions = warden_conditions.dup
+ if login = conditions.delete(:login)
+ where(conditions).find_by("lower(username) = :value OR lower(email) = :value", value: login.downcase.strip)
else
- find_by(conditions)
end
end
From line 767:
+ def filter_items(filter_name)
+ case filter_name
when 'admins'
+ admins
when 'blocked'
+ blocked
when 'blocked_pending_approval'
+ blocked_pending_approval
when 'banned'
+ banned
when 'two_factor_disabled'
+ without_two_factor
when 'two_factor_enabled'
+ with_two_factor
when 'wop'
+ without_projects
when 'external'
- external
when 'deactivated'
+ deactivated
when "trusted"
+ trusted
else
+ active_without_ghosts
end
end
From line 1383:
def crowd_user?
+ if identities.loaded?
- identities.find { |identity| identity.provider == 'crowd' && identity.extern_uid.present? }
else
+ identities.with_any_extern_uid('crowd').exists?
end
end
From line 1475:
+ def ldap_sync_time
# This number resides in this method so it can be redefined in EE.
- 1.hour
end
From line 1508:
+ def can_leave_project?(project)
- project.namespace != namespace &&
project.member(self)
end
From line 1812:
+ def can_remove_self?
- true
end
From line 1981:
+ def access_level=(new_level)
- new_level = new_level.to_s
- return unless %w[admin regular].include?(new_level)
- self.admin = (new_level == 'admin')
end
From line 2304:
+ def consume_otp!
+ if self.consumed_timestep != current_otp_timestep
+ self.consumed_timestep = current_otp_timestep
+ return Gitlab::Database.read_only? ? true : save(validate: false)
end
- false
end
From line 2426:
+ def has_current_license?
- false
end
Edited by Ash McKenzie