Unify Creation date specs

This commit is contained in:
taitus
2023-12-18 21:49:52 +01:00
parent 98aea85eaa
commit b979c17a4b
8 changed files with 25 additions and 192 deletions

View File

@@ -6,34 +6,6 @@ describe "Commenting Budget::Investments" do
it_behaves_like "flaggable", :budget_investment_comment
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)
old_child = create(:comment,
commentable: investment,
parent_id: new_root.id,
created_at: Time.current - 10)
new_child = create(:comment,
commentable: investment,
parent_id: new_root.id,
created_at: Time.current)
visit budget_investment_path(investment.budget, investment, order: :most_voted)
expect(new_root.body).to appear_before(old_root.body)
expect(old_child.body).to appear_before(new_child.body)
visit budget_investment_path(investment.budget, investment, order: :newest)
expect(new_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.body)
visit budget_investment_path(investment.budget, investment, order: :oldest)
expect(old_root.body).to appear_before(new_root.body)
expect(old_child.body).to appear_before(new_child.body)
end
scenario "Turns links into html links" do
create(:comment, commentable: investment, body: "Built with http://rubyonrails.org/")

View File

@@ -25,28 +25,6 @@ describe "Commenting debates" do
end
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)
old_child = create(:comment, commentable: debate, parent_id: new_root.id, created_at: Time.current - 10)
new_child = create(:comment, commentable: debate, parent_id: new_root.id, created_at: Time.current)
visit debate_path(debate, order: :most_voted)
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: :newest)
expect(new_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.body)
visit debate_path(debate, order: :oldest)
expect(old_root.body).to appear_before(new_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/")

View File

@@ -6,34 +6,6 @@ describe "Commenting legislation questions" do
it_behaves_like "flaggable", :legislation_annotation_comment
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)
old_child = create(:comment,
commentable: annotation,
parent_id: new_root.id,
created_at: Time.current - 10)
new_child = create(:comment,
commentable: annotation,
parent_id: new_root.id,
created_at: Time.current)
visit polymorphic_path(annotation, order: :most_voted)
expect(new_root.body).to appear_before(old_root.body)
expect(old_child.body).to appear_before(new_child.body)
visit polymorphic_path(annotation, order: :newest)
expect(new_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.body)
visit polymorphic_path(annotation, order: :oldest)
expect(old_root.body).to appear_before(new_root.body)
expect(old_child.body).to appear_before(new_child.body)
end
scenario "Turns links into html links" do
annotation = create(:legislation_annotation, author: user)
annotation.comments << create(:comment, body: "Built with http://rubyonrails.org/")

View File

@@ -10,28 +10,6 @@ describe "Commenting legislation questions" do
it_behaves_like "flaggable", :legislation_question_comment
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)
old_child = create(:comment, commentable: question, parent_id: new_root.id, created_at: Time.current - 10)
new_child = create(:comment, commentable: question, parent_id: new_root.id, created_at: Time.current)
visit legislation_process_question_path(question.process, question, order: :most_voted)
expect(new_root.body).to appear_before(old_root.body)
expect(old_child.body).to appear_before(new_child.body)
visit legislation_process_question_path(question.process, question, order: :newest)
expect(new_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.body)
visit legislation_process_question_path(question.process, question, order: :oldest)
expect(old_root.body).to appear_before(new_root.body)
expect(old_child.body).to appear_before(new_child.body)
end
scenario "Turns links into html links" do
create(:comment, commentable: question, body: "Built with http://rubyonrails.org/")

View File

@@ -4,28 +4,6 @@ describe "Commenting polls" do
let(:user) { create(:user) }
let(:poll) { create(:poll, author: create(:user)) }
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)
old_child = create(:comment, commentable: poll, parent_id: new_root.id, created_at: Time.current - 10)
new_child = create(:comment, commentable: poll, parent_id: new_root.id, created_at: Time.current)
visit poll_path(poll, order: :most_voted)
expect(new_root.body).to appear_before(old_root.body)
expect(old_child.body).to appear_before(new_child.body)
visit poll_path(poll, order: :newest)
expect(new_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.body)
visit poll_path(poll, order: :oldest)
expect(old_root.body).to appear_before(new_root.body)
expect(old_child.body).to appear_before(new_child.body)
end
scenario "Turns links into html links" do
create(:comment, commentable: poll, body: "Built with http://rubyonrails.org/")

