Commit fe66361c6230f16f125d3d3105e46e0a849d6f10
Exists in
web_steps_improvements
and in
8 other branches
Merge branch 'keep_filters_after_close_tasks' into 'master'
Keep filters after close tasks See merge request !798
Showing
6 changed files
with
76 additions
and
4 deletions
Show diff stats
app/controllers/my_profile/tasks_controller.rb
1 | 1 | class TasksController < MyProfileController |
2 | 2 | |
3 | + include TasksHelper | |
4 | + | |
3 | 5 | protect [:perform_task, :view_tasks], :profile, :only => [:index] |
4 | 6 | protect :perform_task, :profile, :except => [:index] |
5 | 7 | |
... | ... | @@ -58,12 +60,12 @@ class TasksController < MyProfileController |
58 | 60 | end |
59 | 61 | end |
60 | 62 | |
61 | - url = { :action => 'index' } | |
63 | + url = tasks_url(:action => 'index') | |
62 | 64 | if failed.blank? |
63 | 65 | session[:notice] = _("All decisions were applied successfully.") |
64 | 66 | else |
65 | 67 | session[:notice] = _("Some decisions couldn't be applied.") |
66 | - url[:failed] = failed | |
68 | + url = tasks_url(:action => 'index', :failed => failed) | |
67 | 69 | end |
68 | 70 | redirect_to url |
69 | 71 | end | ... | ... |
... | ... | @@ -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 | 45 | <em><%= _('No pending tasks for %s') % profile.name %></em> |
46 | 46 | </p> |
47 | 47 | <% else %> |
48 | - <%= form_tag :action => 'close' do%> | |
48 | + <%= form_tag tasks_url(:action => 'close') do%> | |
49 | 49 | <% button_bar(:class => 'task-actions') do %> |
50 | 50 | <%# FiXME button(:edit, _('View my requests'), :action => 'list_requested') %> |
51 | 51 | <%# FIXME button('menu-mail', _('Send request'), :action => 'new') %> | ... | ... |
... | ... | @@ -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 | 497 | Given /^someone suggested the following article to be published$/ do |table| |
498 | 498 | table.hashes.map{|item| item.dup}.each do |item| |
499 | 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 | 503 | end |
502 | 504 | end |
503 | 505 | ... | ... |
test/functional/tasks_controller_test.rb
... | ... | @@ -73,6 +73,17 @@ class TasksControllerTest < ActionController::TestCase |
73 | 73 | ok('task should be finished') { t.status == Task::Status::FINISHED } |
74 | 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 | 87 | should 'be able to cancel a task' do |
77 | 88 | t = profile.tasks.build; t.save! |
78 | 89 | ... | ... |