Merge pull request #961 from cesy/issue476

Issue 476 edited by date on comments and posts
This commit is contained in:
pozorvlak
2016-06-02 16:53:44 +01:00
5 changed files with 84 additions and 11 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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
end

View File

@@ -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