View File

@@ -6,28 +6,6 @@ describe "Commenting proposals" do
it_behaves_like "flaggable", :proposal_comment
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)
old_child = create(:comment, commentable: proposal, parent_id: new_root.id, created_at: Time.current - 10)
new_child = create(:comment, commentable: proposal, parent_id: new_root.id, created_at: Time.current)
visit proposal_path(proposal, order: :most_voted)
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: :newest)
expect(new_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.body)
visit proposal_path(proposal, order: :oldest)
expect(old_root.body).to appear_before(new_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/")

View File

@@ -6,30 +6,6 @@ describe "Commenting topics from proposals" do
it_behaves_like "flaggable", :topic_with_community_comment
scenario "Creation date works differently in roots and child comments when sorting by confidence_score" do
community = proposal.community
topic = create(:topic, community: community)
old_root = create(:comment, commentable: topic, created_at: Time.current - 10)
new_root = create(:comment, commentable: topic, created_at: Time.current)
old_child = create(:comment, commentable: topic, parent_id: new_root.id, created_at: Time.current - 10)
new_child = create(:comment, commentable: topic, parent_id: new_root.id, created_at: Time.current)
visit community_topic_path(community, topic, order: :most_voted)
expect(new_root.body).to appear_before(old_root.body)
expect(old_child.body).to appear_before(new_child.body)
visit community_topic_path(community, topic, order: :newest)
expect(new_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.body)
visit community_topic_path(community, topic, order: :oldest)
expect(old_root.body).to appear_before(new_root.body)
expect(old_child.body).to appear_before(new_child.body)
end
scenario "Turns links into html links" do
community = proposal.community
topic = create(:topic, community: community)
@@ -429,30 +405,6 @@ describe "Commenting topics from budget investments" do
let(:user) { create(:user) }
let(:investment) { create(:budget_investment) }
scenario "Creation date works differently in roots and child comments when sorting by confidence_score" do
community = investment.community
topic = create(:topic, community: community)
old_root = create(:comment, commentable: topic, created_at: Time.current - 10)
new_root = create(:comment, commentable: topic, created_at: Time.current)
old_child = create(:comment, commentable: topic, parent_id: new_root.id, created_at: Time.current - 10)
new_child = create(:comment, commentable: topic, parent_id: new_root.id, created_at: Time.current)
visit community_topic_path(community, topic, order: :most_voted)
expect(new_root.body).to appear_before(old_root.body)
expect(old_child.body).to appear_before(new_child.body)
visit community_topic_path(community, topic, order: :newest)
expect(new_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.body)
visit community_topic_path(community, topic, order: :oldest)
expect(old_root.body).to appear_before(new_root.body)
expect(old_child.body).to appear_before(new_child.body)
end
scenario "Turns links into html links" do
community = investment.community
topic = create(:topic, community: community)

View File

@@ -205,6 +205,31 @@ describe "Comments" do
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: resource, created_at: Time.current - 10)
new_root = create(:comment, commentable: resource, created_at: Time.current)
old_child = create(:comment,
commentable: resource,
parent_id: new_root.id,
created_at: Time.current - 10)
new_child = create(:comment, commentable: resource, parent_id: new_root.id, created_at: Time.current)
visit polymorphic_path(resource, order: :most_voted)
expect(new_root.body).to appear_before(old_root.body)
expect(old_child.body).to appear_before(new_child.body)
visit polymorphic_path(resource, order: :newest)
expect(new_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.body)
visit polymorphic_path(resource, order: :oldest)
expect(old_root.body).to appear_before(new_root.body)
expect(old_child.body).to appear_before(new_child.body)
end
scenario "Errors on create" do
login_as(user)
visit polymorphic_path(resource)