From a8d01550dcec54bf8c86dc13d7a4b8d903761266 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 25 Nov 2013 08:09:14 -0500 Subject: [PATCH 1/3] Prep for unit testing --- app/config/testing/database.php | 14 ++++++++++++++ app/tests/TestCase.php | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 app/config/testing/database.php diff --git a/app/config/testing/database.php b/app/config/testing/database.php new file mode 100644 index 0000000000..b15c97c575 --- /dev/null +++ b/app/config/testing/database.php @@ -0,0 +1,14 @@ + 'sqlite', + + 'connections' => array( + 'sqlite' => array( + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '' + ), + ) +); \ No newline at end of file diff --git a/app/tests/TestCase.php b/app/tests/TestCase.php index 49b80fc274..c9f4d33996 100755 --- a/app/tests/TestCase.php +++ b/app/tests/TestCase.php @@ -2,6 +2,18 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase { + /** + * Default preparation for each test + * + */ + public function setUp() + { + parent::setUp(); // Don't forget this! + + $this->prepareForTests(); + } + + /** * Creates the application. * @@ -16,4 +28,15 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase { return require __DIR__.'/../../bootstrap/start.php'; } + /** + * Migrates the database and set the mailer to 'pretend'. + * This will cause the tests to run quickly. + * + */ + private function prepareForTests() + { + Artisan::call('migrate'); + Mail::pretend(true); + } + } From 57d0f3643518190f0b4a6fe33ac6d83eda647119 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 25 Nov 2013 08:25:34 -0500 Subject: [PATCH 2/3] Fixes #4 --- app/controllers/admin/ModelsController.php | 7 ++++--- app/views/backend/models/edit.blade.php | 13 ++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/ModelsController.php b/app/controllers/admin/ModelsController.php index d186f2f9d2..cdfc0eb956 100644 --- a/app/controllers/admin/ModelsController.php +++ b/app/controllers/admin/ModelsController.php @@ -38,7 +38,8 @@ class ModelsController extends AdminController { { // Show the page $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); - return View::make('backend/models/edit')->with('depreciation_list',$depreciation_list)->with('model',new Model); + $category_list = array('' => '') + DB::table('categories')->lists('name', 'id'); + return View::make('backend/models/edit')->with('category_list',$category_list)->with('depreciation_list',$depreciation_list)->with('model',new Model); } @@ -102,8 +103,8 @@ class ModelsController extends AdminController { } $depreciation_list = array('' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); - $model_options = array('' => 'Top Level') + DB::table('models')->where('id', '!=', $modelId)->lists('name', 'id'); - return View::make('backend/models/edit', compact('model'))->with('model_options',$model_options)->with('depreciation_list',$depreciation_list); + $category_list = array('' => '') + DB::table('categories')->lists('name', 'id'); + return View::make('backend/models/edit', compact('model'))->with('category_list',$category_list)->with('depreciation_list',$depreciation_list); } diff --git a/app/views/backend/models/edit.blade.php b/app/views/backend/models/edit.blade.php index 6518647c90..7288d48cc7 100755 --- a/app/views/backend/models/edit.blade.php +++ b/app/views/backend/models/edit.blade.php @@ -30,8 +30,7 @@ - -
+
@@ -60,7 +59,15 @@ {{ $errors->first('depreciation_id', ':message') }}
- + + +
+ +
+ {{ Form::select('category_id', $category_list , Input::old('category_id', $model->category_id), array('class'=>'select2', 'style'=>'width:250px')) }} + {{ $errors->first('category_id', ':message') }} +
+
From 1a970716cc0c813499d644dad8d71216e31f4e09 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 25 Nov 2013 08:25:47 -0500 Subject: [PATCH 3/3] Experimenting with nicer error messages --- app/views/backend/assets/edit.blade.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/views/backend/assets/edit.blade.php b/app/views/backend/assets/edit.blade.php index 6afa0956db..f62f525270 100755 --- a/app/views/backend/assets/edit.blade.php +++ b/app/views/backend/assets/edit.blade.php @@ -43,7 +43,7 @@
- {{ $errors->first('asset_tag', ':message') }} + {{ $errors->first('asset_tag', ' :message') }}
@@ -51,7 +51,7 @@
- {{ $errors->first('name', ':message') }} + {{ $errors->first('name', ' :message') }}
@@ -61,7 +61,7 @@
- {{ $errors->first('serial', ':message') }} + {{ $errors->first('serial', ' :message') }}
@@ -70,7 +70,7 @@
- {{ $errors->first('order_number', ':message') }} + {{ $errors->first('order_number', ' :message') }}
@@ -79,7 +79,7 @@
{{ Form::select('model_id', $model_list , Input::old('model_id', $asset->model_id), array('class'=>'select2', 'style'=>'min-width:350px')) }} - {{ $errors->first('model_id', ':message') }} + {{ $errors->first('model_id', ' :message') }}
@@ -88,7 +88,7 @@
- {{ $errors->first('purchase_date', ':message') }} + {{ $errors->first('purchase_date', ' :message') }}
@@ -100,7 +100,7 @@
$ - {{ $errors->first('purchase_cost', ':message') }} + {{ $errors->first('purchase_cost', ' :message') }}
@@ -110,7 +110,7 @@
months - {{ $errors->first('warranty_months', ':message') }} + {{ $errors->first('warranty_months', ' :message') }}
@@ -120,7 +120,7 @@
{{ Form::select('depreciation_id', $depreciation_list , Input::old('depreciation_id', $asset->depreciation_id), array('class'=>'select2', 'style'=>'width:250px')) }} - {{ $errors->first('depreciation_id', ':message') }} + {{ $errors->first('depreciation_id', ' :message') }}
@@ -131,7 +131,7 @@
{{ Form::select('status_id', $statuslabel_list , Input::old('status_id', $asset->status_id), array('class'=>'select2', 'style'=>'width:250px')) }} - {{ $errors->first('depreciation_id', ':message') }} + {{ $errors->first('depreciation_id', ' :message') }}
@@ -142,7 +142,7 @@
- {{ $errors->first('notes', ':message') }} + {{ $errors->first('notes', ' :message') }}