Skip to content

Firefly III: a personal finances manager

First attempt at account controller::index.

James Cole8b085af6a14a
diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php
index 1674601f81..910eac7db5 100644
--- a/app/Http/Controllers/AccountController.php
+++ b/app/Http/Controllers/AccountController.php
@@ -84,10 +84,10 @@ class AccountController extends Controller
*/
public function edit(Account $account, AccountRepositoryInterface $repository)
{
- $what = Config::get('firefly.shortNamesByFullName')[$account->accountType->type];
- $subTitle = 'Edit ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"';
- $subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
- $openingBalance = $repository->openingBalanceTransaction($account);
+ $what = Config::get('firefly.shortNamesByFullName')[$account->accountType->type];
+ $subTitle = 'Edit ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"';
+ $subTitleIcon = Config::get('firefly.subIconsByIdentifier.' . $what);
+ $openingBalance = $repository->openingBalanceTransaction($account);
// pre fill some useful values.
@@ -134,7 +134,7 @@ class AccountController extends Controller
$total = Auth::user()->accounts()->accountTypeIn($types)->count();
// last activity:
- $start = clone Session::get('start');
+ $start = clone Session::get('start', Carbon::now()->startOfMonth());
$start->subDay();
$set->each(
function (Account $account) use ($start) {
diff --git a/tests/controllers/AccountControllerTest.php b/tests/controllers/AccountControllerTest.php
index 8734f10f5a..07da123560 100644
--- a/tests/controllers/AccountControllerTest.php
+++ b/tests/controllers/AccountControllerTest.php
@@ -1,4 +1,5 @@
<?php
+use Carbon\Carbon;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionCurrency;
use League\FactoryMuffin\Facade as FactoryMuffin;
@@ -121,7 +122,21 @@ class AccountControllerTest extends TestCase
public function testIndex()
{
- $this->markTestIncomplete();
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $this->be($user);
+
+ // get currency code:
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ Amount::shouldReceive('getCurrencyCode')->andReturn($currency->code);
+
+ // put stuff in session:
+ $this->session(['start' => new Carbon, 'end' => new Carbon]);
+
+ // get edit page:
+ $this->call('GET', '/accounts/asset');
+ $this->assertResponseOk();
+ $this->assertViewHas('what', 'asset');
+
}
public function testShow()