Commit b2254a348f543db091c2b43c21564bb23fd75029

Authored by Leandro Santos
2 parents 70d1c20e fe715b13
Exists in staging and in 1 other branch production

Merge branch 'master' into staging

app/helpers/application_helper.rb
... ... @@ -966,11 +966,16 @@ module ApplicationHelper
966 966 content_tag(:div, _('Source: %s') % source_url, :id => 'article-source') unless source_url.nil?
967 967 end
968 968  
969   - def task_information(task)
  969 + def task_information(task, params = {})
970 970 values = {}
971 971 values.merge!(task.information[:variables]) if task.information[:variables]
972 972 values.merge!({:requestor => link_to(task.requestor.name, task.requestor.url)}) if task.requestor
973   - values.merge!({:target => link_to(task.target.name, task.target.url)}) if (task.target && task.target.respond_to?(:url))
  973 + if (task.target && task.target.respond_to?(:url))
  974 + values.merge!({:target => link_to(task.target.name, task.target.url)})
  975 + target_detail = _("in %s").html_safe % values[:target]
  976 + target_detail = '' if task.target.identifier == params[:profile]
  977 + values.merge!({:target_detail => target_detail})
  978 + end
974 979 values.merge!({:subject => content_tag('span', task.subject, :class=>'task_target')}) if task.subject
975 980 values.merge!({:linked_subject => link_to(content_tag('span', task.linked_subject[:text], :class => 'task_target'), task.linked_subject[:url])}) if task.linked_subject
976 981 (task.information[:message] % values).html_safe
... ...
app/models/suggest_article.rb
... ... @@ -65,7 +65,7 @@ class SuggestArticle < Task
65 65  
66 66 def information
67 67 variables = requestor.blank? ? {:requestor => sender} : {}
68   - { :message => _('%{requestor} suggested the publication of the article: %{subject}.').html_safe,
  68 + { :message => _('%{requestor} suggested the publication %{target_detail} of the article: %{subject}.').html_safe,
69 69 :variables => variables }
70 70 end
71 71  
... ...
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
... ... @@ -545,12 +545,6 @@ class ApplicationHelperTest &lt; ActionView::TestCase
545 545 assert_equal ["1 for b", "2 for c", "3 for a"], unique_with_count(%w(a b c a c a))
546 546 end
547 547  
548   - should 'show task information with the requestor' do
549   - person = create_user('usertest').person
550   - task = create(Task, :requestor => person)
551   - assert_match person.name, task_information(task)
552   - end
553   -
554 548 should 'return nil when :show_zoom_button_on_article_images is not enabled in environment' do
555 549 env = Environment.default
556 550 env.stubs(:enabled?).with(:show_zoom_button_on_article_images).returns(false)
... ... @@ -960,6 +954,37 @@ class ApplicationHelperTest &lt; ActionView::TestCase
960 954 refute current_editor_is?(nil)
961 955 end
962 956  
  957 + should 'show task information with the requestor' do
  958 + person = create_user('usertest').person
  959 + task = create(Task, :requestor => person)
  960 + assert_match person.name, task_information(task)
  961 + end
  962 +
  963 + should 'show task information with variables information on suggest article tasks' do
  964 + person = create_user('usertest').person
  965 + task = create(SuggestArticle, :name => person.name, :target => person)
  966 + assert_match person.name, task_information(task)
  967 + end
  968 +
  969 + should 'show task information with target detail information on suggest article tasks' do
  970 + person = create_user('usertest').person
  971 + task = create(SuggestArticle, :target => person)
  972 + assert_match /in.*#{person.name}/, task_information(task)
  973 + end
  974 +
  975 + should "show task information without target detail information on suggest article tasks if it's in the same profile" do
  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})
  986 + end
  987 +
963 988 protected
964 989 include NoosferoTestHelper
965 990  
... ...