diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index 6357188..80bf161 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -84,7 +84,7 @@ class TasksController < MyProfileController end end - url = task_action(:index) + url = { :action => 'index' } if failed.blank? session[:notice] = _("All decisions were applied successfully.") @@ -133,10 +133,9 @@ class TasksController < MyProfileController ActsAsTaggableOn.remove_unused_tags = true - task = Task.to(profile).find_by_id params[:task_id] - save = user.tag(task, with: params[:tag_list], on: :tags) - - if save + task = profile.tasks.find_by_id(params[:task_id]) + + if task && task.update_attributes(:tag_list => params[:tag_list]) result[:success] = true end end diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index 775ead6..443db65 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -464,11 +464,8 @@ class TasksControllerTest < ActionController::TestCase requestor = fast_create(Person) - task_one = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Task Test'}) - task_two = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Another Task'}) - - person.tag(task_one, with: 'noosfero,test', on: :tags) - person.tag(task_two, with: 'test', on: :tags) + task_one = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Task Test'}, :tag_list => 'noosfero, test') + task_two = Task.create!(:requestor => requestor, :target => person, :data => {:name => 'Another Task'}, :tag_list => 'test') get :index, :filter_tags => 'noosfero' @@ -730,9 +727,6 @@ class TasksControllerTest < ActionController::TestCase assert_not_includes task_one.tags_from(nil), 'test' end -#region_validators_controller_test.rb: give_permission('ze', 'manage_environment_validators', environment) -#profile_editor_controller_test.rb: user2.stubs(:has_permission?).with('edit_profile', anything).returns(true) -#profile_editor_controller_test.rb: user2.expects(:has_permission?).with(:manage_friends, anything).returns(true) should 'not tag task with permission but another user' do requestor = fast_create(Person) diff --git a/test/unit/task_test.rb b/test/unit/task_test.rb index 994eb7a..e09c5bd 100644 --- a/test/unit/task_test.rb +++ b/test/unit/task_test.rb @@ -370,26 +370,21 @@ class TaskTest < ActiveSupport::TestCase assert_not_includes Task.of(type), t3 assert_includes Task.of(nil), t3 end - -#FIXME This tests are not working # should 'filter tasks by tags with named scope' do -# -# requestor = fast_create(Person) -# target = fast_create(Person) -# profile = sample_user -# -# task_one = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Task Test'}) -# task_two = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Another Task'}) -# -# profile.tag(task_one, with: 'noosfero,test', on: :tags) -# profile.tag(task_two, with: 'test', on: :tags) -# -# data = Task.tagged_with('noosfero', any: true) -# -# assert_includes data, task_one -# assert_not_includes data, task_two -# -# end + + requestor = fast_create(Person) + target = fast_create(Person) + profile = sample_user + + task_one = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Task Test'}, :tag_list => 'noosfero,test') + task_two = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Another Task'}, :tag_list => 'test') + + data = Task.tagged_with('noosfero', any: true) + + assert_includes data, task_one + assert_not_includes data, task_two + + end should 'order tasks by some attribute correctly' do Task.destroy_all @@ -497,22 +492,19 @@ class TaskTest < ActiveSupport::TestCase task.save! assert_equal person, task.responsible end -#FIXME this tests are not working -# should 'save tasks tags' do -# -# requestor = fast_create(Person) -# target = fast_create(Person) -# profile = sample_user -# -# task_one = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Task Test'}) -# task_two = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Another Task'}) -# -# profile.tag(task_one, with: 'noosfero,test', on: :tags) -# profile.tag(task_two, with: 'test', on: :tags) -# -# assert_includes task_one.tags_from(nil), 'test' -# assert_not_includes task_two.tags_from(nil), 'noosfero' -# end + + should 'save tasks tags' do + + requestor = fast_create(Person) + target = fast_create(Person) + profile = sample_user + + task_one = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Task Test'}, :tag_list => 'noosfero,test') + task_two = Task.create!(:requestor => requestor, :target => target, :data => {:name => 'Another Task'}, :tag_list => 'test') + + assert_includes task_one.tags_from(nil), 'test' + assert_not_includes task_two.tags_from(nil), 'noosfero' + end should 'store who finish the task' do t = Task.create -- libgit2 0.21.2