Commit 9fc15501de99ed770c9e045da45ab80ba3c8301d

Authored by Leandro Santos
1 parent e1d2bf9c

HOTFIX: fix tests

app/controllers/my_profile/tasks_controller.rb
... ... @@ -84,7 +84,7 @@ class TasksController < MyProfileController
84 84 end
85 85 end
86 86  
87   - url = task_action(:index)
  87 + url = { :action => 'index' }
88 88  
89 89 if failed.blank?
90 90 session[:notice] = _("All decisions were applied successfully.")
... ... @@ -133,10 +133,9 @@ class TasksController < MyProfileController
133 133  
134 134 ActsAsTaggableOn.remove_unused_tags = true
135 135  
136   - task = Task.to(profile).find_by_id params[:task_id]
137   - save = user.tag(task, with: params[:tag_list], on: :tags)
138   -
139   - if save
  136 + task = profile.tasks.find_by_id(params[:task_id])
  137 +
  138 + if task && task.update_attributes(:tag_list => params[:tag_list])
140 139 result[:success] = true
141 140 end
142 141 end
... ...
test/functional/tasks_controller_test.rb
... ... @@ -464,11 +464,8 @@ class TasksControllerTest < ActionController::TestCase
464 464  
465 465 requestor = fast_create(Person)
466 466  
467   - task_one = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Task Test'})
468   - task_two = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Another Task'})
469   -
470   - person.tag(task_one, with: 'noosfero,test', on: :tags)
471   - person.tag(task_two, with: 'test', on: :tags)
  467 + task_one = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Task Test'}, :tag_list => 'noosfero, test')
  468 + task_two = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Another Task'}, :tag_list => 'test')
472 469  
473 470 get :index, :filter_tags => 'noosfero'
474 471  
... ... @@ -730,9 +727,6 @@ class TasksControllerTest < ActionController::TestCase
730 727  
731 728 assert_not_includes task_one.tags_from(nil), 'test'
732 729 end
733   -#region_validators_controller_test.rb: give_permission('ze', 'manage_environment_validators', environment)
734   -#profile_editor_controller_test.rb: user2.stubs(:has_permission?).with('edit_profile', anything).returns(true)
735   -#profile_editor_controller_test.rb: user2.expects(:has_permission?).with(:manage_friends, anything).returns(true)
736 730  
737 731 should 'not tag task with permission but another user' do
738 732 requestor = fast_create(Person)
... ...
test/unit/task_test.rb
... ... @@ -370,26 +370,21 @@ class TaskTest < ActiveSupport::TestCase
370 370 assert_not_includes Task.of(type), t3
371 371 assert_includes Task.of(nil), t3
372 372 end
373   -
374   -#FIXME This tests are not working
375 373 # should 'filter tasks by tags with named scope' do
376   -#
377   -# requestor = fast_create(Person)
378   -# target = fast_create(Person)
379   -# profile = sample_user
380   -#
381   -# task_one = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Task Test'})
382   -# task_two = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Another Task'})
383   -#
384   -# profile.tag(task_one, with: 'noosfero,test', on: :tags)
385   -# profile.tag(task_two, with: 'test', on: :tags)
386   -#
387   -# data = Task.tagged_with('noosfero', any: true)
388   -#
389   -# assert_includes data, task_one
390   -# assert_not_includes data, task_two
391   -#
392   -# end
  374 +
  375 + requestor = fast_create(Person)
  376 + target = fast_create(Person)
  377 + profile = sample_user
  378 +
  379 + task_one = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Task Test'}, :tag_list => 'noosfero,test')
  380 + task_two = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Another Task'}, :tag_list => 'test')
  381 +
  382 + data = Task.tagged_with('noosfero', any: true)
  383 +
  384 + assert_includes data, task_one
  385 + assert_not_includes data, task_two
  386 +
  387 + end
393 388  
394 389 should 'order tasks by some attribute correctly' do
395 390 Task.destroy_all
... ... @@ -497,22 +492,19 @@ class TaskTest < ActiveSupport::TestCase
497 492 task.save!
498 493 assert_equal person, task.responsible
499 494 end
500   -#FIXME this tests are not working
501   -# should 'save tasks tags' do
502   -#
503   -# requestor = fast_create(Person)
504   -# target = fast_create(Person)
505   -# profile = sample_user
506   -#
507   -# task_one = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Task Test'})
508   -# task_two = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Another Task'})
509   -#
510   -# profile.tag(task_one, with: 'noosfero,test', on: :tags)
511   -# profile.tag(task_two, with: 'test', on: :tags)
512   -#
513   -# assert_includes task_one.tags_from(nil), 'test'
514   -# assert_not_includes task_two.tags_from(nil), 'noosfero'
515   -# end
  495 +
  496 + should 'save tasks tags' do
  497 +
  498 + requestor = fast_create(Person)
  499 + target = fast_create(Person)
  500 + profile = sample_user
  501 +
  502 + task_one = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Task Test'}, :tag_list => 'noosfero,test')
  503 + task_two = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Another Task'}, :tag_list => 'test')
  504 +
  505 + assert_includes task_one.tags_from(nil), 'test'
  506 + assert_not_includes task_two.tags_from(nil), 'noosfero'
  507 + end
516 508  
517 509 should 'store who finish the task' do
518 510 t = Task.create
... ...