Commit cee435f612f8f621756408183d031cf14f6963a4

Authored by Leandro Santos
1 parent 58a43daa

passing params to task_information helper

app/helpers/application_helper.rb
... ... @@ -964,7 +964,7 @@ module ApplicationHelper
964 964 content_tag(:div, _('Source: %s') % source_url, :id => 'article-source') unless source_url.nil?
965 965 end
966 966  
967   - def task_information(task)
  967 + def task_information(task, params = {})
968 968 values = {}
969 969 values.merge!(task.information[:variables]) if task.information[:variables]
970 970 values.merge!({:requestor => link_to(task.requestor.name, task.requestor.url)}) if task.requestor
... ...
app/views/profile_editor/_pending_tasks.html.erb
... ... @@ -4,7 +4,7 @@
4 4 <div class='pending-tasks'>
5 5 <h2><%= _('You have %s pending requests' % @pending_tasks.count) %></h2>
6 6 <ul>
7   - <%= safe_join(@pending_tasks.limit(5).map {|task| content_tag('li', task_information(task).html_safe)}) %>
  7 + <%= safe_join(@pending_tasks.limit(5).map {|task| content_tag('li', task_information(task, params).html_safe)}) %>
8 8 </ul>
9 9 <%= button(:todo, _('Process requests'), :controller => 'tasks', :action => 'index') %>
10 10 </div>
... ...
app/views/spam/_task.html.erb
... ... @@ -2,7 +2,7 @@
2 2 <%= render :partial => 'tasks/task_icon', :locals => {:task => task} %>
3 3 <%= render :partial => 'tasks/task_title', :locals => {:task => task} %>
4 4 <div class="task-information">
5   - <%= task_information(task) %>
  5 + <%= task_information(task, params) %>
6 6 </div>
7 7  
8 8 <%= yield %> <%# ??? %>
... ...
app/views/tasks/_task.html.erb
... ... @@ -47,7 +47,7 @@
47 47  
48 48  
49 49 <div class="task_information">
50   - <%= task_information(task) %>
  50 + <%= task_information(task, params) %>
51 51 </div>
52 52  
53 53 <%= fields_for "tasks[#{task.id}][task]", task do |f| %>
... ...
app/views/tasks/_task_processed.html.erb
1 1 <div class="title">
2   - <%= task_information(task) %>
  2 + <%= task_information(task, params) %>
3 3 </div>
4 4 <div class="status">
5 5 <%= _(Task::Status.names[task.status]) %>
... ...
test/unit/application_helper_test.rb
... ... @@ -973,10 +973,16 @@ class ApplicationHelperTest &lt; ActionView::TestCase
973 973 end
974 974  
975 975 should "show task information without target detail information on suggest article tasks if it's in the same profile" do
976   - person = create_user('usertest').person
977   - task = create(SuggestArticle, :target => person)
978   - self.stubs(:params).returns({:profile => person.identifier})
979   - assert_no_match /in.*#{person.name}/, task_information(task)
  976 + profile = fast_create(Community)
  977 + task = create(SuggestArticle, :target => profile)
  978 + assert_no_match /in.*#{profile.name}/, task_information(task, {:profile => profile.identifier})
  979 + end
  980 +
  981 + should "show task information with target detail information on suggest article with profile parameter to another profile" do
  982 + profile = fast_create(Community)
  983 + another_profile = fast_create(Community)
  984 + task = create(SuggestArticle, :target => profile)
  985 + assert_match /in.*#{profile.name}/, task_information(task, {:profile => another_profile.identifier})
980 986 end
981 987  
982 988 protected
... ...