Skip to content
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

fix: Parse.server doesn't return server url #1821

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Parse/Parse/Source/Parse.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ + (void)initializeWithConfigurationAllowingReinitialize:(ParseClientConfiguratio
[manager startManaging];

currentParseManager_ = manager;
currentParseConfiguration_ = configuration;

#if TARGET_OS_IOS
[PFNetworkActivityIndicatorManager sharedManager].enabled = YES;
Expand Down Expand Up @@ -135,7 +136,7 @@ + (nullable NSString *)getClientKey {
+ (nullable NSString *)server {
ParseClientConfiguration *config = currentParseManager_ ? currentParseManager_.configuration
: currentParseConfiguration_;
return currentParseManager_.configuration.server;
return config.server;
}

///--------------------------------------
Expand Down
23 changes: 23 additions & 0 deletions Parse/Tests/Unit/ParseClientConfigurationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
@import Foundation;

#import "PFTestCase.h"
#import "Parse_Private.h"
#import "ParseClientConfiguration.h"
#import "ParseClientConfiguration_Private.h"
#import "PFExtensionDataSharingTestHelper.h"
Expand Down Expand Up @@ -145,4 +146,26 @@ - (void)testServerValidation {
}];
}

- (void)testSetServerURL {
ParseClientConfiguration *config = [ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> 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
Loading