Merge pull request #2598 from differentreality/disabled_user

Revert change of active user definition
This commit is contained in:
Henne Vogelsang 2019-10-25 20:00:54 +02:00 committed by GitHub
commit af8cfafb2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -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
}

View file

@ -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