Skip to content

Commit

Permalink
Fixed priority problem in team view.
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Tufró committed Jul 8, 2010
1 parent dd31ed6 commit a8ae035
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions app/models/story.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def finished?
end

def start
self.priority = old_priority if finished?
self.status = 'in_progress'
return self.save
end
Expand All @@ -74,6 +75,8 @@ def stop

def finish
self.status = 'finished'
self.old_priority = priority
self.priority = -1
return self.save
end

Expand Down
5 changes: 2 additions & 3 deletions app/models/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class Team < ActiveRecord::Base
#
################################################################################################################
def stories
stories = projects.collect { |project| project.stories }.flatten
stories = stories.sort_by {|story| [story.priority, story.updated_at] }
stories.reverse
project_ids = projects.collect { |project| project.id }
Story.all(:conditions => {:project_id => project_ids}, :order => "priority DESC, updated_at DESC")
end
end
4 changes: 1 addition & 3 deletions app/views/backlog/_backlog_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@
%th Size
%th Description

= render :partial => 'stories/story', :collection => @stories.in_progress
= render :partial => 'stories/story', :collection => @stories.not_started
= render :partial => 'stories/story', :collection => @stories.finished
= render :partial => 'stories/story', :collection => @stories
9 changes: 9 additions & 0 deletions db/migrate/20100708202719_add_old_priority_to_stories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddOldPriorityToStories < ActiveRecord::Migration
def self.up
add_column :stories, :old_priority, :integer
end

def self.down
remove_column :stories, :old_priority
end
end
7 changes: 6 additions & 1 deletion test/unit/story_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class StoryTest < ActiveSupport::TestCase
should "return -1" do
assert_equal -1, @story.priority
end

should "return 10 if calling old_priority" do
assert_equal 10, @story.old_priority
end

context "if i change the realid" do
setup do
Expand Down Expand Up @@ -235,11 +239,12 @@ class StoryTest < ActiveSupport::TestCase
@story.finish
end

should "should finish the story" do
should "finish the story" do
assert !@project.stories.in_progress.include?(@story)
assert !@project.stories.not_started.include?(@story)
assert @project.stories.finished.include?(@story)
assert_equal -1, @story.priority
assert_equal 2000, @story.old_priority
end
end

Expand Down

0 comments on commit a8ae035

Please sign in to comment.