Skip to content

Commit 06569b9

Browse files
authored
Rename CommentStatus::Approve to CommentStatus::Approved (#736)
* Add test cases to verify CommentStatus * Rename CommentStatus::Approve to CommentStatus::Approved
1 parent 64b01cd commit 06569b9

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

scripts/setup-test-site.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ wp user create test_author [email protected] --role=author
7878
# This is used in `/posts` integration tests that updates the `template` field
7979
wp theme activate twentytwentyfour
8080

81+
wp comment trash 22
82+
wp comment spam 23
83+
8184
create_test_credentials () {
8285
local SITE_URL
8386
local ADMIN_USERNAME

wp_api/src/comments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ pub enum CommentAuthorAvatarUrlSize {
569569
pub enum CommentStatus {
570570
Hold,
571571
#[default]
572-
Approve,
572+
Approved,
573573
Spam,
574574
Trash,
575575
#[serde(untagged)]
@@ -640,7 +640,7 @@ mod tests {
640640
#[case(generate!(CommentListParams, (parent_exclude, vec![CommentId(55555), CommentId(55556)])), "parent_exclude=55555%2C55556")]
641641
#[case(generate!(CommentListParams, (post, vec![PostId(66666), PostId(66667)])), "post=66666%2C66667")]
642642
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Hold))), "status=hold")]
643-
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Approve))), "status=approve")]
643+
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Approved))), "status=approved")]
644644
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Spam))), "status=spam")]
645645
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Trash))), "status=trash")]
646646
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Custom("foo".to_string())))), "status=foo")]

wp_api/src/request/endpoint/comments_endpoint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ mod tests {
108108
#[case(generate!(CommentListParams, (parent_exclude, vec![CommentId(55555), CommentId(55556)])), "parent_exclude=55555%2C55556")]
109109
#[case(generate!(CommentListParams, (post, vec![PostId(66666), PostId(66667)])), "post=66666%2C66667")]
110110
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Hold))), "status=hold")]
111-
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Approve))), "status=approve")]
111+
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Approved))), "status=approved")]
112112
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Spam))), "status=spam")]
113113
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Trash))), "status=trash")]
114114
#[case(generate!(CommentListParams, (status, Some(CommentStatus::Custom("foo".to_string())))), "status=foo")]

wp_api_integration_tests/tests/test_comments_err.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ async fn create_err_comment_invalid_post_id() {
187187
#[parallel]
188188
async fn create_err_comment_invalid_status(
189189
#[values(
190-
CommentStatus::Approve,
190+
CommentStatus::Approved,
191191
CommentStatus::Hold,
192192
CommentStatus::Spam,
193193
CommentStatus::Trash

wp_api_integration_tests/tests/test_comments_immut.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ async fn list_comments_with_edit_context_parse_author_avatar_urls(
232232
#[case::parent_exclude(generate!(CommentListParams, (parent, vec![CommentId(1), CommentId(2)])))]
233233
#[case::post(generate!(CommentListParams, (post, vec![PostId(1), PostId(2)])))]
234234
#[case::status_hold(generate!(CommentListParams, (status, Some(CommentStatus::Hold))))]
235-
#[case::status_approve(generate!(CommentListParams, (status, Some(CommentStatus::Approve))))]
235+
#[case::status_approve(generate!(CommentListParams, (status, Some(CommentStatus::Approved))))]
236236
#[case::status_spam(generate!(CommentListParams, (status, Some(CommentStatus::Spam))))]
237237
#[case::status_trash(generate!(CommentListParams, (status, Some(CommentStatus::Trash))))]
238238
#[case::comment_type_comment(generate!(CommentListParams, (comment_type, Some(CommentType::Comment))))]
@@ -382,4 +382,21 @@ mod filter {
382382
.data;
383383
comment.assert_that_instance_fields_nullability_match_provided_fields(fields)
384384
}
385+
386+
#[rstest]
387+
#[case(1, CommentStatus::Approved)]
388+
#[case(6, CommentStatus::Hold)]
389+
#[case(22, CommentStatus::Trash)]
390+
#[case(23, CommentStatus::Spam)]
391+
#[tokio::test]
392+
#[parallel]
393+
async fn parse_status(#[case] id: i64, #[case] status: CommentStatus) {
394+
let comment = api_client()
395+
.comments()
396+
.retrieve_with_edit_context(&CommentId(id), &CommentRetrieveParams::default())
397+
.await
398+
.assert_response()
399+
.data;
400+
assert_eq!(comment.status, status);
401+
}
385402
}

0 commit comments

Comments
 (0)