Skip to content

Commit

Permalink
Fix setPersistedBooleanProperty
Browse files Browse the repository at this point in the history
Summary: WE should update the var in memory in setters. This line was somehow overlooked.

Reviewed By: dreamolight

Differential Revision: D51333425

fbshipit-source-id: cdf8bd5f0d97fe5a2b900c2d1ce0e198c65636c9
  • Loading branch information
Tao Xu authored and facebook-github-bot committed Nov 15, 2023
1 parent fbb6084 commit 5c38779
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ extension Settings {

func setPersistedBooleanProperty(_ property: PersistedBooleanValue, to value: Bool) {
validateConfiguration()
self[keyPath: property.backingKeyPath] = value
// swiftformat:disable:next redundantSelf
self.dataStore?.fb_setObject(value, forKey: property.persistenceKey.rawValue)
logIfSDKSettingsChanged()
Expand Down
14 changes: 14 additions & 0 deletions FBSDKCoreKit/FBSDKCoreKitTests/SettingsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,20 @@ final class SettingsTests: XCTestCase {

// MARK: - Auto Log App Events Enabled

func testAutoLogAppEventsEnabledFromKeyPath() {
configureSettings()
settings.isAutoLogAppEventsEnabled = false
XCTAssertFalse(
settings.isAutoLogAppEventsEnabled,
"Auto logging should pick up the correct value from KeyPath"
)
settings.isAutoLogAppEventsEnabled = true
XCTAssertTrue(
settings.isAutoLogAppEventsEnabled,
"Auto logging should pick up the correct value from KeyPath when value changed"
)
}

func testAutoLogAppEventsEnabledFromPlist() {
bundle = TestBundle(infoDictionary: ["FacebookAutoLogAppEventsEnabled": false])
configureSettings()
Expand Down

0 comments on commit 5c38779

Please sign in to comment.