Skip to content

Commit

Permalink
FIX Title bug due to silverstripe#320
Browse files Browse the repository at this point in the history
  • Loading branch information
camfindlay committed Nov 9, 2015
1 parent 01091ee commit 12674ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion code/model/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ public function getArchiveYear() {
if(preg_match('/^[0-9]{4}$/', $year = $this->request->param('Year'))) {
return (int) $year;
}
} else {
} elseif($this->request->param('Action') == 'archive') {
return SS_Datetime::now()->Year();
}

Expand Down
11 changes: 10 additions & 1 deletion tests/BlogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ public function testArchiveLinks() {

$link = Controller::join_links($blog->Link('archive'));
$this->assertEquals(200, $this->getStatusOf($link), 'HTTP Status should be 200');
$this->assertEquals('2013', ModelAsController::controller_for($blog)->getArchiveYear(), 'Defaults to current year');

$link = Controller::join_links($blog->Link('archive'), 'invalid-year');

Expand All @@ -126,6 +125,16 @@ public function testArchiveLinks() {

}

/*
* Test archive year
*/
public function testArchiveYear(){
$blog = $this->objFromFixture('Blog', 'FirstBlog');
$controller = new Blog_Controller($blog);
$this->requestURL($controller, 'first-post/archive/');
$this->assertEquals(2013, $controller->getArchiveYear(), 'getArchiveYear should return 2013');
}

/**
* @param string $link
*
Expand Down

0 comments on commit 12674ed

Please sign in to comment.