diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index ca536c9..cce2b51 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -1,5 +1,7 @@ class TasksController < MyProfileController + include TasksHelper + protect [:perform_task, :view_tasks], :profile, :only => [:index] protect :perform_task, :profile, :except => [:index] @@ -58,12 +60,12 @@ class TasksController < MyProfileController end end - url = { :action => 'index' } + url = tasks_url(:action => 'index') if failed.blank? session[:notice] = _("All decisions were applied successfully.") else session[:notice] = _("Some decisions couldn't be applied.") - url[:failed] = failed + url = tasks_url(:action => 'index', :failed => failed) end redirect_to url end diff --git a/app/helpers/tasks_helper.rb b/app/helpers/tasks_helper.rb new file mode 100644 index 0000000..74c1070 --- /dev/null +++ b/app/helpers/tasks_helper.rb @@ -0,0 +1,12 @@ +module TasksHelper + + def tasks_url options = {} + url_for(options.merge(filter_params)) + end + + def filter_params + filter_fields = ['filter_type', 'filter_text', 'filter_responsible', 'filter_tags'] + params.select {|filter| filter if filter_fields.include? filter } + end + +end diff --git a/app/views/tasks/index.html.erb b/app/views/tasks/index.html.erb index 6eb8533..baa32e7 100644 --- a/app/views/tasks/index.html.erb +++ b/app/views/tasks/index.html.erb @@ -45,7 +45,7 @@ <%= _('No pending tasks for %s') % profile.name %>

<% else %> - <%= form_tag :action => 'close' do%> + <%= form_tag tasks_url(:action => 'close') do%> <% button_bar(:class => 'task-actions') do %> <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> diff --git a/features/manage_tasks.feature b/features/manage_tasks.feature new file mode 100644 index 0000000..5fe0b56 --- /dev/null +++ b/features/manage_tasks.feature @@ -0,0 +1,45 @@ +Feature: manage tasks + As an community admin user + I want to manage pending tasks + In order to approve or disapprove them + + Background: + Given the following users + | login | name | email | + | bob | Bob Rezende | bob@invalid.br | + | maria | Maria Sousa | maria@invalid.br | + | marie | Marie Curie | marie@invalid.br | + | mario | Mario Souto | mario@invalid.br | + And the following community + | identifier | name | + | mycommunity | My Community | + And the community "My Community" is closed + And the articles of "My Community" are moderated + And "Bob Rezende" is admin of "My Community" + And "Mario Souto" is a member of "My Community" + + @selenium + Scenario: keep filters after close tasks + Given "Marie Curie" asked to join "My Community" + And "Maria Sousa" asked to join "My Community" + And someone suggested the following article to be published + |name | target | email | body | person | + |Sample Article | mycommunity | mario@invalid.br | Corpo | mario | + |Other Article | mycommunity | maria@invalid.br | Corpo | maria | + |Another Article | mycommunity | marie@invalid.br | Corpo | marie | + And I am logged in as "bob" + And I go to mycommunity's control panel + And I follow "Tasks" + And I should see "Marie Curie wants to be a member of 'My Community'" + And I should see "Maria Sousa wants to be a member of 'My Community'" + And I should see "Mario Souto suggested the publication of the article: Sample Article" + And I should see "Maria Sousa suggested the publication of the article: Other Article" + And I should see "Marie Curie suggested the publication of the article: Another Article" + When I select "New member" from "Type of task" + And I press "Search" + And I should see "wants to be a member of 'My Community'" + And I should not see "suggested the publication of the article:" + And I choose "Accept" + And I press "Apply" + And I should see "wants to be a member of 'My Community'" + Then I should not see "suggested the publication of the article:" diff --git a/features/step_definitions/noosfero_steps.rb b/features/step_definitions/noosfero_steps.rb index 64b1a10..0526879 100644 --- a/features/step_definitions/noosfero_steps.rb +++ b/features/step_definitions/noosfero_steps.rb @@ -497,7 +497,9 @@ end Given /^someone suggested the following article to be published$/ do |table| table.hashes.map{|item| item.dup}.each do |item| target = Community[item.delete('target')] - task = SuggestArticle.create!(:target => target, :data => item) + article = {:name => item.delete('name'), :body => item.delete('body')} + person = Profile[item.delete('person')] + task = SuggestArticle.create!(:target => target, :article => article, :requestor => person) end end diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index 947509c..0175d16 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -73,6 +73,17 @@ class TasksControllerTest < ActionController::TestCase ok('task should be finished') { t.status == Task::Status::FINISHED } end + should 'keep filters after close a task' do + t = profile.tasks.build; t.save! + + post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}}, :filter_type => t.type + assert_redirected_to :action => 'index', :filter_type => t.type + assert_equal @controller.params[:filter_type], t.type + + t.reload + ok('task should be finished') { t.status == Task::Status::FINISHED } + end + should 'be able to cancel a task' do t = profile.tasks.build; t.save! -- libgit2 0.21.2