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

Allow developer to get controller to show lock. #349

Merged
merged 1 commit into from
Nov 28, 2016
Merged
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
14 changes: 10 additions & 4 deletions Lock/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ class Router: Navigable {
}
}
self.onAuthentication = { [weak controller] credentials in
Queue.main.async {
controller?.presentingViewController?.dismiss(animated: true, completion: { _ in
lock.callback(.success(credentials))
})
let closure: () -> ()
if let presentingController = controller?.presentingViewController {
closure = {
presentingController.dismiss(animated: true, completion: { _ in
lock.callback(.success(credentials))
})
}
} else {
closure = { lock.callback(.success(credentials)) }
}
Queue.main.async(closure)
}

self.onBack = {
Expand Down
14 changes: 14 additions & 0 deletions LockTests/Router/RouterSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ class RouterSpec: QuickSpec {
}
}

it("should call callback with auth result when lock was displayed without present") {
controller.presenting = nil
let credentials = Credentials(accessToken: "ACCESS_TOKEN", tokenType: "bearer")
waitUntil(timeout: 2) { done in
lock.callback = { result in
if case .success(let actual) = result {
expect(actual) == credentials
done()
}
}
router.onAuthentication(credentials)
}
}

describe("back") {

beforeEach {
Expand Down