File tree Expand file tree Collapse file tree 3 files changed +14
-19
lines changed
Expand file tree Collapse file tree 3 files changed +14
-19
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ import Plot
1818enum BlogController {
1919
2020 static func index( req: Request ) async throws -> HTML {
21- BlogActions . Index. View ( path: req. url. path, model: BlogActions . Model ( ) ) . document ( )
21+ BlogActions . Index. View ( path: req. url. path, model: try BlogActions . Model ( ) ) . document ( )
2222 }
2323
2424 static func indexFeed( req: Request ) async throws -> RSS {
25- let model = BlogActions . Model ( )
25+ let model = try BlogActions . Model ( )
2626 let items = model. summaries. map { summary -> Node < RSS . ChannelContext > in
2727 . item(
2828 . guid(
@@ -58,7 +58,7 @@ enum BlogController {
5858 guard let slug = req. parameters. get ( " slug " )
5959 else { throw Abort ( . notFound) }
6060
61- let model = BlogActions . Model ( )
61+ let model = try BlogActions . Model ( )
6262 if let summary = model. summaries. first ( where: { $0. slug == slug } ) {
6363 return BlogActions . Show. View ( path: req. url. path,
6464 model: summary) . document ( )
Original file line number Diff line number Diff line change @@ -35,20 +35,15 @@ enum BlogActions {
3535
3636 var summaries : [ PostSummary ]
3737
38- init ( ) {
39- do {
40- let allSummaries = try Self . allSummaries ( )
41-
42- summaries = if Current . environment ( ) == . production {
43- // Only "published" posts show in production.
44- allSummaries. filter { $0. published }
45- } else {
46- // Show *everything* in development and on staging.
47- allSummaries
48- }
49- } catch {
50- Current . logger ( ) . report ( error: error)
51- summaries = [ ]
38+ init ( ) throws {
39+ let allSummaries = try Self . allSummaries ( )
40+
41+ summaries = if Current . environment ( ) == . production {
42+ // Only "published" posts show in production.
43+ allSummaries. filter { $0. published }
44+ } else {
45+ // Show *everything* in development and on staging.
46+ allSummaries
5247 }
5348 }
5449
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ class BlogActionsModelTests: AppTestCase {
3838 Current . environment = { . development }
3939
4040 // MUT
41- let summaries = BlogActions . Model ( ) . summaries
41+ let summaries = try BlogActions . Model ( ) . summaries
4242
4343 XCTAssertEqual ( summaries. count, 2 )
4444 XCTAssertEqual ( summaries. map ( \. slug) , [ " post-2 " , " post-1 " ] )
@@ -59,7 +59,7 @@ class BlogActionsModelTests: AppTestCase {
5959 Current . environment = { . production }
6060
6161 // MUT
62- let summaries = BlogActions . Model ( ) . summaries
62+ let summaries = try BlogActions . Model ( ) . summaries
6363
6464 // validate
6565 XCTAssertEqual ( summaries. map ( \. slug) , [ " post-1 " ] )
You can’t perform that action at this time.
0 commit comments