Simplify legislation variable names
Since we're in the context of the legislation section, we don't need the `legislation_` prefix.
This commit is contained in:
@@ -2,17 +2,17 @@ require "rails_helper"
|
|||||||
|
|
||||||
describe "Commenting legislation questions" do
|
describe "Commenting legislation questions" do
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
let(:legislation_annotation) { create :legislation_annotation, author: user }
|
let(:annotation) { create :legislation_annotation, author: user }
|
||||||
|
|
||||||
it_behaves_like "flaggable", :legislation_annotation_comment
|
it_behaves_like "flaggable", :legislation_annotation_comment
|
||||||
|
|
||||||
scenario "Index" do
|
scenario "Index" do
|
||||||
3.times { create(:comment, commentable: legislation_annotation) }
|
3.times { create(:comment, commentable: annotation) }
|
||||||
comment = Comment.includes(:user).last
|
comment = Comment.includes(:user).last
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
expect(page).to have_css(".comment", count: 4)
|
expect(page).to have_css(".comment", count: 4)
|
||||||
|
|
||||||
@@ -24,12 +24,12 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Show" do
|
scenario "Show" do
|
||||||
href = legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
href = legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
parent_comment = create(:comment, commentable: legislation_annotation, body: "Parent")
|
parent_comment = create(:comment, commentable: annotation, body: "Parent")
|
||||||
create(:comment, commentable: legislation_annotation, parent: parent_comment, body: "First subcomment")
|
create(:comment, commentable: annotation, parent: parent_comment, body: "First subcomment")
|
||||||
create(:comment, commentable: legislation_annotation, parent: parent_comment, body: "Last subcomment")
|
create(:comment, commentable: annotation, parent: parent_comment, body: "Last subcomment")
|
||||||
|
|
||||||
visit comment_path(parent_comment)
|
visit comment_path(parent_comment)
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ describe "Commenting legislation questions" do
|
|||||||
expect(page).to have_content "First subcomment"
|
expect(page).to have_content "First subcomment"
|
||||||
expect(page).to have_content "Last subcomment"
|
expect(page).to have_content "Last subcomment"
|
||||||
|
|
||||||
expect(page).to have_link "Go back to #{legislation_annotation.title}", href: href
|
expect(page).to have_link "Go back to #{annotation.title}", href: href
|
||||||
|
|
||||||
within ".comment", text: "Parent" do
|
within ".comment", text: "Parent" do
|
||||||
expect(page).to have_selector(".comment", count: 2)
|
expect(page).to have_selector(".comment", count: 2)
|
||||||
@@ -46,29 +46,29 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Link to comment show" do
|
scenario "Link to comment show" do
|
||||||
comment = create(:comment, commentable: legislation_annotation, user: user)
|
comment = create(:comment, commentable: annotation, user: user)
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
within "#comment_#{comment.id}" do
|
within "#comment_#{comment.id}" do
|
||||||
expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T")
|
expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T")
|
||||||
click_link comment.created_at.strftime("%Y-%m-%d %T")
|
click_link comment.created_at.strftime("%Y-%m-%d %T")
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(page).to have_link "Go back to #{legislation_annotation.title}"
|
expect(page).to have_link "Go back to #{annotation.title}"
|
||||||
expect(page).to have_current_path(comment_path(comment))
|
expect(page).to have_current_path(comment_path(comment))
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Collapsable comments" do
|
scenario "Collapsable comments" do
|
||||||
parent_comment = legislation_annotation.comments.first
|
parent_comment = annotation.comments.first
|
||||||
child_comment = create(:comment, body: "First subcomment", commentable: legislation_annotation, parent: parent_comment)
|
child_comment = create(:comment, body: "First subcomment", commentable: annotation, parent: parent_comment)
|
||||||
grandchild_comment = create(:comment, body: "Last subcomment", commentable: legislation_annotation, parent: child_comment)
|
grandchild_comment = create(:comment, body: "Last subcomment", commentable: annotation, parent: child_comment)
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
expect(page).to have_css(".comment", count: 3)
|
expect(page).to have_css(".comment", count: 3)
|
||||||
expect(page).to have_content("1 response (collapse)", count: 2)
|
expect(page).to have_content("1 response (collapse)", count: 2)
|
||||||
@@ -101,16 +101,16 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Comment order" do
|
scenario "Comment order" do
|
||||||
c1 = create(:comment, :with_confidence_score, commentable: legislation_annotation, cached_votes_up: 100,
|
c1 = create(:comment, :with_confidence_score, commentable: annotation, cached_votes_up: 100,
|
||||||
cached_votes_total: 120, created_at: Time.current - 2)
|
cached_votes_total: 120, created_at: Time.current - 2)
|
||||||
c2 = create(:comment, :with_confidence_score, commentable: legislation_annotation, cached_votes_up: 10,
|
c2 = create(:comment, :with_confidence_score, commentable: annotation, cached_votes_up: 10,
|
||||||
cached_votes_total: 12, created_at: Time.current - 1)
|
cached_votes_total: 12, created_at: Time.current - 1)
|
||||||
c3 = create(:comment, :with_confidence_score, commentable: legislation_annotation, cached_votes_up: 1,
|
c3 = create(:comment, :with_confidence_score, commentable: annotation, cached_votes_up: 1,
|
||||||
cached_votes_total: 2, created_at: Time.current)
|
cached_votes_total: 2, created_at: Time.current)
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation,
|
annotation,
|
||||||
order: :most_voted)
|
order: :most_voted)
|
||||||
|
|
||||||
expect(c1.body).to appear_before(c2.body)
|
expect(c1.body).to appear_before(c2.body)
|
||||||
@@ -132,30 +132,30 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Creation date works differently in roots and in child comments, even when sorting by confidence_score" do
|
scenario "Creation date works differently in roots and in child comments, even when sorting by confidence_score" do
|
||||||
old_root = create(:comment, commentable: legislation_annotation, created_at: Time.current - 10)
|
old_root = create(:comment, commentable: annotation, created_at: Time.current - 10)
|
||||||
new_root = create(:comment, commentable: legislation_annotation, created_at: Time.current)
|
new_root = create(:comment, commentable: annotation, created_at: Time.current)
|
||||||
old_child = create(:comment, commentable: legislation_annotation, parent_id: new_root.id, created_at: Time.current - 10)
|
old_child = create(:comment, commentable: annotation, parent_id: new_root.id, created_at: Time.current - 10)
|
||||||
new_child = create(:comment, commentable: legislation_annotation, parent_id: new_root.id, created_at: Time.current)
|
new_child = create(:comment, commentable: annotation, parent_id: new_root.id, created_at: Time.current)
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation,
|
annotation,
|
||||||
order: :most_voted)
|
order: :most_voted)
|
||||||
|
|
||||||
expect(new_root.body).to appear_before(old_root.body)
|
expect(new_root.body).to appear_before(old_root.body)
|
||||||
expect(old_child.body).to appear_before(new_child.body)
|
expect(old_child.body).to appear_before(new_child.body)
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation,
|
annotation,
|
||||||
order: :newest)
|
order: :newest)
|
||||||
|
|
||||||
expect(new_root.body).to appear_before(old_root.body)
|
expect(new_root.body).to appear_before(old_root.body)
|
||||||
expect(new_child.body).to appear_before(old_child.body)
|
expect(new_child.body).to appear_before(old_child.body)
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation,
|
annotation,
|
||||||
order: :oldest)
|
order: :oldest)
|
||||||
|
|
||||||
expect(old_root.body).to appear_before(new_root.body)
|
expect(old_root.body).to appear_before(new_root.body)
|
||||||
@@ -163,12 +163,12 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Turns links into html links" do
|
scenario "Turns links into html links" do
|
||||||
legislation_annotation = create :legislation_annotation, author: user
|
annotation = create :legislation_annotation, author: user
|
||||||
legislation_annotation.comments << create(:comment, body: "Built with http://rubyonrails.org/")
|
annotation.comments << create(:comment, body: "Built with http://rubyonrails.org/")
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
within all(".comment").first do
|
within all(".comment").first do
|
||||||
expect(page).to have_content "Built with http://rubyonrails.org/"
|
expect(page).to have_content "Built with http://rubyonrails.org/"
|
||||||
@@ -179,12 +179,12 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Sanitizes comment body for security" do
|
scenario "Sanitizes comment body for security" do
|
||||||
create :comment, commentable: legislation_annotation,
|
create :comment, commentable: annotation,
|
||||||
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
|
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
within all(".comment").first do
|
within all(".comment").first do
|
||||||
expect(page).to have_content "click me http://www.url.com"
|
expect(page).to have_content "click me http://www.url.com"
|
||||||
@@ -195,11 +195,11 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
scenario "Paginated comments" do
|
scenario "Paginated comments" do
|
||||||
per_page = 10
|
per_page = 10
|
||||||
(per_page + 2).times { create(:comment, commentable: legislation_annotation) }
|
(per_page + 2).times { create(:comment, commentable: annotation) }
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
expect(page).to have_css(".comment", count: per_page)
|
expect(page).to have_css(".comment", count: per_page)
|
||||||
within("ul.pagination") do
|
within("ul.pagination") do
|
||||||
@@ -215,10 +215,10 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
describe "Not logged user" do
|
describe "Not logged user" do
|
||||||
scenario "can not see comments forms" do
|
scenario "can not see comments forms" do
|
||||||
create(:comment, commentable: legislation_annotation)
|
create(:comment, commentable: annotation)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
expect(page).to have_content "You must sign in or sign up to leave a comment"
|
expect(page).to have_content "You must sign in or sign up to leave a comment"
|
||||||
within("#comments") do
|
within("#comments") do
|
||||||
@@ -230,9 +230,9 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
scenario "Create" do
|
scenario "Create" do
|
||||||
login_as(user)
|
login_as(user)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
fill_in "Leave your comment", with: "Have you thought about...?"
|
fill_in "Leave your comment", with: "Have you thought about...?"
|
||||||
click_button "Publish comment"
|
click_button "Publish comment"
|
||||||
@@ -245,9 +245,9 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
scenario "Errors on create" do
|
scenario "Errors on create" do
|
||||||
login_as(user)
|
login_as(user)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
click_button "Publish comment"
|
click_button "Publish comment"
|
||||||
|
|
||||||
@@ -276,13 +276,13 @@ describe "Commenting legislation questions" do
|
|||||||
scenario "Reply" do
|
scenario "Reply" do
|
||||||
citizen = create(:user, username: "Ana")
|
citizen = create(:user, username: "Ana")
|
||||||
manuela = create(:user, username: "Manuela")
|
manuela = create(:user, username: "Manuela")
|
||||||
legislation_annotation = create(:legislation_annotation, author: citizen)
|
annotation = create(:legislation_annotation, author: citizen)
|
||||||
comment = legislation_annotation.comments.first
|
comment = annotation.comments.first
|
||||||
|
|
||||||
login_as(manuela)
|
login_as(manuela)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
click_link "Reply"
|
click_link "Reply"
|
||||||
|
|
||||||
@@ -300,13 +300,13 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
scenario "Reply update parent comment responses count" do
|
scenario "Reply update parent comment responses count" do
|
||||||
manuela = create(:user, :level_two, username: "Manuela")
|
manuela = create(:user, :level_two, username: "Manuela")
|
||||||
legislation_annotation = create(:legislation_annotation)
|
annotation = create(:legislation_annotation)
|
||||||
comment = legislation_annotation.comments.first
|
comment = annotation.comments.first
|
||||||
|
|
||||||
login_as(manuela)
|
login_as(manuela)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
within ".comment", text: comment.body do
|
within ".comment", text: comment.body do
|
||||||
click_link "Reply"
|
click_link "Reply"
|
||||||
@@ -319,14 +319,14 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
scenario "Reply show parent comments responses when hidden" do
|
scenario "Reply show parent comments responses when hidden" do
|
||||||
manuela = create(:user, :level_two, username: "Manuela")
|
manuela = create(:user, :level_two, username: "Manuela")
|
||||||
legislation_annotation = create(:legislation_annotation)
|
annotation = create(:legislation_annotation)
|
||||||
comment = legislation_annotation.comments.first
|
comment = annotation.comments.first
|
||||||
create(:comment, commentable: legislation_annotation, parent: comment)
|
create(:comment, commentable: annotation, parent: comment)
|
||||||
|
|
||||||
login_as(manuela)
|
login_as(manuela)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
within ".comment", text: comment.body do
|
within ".comment", text: comment.body do
|
||||||
click_link text: "1 response (collapse)"
|
click_link text: "1 response (collapse)"
|
||||||
@@ -339,12 +339,12 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Errors on reply" do
|
scenario "Errors on reply" do
|
||||||
comment = legislation_annotation.comments.first
|
comment = annotation.comments.first
|
||||||
|
|
||||||
login_as(user)
|
login_as(user)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
click_link "Reply"
|
click_link "Reply"
|
||||||
|
|
||||||
@@ -355,28 +355,28 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "N replies" do
|
scenario "N replies" do
|
||||||
parent = create(:comment, commentable: legislation_annotation)
|
parent = create(:comment, commentable: annotation)
|
||||||
|
|
||||||
7.times do
|
7.times do
|
||||||
create(:comment, commentable: legislation_annotation, parent: parent)
|
create(:comment, commentable: annotation, parent: parent)
|
||||||
parent = parent.children.first
|
parent = parent.children.first
|
||||||
end
|
end
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
expect(page).to have_css(".comment.comment.comment.comment.comment.comment.comment.comment")
|
expect(page).to have_css(".comment.comment.comment.comment.comment.comment.comment.comment")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Erasing a comment's author" do
|
scenario "Erasing a comment's author" do
|
||||||
legislation_annotation = create(:legislation_annotation)
|
annotation = create(:legislation_annotation)
|
||||||
comment = create(:comment, commentable: legislation_annotation, body: "this should be visible")
|
comment = create(:comment, commentable: annotation, body: "this should be visible")
|
||||||
comment.user.erase
|
comment.user.erase
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
within "#comment_#{comment.id}" do
|
within "#comment_#{comment.id}" do
|
||||||
expect(page).to have_content("User deleted")
|
expect(page).to have_content("User deleted")
|
||||||
@@ -385,12 +385,12 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Submit button is disabled after clicking" do
|
scenario "Submit button is disabled after clicking" do
|
||||||
legislation_annotation = create(:legislation_annotation)
|
annotation = create(:legislation_annotation)
|
||||||
login_as(user)
|
login_as(user)
|
||||||
|
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
fill_in "Leave your comment", with: "Testing submit button!"
|
fill_in "Leave your comment", with: "Testing submit button!"
|
||||||
click_button "Publish comment"
|
click_button "Publish comment"
|
||||||
@@ -405,12 +405,12 @@ describe "Commenting legislation questions" do
|
|||||||
moderator = create(:moderator)
|
moderator = create(:moderator)
|
||||||
|
|
||||||
login_as(moderator.user)
|
login_as(moderator.user)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
fill_in "Leave your comment", with: "I am moderating!"
|
fill_in "Leave your comment", with: "I am moderating!"
|
||||||
check "comment-as-moderator-legislation_annotation_#{legislation_annotation.id}"
|
check "comment-as-moderator-legislation_annotation_#{annotation.id}"
|
||||||
click_button "Publish comment"
|
click_button "Publish comment"
|
||||||
|
|
||||||
within "#comments" do
|
within "#comments" do
|
||||||
@@ -425,13 +425,13 @@ describe "Commenting legislation questions" do
|
|||||||
citizen = create(:user, username: "Ana")
|
citizen = create(:user, username: "Ana")
|
||||||
manuela = create(:user, username: "Manuela")
|
manuela = create(:user, username: "Manuela")
|
||||||
moderator = create(:moderator, user: manuela)
|
moderator = create(:moderator, user: manuela)
|
||||||
legislation_annotation = create(:legislation_annotation, author: citizen)
|
annotation = create(:legislation_annotation, author: citizen)
|
||||||
comment = legislation_annotation.comments.first
|
comment = annotation.comments.first
|
||||||
|
|
||||||
login_as(manuela)
|
login_as(manuela)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
click_link "Reply"
|
click_link "Reply"
|
||||||
|
|
||||||
@@ -455,9 +455,9 @@ describe "Commenting legislation questions" do
|
|||||||
moderator = create(:moderator)
|
moderator = create(:moderator)
|
||||||
|
|
||||||
login_as(moderator.user)
|
login_as(moderator.user)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
expect(page).not_to have_content "Comment as administrator"
|
expect(page).not_to have_content "Comment as administrator"
|
||||||
end
|
end
|
||||||
@@ -468,12 +468,12 @@ describe "Commenting legislation questions" do
|
|||||||
admin = create(:administrator)
|
admin = create(:administrator)
|
||||||
|
|
||||||
login_as(admin.user)
|
login_as(admin.user)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
fill_in "Leave your comment", with: "I am your Admin!"
|
fill_in "Leave your comment", with: "I am your Admin!"
|
||||||
check "comment-as-administrator-legislation_annotation_#{legislation_annotation.id}"
|
check "comment-as-administrator-legislation_annotation_#{annotation.id}"
|
||||||
click_button "Publish comment"
|
click_button "Publish comment"
|
||||||
|
|
||||||
within "#comments" do
|
within "#comments" do
|
||||||
@@ -488,13 +488,13 @@ describe "Commenting legislation questions" do
|
|||||||
citizen = create(:user, username: "Ana")
|
citizen = create(:user, username: "Ana")
|
||||||
manuela = create(:user, username: "Manuela")
|
manuela = create(:user, username: "Manuela")
|
||||||
admin = create(:administrator, user: manuela)
|
admin = create(:administrator, user: manuela)
|
||||||
legislation_annotation = create(:legislation_annotation, author: citizen)
|
annotation = create(:legislation_annotation, author: citizen)
|
||||||
comment = legislation_annotation.comments.first
|
comment = annotation.comments.first
|
||||||
|
|
||||||
login_as(manuela)
|
login_as(manuela)
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
click_link "Reply"
|
click_link "Reply"
|
||||||
|
|
||||||
@@ -515,9 +515,9 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "can not comment as a moderator", :admin do
|
scenario "can not comment as a moderator", :admin do
|
||||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||||
legislation_annotation.draft_version,
|
annotation.draft_version,
|
||||||
legislation_annotation)
|
annotation)
|
||||||
|
|
||||||
expect(page).not_to have_content "Comment as moderator"
|
expect(page).not_to have_content "Comment as moderator"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ require "rails_helper"
|
|||||||
describe "Commenting legislation questions" do
|
describe "Commenting legislation questions" do
|
||||||
let(:user) { create :user, :level_two }
|
let(:user) { create :user, :level_two }
|
||||||
let(:process) { create :legislation_process, :in_debate_phase }
|
let(:process) { create :legislation_process, :in_debate_phase }
|
||||||
let(:legislation_question) { create :legislation_question, process: process }
|
let(:question) { create :legislation_question, process: process }
|
||||||
|
|
||||||
context "Concerns" do
|
context "Concerns" do
|
||||||
it_behaves_like "notifiable in-app", :legislation_question
|
it_behaves_like "notifiable in-app", :legislation_question
|
||||||
@@ -11,10 +11,10 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Index" do
|
scenario "Index" do
|
||||||
3.times { create(:comment, commentable: legislation_question) }
|
3.times { create(:comment, commentable: question) }
|
||||||
comment = Comment.includes(:user).last
|
comment = Comment.includes(:user).last
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
expect(page).to have_css(".comment", count: 3)
|
expect(page).to have_css(".comment", count: 3)
|
||||||
|
|
||||||
@@ -26,10 +26,10 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Show" do
|
scenario "Show" do
|
||||||
href = legislation_process_question_path(legislation_question.process, legislation_question)
|
href = legislation_process_question_path(question.process, question)
|
||||||
parent_comment = create(:comment, commentable: legislation_question, body: "Parent")
|
parent_comment = create(:comment, commentable: question, body: "Parent")
|
||||||
create(:comment, commentable: legislation_question, parent: parent_comment, body: "First subcomment")
|
create(:comment, commentable: question, parent: parent_comment, body: "First subcomment")
|
||||||
create(:comment, commentable: legislation_question, parent: parent_comment, body: "Last subcomment")
|
create(:comment, commentable: question, parent: parent_comment, body: "Last subcomment")
|
||||||
|
|
||||||
visit comment_path(parent_comment)
|
visit comment_path(parent_comment)
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ describe "Commenting legislation questions" do
|
|||||||
expect(page).to have_content "First subcomment"
|
expect(page).to have_content "First subcomment"
|
||||||
expect(page).to have_content "Last subcomment"
|
expect(page).to have_content "Last subcomment"
|
||||||
|
|
||||||
expect(page).to have_link "Go back to #{legislation_question.title}", href: href
|
expect(page).to have_link "Go back to #{question.title}", href: href
|
||||||
|
|
||||||
within ".comment", text: "Parent" do
|
within ".comment", text: "Parent" do
|
||||||
expect(page).to have_selector(".comment", count: 2)
|
expect(page).to have_selector(".comment", count: 2)
|
||||||
@@ -46,9 +46,9 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Link to comment show" do
|
scenario "Link to comment show" do
|
||||||
comment = create(:comment, commentable: legislation_question, user: user)
|
comment = create(:comment, commentable: question, user: user)
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
within "#comment_#{comment.id}" do
|
within "#comment_#{comment.id}" do
|
||||||
expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T")
|
expect(page).to have_link comment.created_at.strftime("%Y-%m-%d %T")
|
||||||
@@ -56,16 +56,16 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
click_link comment.created_at.strftime("%Y-%m-%d %T")
|
click_link comment.created_at.strftime("%Y-%m-%d %T")
|
||||||
|
|
||||||
expect(page).to have_link "Go back to #{legislation_question.title}"
|
expect(page).to have_link "Go back to #{question.title}"
|
||||||
expect(page).to have_current_path(comment_path(comment))
|
expect(page).to have_current_path(comment_path(comment))
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Collapsable comments" do
|
scenario "Collapsable comments" do
|
||||||
parent_comment = create(:comment, body: "Main comment", commentable: legislation_question)
|
parent_comment = create(:comment, body: "Main comment", commentable: question)
|
||||||
child_comment = create(:comment, body: "First subcomment", commentable: legislation_question, parent: parent_comment)
|
child_comment = create(:comment, body: "First subcomment", commentable: question, parent: parent_comment)
|
||||||
grandchild_comment = create(:comment, body: "Last subcomment", commentable: legislation_question, parent: child_comment)
|
grandchild_comment = create(:comment, body: "Last subcomment", commentable: question, parent: child_comment)
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
expect(page).to have_css(".comment", count: 3)
|
expect(page).to have_css(".comment", count: 3)
|
||||||
expect(page).to have_content("1 response (collapse)", count: 2)
|
expect(page).to have_content("1 response (collapse)", count: 2)
|
||||||
@@ -98,14 +98,14 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Comment order" do
|
scenario "Comment order" do
|
||||||
c1 = create(:comment, :with_confidence_score, commentable: legislation_question, cached_votes_up: 100,
|
c1 = create(:comment, :with_confidence_score, commentable: question, cached_votes_up: 100,
|
||||||
cached_votes_total: 120, created_at: Time.current - 2)
|
cached_votes_total: 120, created_at: Time.current - 2)
|
||||||
c2 = create(:comment, :with_confidence_score, commentable: legislation_question, cached_votes_up: 10,
|
c2 = create(:comment, :with_confidence_score, commentable: question, cached_votes_up: 10,
|
||||||
cached_votes_total: 12, created_at: Time.current - 1)
|
cached_votes_total: 12, created_at: Time.current - 1)
|
||||||
c3 = create(:comment, :with_confidence_score, commentable: legislation_question, cached_votes_up: 1,
|
c3 = create(:comment, :with_confidence_score, commentable: question, cached_votes_up: 1,
|
||||||
cached_votes_total: 2, created_at: Time.current)
|
cached_votes_total: 2, created_at: Time.current)
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question, order: :most_voted)
|
visit legislation_process_question_path(question.process, question, order: :most_voted)
|
||||||
|
|
||||||
expect(c1.body).to appear_before(c2.body)
|
expect(c1.body).to appear_before(c2.body)
|
||||||
expect(c2.body).to appear_before(c3.body)
|
expect(c2.body).to appear_before(c3.body)
|
||||||
@@ -126,31 +126,31 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Creation date works differently in roots and in child comments, even when sorting by confidence_score" do
|
scenario "Creation date works differently in roots and in child comments, even when sorting by confidence_score" do
|
||||||
old_root = create(:comment, commentable: legislation_question, created_at: Time.current - 10)
|
old_root = create(:comment, commentable: question, created_at: Time.current - 10)
|
||||||
new_root = create(:comment, commentable: legislation_question, created_at: Time.current)
|
new_root = create(:comment, commentable: question, created_at: Time.current)
|
||||||
old_child = create(:comment, commentable: legislation_question, parent_id: new_root.id, created_at: Time.current - 10)
|
old_child = create(:comment, commentable: question, parent_id: new_root.id, created_at: Time.current - 10)
|
||||||
new_child = create(:comment, commentable: legislation_question, parent_id: new_root.id, created_at: Time.current)
|
new_child = create(:comment, commentable: question, parent_id: new_root.id, created_at: Time.current)
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question, order: :most_voted)
|
visit legislation_process_question_path(question.process, question, order: :most_voted)
|
||||||
|
|
||||||
expect(new_root.body).to appear_before(old_root.body)
|
expect(new_root.body).to appear_before(old_root.body)
|
||||||
expect(old_child.body).to appear_before(new_child.body)
|
expect(old_child.body).to appear_before(new_child.body)
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question, order: :newest)
|
visit legislation_process_question_path(question.process, question, order: :newest)
|
||||||
|
|
||||||
expect(new_root.body).to appear_before(old_root.body)
|
expect(new_root.body).to appear_before(old_root.body)
|
||||||
expect(new_child.body).to appear_before(old_child.body)
|
expect(new_child.body).to appear_before(old_child.body)
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question, order: :oldest)
|
visit legislation_process_question_path(question.process, question, order: :oldest)
|
||||||
|
|
||||||
expect(old_root.body).to appear_before(new_root.body)
|
expect(old_root.body).to appear_before(new_root.body)
|
||||||
expect(old_child.body).to appear_before(new_child.body)
|
expect(old_child.body).to appear_before(new_child.body)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Turns links into html links" do
|
scenario "Turns links into html links" do
|
||||||
create :comment, commentable: legislation_question, body: "Built with http://rubyonrails.org/"
|
create :comment, commentable: question, body: "Built with http://rubyonrails.org/"
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
within first(".comment") do
|
within first(".comment") do
|
||||||
expect(page).to have_content "Built with http://rubyonrails.org/"
|
expect(page).to have_content "Built with http://rubyonrails.org/"
|
||||||
@@ -161,10 +161,10 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Sanitizes comment body for security" do
|
scenario "Sanitizes comment body for security" do
|
||||||
create :comment, commentable: legislation_question,
|
create :comment, commentable: question,
|
||||||
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
|
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
within first(".comment") do
|
within first(".comment") do
|
||||||
expect(page).to have_content "click me http://www.url.com"
|
expect(page).to have_content "click me http://www.url.com"
|
||||||
@@ -175,9 +175,9 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
scenario "Paginated comments" do
|
scenario "Paginated comments" do
|
||||||
per_page = 10
|
per_page = 10
|
||||||
(per_page + 2).times { create(:comment, commentable: legislation_question) }
|
(per_page + 2).times { create(:comment, commentable: question) }
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
expect(page).to have_css(".comment", count: per_page)
|
expect(page).to have_css(".comment", count: per_page)
|
||||||
within("ul.pagination") do
|
within("ul.pagination") do
|
||||||
@@ -193,8 +193,8 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
describe "Not logged user" do
|
describe "Not logged user" do
|
||||||
scenario "can not see comments forms" do
|
scenario "can not see comments forms" do
|
||||||
create(:comment, commentable: legislation_question)
|
create(:comment, commentable: question)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
expect(page).to have_content "You must sign in or sign up to leave a comment"
|
expect(page).to have_content "You must sign in or sign up to leave a comment"
|
||||||
within("#comments") do
|
within("#comments") do
|
||||||
@@ -206,7 +206,7 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
scenario "Create" do
|
scenario "Create" do
|
||||||
login_as(user)
|
login_as(user)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
fill_in "Leave your answer", with: "Have you thought about...?"
|
fill_in "Leave your answer", with: "Have you thought about...?"
|
||||||
click_button "Publish answer"
|
click_button "Publish answer"
|
||||||
@@ -219,7 +219,7 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
scenario "Errors on create" do
|
scenario "Errors on create" do
|
||||||
login_as(user)
|
login_as(user)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
click_button "Publish answer"
|
click_button "Publish answer"
|
||||||
|
|
||||||
@@ -230,7 +230,7 @@ describe "Commenting legislation questions" do
|
|||||||
unverified_user = create :user
|
unverified_user = create :user
|
||||||
login_as(unverified_user)
|
login_as(unverified_user)
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
expect(page).to have_content "To participate verify your account"
|
expect(page).to have_content "To participate verify your account"
|
||||||
end
|
end
|
||||||
@@ -239,7 +239,7 @@ describe "Commenting legislation questions" do
|
|||||||
process.update!(debate_start_date: Date.current - 2.days, debate_end_date: Date.current - 1.day)
|
process.update!(debate_start_date: Date.current - 2.days, debate_end_date: Date.current - 1.day)
|
||||||
login_as(user)
|
login_as(user)
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
expect(page).to have_content "Closed phase"
|
expect(page).to have_content "Closed phase"
|
||||||
end
|
end
|
||||||
@@ -247,10 +247,10 @@ describe "Commenting legislation questions" do
|
|||||||
scenario "Reply" do
|
scenario "Reply" do
|
||||||
citizen = create(:user, username: "Ana")
|
citizen = create(:user, username: "Ana")
|
||||||
manuela = create(:user, :level_two, username: "Manuela")
|
manuela = create(:user, :level_two, username: "Manuela")
|
||||||
comment = create(:comment, commentable: legislation_question, user: citizen)
|
comment = create(:comment, commentable: question, user: citizen)
|
||||||
|
|
||||||
login_as(manuela)
|
login_as(manuela)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
click_link "Reply"
|
click_link "Reply"
|
||||||
|
|
||||||
@@ -268,10 +268,10 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
scenario "Reply update parent comment responses count" do
|
scenario "Reply update parent comment responses count" do
|
||||||
manuela = create(:user, :level_two, username: "Manuela")
|
manuela = create(:user, :level_two, username: "Manuela")
|
||||||
comment = create(:comment, commentable: legislation_question)
|
comment = create(:comment, commentable: question)
|
||||||
|
|
||||||
login_as(manuela)
|
login_as(manuela)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
within ".comment", text: comment.body do
|
within ".comment", text: comment.body do
|
||||||
click_link "Reply"
|
click_link "Reply"
|
||||||
@@ -284,11 +284,11 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
scenario "Reply show parent comments responses when hidden" do
|
scenario "Reply show parent comments responses when hidden" do
|
||||||
manuela = create(:user, :level_two, username: "Manuela")
|
manuela = create(:user, :level_two, username: "Manuela")
|
||||||
comment = create(:comment, commentable: legislation_question)
|
comment = create(:comment, commentable: question)
|
||||||
create(:comment, commentable: legislation_question, parent: comment)
|
create(:comment, commentable: question, parent: comment)
|
||||||
|
|
||||||
login_as(manuela)
|
login_as(manuela)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
within ".comment", text: comment.body do
|
within ".comment", text: comment.body do
|
||||||
click_link text: "1 response (collapse)"
|
click_link text: "1 response (collapse)"
|
||||||
@@ -301,10 +301,10 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Errors on reply" do
|
scenario "Errors on reply" do
|
||||||
comment = create(:comment, commentable: legislation_question, user: user)
|
comment = create(:comment, commentable: question, user: user)
|
||||||
|
|
||||||
login_as(user)
|
login_as(user)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
click_link "Reply"
|
click_link "Reply"
|
||||||
|
|
||||||
@@ -315,22 +315,22 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "N replies" do
|
scenario "N replies" do
|
||||||
parent = create(:comment, commentable: legislation_question)
|
parent = create(:comment, commentable: question)
|
||||||
|
|
||||||
7.times do
|
7.times do
|
||||||
create(:comment, commentable: legislation_question, parent: parent)
|
create(:comment, commentable: question, parent: parent)
|
||||||
parent = parent.children.first
|
parent = parent.children.first
|
||||||
end
|
end
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
expect(page).to have_css(".comment.comment.comment.comment.comment.comment.comment.comment")
|
expect(page).to have_css(".comment.comment.comment.comment.comment.comment.comment.comment")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Erasing a comment's author" do
|
scenario "Erasing a comment's author" do
|
||||||
comment = create(:comment, commentable: legislation_question, body: "this should be visible")
|
comment = create(:comment, commentable: question, body: "this should be visible")
|
||||||
comment.user.erase
|
comment.user.erase
|
||||||
|
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
within "#comment_#{comment.id}" do
|
within "#comment_#{comment.id}" do
|
||||||
expect(page).to have_content("User deleted")
|
expect(page).to have_content("User deleted")
|
||||||
expect(page).to have_content("this should be visible")
|
expect(page).to have_content("this should be visible")
|
||||||
@@ -339,7 +339,7 @@ describe "Commenting legislation questions" do
|
|||||||
|
|
||||||
scenario "Submit button is disabled after clicking" do
|
scenario "Submit button is disabled after clicking" do
|
||||||
login_as(user)
|
login_as(user)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
fill_in "Leave your answer", with: "Testing submit button!"
|
fill_in "Leave your answer", with: "Testing submit button!"
|
||||||
click_button "Publish answer"
|
click_button "Publish answer"
|
||||||
@@ -354,10 +354,10 @@ describe "Commenting legislation questions" do
|
|||||||
moderator = create(:moderator)
|
moderator = create(:moderator)
|
||||||
|
|
||||||
login_as(moderator.user)
|
login_as(moderator.user)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
fill_in "Leave your answer", with: "I am moderating!"
|
fill_in "Leave your answer", with: "I am moderating!"
|
||||||
check "comment-as-moderator-legislation_question_#{legislation_question.id}"
|
check "comment-as-moderator-legislation_question_#{question.id}"
|
||||||
click_button "Publish answer"
|
click_button "Publish answer"
|
||||||
|
|
||||||
within "#comments" do
|
within "#comments" do
|
||||||
@@ -372,10 +372,10 @@ describe "Commenting legislation questions" do
|
|||||||
citizen = create(:user, username: "Ana")
|
citizen = create(:user, username: "Ana")
|
||||||
manuela = create(:user, username: "Manuela")
|
manuela = create(:user, username: "Manuela")
|
||||||
moderator = create(:moderator, user: manuela)
|
moderator = create(:moderator, user: manuela)
|
||||||
comment = create(:comment, commentable: legislation_question, user: citizen)
|
comment = create(:comment, commentable: question, user: citizen)
|
||||||
|
|
||||||
login_as(manuela)
|
login_as(manuela)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
click_link "Reply"
|
click_link "Reply"
|
||||||
|
|
||||||
@@ -399,7 +399,7 @@ describe "Commenting legislation questions" do
|
|||||||
moderator = create(:moderator)
|
moderator = create(:moderator)
|
||||||
|
|
||||||
login_as(moderator.user)
|
login_as(moderator.user)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
expect(page).not_to have_content "Comment as administrator"
|
expect(page).not_to have_content "Comment as administrator"
|
||||||
end
|
end
|
||||||
@@ -410,10 +410,10 @@ describe "Commenting legislation questions" do
|
|||||||
admin = create(:administrator)
|
admin = create(:administrator)
|
||||||
|
|
||||||
login_as(admin.user)
|
login_as(admin.user)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
fill_in "Leave your answer", with: "I am your Admin!"
|
fill_in "Leave your answer", with: "I am your Admin!"
|
||||||
check "comment-as-administrator-legislation_question_#{legislation_question.id}"
|
check "comment-as-administrator-legislation_question_#{question.id}"
|
||||||
click_button "Publish answer"
|
click_button "Publish answer"
|
||||||
|
|
||||||
within "#comments" do
|
within "#comments" do
|
||||||
@@ -428,10 +428,10 @@ describe "Commenting legislation questions" do
|
|||||||
citizen = create(:user, username: "Ana")
|
citizen = create(:user, username: "Ana")
|
||||||
manuela = create(:user, username: "Manuela")
|
manuela = create(:user, username: "Manuela")
|
||||||
admin = create(:administrator, user: manuela)
|
admin = create(:administrator, user: manuela)
|
||||||
comment = create(:comment, commentable: legislation_question, user: citizen)
|
comment = create(:comment, commentable: question, user: citizen)
|
||||||
|
|
||||||
login_as(manuela)
|
login_as(manuela)
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
click_link "Reply"
|
click_link "Reply"
|
||||||
|
|
||||||
@@ -452,7 +452,7 @@ describe "Commenting legislation questions" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "can not comment as a moderator", :admin do
|
scenario "can not comment as a moderator", :admin do
|
||||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
visit legislation_process_question_path(question.process, question)
|
||||||
|
|
||||||
expect(page).not_to have_content "Comment as moderator"
|
expect(page).not_to have_content "Comment as moderator"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user