Added a Rate#locked? check. #1919

This commit is contained in:
Eric Davis
2009-01-16 15:23:30 -08:00
parent 931ecae4d1
commit 9b0332bf78
2 changed files with 16 additions and 0 deletions

View File

@@ -13,4 +13,7 @@ class Rate < ActiveRecord::Base
}
}
def locked?
return self.time_entries.length > 0
end
end

View File

@@ -57,3 +57,16 @@ describe Rate, 'associations' do
end
describe Rate, 'locked?' do
it 'should be true if a Time Entry is associated' do
rate = Rate.new
rate.time_entries << mock_model(TimeEntry)
rate.locked?.should be_true
end
it 'should be false if no Time Entries are associated' do
rate = Rate.new
rate.locked?.should be_false
end
end