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