Skip to content

Commit

Permalink
Save Team when resuming from HandoffService
Browse files Browse the repository at this point in the history
[app_store]
  • Loading branch information
ZachOrr committed Feb 26, 2020
1 parent 3a85039 commit 82685ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tba-unit-tests/Services/HandoffServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class HandoffServiceTests: TBATestCase {
// Make sure Event was inserted
let event = Event.findOrFetch(in: persistentContainer.viewContext, matching: Event.predicate(key: eventKey))!
XCTAssertEqual(event.key, eventKey)
XCTAssertFalse(event.objectID.isTemporaryID)

let teams = Team.fetch(in: persistentContainer.viewContext)
XCTAssertEqual(teams.count, 0)
Expand Down Expand Up @@ -148,6 +149,7 @@ class HandoffServiceTests: TBATestCase {
// Make sure Team was inserted
let team = Team.findOrFetch(in: persistentContainer.viewContext, matching: Team.predicate(key: teamKey))!
XCTAssertEqual(team.key, teamKey)
XCTAssertFalse(team.objectID.isTemporaryID)

let events = Event.fetch(in: persistentContainer.viewContext)
XCTAssertEqual(events.count, 0)
Expand Down
1 change: 1 addition & 0 deletions the-blue-alliance-ios/Services/HandoffService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class HandoffService {
// If the Team doesn't exist, but our key matches what we consider a "safe" regex, insert the Team and push
if team == nil, let teamKeyRegex = teamKeyRegex, teamKeyRegex.numberOfMatches(in: key, options: [], range: NSRange(location: 0, length: key.count)) == 1 {
team = Team.insert(key, in: persistentContainer.viewContext)
persistentContainer.viewContext.saveOrRollback(errorRecorder: Crashlytics.sharedInstance())
}
guard let uri = team?.objectID.uriRepresentation() else {
return false
Expand Down

0 comments on commit 82685ac

Please sign in to comment.