mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-19 06:15:44 -04:00
Order crops case-insensitively by default.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user