summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2014-10-10 15:15:34 +0300
committerValery Sizov <valery@gitlab.com>2014-10-13 16:07:57 +0300
commit4e0da2325b689221cb7f675648380fcbc2a9a492 (patch)
tree822f3c3dc738e4ec31f46dd64e862db270c70edf /spec
parent9c824888c899393b5d72afe18b8bb0a134beec67 (diff)
downloadgitlab-ce-4e0da2325b689221cb7f675648380fcbc2a9a492.tar.gz
Admin: user sorting
Diffstat (limited to 'spec')
-rw-r--r--spec/models/user_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 0250014bc21..8c79bf5f3c2 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -429,4 +429,32 @@ describe User do
expect(user.starred?(project)).to be_false
end
end
+
+ describe "#sort" do
+ before do
+ User.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'
+ end
+
+ it "sorts users as recently_signed_in" do
+ User.sort('recent_sign_in').first.should == @user
+ end
+
+ it "sorts users as late_signed_in" do
+ User.sort('oldest_sign_in').first.should == @user1
+ end
+
+ it "sorts users as recently_created" do
+ User.sort('recently_created').first.should == @user
+ end
+
+ it "sorts users as late_created" do
+ User.sort('late_created').first.should == @user1
+ end
+
+ it "sorts users by name when nil is passed" do
+ User.sort(nil).first.should == @user
+ end
+ end
end