Commit 355a1dfcfaa1730a6c30d2e25749692310d634b4
Committed by
Rodrigo Souto
1 parent
3e94afa3
Exists in
web_steps_improvements
and in
8 other branches
task: keep filters applied to tasks after close action
- Rename TasksHelper file - Referencing TasksHelper in TaskController - Refactoring task_action/url helper method - Manage tasks feature - Update SuggetstArticle step - Adds functional test for keeping tasks filter Signed-off-by: Alexandre Barbosa <alexandreab@live.com> Signed-off-by: Joenio Costa <joenio@colivre.coop.br> Signed-off-by: Ábner Silva de Oliveira <abner.oliveira@serpro.gov.br> Signed-off-by: Gustavo Jaruga <darkshades@gmail.com> Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Showing
6 changed files
with
76 additions
and
4 deletions
Show diff stats
app/controllers/my_profile/tasks_controller.rb
1 | class TasksController < MyProfileController | 1 | class TasksController < MyProfileController |
2 | 2 | ||
3 | + include TasksHelper | ||
4 | + | ||
3 | protect [:perform_task, :view_tasks], :profile, :only => [:index] | 5 | protect [:perform_task, :view_tasks], :profile, :only => [:index] |
4 | protect :perform_task, :profile, :except => [:index] | 6 | protect :perform_task, :profile, :except => [:index] |
5 | 7 | ||
@@ -58,12 +60,12 @@ class TasksController < MyProfileController | @@ -58,12 +60,12 @@ class TasksController < MyProfileController | ||
58 | end | 60 | end |
59 | end | 61 | end |
60 | 62 | ||
61 | - url = { :action => 'index' } | 63 | + url = tasks_url(:action => 'index') |
62 | if failed.blank? | 64 | if failed.blank? |
63 | session[:notice] = _("All decisions were applied successfully.") | 65 | session[:notice] = _("All decisions were applied successfully.") |
64 | else | 66 | else |
65 | session[:notice] = _("Some decisions couldn't be applied.") | 67 | session[:notice] = _("Some decisions couldn't be applied.") |
66 | - url[:failed] = failed | 68 | + url = tasks_url(:action => 'index', :failed => failed) |
67 | end | 69 | end |
68 | redirect_to url | 70 | redirect_to url |
69 | end | 71 | end |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +module TasksHelper | ||
2 | + | ||
3 | + def tasks_url options = {} | ||
4 | + url_for(options.merge(filter_params)) | ||
5 | + end | ||
6 | + | ||
7 | + def filter_params | ||
8 | + filter_fields = ['filter_type', 'filter_text', 'filter_responsible', 'filter_tags'] | ||
9 | + params.select {|filter| filter if filter_fields.include? filter } | ||
10 | + end | ||
11 | + | ||
12 | +end |
app/views/tasks/index.html.erb
@@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
45 | <em><%= _('No pending tasks for %s') % profile.name %></em> | 45 | <em><%= _('No pending tasks for %s') % profile.name %></em> |
46 | </p> | 46 | </p> |
47 | <% else %> | 47 | <% else %> |
48 | - <%= form_tag :action => 'close' do%> | 48 | + <%= form_tag tasks_url(:action => 'close') do%> |
49 | <% button_bar(:class => 'task-actions') do %> | 49 | <% button_bar(:class => 'task-actions') do %> |
50 | <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> | 50 | <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> |
51 | <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> | 51 | <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> |
@@ -0,0 +1,45 @@ | @@ -0,0 +1,45 @@ | ||
1 | +Feature: manage tasks | ||
2 | + As an community admin user | ||
3 | + I want to manage pending tasks | ||
4 | + In order to approve or disapprove them | ||
5 | + | ||
6 | + Background: | ||
7 | + Given the following users | ||
8 | + | login | name | email | | ||
9 | + | bob | Bob Rezende | bob@invalid.br | | ||
10 | + | maria | Maria Sousa | maria@invalid.br | | ||
11 | + | marie | Marie Curie | marie@invalid.br | | ||
12 | + | mario | Mario Souto | mario@invalid.br | | ||
13 | + And the following community | ||
14 | + | identifier | name | | ||
15 | + | mycommunity | My Community | | ||
16 | + And the community "My Community" is closed | ||
17 | + And the articles of "My Community" are moderated | ||
18 | + And "Bob Rezende" is admin of "My Community" | ||
19 | + And "Mario Souto" is a member of "My Community" | ||
20 | + | ||
21 | + @selenium | ||
22 | + Scenario: keep filters after close tasks | ||
23 | + Given "Marie Curie" asked to join "My Community" | ||
24 | + And "Maria Sousa" asked to join "My Community" | ||
25 | + And someone suggested the following article to be published | ||
26 | + |name | target | email | body | person | | ||
27 | + |Sample Article | mycommunity | mario@invalid.br | Corpo | mario | | ||
28 | + |Other Article | mycommunity | maria@invalid.br | Corpo | maria | | ||
29 | + |Another Article | mycommunity | marie@invalid.br | Corpo | marie | | ||
30 | + And I am logged in as "bob" | ||
31 | + And I go to mycommunity's control panel | ||
32 | + And I follow "Tasks" | ||
33 | + And I should see "Marie Curie wants to be a member of 'My Community'" | ||
34 | + And I should see "Maria Sousa wants to be a member of 'My Community'" | ||
35 | + And I should see "Mario Souto suggested the publication of the article: Sample Article" | ||
36 | + And I should see "Maria Sousa suggested the publication of the article: Other Article" | ||
37 | + And I should see "Marie Curie suggested the publication of the article: Another Article" | ||
38 | + When I select "New member" from "Type of task" | ||
39 | + And I press "Search" | ||
40 | + And I should see "wants to be a member of 'My Community'" | ||
41 | + And I should not see "suggested the publication of the article:" | ||
42 | + And I choose "Accept" | ||
43 | + And I press "Apply" | ||
44 | + And I should see "wants to be a member of 'My Community'" | ||
45 | + Then I should not see "suggested the publication of the article:" |
features/step_definitions/noosfero_steps.rb
@@ -497,7 +497,9 @@ end | @@ -497,7 +497,9 @@ end | ||
497 | Given /^someone suggested the following article to be published$/ do |table| | 497 | Given /^someone suggested the following article to be published$/ do |table| |
498 | table.hashes.map{|item| item.dup}.each do |item| | 498 | table.hashes.map{|item| item.dup}.each do |item| |
499 | target = Community[item.delete('target')] | 499 | target = Community[item.delete('target')] |
500 | - task = SuggestArticle.create!(:target => target, :data => item) | 500 | + article = {:name => item.delete('name'), :body => item.delete('body')} |
501 | + person = Profile[item.delete('person')] | ||
502 | + task = SuggestArticle.create!(:target => target, :article => article, :requestor => person) | ||
501 | end | 503 | end |
502 | end | 504 | end |
503 | 505 |
test/functional/tasks_controller_test.rb
@@ -73,6 +73,17 @@ class TasksControllerTest < ActionController::TestCase | @@ -73,6 +73,17 @@ class TasksControllerTest < ActionController::TestCase | ||
73 | ok('task should be finished') { t.status == Task::Status::FINISHED } | 73 | ok('task should be finished') { t.status == Task::Status::FINISHED } |
74 | end | 74 | end |
75 | 75 | ||
76 | + should 'keep filters after close a task' do | ||
77 | + t = profile.tasks.build; t.save! | ||
78 | + | ||
79 | + post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}}, :filter_type => t.type | ||
80 | + assert_redirected_to :action => 'index', :filter_type => t.type | ||
81 | + assert_equal @controller.params[:filter_type], t.type | ||
82 | + | ||
83 | + t.reload | ||
84 | + ok('task should be finished') { t.status == Task::Status::FINISHED } | ||
85 | + end | ||
86 | + | ||
76 | should 'be able to cancel a task' do | 87 | should 'be able to cancel a task' do |
77 | t = profile.tasks.build; t.save! | 88 | t = profile.tasks.build; t.save! |
78 | 89 |