mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-28 04:48:49 +01:00
fix #1417. We now handle unblocking a todo that is part of a hidden project or context
This commit is contained in:
parent
411c05c670
commit
2dca8bc0bf
2 changed files with 31 additions and 3 deletions
|
|
@ -78,7 +78,7 @@ class Todo < ActiveRecord::Base
|
|||
transitions :to => :active, :from => [:completed], :guard => :no_uncompleted_predecessors?
|
||||
transitions :to => :active, :from => [:pending], :guard => :no_uncompleted_predecessors_or_deferral?
|
||||
transitions :to => :pending, :from => [:completed], :guard => :uncompleted_predecessors?
|
||||
transitions :to => :deferred, :from => [:pending], :guard => :no_uncompleted_predecessors?
|
||||
transitions :to => :deferred, :from => [:pending], :guard => :guard_for_transition_from_deferred_to_pending
|
||||
end
|
||||
|
||||
aasm_event :hide do
|
||||
|
|
@ -92,7 +92,7 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
|
||||
aasm_event :block do
|
||||
transitions :to => :pending, :from => [:active, :deferred]
|
||||
transitions :to => :pending, :from => [:active, :deferred, :project_hidden]
|
||||
end
|
||||
|
||||
attr_protected :user
|
||||
|
|
@ -142,6 +142,14 @@ class Todo < ActiveRecord::Base
|
|||
return !uncompleted_predecessors.all.empty?
|
||||
end
|
||||
|
||||
def guard_for_transition_from_deferred_to_pending
|
||||
no_uncompleted_predecessors? && not_part_of_hidden_container?
|
||||
end
|
||||
|
||||
def not_part_of_hidden_container?
|
||||
!( (self.project && self.project.hidden?) || self.context.hidden? )
|
||||
end
|
||||
|
||||
# Returns a string with description <context, project>
|
||||
def specification
|
||||
project_name = self.project.is_a?(NullProject) ? "(none)" : self.project.name
|
||||
|
|
@ -185,7 +193,7 @@ class Todo < ActiveRecord::Base
|
|||
def remove_predecessor(predecessor)
|
||||
self.predecessors.delete(predecessor)
|
||||
if self.predecessors.empty?
|
||||
self.activate!
|
||||
self.not_part_of_hidden_container? ? self.activate! : self.hide!
|
||||
else
|
||||
save!
|
||||
end
|
||||
|
|
|
|||
|
|
@ -224,6 +224,26 @@ class TodoTest < ActiveSupport::TestCase
|
|||
assert !@not_completed1.starred?
|
||||
end
|
||||
|
||||
def test_hidden_todo_remains_hidden_after_getting_unblokked
|
||||
todo = todos(:call_bill)
|
||||
project=todo.project
|
||||
project.hide!
|
||||
|
||||
assert todo.reload.hidden?, "todo in hidden project should be hidden"
|
||||
|
||||
todo2 = todos(:call_dino_ext)
|
||||
todo.add_predecessor(todo2)
|
||||
todo.block!
|
||||
|
||||
assert todo.pending?, "todo with predecessor should be blocked"
|
||||
|
||||
# cannot activate if part of hidden project
|
||||
assert_raise(AASM::InvalidTransition) { todo.activate! }
|
||||
|
||||
todo.remove_predecessor(todo2)
|
||||
assert todo.reload.hidden?, "todo should be put back in hidden state"
|
||||
end
|
||||
|
||||
def test_todo_specification_handles_null_project
|
||||
# @not_completed1 has a project
|
||||
todo_desc = @not_completed1.description
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue