mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Implement edit functionality for post notices (#11140)
All post notice related custom fields were moved to a single one.
This commit is contained in:
@@ -1914,21 +1914,17 @@ describe PostsController do
|
||||
it 'can create and remove notices as a moderator' do
|
||||
sign_in(moderator)
|
||||
|
||||
put "/posts/#{public_post.id}/notice.json", params: { notice: "Hello *world*!\n\nhttps://github.com/discourse/discourse" }
|
||||
raw_notice = "Hello *world*!\n\nhttps://github.com/discourse/discourse"
|
||||
put "/posts/#{public_post.id}/notice.json", params: { notice: raw_notice }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
public_post.reload
|
||||
expect(public_post.custom_fields[Post::NOTICE_TYPE]).to eq(Post.notices[:custom])
|
||||
expect(public_post.custom_fields[Post::NOTICE_ARGS]).to include('<p>Hello <em>world</em>!</p>')
|
||||
expect(public_post.custom_fields[Post::NOTICE_ARGS]).not_to include('onebox')
|
||||
expect(public_post.reload.custom_fields[Post::NOTICE]).to eq("type" => Post.notices[:custom], "raw" => raw_notice, "cooked" => PrettyText.cook(raw_notice, features: { onebox: false }))
|
||||
expect(UserHistory.where(action: UserHistory.actions[:post_staff_note_create]).count).to eq(1)
|
||||
|
||||
put "/posts/#{public_post.id}/notice.json", params: { notice: nil }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
public_post.reload
|
||||
expect(public_post.custom_fields[Post::NOTICE_TYPE]).to eq(nil)
|
||||
expect(public_post.custom_fields[Post::NOTICE_ARGS]).to eq(nil)
|
||||
expect(public_post.reload.custom_fields[Post::NOTICE]).to eq(nil)
|
||||
expect(UserHistory.where(action: UserHistory.actions[:post_staff_note_destroy]).count).to eq(1)
|
||||
end
|
||||
|
||||
@@ -1945,20 +1941,16 @@ describe PostsController do
|
||||
end
|
||||
|
||||
it 'can create and remove notices as a group moderator' do
|
||||
put "/posts/#{public_post.id}/notice.json", params: { notice: "Hello *world*!\n\nhttps://github.com/discourse/discourse" }
|
||||
raw_notice = "Hello *world*!\n\nhttps://github.com/discourse/discourse"
|
||||
put "/posts/#{public_post.id}/notice.json", params: { notice: raw_notice }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
public_post.reload
|
||||
expect(public_post.custom_fields[Post::NOTICE_TYPE]).to eq(Post.notices[:custom])
|
||||
expect(public_post.custom_fields[Post::NOTICE_ARGS]).to include('<p>Hello <em>world</em>!</p>')
|
||||
expect(public_post.custom_fields[Post::NOTICE_ARGS]).not_to include('onebox')
|
||||
expect(public_post.reload.custom_fields[Post::NOTICE]).to eq("type" => Post.notices[:custom], "raw" => raw_notice, "cooked" => PrettyText.cook(raw_notice, features: { onebox: false }))
|
||||
|
||||
put "/posts/#{public_post.id}/notice.json", params: { notice: nil }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
public_post.reload
|
||||
expect(public_post.custom_fields[Post::NOTICE_TYPE]).to eq(nil)
|
||||
expect(public_post.custom_fields[Post::NOTICE_ARGS]).to eq(nil)
|
||||
expect(public_post.reload.custom_fields[Post::NOTICE]).to eq(nil)
|
||||
end
|
||||
|
||||
it 'prevents a group moderator from altering notes outside of their category' do
|
||||
|
||||
Reference in New Issue
Block a user