Unify comment order specs
This commit is contained in:
@@ -6,34 +6,6 @@ describe "Commenting Budget::Investments" do
|
||||
|
||||
it_behaves_like "flaggable", :budget_investment_comment
|
||||
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 10,
|
||||
cached_votes_total: 12, created_at: Time.current - 1)
|
||||
c3 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 1,
|
||||
cached_votes_total: 2, created_at: Time.current)
|
||||
|
||||
visit budget_investment_path(investment.budget, investment, order: :most_voted)
|
||||
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
|
||||
click_link "Newest first"
|
||||
|
||||
expect(page).to have_link "Newest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c3.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c1.body)
|
||||
|
||||
click_link "Oldest first"
|
||||
|
||||
expect(page).to have_link "Oldest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario "Creation date works differently in roots and child comments when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: investment, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: investment, created_at: Time.current)
|
||||
|
||||
@@ -25,34 +25,6 @@ describe "Commenting debates" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: debate, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: debate, cached_votes_up: 10,
|
||||
cached_votes_total: 12, created_at: Time.current - 1)
|
||||
c3 = create(:comment, :with_confidence_score, commentable: debate, cached_votes_up: 1,
|
||||
cached_votes_total: 2, created_at: Time.current)
|
||||
|
||||
visit debate_path(debate, order: :most_voted)
|
||||
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
|
||||
click_link "Newest first"
|
||||
|
||||
expect(page).to have_link "Newest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c3.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c1.body)
|
||||
|
||||
click_link "Oldest first"
|
||||
|
||||
expect(page).to have_link "Oldest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario "Creation date works differently in roots and child comments when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: debate, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: debate, created_at: Time.current)
|
||||
|
||||
@@ -6,34 +6,6 @@ describe "Commenting legislation questions" do
|
||||
|
||||
it_behaves_like "flaggable", :legislation_annotation_comment
|
||||
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: annotation, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: annotation, cached_votes_up: 10,
|
||||
cached_votes_total: 12, created_at: Time.current - 1)
|
||||
c3 = create(:comment, :with_confidence_score, commentable: annotation, cached_votes_up: 1,
|
||||
cached_votes_total: 2, created_at: Time.current)
|
||||
|
||||
visit polymorphic_path(annotation, order: :most_voted)
|
||||
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
|
||||
click_link "Newest first"
|
||||
|
||||
expect(page).to have_link "Newest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c3.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c1.body)
|
||||
|
||||
click_link "Oldest first"
|
||||
|
||||
expect(page).to have_link "Oldest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario "Creation date works differently in roots and child comments when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: annotation, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: annotation, created_at: Time.current)
|
||||
|
||||
@@ -10,34 +10,6 @@ describe "Commenting legislation questions" do
|
||||
it_behaves_like "flaggable", :legislation_question_comment
|
||||
end
|
||||
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: question, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: question, cached_votes_up: 10,
|
||||
cached_votes_total: 12, created_at: Time.current - 1)
|
||||
c3 = create(:comment, :with_confidence_score, commentable: question, cached_votes_up: 1,
|
||||
cached_votes_total: 2, created_at: Time.current)
|
||||
|
||||
visit legislation_process_question_path(question.process, question, order: :most_voted)
|
||||
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
|
||||
click_link "Newest first"
|
||||
|
||||
expect(page).to have_link "Newest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c3.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c1.body)
|
||||
|
||||
click_link "Oldest first"
|
||||
|
||||
expect(page).to have_link "Oldest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario "Creation date works differently in roots and child comments when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: question, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: question, created_at: Time.current)
|
||||
|
||||
@@ -4,34 +4,6 @@ describe "Commenting polls" do
|
||||
let(:user) { create(:user) }
|
||||
let(:poll) { create(:poll, author: create(:user)) }
|
||||
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: poll, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: poll, cached_votes_up: 10,
|
||||
cached_votes_total: 12, created_at: Time.current - 1)
|
||||
c3 = create(:comment, :with_confidence_score, commentable: poll, cached_votes_up: 1,
|
||||
cached_votes_total: 2, created_at: Time.current)
|
||||
|
||||
visit poll_path(poll, order: :most_voted)
|
||||
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
|
||||
click_link "Newest first"
|
||||
|
||||
expect(page).to have_link "Newest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c3.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c1.body)
|
||||
|
||||
click_link "Oldest first"
|
||||
|
||||
expect(page).to have_link "Oldest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario "Creation date works differently in roots and child comments when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: poll, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: poll, created_at: Time.current)
|
||||
|
||||
@@ -6,34 +6,6 @@ describe "Commenting proposals" do
|
||||
|
||||
it_behaves_like "flaggable", :proposal_comment
|
||||
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 10,
|
||||
cached_votes_total: 12, created_at: Time.current - 1)
|
||||
c3 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 1,
|
||||
cached_votes_total: 2, created_at: Time.current)
|
||||
|
||||
visit proposal_path(proposal, order: :most_voted)
|
||||
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
|
||||
click_link "Newest first"
|
||||
|
||||
expect(page).to have_link "Newest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c3.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c1.body)
|
||||
|
||||
click_link "Oldest first"
|
||||
|
||||
expect(page).to have_link "Oldest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario "Creation date works differently in roots and child comments when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: proposal, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: proposal, created_at: Time.current)
|
||||
|
||||
@@ -6,36 +6,6 @@ describe "Commenting topics from proposals" do
|
||||
|
||||
it_behaves_like "flaggable", :topic_with_community_comment
|
||||
|
||||
scenario "Comment order" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
c1 = create(:comment, :with_confidence_score, commentable: topic, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: topic, cached_votes_up: 10,
|
||||
cached_votes_total: 12, created_at: Time.current - 1)
|
||||
c3 = create(:comment, :with_confidence_score, commentable: topic, cached_votes_up: 1,
|
||||
cached_votes_total: 2, created_at: Time.current)
|
||||
|
||||
visit community_topic_path(community, topic, order: :most_voted)
|
||||
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
|
||||
click_link "Newest first"
|
||||
|
||||
expect(page).to have_link "Newest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c3.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c1.body)
|
||||
|
||||
click_link "Oldest first"
|
||||
|
||||
expect(page).to have_link "Oldest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario "Creation date works differently in roots and child comments when sorting by confidence_score" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
@@ -459,36 +429,6 @@ describe "Commenting topics from budget investments" do
|
||||
let(:user) { create(:user) }
|
||||
let(:investment) { create(:budget_investment) }
|
||||
|
||||
scenario "Comment order" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
c1 = create(:comment, :with_confidence_score, commentable: topic, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: topic, cached_votes_up: 10,
|
||||
cached_votes_total: 12, created_at: Time.current - 1)
|
||||
c3 = create(:comment, :with_confidence_score, commentable: topic, cached_votes_up: 1,
|
||||
cached_votes_total: 2, created_at: Time.current)
|
||||
|
||||
visit community_topic_path(community, topic, order: :most_voted)
|
||||
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
|
||||
click_link "Newest first"
|
||||
|
||||
expect(page).to have_link "Newest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c3.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c1.body)
|
||||
|
||||
click_link "Oldest first"
|
||||
|
||||
expect(page).to have_link "Oldest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario "Creation date works differently in roots and child comments when sorting by confidence_score" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
|
||||
@@ -177,6 +177,34 @@ describe "Comments" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: resource, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: resource, cached_votes_up: 10,
|
||||
cached_votes_total: 12, created_at: Time.current - 1)
|
||||
c3 = create(:comment, :with_confidence_score, commentable: resource, cached_votes_up: 1,
|
||||
cached_votes_total: 2, created_at: Time.current)
|
||||
|
||||
visit polymorphic_path(resource, order: :most_voted)
|
||||
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
|
||||
click_link "Newest first"
|
||||
|
||||
expect(page).to have_link "Newest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c3.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c1.body)
|
||||
|
||||
click_link "Oldest first"
|
||||
|
||||
expect(page).to have_link "Oldest first", class: "is-active"
|
||||
expect(page).to have_current_path(/#comments/, url: true)
|
||||
expect(c1.body).to appear_before(c2.body)
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario "Errors on create" do
|
||||
login_as(user)
|
||||
visit polymorphic_path(resource)
|
||||
|
||||
Reference in New Issue
Block a user