From ad581acc3281b9733317d17bb6b3c86717c8296b Mon Sep 17 00:00:00 2001 From: Amos Chan Date: Sat, 12 Nov 2016 21:52:31 -0500 Subject: [PATCH] Remove redundant convenience initializer --- .../Latest Bulletin/BulletinViewModel.swift | 23 ++++++++----------- .../BulletinViewModelSpec.swift | 2 +- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/FisherHall/Features/Latest Bulletin/BulletinViewModel.swift b/FisherHall/Features/Latest Bulletin/BulletinViewModel.swift index 2b77ae8..b57a8ef 100644 --- a/FisherHall/Features/Latest Bulletin/BulletinViewModel.swift +++ b/FisherHall/Features/Latest Bulletin/BulletinViewModel.swift @@ -6,21 +6,11 @@ class BulletinViewModel { let bannerURLString: String var serviceOrder: String - convenience init(name: String, publishedAt: NSDate, bannerURL: String? = nil, serviceOrder: String? = nil) { - let bannerOrDefault = bannerURL ?? "https://s3.amazonaws.com/mcac/app/assets/images/theme-1920-6099a636f0f320b6d38b157909e64be6.jpg" - self.init( - name: name, - publishedAt: publishedAt, - bannerURL: bannerOrDefault, - serviceOrder: serviceOrder ?? "" - ) - } - - init(name: String, publishedAt: NSDate, bannerURL: String, serviceOrder: String) { + init(name: String, publishedAt: NSDate, bannerURL: String? = nil, serviceOrder: String? = nil) { self.name = name self.publishedAt = publishedAt - self.bannerURLString = bannerURL - self.serviceOrder = serviceOrder + bannerURLString = bannerURL ?? "https://s3.amazonaws.com/mcac/app/assets/images/theme-1920-6099a636f0f320b6d38b157909e64be6.jpg" + self.serviceOrder = serviceOrder ?? "" } public static func fromResource(resource: BulletinResource) -> BulletinViewModel? { @@ -28,7 +18,12 @@ class BulletinViewModel { return nil } - return BulletinViewModel(name: name, publishedAt: publishedAt, bannerURL: resource.bannerUrl?.absoluteString, serviceOrder: resource.serviceOrder) + return BulletinViewModel( + name: name, + publishedAt: publishedAt, + bannerURL: resource.bannerUrl?.absoluteString, + serviceOrder: resource.serviceOrder + ) } public func bannerURL() -> URL? { diff --git a/FisherHallTests/Features/Latest Bulletin/BulletinViewModelSpec.swift b/FisherHallTests/Features/Latest Bulletin/BulletinViewModelSpec.swift index 363a7a0..72c18f0 100644 --- a/FisherHallTests/Features/Latest Bulletin/BulletinViewModelSpec.swift +++ b/FisherHallTests/Features/Latest Bulletin/BulletinViewModelSpec.swift @@ -6,7 +6,7 @@ import Nimble class BulletinViewModelSpec: QuickSpec { override func spec() { - fdescribe("fromResource") { + describe("fromResource") { context("when resource doesn't contain required fields") { var subject: BulletinViewModel!