Unify sanitizes comment spec
This commit is contained in:
@@ -6,21 +6,6 @@ describe "Commenting Budget::Investments" do
|
||||
|
||||
it_behaves_like "flaggable", :budget_investment_comment
|
||||
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create(:comment, commentable: investment,
|
||||
body: "<script>alert('hola')</script> " \
|
||||
"<a href=\"javascript:alert('sorpresa!')\">click me<a/> " \
|
||||
"http://www.url.com")
|
||||
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: investment) }
|
||||
|
||||
@@ -25,21 +25,6 @@ describe "Commenting debates" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create(:comment, commentable: debate,
|
||||
body: "<script>alert('hola')</script> " \
|
||||
"<a href=\"javascript:alert('sorpresa!')\">click me<a/> " \
|
||||
"http://www.url.com")
|
||||
|
||||
visit debate_path(debate)
|
||||
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: debate) }
|
||||
|
||||
@@ -6,21 +6,6 @@ describe "Commenting legislation questions" do
|
||||
|
||||
it_behaves_like "flaggable", :legislation_annotation_comment
|
||||
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create(:comment, commentable: annotation,
|
||||
body: "<script>alert('hola')</script> " \
|
||||
"<a href=\"javascript:alert('sorpresa!')\">click me<a/> " \
|
||||
"http://www.url.com")
|
||||
|
||||
visit polymorphic_path(annotation)
|
||||
|
||||
within all(".comment").first do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: annotation) }
|
||||
|
||||
@@ -10,21 +10,6 @@ describe "Commenting legislation questions" do
|
||||
it_behaves_like "flaggable", :legislation_question_comment
|
||||
end
|
||||
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create(:comment, commentable: question,
|
||||
body: "<script>alert('hola')</script> " \
|
||||
"<a href=\"javascript:alert('sorpresa!')\">click me<a/> " \
|
||||
"http://www.url.com")
|
||||
|
||||
visit legislation_process_question_path(question.process, question)
|
||||
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: question) }
|
||||
|
||||
@@ -4,21 +4,6 @@ describe "Commenting polls" do
|
||||
let(:user) { create(:user) }
|
||||
let(:poll) { create(:poll, author: create(:user)) }
|
||||
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create(:comment, commentable: poll,
|
||||
body: "<script>alert('hola')</script> " \
|
||||
"<a href=\"javascript:alert('sorpresa!')\">click me<a/> " \
|
||||
"http://www.url.com")
|
||||
|
||||
visit poll_path(poll)
|
||||
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: poll) }
|
||||
|
||||
@@ -6,21 +6,6 @@ describe "Commenting proposals" do
|
||||
|
||||
it_behaves_like "flaggable", :proposal_comment
|
||||
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create(:comment, commentable: proposal,
|
||||
body: "<script>alert('hola')</script> " \
|
||||
"<a href=\"javascript:alert('sorpresa!')\">click me<a/> " \
|
||||
"http://www.url.com")
|
||||
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: proposal) }
|
||||
|
||||
@@ -6,23 +6,6 @@ describe "Commenting topics from proposals" do
|
||||
|
||||
it_behaves_like "flaggable", :topic_with_community_comment
|
||||
|
||||
scenario "Sanitizes comment body for security" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
create(:comment, commentable: topic,
|
||||
body: "<script>alert('hola')</script> " \
|
||||
"<a href=\"javascript:alert('sorpresa!')\">click me<a/> " \
|
||||
"http://www.url.com")
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Paginated comments" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
@@ -390,23 +373,6 @@ describe "Commenting topics from budget investments" do
|
||||
let(:user) { create(:user) }
|
||||
let(:investment) { create(:budget_investment) }
|
||||
|
||||
scenario "Sanitizes comment body for security" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
create(:comment, commentable: topic,
|
||||
body: "<script>alert('hola')</script> " \
|
||||
"<a href=\"javascript:alert('sorpresa!')\">click me<a/> " \
|
||||
"http://www.url.com")
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Paginated comments" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
|
||||
@@ -243,6 +243,21 @@ describe "Comments" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create(:comment, commentable: resource,
|
||||
body: "<script>alert('hola')</script> " \
|
||||
"<a href=\"javascript:alert('sorpresa!')\">click me<a/> " \
|
||||
"http://www.url.com")
|
||||
|
||||
visit polymorphic_path(resource)
|
||||
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Errors on create" do
|
||||
login_as(user)
|
||||
visit polymorphic_path(resource)
|
||||
|
||||
Reference in New Issue
Block a user