Commit 58a43daa8907749f7fdb82a54bfa3046bdbc4fcf
1 parent
169bd9ef
Exists in
staging
and in
3 other branches
explicit target detail in task information
Showing
3 changed files
with
32 additions
and
8 deletions
Show diff stats
app/helpers/application_helper.rb
| ... | ... | @@ -968,7 +968,12 @@ module ApplicationHelper |
| 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 |
| 971 | - values.merge!({:target => link_to(task.target.name, task.target.url)}) if (task.target && task.target.respond_to?(:url)) | |
| 971 | + if (task.target && task.target.respond_to?(:url)) | |
| 972 | + values.merge!({:target => link_to(task.target.name, task.target.url)}) | |
| 973 | + target_detail = _("in %s").html_safe % values[:target] | |
| 974 | + target_detail = '' if task.target.identifier == params[:profile] | |
| 975 | + values.merge!({:target_detail => target_detail}) | |
| 976 | + end | |
| 972 | 977 | values.merge!({:subject => content_tag('span', task.subject, :class=>'task_target')}) if task.subject |
| 973 | 978 | values.merge!({:linked_subject => link_to(content_tag('span', task.linked_subject[:text], :class => 'task_target'), task.linked_subject[:url])}) if task.linked_subject |
| 974 | 979 | (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 | ... | ... |
test/unit/application_helper_test.rb
| ... | ... | @@ -545,12 +545,6 @@ class ApplicationHelperTest < 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,31 @@ class ApplicationHelperTest < 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 | + 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) | |
| 980 | + end | |
| 981 | + | |
| 963 | 982 | protected |
| 964 | 983 | include NoosferoTestHelper |
| 965 | 984 | ... | ... |