Merge pull request #38 from micmania1/36-unused-variable

BUG Unused variable put to use. Doesn't show future posts on live stage
This commit is contained in:
Michael Strong 2014-11-13 23:09:52 +13:00
commit 43ae8bf19c
2 changed files with 27 additions and 32 deletions

View File

@ -15,15 +15,10 @@ class BlogPostFilter extends DataExtension {
* Augment queries so that we don't fetch unpublished articles. * Augment queries so that we don't fetch unpublished articles.
**/ **/
public function augmentSQL(SQLQuery &$query) { public function augmentSQL(SQLQuery &$query) {
if(!Permission::check("VIEW_DRAFT_CONTENT")) {
$stage = Versioned::current_stage(); $stage = Versioned::current_stage();
if($stage == "Stage") $stage = ""; if($stage == 'Live' || !Permission::check("VIEW_DRAFT_CONTENT")) {
else $stage = "_" . Convert::raw2sql($stage);
$query->addWhere("PublishDate < '" . Convert::raw2sql(SS_Datetime::now()) . "'"); $query->addWhere("PublishDate < '" . Convert::raw2sql(SS_Datetime::now()) . "'");
} }
} }
/** /**

View File

@ -58,37 +58,37 @@ class BlogTest extends SapphireTest {
$response = Director::test($archiveLink); $response = Director::test($archiveLink);
$this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200"); $this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
// $archiveLink = Controller::join_links($blog->Link("archive"), 2013, 10); $archiveLink = Controller::join_links($blog->Link("archive"), 2013, 10);
// $response = Director::test($archiveLink); $response = Director::test($archiveLink);
// $this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200"); $this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
// $archiveLink = Controller::join_links($blog->Link("archive"), 2013); $archiveLink = Controller::join_links($blog->Link("archive"), 2013);
// $response = Director::test($archiveLink); $response = Director::test($archiveLink);
// $this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200"); $this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
// $archiveLink = Controller::join_links($blog->Link("archive"), 2011, 10, 01); $archiveLink = Controller::join_links($blog->Link("archive"), 2011, 10, 01);
// $response = Director::test($archiveLink); // No posts on this date, but a valid entry. $response = Director::test($archiveLink); // No posts on this date, but a valid entry.
// $this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200"); $this->assertEquals(200, $response->getStatusCode(), "HTTP Status should be 200");
// // Test invalid links & dates // Test invalid links & dates
// $response = Director::test($blog->Link("archive")); // 404 when no date is set $response = Director::test($blog->Link("archive")); // 404 when no date is set
// $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404"); $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
// // Invalid year // Invalid year
// $archiveLink = Controller::join_links($blog->Link("archive"), "invalid-year"); $archiveLink = Controller::join_links($blog->Link("archive"), "invalid-year");
// $response = Director::test($archiveLink); // 404 when an invalid yer is set $response = Director::test($archiveLink); // 404 when an invalid yer is set
// $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404"); $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
// // Invalid month // Invalid month
// $archiveLink = Controller::join_links($blog->Link("archive"), "2013", "99"); $archiveLink = Controller::join_links($blog->Link("archive"), "2013", "99");
// $response = Director::test($archiveLink); // 404 when an invalid month is set $response = Director::test($archiveLink); // 404 when an invalid month is set
// $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404"); $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
// // Invalid day // Invalid day
// $archiveLink = Controller::join_links($blog->Link("archive"), "2013", "10", "99"); $archiveLink = Controller::join_links($blog->Link("archive"), "2013", "10", "99");
// $response = Director::test($archiveLink); // 404 when an invalid day is set $response = Director::test($archiveLink); // 404 when an invalid day is set
// $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404"); $this->assertEquals(404, $response->getStatusCode(), "HTTP Status should be 404");
} }