Use shared specs to flag comments
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
shared_examples "flaggable" do |factory_name|
|
||||
let(:user) { create(:user) }
|
||||
include ActionView::RecordIdentifier
|
||||
|
||||
let(:user) { create(:user, :level_two) }
|
||||
let(:flaggable) { create(factory_name) }
|
||||
let(:path) { polymorphic_path(flaggable) }
|
||||
|
||||
let(:path) do
|
||||
if flaggable.is_a?(Comment)
|
||||
polymorphic_path(flaggable.commentable)
|
||||
else
|
||||
polymorphic_path(flaggable)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Flagging as inappropriate", :js do
|
||||
login_as(user)
|
||||
visit path
|
||||
|
||||
within ".flag-content" do
|
||||
within "##{dom_id(flaggable)} .flag-content" do
|
||||
find(".icon-flag").click
|
||||
click_link "Flag as inappropriate"
|
||||
|
||||
@@ -24,7 +33,7 @@ shared_examples "flaggable" do |factory_name|
|
||||
login_as(user)
|
||||
visit path
|
||||
|
||||
within ".flag-content" do
|
||||
within "##{dom_id(flaggable)} .flag-content" do
|
||||
expect(page).to have_css ".flag-active"
|
||||
|
||||
find(".icon-flag").click
|
||||
@@ -41,7 +50,7 @@ shared_examples "flaggable" do |factory_name|
|
||||
login_as(user)
|
||||
visit path
|
||||
|
||||
within ".flag-content" do
|
||||
within "##{dom_id(flaggable)} .flag-content" do
|
||||
find(".icon-flag").click
|
||||
click_link "Flag as inappropriate"
|
||||
|
||||
@@ -56,4 +65,24 @@ shared_examples "flaggable" do |factory_name|
|
||||
|
||||
expect(Flag.flagged?(user, flaggable)).not_to be
|
||||
end
|
||||
|
||||
scenario "Flagging a comment with a child does not update its children", :js do
|
||||
skip "Only for comments" unless flaggable.is_a?(Comment)
|
||||
|
||||
child_comment = create(:comment, commentable: flaggable.commentable, parent: flaggable)
|
||||
|
||||
login_as(user)
|
||||
visit path
|
||||
|
||||
within "##{dom_id(flaggable)} > .comment-body .flag-content" do
|
||||
find(".icon-flag").click
|
||||
click_link "Flag as inappropriate"
|
||||
|
||||
expect(page).to have_css ".flag-active"
|
||||
end
|
||||
|
||||
within "##{dom_id(child_comment)} .flag-content" do
|
||||
expect(page).not_to have_css ".flag-active"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user