Skip to content

Commit

Permalink
Update config when the session starts and ends (#822)
Browse files Browse the repository at this point in the history
  • Loading branch information
dusi committed Aug 29, 2019
1 parent 388942f commit 27c71eb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Kickstarter-iOS/ViewModels/AppDelegateViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi

self.updateConfigInEnvironment = Signal.merge([
self.applicationWillEnterForegroundProperty.signal,
self.applicationLaunchOptionsProperty.signal.ignoreValues()
self.applicationLaunchOptionsProperty.signal.ignoreValues(),
self.userSessionEndedProperty.signal,
self.userSessionStartedProperty.signal
])
.switchMap { AppEnvironment.current.apiService.fetchConfig().demoteErrors() }

Expand Down
12 changes: 12 additions & 0 deletions Kickstarter-iOS/ViewModels/AppDelegateViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,18 @@ final class AppDelegateViewModelTests: TestCase {
self.vm.inputs.applicationWillEnterForeground()
self.updateConfigInEnvironment.assertValues([config1, config2])
}

let config3 = Config.template |> Config.lens.countryCode .~ "CZ"
withEnvironment(apiService: MockService(fetchConfigResponse: config3)) {
self.vm.inputs.userSessionEnded()
self.updateConfigInEnvironment.assertValues([config1, config2, config3])
}

let config4 = Config.template |> Config.lens.countryCode .~ "CA"
withEnvironment(apiService: MockService(fetchConfigResponse: config4)) {
self.vm.inputs.userSessionStarted()
self.updateConfigInEnvironment.assertValues([config1, config2, config3, config4])
}
}

func testPresentViewController() {
Expand Down

0 comments on commit 27c71eb

Please sign in to comment.