aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/views/comment/_single_comment.rhtml3
-rw-r--r--spec/controllers/request_controller_spec.rb19
2 files changed, 21 insertions, 1 deletions
diff --git a/app/views/comment/_single_comment.rhtml b/app/views/comment/_single_comment.rhtml
index 003f60360..03c77f3b1 100644
--- a/app/views/comment/_single_comment.rhtml
+++ b/app/views/comment/_single_comment.rhtml
@@ -1,6 +1,7 @@
<div class="comment_in_request" id="comment-<%=comment.id.to_s%>">
<h2>
- <%= comment.user ? user_link(comment.user) : 'You' %>
+ <%# When not logged in, but mid-comment-leaving, there'll be no comment.user %>
+ <%= !comment.user || (!@user.nil? && @user.id == comment.user.id) ? "You" : user_link(comment.user) %>
left an annotation (<%= simple_date(comment.created_at || Time.now) %>)
</h2>
<div class="comment_in_request_text">
diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb
index cc36c4656..64552f18b 100644
--- a/spec/controllers/request_controller_spec.rb
+++ b/spec/controllers/request_controller_spec.rb
@@ -476,6 +476,25 @@ describe RequestController, "comment alerts" do
end
+describe RequestController, "when viewing comments" do
+ integrate_views
+ fixtures :users
+
+ it "should link to the user who submitted it" do
+ session[:user_id] = users(:bob_smith_user).id
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
+ response.should have_text(/silly_emnameem.*?>\s+left an annotation/)
+ response.should_not have_text(/You\s+left an annotation/)
+ end
+
+ it "should say if you were the user who submitted it" do
+ session[:user_id] = users(:silly_name_user).id
+ get :show, :url_title => 'why_do_you_have_such_a_fancy_dog'
+ response.should have_text(/You\s+left an annotation/)
+ end
+
+end
+