* Prepare factories and associations for Users::DeleteActivity specs * Altered user associations, delete the needed associations in Users::DeleteActivity * Moved and refined user deletion spec * Removed useless commented user associations * Refactored BackupData factory * Refactored ProfilePin factory * Refactored Reaction factory * Fixed specs: Keep default _type in factories or specify it in tests * Ok, notes shouldn't be deleted on user deletion * Fixed creating reactable for specs * Specify commentable/commentable_type explicitly when creating data for tests * Fixed typo in the comments spec * Removed unnneeded space * Added aggregate_failures for testing user associations deletion * Keep feedback_messages while deleting user activities
49 lines
1.4 KiB
Ruby
49 lines
1.4 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "Creating Comment", type: :system, js: true do
|
|
let(:user) { create(:user) }
|
|
let(:raw_comment) { Faker::Lorem.paragraph }
|
|
# the article should be created before signing in
|
|
let!(:article) { create(:article, user_id: user.id, show_comments: true) }
|
|
|
|
before do
|
|
sign_in user
|
|
end
|
|
|
|
it "User fills out comment box normally" do
|
|
visit article.path.to_s
|
|
|
|
wait_for_javascript
|
|
|
|
fill_in "text-area", with: raw_comment
|
|
click_button("SUBMIT")
|
|
expect(page).to have_text(raw_comment)
|
|
end
|
|
|
|
it "User fill out comment box then click previews and submit" do
|
|
visit article.path.to_s
|
|
|
|
wait_for_javascript
|
|
|
|
fill_in "text-area", with: raw_comment
|
|
click_button("PREVIEW")
|
|
expect(page).to have_text(raw_comment)
|
|
expect(page).to have_text("MARKDOWN")
|
|
click_button("MARKDOWN")
|
|
expect(page).to have_text("PREVIEW")
|
|
click_button("SUBMIT")
|
|
expect(page).to have_text(raw_comment)
|
|
end
|
|
|
|
it "User replies to a comment" do
|
|
create(:comment, commentable: article, user_id: user.id)
|
|
visit article.path.to_s
|
|
|
|
wait_for_javascript
|
|
|
|
find(".toggle-reply-form").click
|
|
find(:xpath, "//div[@class='actions']/form[@class='new_comment']/textarea").set(raw_comment)
|
|
find(:xpath, "//div[contains(@class, 'reply-actions')]/input[@name='commit']").click
|
|
expect(page).to have_text(raw_comment)
|
|
end
|
|
end
|