diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-03-14 11:47:52 +0000 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-03-25 09:58:00 +0000 |
commit | eff755504d45bfeff415786dcd0dbbb4c47e8dd0 (patch) | |
tree | 3bad8adc1347e16c87827bfa43aa9f81e147da6e | |
parent | 271adedcd705c7e6aa61e9706b5dc2832dea528f (diff) |
Add AdminHelper#comment_visibility
Get the canonical human-readable status of a comment
-rw-r--r-- | app/helpers/admin_helper.rb | 5 | ||||
-rw-r--r-- | app/views/admin_request/_some_annotations.html.erb | 2 | ||||
-rw-r--r-- | spec/helpers/admin_helper_spec.rb | 21 |
3 files changed, 27 insertions, 1 deletions
diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 059cebdfa..151e53758 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -33,5 +33,10 @@ module AdminHelper link_to(eye, user_path(user), :title => "view user's page on public website") + " " + link_to(h(user.name), admin_user_show_path(user), :title => "view full details") end + + def comment_visibility(comment) + comment.visible? ? 'Visible' : 'Hidden' + end + end diff --git a/app/views/admin_request/_some_annotations.html.erb b/app/views/admin_request/_some_annotations.html.erb index 9123b0c30..7adcdc5bb 100644 --- a/app/views/admin_request/_some_annotations.html.erb +++ b/app/views/admin_request/_some_annotations.html.erb @@ -15,7 +15,7 @@ <%= admin_value(comment.created_at) %> <% end %> - <%= comment.visible ? 'Visible' : 'Hidden' %> + <%= comment_visibility(comment) %> <blockquote class="incoming-message"> <%= truncate(comment.body, :length => 400) %> diff --git a/spec/helpers/admin_helper_spec.rb b/spec/helpers/admin_helper_spec.rb new file mode 100644 index 000000000..804fcc7fd --- /dev/null +++ b/spec/helpers/admin_helper_spec.rb @@ -0,0 +1,21 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe AdminHelper do + + include AdminHelper + + describe :comment_visibility do + + it 'shows the status of a visible comment' do + comment = Factory.build(:visible_comment) + comment_visibility(comment).should == 'Visible' + end + + it 'shows the status of a hidden comment' do + comment = Factory.build(:hidden_comment) + comment_visibility(comment).should == 'Hidden' + end + + end + +end |