diff options
author | Poornima <poornima.malepati@gmail.com> | 2017-08-26 18:05:25 +0530 |
---|---|---|
committer | Poornima <poornima.malepati@gmail.com> | 2018-02-05 23:05:54 +0530 |
commit | cca13d1e40812b60462461ca4387324778654960 (patch) | |
tree | 3112c01fd9df0205c196fbbdc7bf9d46fd546983 /spec | |
parent | 1214d8de691494138cbaab10da242c71504158de (diff) | |
download | gitlab-ce-cca13d1e40812b60462461ca4387324778654960.tar.gz |
Using correct column for sorting users by Recent Sign-in
Removing last_sign_in_at in specs
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/user_spec.rb | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 18c91d4cffd..27b33e29060 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1433,28 +1433,34 @@ describe User do describe '#sort' do before do described_class.delete_all - @user = create :user, created_at: Date.today, last_sign_in_at: Date.today, name: 'Alpha' - @user1 = create :user, created_at: Date.today - 1, last_sign_in_at: Date.today - 1, name: 'Omega' - @user2 = create :user, created_at: Date.today - 2, last_sign_in_at: nil, name: 'Beta' + @user = create :user, created_at: Date.today, current_sign_in_at: Date.today, name: 'Alpha' + @user1 = create :user, created_at: Date.today - 1, current_sign_in_at: Date.today - 1, name: 'Omega' + @user2 = create :user, created_at: Date.today - 2, name: 'Beta' end context 'when sort by recent_sign_in' do - it 'sorts users by the recent sign-in time' do - expect(described_class.sort('recent_sign_in').first).to eq(@user) + let(:users) { described_class.sort('recent_sign_in') } + + it 'sorts users by recent sign-in time' do + expect(users.first).to eq(@user) + expect(users.second).to eq(@user1) end it 'pushes users who never signed in to the end' do - expect(described_class.sort('recent_sign_in').third).to eq(@user2) + expect(users.third).to eq(@user2) end end context 'when sort by oldest_sign_in' do + let(:users) { described_class.sort('oldest_sign_in') } + it 'sorts users by the oldest sign-in time' do - expect(described_class.sort('oldest_sign_in').first).to eq(@user1) + expect(users.first).to eq(@user1) + expect(users.second).to eq(@user) end it 'pushes users who never signed in to the end' do - expect(described_class.sort('oldest_sign_in').third).to eq(@user2) + expect(users.third).to eq(@user2) end end |