Example #1
0
 public function newSnapshot($date, $fields, $sprint = null)
 {
     $snapshot = new SprintSnapshot($fields);
     $snapshot->sprint = $sprint ?: new Sprint(['ignore_estimates' => false, 'title' => 'wat']);
     $snapshot->setCreatedAt($date);
     return $snapshot;
 }
 public function delete(SprintSnapshot $snapshot)
 {
     if ($snapshot->delete()) {
         Flash::success('The snapshot was deleted.');
         return Redirect::route('sprint_path', ['sprint' => $snapshot->sprint->phabricator_id]);
     } else {
         Flash::error('The snapshot could not be deleted. Please try again.');
         return Redirect::back();
     }
 }
Example #3
0
 public function testShouldConsiderCurrentNumberOfStoryPoints()
 {
     $daySeconds = 3600 * 24;
     $dateFormat = 'Y-m-d';
     $currentTime = time();
     $duration = [date($dateFormat, $currentTime - 2 * $daySeconds), date($dateFormat, $currentTime - $daySeconds), date($dateFormat, $currentTime), date($dateFormat, $currentTime + $daySeconds)];
     $snapshot = new SprintSnapshot(['total_points' => 42]);
     $snapshot->setCreatedAt(date($dateFormat, $currentTime - $daySeconds));
     $scopeLine = new ScopeLine([$snapshot], 40, $duration);
     $data = $scopeLine->getData();
     $this->assertSame($data[$duration[0]], 42);
     $this->assertSame($data[$duration[1]], 42);
     $this->assertSame($data[$duration[2]], 40);
     $this->assertSame($data[$duration[3]], 40);
 }
Example #4
0
 /**
  * @Then I should have created one snapshot for each sprint
  */
 public function iShouldHaveCreatedOneSnapshotForEachSprint()
 {
     $numberOfActiveSprints = count(array_filter(Sprint::all()->all(), function ($sprint) {
         return $sprint->isActive();
     }));
     PHPUnit::assertSame($this->numberOfSnapshots + $numberOfActiveSprints, SprintSnapshot::count());
     SprintSnapshot::take($numberOfActiveSprints)->delete();
     // cleaning up
 }
Example #5
0
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::bind('project', function ($slug) {
    return Project::where('slug', $slug)->first();
});
Route::bind('sprint', function ($phabricatorID) {
    return Sprint::where('phabricator_id', $phabricatorID)->first() ?: new Sprint(['phabricator_id' => $phabricatorID]);
});
Route::bind('snapshot', function ($snapshotID) {
    return SprintSnapshot::where('id', $snapshotID)->first();
});
Route::get('/', ['as' => 'home_path', 'uses' => 'ProjectsController@index']);
Route::get('/login', ['as' => 'login_path', 'uses' => 'SessionsController@login']);
Route::get('/logout', ['as' => 'logout_path', 'uses' => 'SessionsController@logout']);
Route::put('/conduit_certificate', ['middleware' => 'auth', 'as' => 'conduit_certificate_path', 'uses' => 'UsersController@updateCertificate']);
Route::get('/projects/{project}', ['as' => 'project_path', 'uses' => 'ProjectsController@show']);
Route::post('projects/store', ['middleware' => 'admin', 'as' => 'create_project_path', 'uses' => 'ProjectsController@store']);
Route::get('/projects/{project}/sprints/create', ['as' => 'create_sprint_path', 'uses' => 'SprintsController@create']);
Route::post('projects/{project}/sprints/store', ['middleware' => 'auth', 'as' => 'store_sprint_path', 'uses' => 'SprintsController@store']);
Route::get('/sprints/{sprint}', ['as' => 'sprint_path', 'uses' => 'SprintsController@show']);
Route::get('/sprints/{sprint}/export.json', ['as' => 'sprint_export_json_path', 'uses' => 'SprintsController@exportJSON']);
Route::get('/sprints/{sprint}/snapshot', ['as' => 'create_snapshot_path', 'middleware' => 'auth', 'uses' => 'SprintSnapshotsController@store']);
Route::get('/snapshots/{snapshot}/delete', ['as' => 'delete_snapshot_path', 'middleware' => 'admin', 'uses' => 'SprintSnapshotsController@delete']);
Route::get('/live/{sprint}', ['as' => 'sprint_live_path', 'uses' => 'SprintsController@showWithLiveData']);
Route::get('snapshots/{snapshot}', ['as' => 'snapshot_path', 'uses' => 'SprintSnapshotsController@show']);
 private function getSprintDataFactory(SprintSnapshot $snapshot)
 {
     $sprintData = json_decode($snapshot->getData(), true);
     return new SprintDataFactory($snapshot->sprint, $sprintData['tasks'], $sprintData['transactions'], App::make('phabricator'));
 }
Example #7
0
 /**
  * @return SprintSnapshot
  */
 public function createSnapshot()
 {
     $tasks = $this->fetchTasks();
     return SprintSnapshot::create(['sprint_id' => $this->id, 'data' => json_encode($this->fetchSnapshotData($tasks)), 'total_points' => $this->calculateTotalPoints($tasks), 'task_count' => count($tasks)]);
 }