diff --git a/app/views/comments/_single.html.haml b/app/views/comments/_single.html.haml
index af6c328e5..895002b1e 100644
--- a/app/views/comments/_single.html.haml
+++ b/app/views/comments/_single.html.haml
@@ -5,10 +5,13 @@
= render :partial => "members/avatar", :locals => { :member => comment.author }
.col-md-11
.comment-meta
- = (comment.created_at == comment.updated_at) ? 'Posted by' : 'Edited by'
+ Posted by
= link_to comment.author.login_name, member_path(comment.author)
on
- = (comment.created_at == comment.updated_at) ? comment.created_at : comment.updated_at
+ = comment.created_at
+ - if comment.updated_at > comment.created_at
+ and edited at
+ = comment.updated_at
.comment-body
:growstuff_markdown
diff --git a/app/views/posts/_single.html.haml b/app/views/posts/_single.html.haml
index 44750ceac..3ba1e6194 100644
--- a/app/views/posts/_single.html.haml
+++ b/app/views/posts/_single.html.haml
@@ -9,13 +9,16 @@
.post-meta
%p
- = (post.created_at == post.updated_at) ? 'Posted by' : 'Edited by'
+ Posted by
= link_to post.author.login_name, member_path(post.author)
- if post.forum
in
= link_to post.forum, post.forum
on
- = (post.created_at == post.updated_at) ? post.created_at : post.updated_at
+ = post.created_at
+ - if post.updated_at > post.created_at
+ and edited at
+ = post.updated_at
.post-body
:growstuff_markdown
diff --git a/spec/features/comments/commenting_a_comment_spec.rb b/spec/features/comments/commenting_a_comment_spec.rb
index b39d28618..49183c274 100644
--- a/spec/features/comments/commenting_a_comment_spec.rb
+++ b/spec/features/comments/commenting_a_comment_spec.rb
@@ -27,7 +27,7 @@ feature 'Commenting on a post' do
fill_in "comment_body", with: "Testing edit for comment"
click_button "Post comment"
expect(page).to have_content "Comment was successfully updated"
- expect(page).to have_content "Edited by"
+ expect(page).to have_content "edited at"
end
end
end
\ No newline at end of file
diff --git a/spec/features/posts/posting_a_post_spec.rb b/spec/features/posts/posting_a_post_spec.rb
index a1f32942e..ac31b6fec 100644
--- a/spec/features/posts/posting_a_post_spec.rb
+++ b/spec/features/posts/posting_a_post_spec.rb
@@ -27,7 +27,7 @@ feature 'Post a post' do
fill_in "post_subject", with: "Testing Edit"
click_button "Post"
expect(page).to have_content "Post was successfully updated"
- expect(page).to have_content "Edited by"
+ expect(page).to have_content "edited at"
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb
index 75a57b99c..b3a9c0dd9 100644
--- a/spec/views/posts/_single.html.haml_spec.rb
+++ b/spec/views/posts/_single.html.haml_spec.rb
@@ -129,8 +129,75 @@ describe "posts/_single" do
end
end
+
+ context "when post has been edited" do
+ before(:each) do
+ @member = FactoryGirl.create(:member)
+ sign_in @member
+ controller.stub(:current_user) { @member }
+ @post = FactoryGirl.create(:post, :author => @member)
+ @post.update(body: "I am updated")
+ render_post
+ end
+
+ it "shows edited at" do
+ rendered.should have_content "edited at"
+ end
+
+ it "shows the updated time" do
+ rendered.should have_content @post.updated_at
+ end
+ end
+
+ context "when comment has been edited" do
+ before(:each) do
+ @member = FactoryGirl.create(:member)
+ sign_in @member
+ controller.stub(:current_user) { @member }
+ @post = FactoryGirl.create(:post, :author => @member)
+ @comment = FactoryGirl.create(:comment, :post => @post)
+ @comment.update(body: "I've been updated")
+ render :partial => "comments/single", :locals => { :comment => @comment }
+ end
+
+ it "shows edited at time" do
+ rendered.should have_content "edited at"
+ end
+
+ it "shows updated time" do
+ rendered.should have_content @comment.updated_at
+ end
+ end
+
+ context "when post has not been edited" do
+ before(:each) do
+ @member = FactoryGirl.create(:member)
+ sign_in @member
+ controller.stub(:current_user) { @member }
+ @post = FactoryGirl.create(:post, :author => @member)
+ @post.update(updated_at: @post.created_at)
+ render_post
+ end
+
+ it "does not show edited at" do
+ rendered.should_not have_content "edited at #{@post.updated_at}"
+ end
+ end
+
+ context "when comment has not been edited" do
+ before(:each) do
+ @member = FactoryGirl.create(:member)
+ sign_in @member
+ controller.stub(:current_user) { @member }
+ @post = FactoryGirl.create(:post, :author => @member)
+ @comment = FactoryGirl.create(:comment, :post => @post)
+ @comment.update(updated_at: @comment.created_at)
+ render :partial => "comments/single", :locals => { :comment => @comment }
+ end
+
+ it "does not show edited at" do
+ rendered.should_not have_content "edited at #{@comment.updated_at}"
+ end
+ end
+
end
-
-
-
-