Commit f126e4411cf9303d86632bb7e74fac17dd7d21d6

Authored by AntonioTerceiro
1 parent 2b065b7d

ActionItem16: adding pending_for to list pending actions for a given profile




git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@839 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing 2 changed files with 16 additions and 0 deletions   Show diff stats
app/models/task.rb
... ... @@ -134,6 +134,10 @@ class Task < ActiveRecord::Base
134 134  
135 135 class << self
136 136  
  137 + def pending_for(target)
  138 + self.find(:all, :conditions => { :target_id => target.id, :status => Task::Status::ACTIVE })
  139 + end
  140 +
137 141 # generates a random code string consisting of 36 characters in the ranges
138 142 # a-z and 0-9
139 143 def generate_code
... ...
test/unit/task_test.rb
... ... @@ -149,6 +149,18 @@ class TaskTest &lt; Test::Unit::TestCase
149 149 task.save!
150 150 end
151 151  
  152 + should 'be able to list pending tasks for a given target' do
  153 + target = sample_user
  154 +
  155 + assert_equal [], Task.pending_for(target)
  156 +
  157 + task = Task.new
  158 + task.target = target
  159 + task.save!
  160 +
  161 + assert_equal [task], Task.pending_for(target)
  162 + end
  163 +
152 164 protected
153 165  
154 166 def sample_user
... ...