Skip to content

Fixes #3464, App posts deletion request notifications ({{subst:idw}}) on the wrong user's talk page #3495

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

Merged
merged 9 commits into from
Mar 17, 2020
Prev Previous commit
Next Next commit
Fixed DeleteHelper tests and null-pointer exception
  • Loading branch information
VitalyVPinchuk committed Mar 11, 2020
commit 23245a8f34b1575c3a8f5a2d2491f7d27c38a1a7
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ private Observable<Boolean> delete(Media media, String reason) {
String userPageString = "\n{{subst:idw|" + media.getFilename() +
"}} ~~~~";

String creator = media.getCreator().replace(" (page does not exist)", "");
String creator = media.getCreator();
String creatorName = creator == null ? null : creator.replace(" (page does not exist)", "");

return pageEditClient.prependEdit(media.filename, fileDeleteString + "\n", summary)
.flatMap(result -> {
Expand All @@ -113,7 +114,7 @@ private Observable<Boolean> delete(Media media, String reason) {
throw new RuntimeException("Failed to nominate for deletion");
}).flatMap(result -> {
if (result) {
return pageEditClient.appendEdit("User_Talk:" + creator, userPageString + "\n", summary);
return pageEditClient.appendEdit("User_Talk:" + creatorName, userPageString + "\n", summary);
}
throw new RuntimeException("Failed to nominate for deletion");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class DeleteHelperTest {
.thenReturn(Observable.just(true))

`when`(media?.displayTitle).thenReturn("Test file")
`when`(media?.getCreator()).thenReturn("Creator (page does not exist)")
media?.filename="Test file.jpg"
media?.creator="Creator (page does not exist)"

val makeDeletion = deleteHelper?.makeDeletion(context, media, "Test reason")?.blockingGet()
assertNotNull(makeDeletion)
Expand All @@ -84,6 +84,7 @@ class DeleteHelperTest {
.thenReturn(Observable.just(true))
`when`(media?.displayTitle).thenReturn("Test file")
`when`(media?.filename).thenReturn("Test file.jpg")
`when`(media?.creator).thenReturn("Creator (page does not exist)")

deleteHelper?.makeDeletion(context, media, "Test reason")?.blockingGet()
}
Expand All @@ -98,6 +99,7 @@ class DeleteHelperTest {
.thenReturn(Observable.just(false))
`when`(media?.displayTitle).thenReturn("Test file")
`when`(media?.filename).thenReturn("Test file.jpg")
`when`(media?.creator).thenReturn("Creator (page does not exist)")

deleteHelper?.makeDeletion(context, media, "Test reason")?.blockingGet()
}
Expand All @@ -112,6 +114,7 @@ class DeleteHelperTest {
.thenReturn(Observable.just(true))
`when`(media?.displayTitle).thenReturn("Test file")
`when`(media?.filename).thenReturn("Test file.jpg")
`when`(media?.creator).thenReturn("Creator (page does not exist)")

deleteHelper?.makeDeletion(context, media, "Test reason")?.blockingGet()
}
Expand Down