Sha256: fc35e756d0ced4e1ce6efa86c18195232d81340af13906c9af975d60e4f33a56

Contents?: true

Size: 1.77 KB

Versions: 3

Compression:

Stored size: 1.77 KB

Contents

require File.dirname(__FILE__) + '/../test_helper'

class TaskTest < ActiveSupport::TestCase
  include UserSystem
  
  main_scenario
  
  def setup
    self.current_user = User.find(1000001)
  end

  def teardown
    self.current_user = nil
  end

  def test_two_started_tasks
    tasks(:first).start_work
    tasks(:another).start_work
  end

  def test_two_started_tasks_anonymous
    self.current_user = nil
    tasks(:first).start_work
    tasks(:another).start_work
  end
  
  def test_move_task_to_period
    before = Task.find(tasks(:another).id)
    period = periods(:future)
    
    before.move_to_period period
    
    check_move_effects(before, :future)
  end

  def test_move_task_to_period_subtask
    before = Task.find(tasks(:subsubtask).id)
    period = periods(:future)

    before.move_to_period period
    
    check_move_effects(before, :future)
  end

  private
  
  def check_move_effects(before, period_sym)
    after = Task.find(before.id)
    assert_equal before.period_id, after.period_id
    assert_equal Task::POSTPONED, after.resolution
    assert_not_nil after.finished_at
    
    newest_task = Task.find(:first, :order => 'id DESC')
    new_task = Task.find_descendant(periods(period_sym).id, before.id)
    assert_not_nil newest_task
    assert_not_nil new_task
    assert_equal newest_task.id, new_task.id
    assert_equal before.previous_task_id || before.id, new_task.previous_task_id
    assert_nil new_task.finished_at
    assert_nil new_task.resolution
    assert_equal 1, new_task.position
    
    while before.parent
      before = before.parent
      new_parent_task = Task.find_descendant(periods(period_sym).id, before.id)
      assert new_parent_task
      assert_equal new_parent_task.id, new_task.parent_id
      new_task = new_parent_task
    end
  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
backlog-0.37.2 test/unit/task_test.rb
backlog-0.37.1 test/unit/task_test.rb
backlog-0.36.2 test/unit/task_test.rb