Skip to content

Commit

Permalink
Add way to get ordered deadlines in lab
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarrasch committed Aug 14, 2012
1 parent 46efe05 commit eb3c198
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/lab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,10 @@ def method_missing(meth, *args, &blk)
def numbered_name
"Lab #{number}"
end

# Return all deadlines in ascending order
def ordered_deadlines
# So far we rely on the dd model to have default scope
default_deadlines.all
end
end
9 changes: 9 additions & 0 deletions spec/models/lab_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@
it "should have a list of deadlines" do
build(:lab, default_deadlines: [create(:default_deadline)]).should have(1).default_deadlines
end

it "should have a ascending list of deadlines" do
snd = build(:default_deadline_without_lab, at: 50.days.from_now)
fst = build(:default_deadline_without_lab, at: 20.days.from_now)

lab = create(:lab, default_deadlines: [snd, fst])
lab.should have(2).default_deadlines
lab.ordered_deadlines.first.should eq fst
end
end

describe "#active" do
Expand Down

0 comments on commit eb3c198

Please sign in to comment.