* Create DiscussionLocks
* Fix specs
* Update nullify_blank_notes_and_reason
* Update before_validation call
* Updated DiscussionLockPolicy for clarity
* Move permitted_attributes to a constant
* Update route
* Apply suggestions from code review for frontend
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
* Add title tags
* Wrap unlock confirm in main element
* Wrap flash messages up in div
* Actually fix title tags
* Hide comment reply button when discussion is locked
* Add E2E tests
* Try to fix E2E tests
* Cypress...you work locally but not in CI...why!?
* PR feedback
* Update E2E tests
* More E2E updates 😭
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
61 lines
1.8 KiB
Ruby
61 lines
1.8 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "User discussion locks", type: :system, js: true do
|
|
let(:user) { create(:user) }
|
|
let(:article) { create(:article, user: user) }
|
|
let(:discussion_lock) { create(:discussion_lock, article: article, locking_user: user) }
|
|
|
|
before do
|
|
article
|
|
sign_in user
|
|
end
|
|
|
|
context "when an Article does not have a discussion lock" do
|
|
it "shows the discussion lock button in manage" do
|
|
visit dashboard_path
|
|
click_on "Manage"
|
|
|
|
within "div.dashboard-actions" do
|
|
expect(page).to have_link("Lock discussion", href: "#{article.path}/discussion_lock_confirm")
|
|
end
|
|
end
|
|
|
|
it "doesn't show a DiscussionLock on the Article" do
|
|
visit article.path
|
|
expect(page).not_to have_selector("#discussion-lock")
|
|
end
|
|
|
|
it "doesn't hide new comment box on the Article" do
|
|
visit article.path
|
|
expect(page).to have_selector("#new_comment")
|
|
end
|
|
end
|
|
|
|
context "when an Article has a discussion lock" do
|
|
before { discussion_lock }
|
|
|
|
it "shows the unlock discussion lock button in manage" do
|
|
visit dashboard_path
|
|
click_on "Manage"
|
|
|
|
within "div.dashboard-actions" do
|
|
expect(page).to have_link("Unlock discussion", href: "#{article.path}/discussion_unlock_confirm")
|
|
end
|
|
end
|
|
|
|
it "shows a DiscussionLock on the Article" do
|
|
visit article.path
|
|
expect(page).to have_selector("#discussion-lock")
|
|
|
|
within "#discussion-lock" do
|
|
expect(page).to have_text("The discussion has been locked. New comments can't be added.")
|
|
expect(page).to have_text(discussion_lock.reason)
|
|
end
|
|
end
|
|
|
|
it "hides new comment box on the Article" do
|
|
visit article.path
|
|
expect(page).not_to have_selector("#new_comment")
|
|
end
|
|
end
|
|
end
|