File tree Expand file tree Collapse file tree
Modules/Sources/WordPressKitObjC
Tests/WordPressKitTests/WordPressKitTests/Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44#import " RemotePostTerm.h"
55#import " FilePart.h"
66#import " NSString+Helpers.h"
7+ #import " NSString+WPKitNumericValueHack.h"
78
89@import WordPressShared;
910@import WordPressKitModels;
@@ -396,7 +397,8 @@ - (RemotePost *)remotePostFromJSONDictionary:(NSDictionary *)jsonPost {
396397+ (RemotePost *)remotePostFromJSONDictionary : (NSDictionary *)jsonPost {
397398 RemotePost *post = [RemotePost new ];
398399 post.postID = jsonPost[@" ID" ];
399- post.siteID = jsonPost[@" site_ID" ];
400+ // Create and update responses return site_ID as a string, while read responses return a number.
401+ post.siteID = [jsonPost[@" site_ID" ] wpkit_numericValue ];
400402 if (jsonPost[@" author" ] != [NSNull null ]) {
401403 NSDictionary *authorDictionary = jsonPost[@" author" ];
402404 post.authorAvatarURL = authorDictionary[@" avatar_URL" ];
Original file line number Diff line number Diff line change 66* [*] [internal] Stats widgets: migrate the site picker from SiriKit to App Intents [#25753]
77* [*] Fix Blogging Reminders text color in dark mode [#25780]
88* [*] Share extensions: Fix the site picker showing an error while sites are still loading [#25798]
9+ * [*] Share Extension: Fix a crash after uploading a post to WordPress.com [#25773]
910
101127.0
1112-----
Original file line number Diff line number Diff line change @@ -26,6 +26,36 @@ - (PostServiceRemoteREST*)service
2626 return [[PostServiceRemoteREST alloc ] initWithWordPressComRestApi: api siteID: siteID];
2727}
2828
29+ #pragma mark - Mapping posts
30+
31+ - (void )testThatRemotePostMappingConvertsStringSiteIDToNumber
32+ {
33+ NSDictionary *jsonPost = @{
34+ @" ID" : @1147 ,
35+ @" site_ID" : @" 237072388"
36+ };
37+
38+ RemotePost *post = [PostServiceRemoteREST remotePostFromJSONDictionary: jsonPost];
39+
40+ XCTAssertEqualObjects (post.postID , @1147 );
41+ XCTAssertEqualObjects (post.siteID , @237072388 );
42+ XCTAssertTrue ([post.siteID isKindOfClass: [NSNumber class ]]);
43+ }
44+
45+ - (void )testThatRemotePostMappingPreservesNumericSiteID
46+ {
47+ NSDictionary *jsonPost = @{
48+ @" ID" : @1147 ,
49+ @" site_ID" : @237072388
50+ };
51+
52+ RemotePost *post = [PostServiceRemoteREST remotePostFromJSONDictionary: jsonPost];
53+
54+ XCTAssertEqualObjects (post.postID , @1147 );
55+ XCTAssertEqualObjects (post.siteID , @237072388 );
56+ XCTAssertTrue ([post.siteID isKindOfClass: [NSNumber class ]]);
57+ }
58+
2959#pragma mark - Getting posts by ID
3060
3161- (void )testThatGetPostWithIDWorks
You can’t perform that action at this time.
0 commit comments