Go from get to post.

This commit is contained in:
James Cole 2018-12-18 07:08:35 +01:00
parent f71359e73d
commit a3f33ae888
3 changed files with 29 additions and 39 deletions

View File

@ -108,38 +108,7 @@ function sortStop(event, ui) {
page: page,
_token: token
};
// var thisDate = current.data('date');
// var originalBG = current.css('backgroundColor');
//
//
// if (current.prev().data('date') !== thisDate && current.next().data('date') !== thisDate) {
// // animate something with color:
// current.animate({backgroundColor: "#d9534f"}, 200, function () {
// $(this).animate({backgroundColor: originalBG}, 200);
// return undefined;
// });
//
// return false;
// }
//
// // do update
// var list = $('tr[data-date="' + thisDate + '"]');
// var submit = [];
// $.each(list, function (i, v) {
// var row = $(v);
// var id = row.data('id');
// submit.push(id);
// });
//
// // do extra animation when done?
$.get('budgets/reorder', arr);
//
// current.animate({backgroundColor: "#5cb85c"}, 200, function () {
// $(this).animate({backgroundColor: originalBG}, 200);
// return undefined;
// });
// return undefined;
//alert('drop!');
$.post('budgets/reorder', arr);
}

View File

@ -215,7 +215,7 @@ Route::group(
Route::get('list/no-budget/{start_date?}/{end_date?}', ['uses' => 'Budget\ShowController@noBudget', 'as' => 'no-budget']);
// reorder budgets
Route::get('reorder', ['uses' => 'Budget\IndexController@reorder', 'as' => 'reorder']);
Route::post('reorder', ['uses' => 'Budget\IndexController@reorder', 'as' => 'reorder']);
// index
Route::get('{start_date?}/{end_date?}', ['uses' => 'Budget\IndexController@index', 'as' => 'index']);

View File

@ -131,8 +131,8 @@ class IndexControllerTest extends TestCase
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
@ -186,8 +186,8 @@ class IndexControllerTest extends TestCase
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
@ -239,8 +239,8 @@ class IndexControllerTest extends TestCase
$repository = $this->mock(BudgetRepositoryInterface::class);
$journalRepos = $this->mock(JournalRepositoryInterface::class);
$userRepos = $this->mock(UserRepositoryInterface::class);
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$fiscalHelper = $this->mock(FiscalHelperInterface::class);
$date = new Carbon;
$fiscalHelper->shouldReceive('endOfFiscalYear')->atLeast()->once()->andReturn($date);
$fiscalHelper->shouldReceive('startOfFiscalYear')->atLeast()->once()->andReturn($date);
@ -254,4 +254,25 @@ class IndexControllerTest extends TestCase
$response = $this->get(route('budgets.index', ['Hello-there']));
$response->assertStatus(404);
}
/**
* @covers \FireflyIII\Http\Controllers\Budget\IndexController
*/
public function testReorder(): void
{
$repository = $this->mock(BudgetRepositoryInterface::class);
$data = [
'budgetIds' => [1,2],
'page' => 1,
];
$repository->shouldReceive('cleanupBudgets')->atLeast()->once();
$repository->shouldReceive('findNull')->atLeast()->once()->andReturn(new Budget);
$repository->shouldReceive('setBudgetOrder')->atLeast()->once();
$this->be($this->user());
$response = $this->post(route('budgets.reorder', $data));
$response->assertStatus(200);
}
}