diff --git a/app/controllers/ChartController.php b/app/controllers/ChartController.php index 84572d05bc..97a43dd10e 100644 --- a/app/controllers/ChartController.php +++ b/app/controllers/ChartController.php @@ -53,10 +53,6 @@ class ChartController extends BaseController $start = Session::get('start'); $end = Session::get('end'); - \Log::debug('Draw home account chart.'); - \Log::debug('From: ' . $start . ' (' . $start->timezone . ')'); - \Log::debug('Until: ' . $end); - if (is_null($account)) { // get, depending on preferences: /** @var \Firefly\Helper\Preferences\PreferencesHelperInterface $prefs */ diff --git a/app/lib/Firefly/Storage/User/EloquentUserRepository.php b/app/lib/Firefly/Storage/User/EloquentUserRepository.php index 30fac28df2..2de3a89b50 100644 --- a/app/lib/Firefly/Storage/User/EloquentUserRepository.php +++ b/app/lib/Firefly/Storage/User/EloquentUserRepository.php @@ -89,6 +89,12 @@ class EloquentUserRepository implements UserRepositoryInterface /** @noinspection PhpUndefinedFieldInspection */ $user->password = $password; /** @noinspection PhpUndefinedMethodInspection */ + if($user->validate()) { + $user->save(); + } else { + var_dump($user->errors()->all()); + exit; + } $user->save(); return true; diff --git a/app/models/User.php b/app/models/User.php index 1250c2710f..b6852c4dcf 100644 --- a/app/models/User.php +++ b/app/models/User.php @@ -42,7 +42,7 @@ class User extends Ardent implements UserInterface, RemindableInterface public static $rules = [ - 'email' => 'required|email|unique:users,email', + 'email' => 'required|email', 'migrated' => 'required|numeric|between:0,1', 'password' => 'required|between:60,60', 'reset' => 'between:32,32', diff --git a/app/tests/controllers/ChartControllerTest.php b/app/tests/controllers/ChartControllerTest.php new file mode 100644 index 0000000000..f9ad9b7b7c --- /dev/null +++ b/app/tests/controllers/ChartControllerTest.php @@ -0,0 +1,62 @@ +_accounts = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface'); +// $this->_category = $this->mock('Firefly\Helper\Controllers\CategoryInterface'); + $this->_user = m::mock('User', 'Eloquent'); + + } + + public function tearDown() + { + Mockery::close(); + } + + public function testCategoryShowChart() + { + $this->session(['start' => new Carbon, 'end' => new Carbon, 'range' => '1M']); + $category = f::create('Category'); + + // for successful binding: + Auth::shouldReceive('user')->andReturn($this->_user); + Auth::shouldReceive('check')->andReturn(true); + $this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($category->user_id); + + + $this->action('GET', 'ChartController@categoryShowChart', $category->id); + $this->assertResponseOk(); + } + + public function testHomeAccount() + { + $account = f::create('Account'); + $this->session(['start' => new Carbon, 'end' => new Carbon, 'range' => '1M']); + + // for successful binding: + Auth::shouldReceive('user')->andReturn($this->_user); + Auth::shouldReceive('check')->andReturn(true); + $this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn(1); + $this->_accounts->shouldReceive('getByIds')->andReturn([$account]); + + + $this->action('GET', 'ChartController@homeAccount'); + $this->assertResponseOk(); + } +} \ No newline at end of file