Skip to content

Commit

Permalink
Unify errors on reply comments specs
Browse files Browse the repository at this point in the history
Note that the click_link "Reply" is now inside a "within".

This is due to the case of "legislation_annotation" before in the original test
no comment was created as it simply took the one created by default when creating
a "legislation_annotation".

```
comment = annotation.comments.first
```

Now to try to unify this test, we always create a comment, and in this case as we
also created the "legislation_annotation" we have 2 comments, so it is necessary
to add the "click_link" inside the "within".
  • Loading branch information
taitus committed Mar 25, 2024
1 parent f4c3e74 commit f0fa004
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 119 deletions.
15 changes: 0 additions & 15 deletions spec/system/comments/budget_investments_spec.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
require "rails_helper"

describe "Commenting Budget::Investments" do
let(:user) { create(:user) }
let(:investment) { create(:budget_investment) }

it_behaves_like "flaggable", :budget_investment_comment

scenario "Errors on reply" do
comment = create(:comment, commentable: investment, user: user)

login_as(user)
visit budget_investment_path(investment.budget, investment)

click_link "Reply"

within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end

scenario "N replies" do
parent = create(:comment, commentable: investment)

Expand Down
14 changes: 0 additions & 14 deletions spec/system/comments/debates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,6 @@
end
end

scenario "Errors on reply" do
comment = create(:comment, commentable: debate, user: user)

login_as(user)
visit debate_path(debate)

click_link "Reply"

within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end

scenario "N replies" do
parent = create(:comment, commentable: debate)

Expand Down
14 changes: 0 additions & 14 deletions spec/system/comments/legislation_annotations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@

it_behaves_like "flaggable", :legislation_annotation_comment

scenario "Errors on reply" do
comment = annotation.comments.first

login_as(user)
visit polymorphic_path(annotation)

click_link "Reply"

within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end

scenario "N replies" do
parent = create(:comment, commentable: annotation)

Expand Down
14 changes: 0 additions & 14 deletions spec/system/comments/legislation_questions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,6 @@
it_behaves_like "flaggable", :legislation_question_comment
end

scenario "Errors on reply" do
comment = create(:comment, commentable: question, user: user)

login_as(user)
visit legislation_process_question_path(question.process, question)

click_link "Reply"

within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end

scenario "N replies" do
parent = create(:comment, commentable: question)

Expand Down
14 changes: 0 additions & 14 deletions spec/system/comments/polls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@
let(:user) { create(:user) }
let(:poll) { create(:poll, author: create(:user)) }

scenario "Errors on reply" do
comment = create(:comment, commentable: poll, user: user)

login_as(user)
visit poll_path(poll)

click_link "Reply"

within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end

scenario "N replies" do
parent = create(:comment, commentable: poll)

Expand Down
15 changes: 0 additions & 15 deletions spec/system/comments/proposals_spec.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
require "rails_helper"

describe "Commenting proposals" do
let(:user) { create(:user) }
let(:proposal) { create(:proposal) }

it_behaves_like "flaggable", :proposal_comment

scenario "Errors on reply" do
comment = create(:comment, commentable: proposal, user: user)

login_as(user)
visit proposal_path(proposal)

click_link "Reply"

within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end

scenario "N replies" do
parent = create(:comment, commentable: proposal)

Expand Down
33 changes: 0 additions & 33 deletions spec/system/comments/topics_spec.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
require "rails_helper"

describe "Commenting topics from proposals" do
let(:user) { create(:user) }
let(:proposal) { create(:proposal) }

it_behaves_like "flaggable", :topic_with_community_comment

scenario "Errors on reply" do
community = proposal.community
topic = create(:topic, community: community)
comment = create(:comment, commentable: topic, user: user)

login_as(user)
visit community_topic_path(community, topic)

click_link "Reply"

within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end

scenario "N replies" do
community = proposal.community
topic = create(:topic, community: community)
Expand Down Expand Up @@ -274,22 +257,6 @@
let(:user) { create(:user) }
let(:investment) { create(:budget_investment) }

scenario "Errors on reply" do
community = investment.community
topic = create(:topic, community: community)
comment = create(:comment, commentable: topic, user: user)

login_as(user)
visit community_topic_path(community, topic)

click_link "Reply"

within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end

scenario "N replies" do
community = investment.community
topic = create(:topic, community: community)
Expand Down
16 changes: 16 additions & 0 deletions spec/system/comments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,22 @@
end
end

scenario "Errors on reply" do
comment = create(:comment, commentable: resource, user: user)

login_as(user)
visit polymorphic_path(resource)

within "#comment_#{comment.id}" do
click_link "Reply"
end

within "#js-comment-form-comment_#{comment.id}" do
click_button "Publish reply"
expect(page).to have_content "Can't be blank"
end
end

scenario "Errors on create" do
login_as(user)
visit polymorphic_path(resource)
Expand Down

0 comments on commit f0fa004

Please sign in to comment.