mirror of
https://github.com/silverstripe/silverstripe-externallinks.git
synced 2024-10-22 17:05:44 +02:00
BUG: Correcting test code and fixing bug with create report button
This commit is contained in:
parent
da7e45ddd4
commit
6bda4dcc82
@ -31,6 +31,21 @@ class CMSExternalLinks_Controller extends Controller {
|
||||
return;
|
||||
}
|
||||
if (class_exists('QueuedJobService')) {
|
||||
$pages = Versioned::get_by_stage('SiteTree', 'Stage');
|
||||
$noPages = count($pages);
|
||||
|
||||
$track = BrokenExternalPageTrackStatus::create();
|
||||
$track->TotalPages = $noPages;
|
||||
$track->Status = 'Running';
|
||||
$track->write();
|
||||
|
||||
foreach ($pages as $page) {
|
||||
$trackPage = BrokenExternalPageTrack::create();
|
||||
$trackPage->PageID = $page->ID;
|
||||
$trackPage->TrackID = $track->ID;
|
||||
$trackPage->write();
|
||||
}
|
||||
|
||||
$checkLinks = new CheckExternalLinksJob();
|
||||
singleton('QueuedJobService')
|
||||
->queueJob($checkLinks, date('Y-m-d H:i:s', time() + 1));
|
||||
|
@ -6,7 +6,7 @@
|
||||
onmatch: function() {
|
||||
// poll the current job and update the front end status
|
||||
$('#externalLinksReport').hide();
|
||||
$(this).poll();
|
||||
$(this).poll(0);
|
||||
},
|
||||
start: function() {
|
||||
// initiate a new job
|
||||
@ -15,9 +15,9 @@
|
||||
$('#ReportHolder').append('<span class="ss-ui-loading-icon"></span>');
|
||||
$('#externalLinksReport').hide();
|
||||
$.ajax({url: "admin/externallinks/start", async: true, timeout: 3000 });
|
||||
$(this).poll();
|
||||
$(this).poll(1);
|
||||
},
|
||||
poll: function() {
|
||||
poll: function(start) {
|
||||
$.ajax({
|
||||
url: "admin/externallinks/getJobStatus",
|
||||
async: true,
|
||||
@ -32,11 +32,11 @@
|
||||
var completed = obj.Completed ? obj.Completed : 0;
|
||||
var total = obj.Total ? obj.Total : 0;
|
||||
var jobStatus = obj.Status ? obj.Status : 'Running';
|
||||
if (jobStatus == 'Completed') {
|
||||
if (jobStatus == 'Completed' && start == 0) {
|
||||
$('#ReportHolder').text('Report Finished ' + completed + '/' + total);
|
||||
$('#externalLinksReport').show();
|
||||
} else {
|
||||
setTimeout(function() { $('#externalLinksReport').poll(); }, 1000);
|
||||
setTimeout(function() { $('#externalLinksReport').poll(0); }, 1000);
|
||||
}
|
||||
if (total && completed) {
|
||||
if (completed < total) {
|
||||
|
@ -7,7 +7,7 @@ class ExternalLinks extends FunctionalTest {
|
||||
public function testLinks() {
|
||||
// uses http://127.0.0.1 to test a working link
|
||||
$working = $this->objFromFixture('SiteTree', 'working');
|
||||
$working->publish('Stage', 'Stage');
|
||||
$working->write();
|
||||
$task = new CheckExternalLinks();
|
||||
$task->run(null);
|
||||
$brokenLinks = BrokenExternalLink::get()->column('Link');;
|
||||
@ -18,7 +18,7 @@ class ExternalLinks extends FunctionalTest {
|
||||
public function testBrokenLink() {
|
||||
// uses http://192.0.2.1 for a broken link
|
||||
$broken = $this->objFromFixture('SiteTree', 'broken');
|
||||
$broken->publish('Stage', 'Stage');
|
||||
$broken->write();
|
||||
$task = new CheckExternalLinks();
|
||||
$task->run(null);
|
||||
$brokenLinks = BrokenExternalLink::get();
|
||||
|
Loading…
Reference in New Issue
Block a user