FIX Title bug due to #320

This commit is contained in:
Cam Findlay 2015-11-10 09:14:28 +13:00
parent 01091ee20b
commit 12674edb87
2 changed files with 11 additions and 2 deletions

View File

@ -736,7 +736,7 @@ class Blog_Controller extends Page_Controller {
if(preg_match('/^[0-9]{4}$/', $year = $this->request->param('Year'))) { if(preg_match('/^[0-9]{4}$/', $year = $this->request->param('Year'))) {
return (int) $year; return (int) $year;
} }
} else { } elseif($this->request->param('Action') == 'archive') {
return SS_Datetime::now()->Year(); return SS_Datetime::now()->Year();
} }

View File

@ -110,7 +110,6 @@ class BlogTest extends SapphireTest {
$link = Controller::join_links($blog->Link('archive')); $link = Controller::join_links($blog->Link('archive'));
$this->assertEquals(200, $this->getStatusOf($link), 'HTTP Status should be 200'); $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'); $link = Controller::join_links($blog->Link('archive'), 'invalid-year');
@ -126,6 +125,16 @@ class BlogTest extends SapphireTest {
} }
/*
* 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 * @param string $link
* *