Order crops case-insensitively by default.

This commit is contained in:
Miles Gould committed 2013-01-25 11:19:15 +00:00
1 parent 8d2fe8809d
commit dc1ab0912f
2 files changed
+9

No files matched your search

+1
View File
@@ -4,6 +4,7 @@ class Crop < ActiveRecord::Base
attr_accessible :en_wikipedia_url, :system_name
has_many :scientific_names
has_many :plantings
default_scope order("lower(system_name) asc")
def Crop.random
@crop = Crop.offset(rand(Crop.count)).first
+8
View File
@@ -42,4 +42,12 @@ describe Crop do
@rand_crop.system_name.should == 'Tomato'
end
end
context 'ordering' do
it "should be sorted case-insensitively" do
uppercase = FactoryGirl.create(:uppercasecrop)
lowercase = FactoryGirl.create(:lowercasecrop)
Crop.first.should == lowercase
end
end
end