Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-5860 Update tests for error message when commenting as admin #4813

Merged
merged 5 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions features/comments_and_kudos/add_comment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Scenario: Users with different time zone preferences should see the time in thei

Scenario: Cannot comment (no form) while logged as admin

Given the work "Generic Work"
Given the work "Generic Work" by "creator" with guest comments enabled
And I am logged in as an admin
And I view the work "Generic Work"
Then I should see "Generic Work"
Expand All @@ -237,7 +237,7 @@ Scenario: Cannot comment (no form) while logged as admin

Scenario: Cannot reply to comments (no button) while logged as admin

Given the work "Generic Work"
Given the work "Generic Work" by "creator" with guest comments enabled
When I am logged in as "commenter"
And I view the work "Generic Work"
And I post a comment "Woohoo"
Expand Down
20 changes: 10 additions & 10 deletions spec/controllers/comments_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@
expect(flash[:error]).to be_nil
it_redirects_to(chapter_path(comment.commentable, show_comments: true, anchor: "comment_#{comment.id}"))
end

context "when logged in as an admin" do
before { fake_login_admin(create(:admin)) }

it "redirects to root with notice prompting log out" do
get :add_comment_reply, params: { comment_id: comment.id }
it_redirects_to_with_notice(root_path, "Please log out of your admin account first!")
end
end
end

context "guest comments are turned off in admin settings" do
Expand Down Expand Up @@ -174,15 +183,6 @@
it_redirects_to_with_error(work_path(work), "Sorry, this work doesn't allow comments.")
end
end

context "when logged in as an admin" do
before { fake_login_admin(create(:admin)) }

it "redirects to root with notice prompting log out" do
get :add_comment_reply, params: { comment_id: comment.id }
it_redirects_to_with_notice(root_path, "Please log out of your admin account first!")
end
end
end

shared_examples "guest cannot reply to a user with guest replies disabled" do
Expand Down Expand Up @@ -641,7 +641,7 @@
end

context "when logged in as an admin" do
let(:work) { create(:work) }
let(:work) { create(:work, :guest_comments_on) }

before { fake_login_admin(create(:admin)) }

Expand Down
Loading