From 05bcb937999339f103d22fadbb74672acebd1c94 Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Fri, 5 Sep 2008 20:34:54 +0000 Subject: [PATCH] ActionItem371: fixed a bug that make tickets do not have targets --- app/controllers/my_profile/tasks_controller.rb | 2 +- test/functional/tasks_controller_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index 2d23b11..9d35e63 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -23,7 +23,7 @@ class TasksController < MyProfileController end def new - target = profile.friends.find_by_id(params[:target_id]) + target = profile.friends.find_by_id(params[:ticket][:target_id]) if params[:ticket] @ticket = Ticket.new(params[:ticket]) @ticket.target = target @ticket.requestor = profile diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index 169fbcf..61e0fb9 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -128,4 +128,13 @@ class TasksControllerTest < Test::Unit::TestCase assert_includes assigns(:tasks), task end + + should 'set target of ticket when creating it' do + f = create_user('friend').person + profile.add_friend f + + post :new, :profile => profile.identifier, :ticket => {:title => 'test ticket', :target_id => f.id} + + assert_equal f, assigns(:ticket).target + end end -- libgit2 0.21.2