diff --git a/Parse/Parse/Source/Parse.m b/Parse/Parse/Source/Parse.m index f00c1eed1..d324ea602 100644 --- a/Parse/Parse/Source/Parse.m +++ b/Parse/Parse/Source/Parse.m @@ -84,6 +84,7 @@ + (void)initializeWithConfigurationAllowingReinitialize:(ParseClientConfiguratio [manager startManaging]; currentParseManager_ = manager; + currentParseConfiguration_ = configuration; #if TARGET_OS_IOS [PFNetworkActivityIndicatorManager sharedManager].enabled = YES; @@ -135,7 +136,7 @@ + (nullable NSString *)getClientKey { + (nullable NSString *)server { ParseClientConfiguration *config = currentParseManager_ ? currentParseManager_.configuration : currentParseConfiguration_; - return currentParseManager_.configuration.server; + return config.server; } ///-------------------------------------- diff --git a/Parse/Tests/Unit/ParseClientConfigurationTests.m b/Parse/Tests/Unit/ParseClientConfigurationTests.m index a76d7d8be..c614ca175 100644 --- a/Parse/Tests/Unit/ParseClientConfigurationTests.m +++ b/Parse/Tests/Unit/ParseClientConfigurationTests.m @@ -10,6 +10,7 @@ @import Foundation; #import "PFTestCase.h" +#import "Parse_Private.h" #import "ParseClientConfiguration.h" #import "ParseClientConfiguration_Private.h" #import "PFExtensionDataSharingTestHelper.h" @@ -145,4 +146,26 @@ - (void)testServerValidation { }]; } +- (void)testSetServerURL { + ParseClientConfiguration *config = [ParseClientConfiguration configurationWithBlock:^(id configuration) { + configuration.applicationId = @"foo"; + configuration.clientKey = @"bar"; + configuration.server = @"http://localhost"; + configuration.localDatastoreEnabled = YES; + configuration.networkRetryAttempts = 1337; + }]; + + [Parse initializeWithConfiguration:config]; + + XCTAssertEqualObjects(config.server, @"http://localhost"); + XCTAssertEqualObjects(config.server, [Parse server]); + + [Parse setServer:@"http://example.org"]; + XCTAssertEqualObjects([Parse server], @"http://example.org"); + + // Should get server from current config instead of manager + [Parse _clearCurrentManager]; + XCTAssertEqualObjects([Parse server], @"http://example.org"); +} + @end