Unify turns links specs

This commit is contained in:
taitus
2023-12-18 21:50:20 +01:00
parent b979c17a4b
commit 2f01d66557
8 changed files with 13 additions and 109 deletions

View File

@@ -6,19 +6,6 @@ describe "Commenting Budget::Investments" do
it_behaves_like "flaggable", :budget_investment_comment
scenario "Turns links into html links" do
create(:comment, commentable: investment, body: "Built with http://rubyonrails.org/")
visit budget_investment_path(investment.budget, investment)
within first(".comment") do
expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end
end
scenario "Sanitizes comment body for security" do
create(:comment, commentable: investment,
body: "<script>alert('hola')</script> " \

View File

@@ -25,19 +25,6 @@ describe "Commenting debates" do
end
end
scenario "Turns links into html links" do
create(:comment, commentable: debate, body: "Built with http://rubyonrails.org/")
visit debate_path(debate)
within first(".comment") do
expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end
end
scenario "Sanitizes comment body for security" do
create(:comment, commentable: debate,
body: "<script>alert('hola')</script> " \

View File

@@ -6,20 +6,6 @@ describe "Commenting legislation questions" do
it_behaves_like "flaggable", :legislation_annotation_comment
scenario "Turns links into html links" do
annotation = create(:legislation_annotation, author: user)
annotation.comments << create(:comment, body: "Built with http://rubyonrails.org/")
visit polymorphic_path(annotation)
within all(".comment").first do
expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end
end
scenario "Sanitizes comment body for security" do
create(:comment, commentable: annotation,
body: "<script>alert('hola')</script> " \

View File

@@ -10,19 +10,6 @@ describe "Commenting legislation questions" do
it_behaves_like "flaggable", :legislation_question_comment
end
scenario "Turns links into html links" do
create(:comment, commentable: question, body: "Built with http://rubyonrails.org/")
visit legislation_process_question_path(question.process, question)
within first(".comment") do
expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end
end
scenario "Sanitizes comment body for security" do
create(:comment, commentable: question,
body: "<script>alert('hola')</script> " \

View File

@@ -4,19 +4,6 @@ describe "Commenting polls" do
let(:user) { create(:user) }
let(:poll) { create(:poll, author: create(:user)) }
scenario "Turns links into html links" do
create(:comment, commentable: poll, body: "Built with http://rubyonrails.org/")
visit poll_path(poll)
within first(".comment") do
expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end
end
scenario "Sanitizes comment body for security" do
create(:comment, commentable: poll,
body: "<script>alert('hola')</script> " \

View File

@@ -6,19 +6,6 @@ describe "Commenting proposals" do
it_behaves_like "flaggable", :proposal_comment
scenario "Turns links into html links" do
create(:comment, commentable: proposal, body: "Built with http://rubyonrails.org/")
visit proposal_path(proposal)
within first(".comment") do
expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end
end
scenario "Sanitizes comment body for security" do
create(:comment, commentable: proposal,
body: "<script>alert('hola')</script> " \

View File

@@ -6,21 +6,6 @@ describe "Commenting topics from proposals" do
it_behaves_like "flaggable", :topic_with_community_comment
scenario "Turns links into html links" do
community = proposal.community
topic = create(:topic, community: community)
create(:comment, commentable: topic, body: "Built with http://rubyonrails.org/")
visit community_topic_path(community, topic)
within first(".comment") do
expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end
end
scenario "Sanitizes comment body for security" do
community = proposal.community
topic = create(:topic, community: community)
@@ -405,21 +390,6 @@ describe "Commenting topics from budget investments" do
let(:user) { create(:user) }
let(:investment) { create(:budget_investment) }
scenario "Turns links into html links" do
community = investment.community
topic = create(:topic, community: community)
create(:comment, commentable: topic, body: "Built with http://rubyonrails.org/")
visit community_topic_path(community, topic)
within first(".comment") do
expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end
end
scenario "Sanitizes comment body for security" do
community = investment.community
topic = create(:topic, community: community)

View File

@@ -230,6 +230,19 @@ describe "Comments" do
expect(old_child.body).to appear_before(new_child.body)
end
scenario "Turns links into html links" do
create(:comment, commentable: resource, body: "Built with http://rubyonrails.org/")
visit polymorphic_path(resource)
within first(".comment") do
expect(page).to have_content "Built with http://rubyonrails.org/"
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
expect(find_link("http://rubyonrails.org/")[:target]).to be_blank
end
end
scenario "Errors on create" do
login_as(user)
visit polymorphic_path(resource)