diff --git a/features/comments_and_kudos/add_comment.feature b/features/comments_and_kudos/add_comment.feature index 22eb9f46dc3..0ca9036013a 100644 --- a/features/comments_and_kudos/add_comment.feature +++ b/features/comments_and_kudos/add_comment.feature @@ -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" @@ -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" diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 784dc97d8b5..ef8179107a1 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -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 @@ -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 @@ -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)) }