Commit b0ca1d1f

mo khan <mo@mokhan.ca>
2013-06-28 21:53:31
always display the users in the order that the signed up
1 parent 7239eaa
Changed files (2)
app
models
spec
app/models/user.rb
@@ -10,6 +10,7 @@ class User < ActiveRecord::Base
   has_one :avatar
   acts_as_tagger
   before_save :ensure_authentication_token
+  default_scope order(:created_at)
 
   def add_favorite(creation)
     creation.liked_by(self)
spec/models/user_spec.rb
@@ -32,6 +32,7 @@ describe User do
         user.errors[:website].should === []
       end
     end
+
     describe "when the url is not valid" do
       let(:user) {User.new}
       before(:each) do
@@ -45,6 +46,7 @@ describe User do
       end
     end
   end
+
   describe "when commenting on a creation" do
     let(:comment) { fake }
     let(:creation) { fake }
@@ -113,4 +115,27 @@ describe User do
       end
     end
   end
+
+  describe "when loading all the users" do
+    let(:first_person) { FactoryGirl.create(:user) }
+    let(:second_person) { FactoryGirl.create(:user) }
+
+    before :each do
+      first_person
+      second_person
+      first_person.touch
+    end
+
+    let(:results) { User.all }
+
+    it "should load the person who signed up first first" do
+      results[0].should == first_person
+    end
+
+    it "should load the person who signed up next second" do
+      results[1].should == second_person
+    end
+  end
+
+
 end