Commit 05bcb937999339f103d22fadbb74672acebd1c94

Authored by MoisesMachado
1 parent e7e9def1

ActionItem371: fixed a bug that make tickets do not have targets

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2472 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/my_profile/tasks_controller.rb
... ... @@ -23,7 +23,7 @@ class TasksController < MyProfileController
23 23 end
24 24  
25 25 def new
26   - target = profile.friends.find_by_id(params[:target_id])
  26 + target = profile.friends.find_by_id(params[:ticket][:target_id]) if params[:ticket]
27 27 @ticket = Ticket.new(params[:ticket])
28 28 @ticket.target = target
29 29 @ticket.requestor = profile
... ...
test/functional/tasks_controller_test.rb
... ... @@ -128,4 +128,13 @@ class TasksControllerTest < Test::Unit::TestCase
128 128  
129 129 assert_includes assigns(:tasks), task
130 130 end
  131 +
  132 + should 'set target of ticket when creating it' do
  133 + f = create_user('friend').person
  134 + profile.add_friend f
  135 +
  136 + post :new, :profile => profile.identifier, :ticket => {:title => 'test ticket', :target_id => f.id}
  137 +
  138 + assert_equal f, assigns(:ticket).target
  139 + end
131 140 end
... ...