Skip to content

Commit 682d41c

Browse files
authored
AO3-7022 Default to only registered commentors on news post (otwcode#5247)
* AO3-7022 Default to only registered commentors on news post * Fix tests * Extend test to verify new default
1 parent b33ac6e commit 682d41c

File tree

6 files changed

+15
-30
lines changed

6 files changed

+15
-30
lines changed

app/models/admin_post.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class AdminPost < ApplicationRecord
66
enable_all: 0,
77
disable_anon: 1,
88
disable_all: 2
9-
}, _suffix: :comments
9+
}, _default: :disable_anon, _suffix: :comments
1010

1111
belongs_to :language
1212
belongs_to :translated_post, class_name: "AdminPost"

factories/comments.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
end
1414

1515
trait :on_admin_post do
16-
commentable { create(:admin_post) }
16+
commentable { create(:admin_post, comment_permissions: :enable_all) }
1717
end
1818

1919
trait :on_tag do

features/admins/admin_post_news.feature

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,6 @@ Feature: Admin Actions to Post News
3737
Then 0 emails should be delivered to "testadmin-communications@example.org"
3838
But 1 email should be delivered to "admin@example.org"
3939

40-
Scenario: Evil user can impersonate admin in comments
41-
# However, they can't use an icon, so the admin's icon is the guarantee that they're real
42-
# also their username will be plain text and not a link
43-
44-
Given I have posted an admin post
45-
When I am logged in as "happyuser"
46-
And I go to the admin-posts page
47-
When I follow "Default Admin Post"
48-
And I fill in "Comment" with "Excellent, my dear!"
49-
And I press "Comment"
50-
When I log out
51-
And I go to the admin-posts page
52-
And I follow "Default Admin Post"
53-
And I fill in "Comment" with "Behold, ye mighty, and despair!"
54-
And I fill in "Guest name" with "admin"
55-
And I fill in "Guest email" with "admin@example.com"
56-
And I press "Comment"
57-
Then I should see "Comment created!"
58-
And I should see "admin"
59-
And I should see "Behold, ye mighty, and despair!"
60-
6140
Scenario: User views RSS of admin posts
6241

6342
Given I have posted an admin post
@@ -249,6 +228,7 @@ Feature: Admin Actions to Post News
249228
Given I am logged in as a "communications" admin
250229
When I start to make an admin post
251230
And I check "Enable comment moderation"
231+
And I choose "Registered users and guests can comment"
252232
And I press "Post"
253233
Then I should see "Admin Post was successfully created."
254234
And I should not see "Unreviewed Comments"

features/comments_and_kudos/comments_adminposts.feature

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,19 @@ Feature: Commenting on admin posts
117117
Given I have posted an admin post
118118
And basic languages
119119
And I am logged in as a "translation" admin
120-
When I make a translation of an admin post
121-
And I follow "Back to AO3 News Index"
122-
And I follow "Edit"
123-
And I choose "Only registered users can comment"
124-
And I press "Post"
120+
And I make a translation of an admin post
121+
When I follow "Back to AO3 News Index"
122+
And I follow "Show"
125123
Then I should see "Sorry, this news post doesn't allow non-Archive users to comment."
126124
When I follow "Deutsch"
127125
Then I should see "Sorry, this news post doesn't allow non-Archive users to comment."
126+
When I follow "Back to AO3 News Index"
127+
And I follow "Edit"
128+
And I choose "Registered users and guests can comment"
129+
And I press "Post"
130+
Then I should see "Please log out of your admin account to comment."
131+
When I follow "Deutsch"
132+
Then I should see "Please log out of your admin account to comment."
128133

129134
Scenario: Translation of admin post with comments disabled
130135
Given I have posted an admin post with comments disabled

features/step_definitions/admin_steps.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
end
128128

129129
Given "the admin post {string}" do |title|
130-
FactoryBot.create(:admin_post, title: title)
130+
FactoryBot.create(:admin_post, title: title, comment_permissions: :enable_all)
131131
end
132132

133133
Given "the fannish next of kin {string} for the user {string}" do |kin, user|

spec/controllers/comments/default_rails_actions_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
end
1919

2020
it "renders the :new template if commentable is a valid admin post" do
21-
admin_post = create(:admin_post)
21+
admin_post = create(:admin_post, comment_permissions: :enable_all)
2222
get :new, params: { admin_post_id: admin_post.id }
2323
expect(response).to render_template("new")
2424
expect(assigns(:name)).to eq(admin_post.title)

0 commit comments

Comments
 (0)