mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #2598 from differentreality/disabled_user
Revert change of active user definition
This commit is contained in:
commit
af8cfafb2d
2 changed files with 7 additions and 4 deletions
|
|
@ -34,7 +34,7 @@ class User < ApplicationRecord
|
|||
scope :comment_notifiable, ->(conference) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference.id)}
|
||||
|
||||
# scopes for user distributions
|
||||
scope :active, lambda {
|
||||
scope :recent, lambda {
|
||||
where('last_sign_in_at > ?', Date.today - 3.months).where(is_disabled: false)
|
||||
}
|
||||
scope :unconfirmed, -> { where('confirmed_at IS NULL') }
|
||||
|
|
@ -86,6 +86,9 @@ class User < ApplicationRecord
|
|||
accepts_nested_attributes_for :roles
|
||||
|
||||
scope :admin, -> { where(is_admin: true) }
|
||||
scope :active, lambda {
|
||||
where(is_disabled: false)
|
||||
}
|
||||
|
||||
validates :email, presence: true
|
||||
|
||||
|
|
@ -174,7 +177,7 @@ class User < ApplicationRecord
|
|||
# * +hash+ -> hash
|
||||
def self.distribution
|
||||
{
|
||||
'Active' => User.active.count,
|
||||
'Active' => User.recent.count,
|
||||
'Unconfirmed' => User.unconfirmed.count,
|
||||
'Dead' => User.dead.count
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,9 +101,9 @@ describe User do
|
|||
end
|
||||
|
||||
describe 'user distribution scopes' do
|
||||
it 'scopes active users' do
|
||||
it 'scopes recent users' do
|
||||
create(:user, last_sign_in_at: Date.today - 3.months + 1.day) # active
|
||||
expect(User.active.count).to eq(1)
|
||||
expect(User.recent.count).to eq(1)
|
||||
end
|
||||
|
||||
it 'scopes unconfirmed users' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue