diff --git a/spec/features/comments/debates_spec.rb b/spec/features/comments/debates_spec.rb index db4b68060..b077e4773 100644 --- a/spec/features/comments/debates_spec.rb +++ b/spec/features/comments/debates_spec.rb @@ -36,6 +36,23 @@ feature 'Commenting debates' do expect(c2.body).to appear_before(c1.body) end + scenario 'Creation date works differently in roots and in child comments, even when sorting by confidence_score' do + old_root = create(:comment, commentable: debate, created_at: Time.now - 10) + new_root = create(:comment, commentable: debate, created_at: Time.now) + old_child = create(:comment, commentable: debate, parent_id: new_root.id, created_at: Time.now - 10) + new_child = create(:comment, commentable: debate, parent_id: new_root.id, created_at: Time.now) + + visit debate_path(debate) + + expect(new_root.body).to appear_before(old_root.body) + expect(old_child.body).to appear_before(new_child.body) + + visit debate_path(debate, order: :created_at) + + expect(new_root.body).to appear_before(old_root.body) + expect(old_child.body).to appear_before(new_child.body) + end + scenario 'Turns links into html links' do create :comment, commentable: debate, body: 'Built with http://rubyonrails.org/' diff --git a/spec/features/comments/proposals_spec.rb b/spec/features/comments/proposals_spec.rb index 61ae53d38..a706bcfaa 100644 --- a/spec/features/comments/proposals_spec.rb +++ b/spec/features/comments/proposals_spec.rb @@ -20,7 +20,7 @@ feature 'Commenting proposals' do end end - scenario 'Comment order' do + scenario 'Comment order' do c1 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 100, cached_votes_total: 120, created_at: Time.now - 2) c2 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 10, cached_votes_total: 12, created_at: Time.now - 1) c3 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 1, cached_votes_total: 2, created_at: Time.now) @@ -36,6 +36,23 @@ feature 'Commenting proposals' do expect(c2.body).to appear_before(c1.body) end + scenario 'Creation date works differently in roots and in child comments, even when sorting by confidence_score' do + old_root = create(:comment, commentable: proposal, created_at: Time.now - 10) + new_root = create(:comment, commentable: proposal, created_at: Time.now) + old_child = create(:comment, commentable: proposal, parent_id: new_root.id, created_at: Time.now - 10) + new_child = create(:comment, commentable: proposal, parent_id: new_root.id, created_at: Time.now) + + visit proposal_path(proposal) + + expect(new_root.body).to appear_before(old_root.body) + expect(old_child.body).to appear_before(new_child.body) + + visit proposal_path(proposal, order: :created_at) + + expect(new_root.body).to appear_before(old_root.body) + expect(old_child.body).to appear_before(new_child.body) + end + scenario 'Turns links into html links' do create :comment, commentable: proposal, body: 'Built with http://rubyonrails.org/'