Browse Source
Update 2016-07-09.13.19
Update 2016-07-09.13.19
Add project features with TDD Add and fix Payment testpull/1/head
27 changed files with 462 additions and 84 deletions
-
2app/Entities/Payments/PaymentsRepository.php
-
17app/Entities/Projects/Feature.php
-
6app/Entities/Projects/FeaturesRepository.php
-
5app/Entities/Projects/ProjectsRepository.php
-
18app/Http/Controllers/Projects/FeaturesController.php
-
3app/Http/Controllers/Projects/ProjectsController.php
-
36app/Http/Requests/Features/CreateRequest.php
-
34app/Http/Requests/Features/DeleteRequest.php
-
36app/Http/Requests/Features/UpdateRequest.php
-
4app/Http/routes/projects.php
-
5app/Providers/AuthServiceProvider.php
-
40database/factories/ModelFactory.php
-
3resources/lang/id/feature.php
-
17resources/views/features/create.blade.php
-
25resources/views/features/delete.blade.php
-
32resources/views/features/edit.blade.php
-
18resources/views/features/partials/feature-show.blade.php
-
25resources/views/features/show.blade.php
-
4resources/views/masters/delete.blade.php
-
2resources/views/masters/show.blade.php
-
8resources/views/payments/index.blade.php
-
2resources/views/projects/edit.blade.php
-
27resources/views/projects/features.blade.php
-
2resources/views/projects/partials/breadcrumb.blade.php
-
2resources/views/projects/partials/project-show.blade.php
-
135tests/ManageFeaturesTest.php
-
38tests/ManagePaymentsTest.php
@ -0,0 +1,36 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Http\Requests\Features; |
||||
|
|
||||
|
use App\Entities\Projects\Project; |
||||
|
use App\Http\Requests\Request; |
||||
|
|
||||
|
class CreateRequest extends Request { |
||||
|
|
||||
|
/** |
||||
|
* Determine if the user is authorized to make this request. |
||||
|
* |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function authorize() |
||||
|
{ |
||||
|
$project = Project::findOrFail($this->segment(2)); |
||||
|
return auth()->user()->can('manage_features', $project); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Get the validation rules that apply to the request. |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function rules() |
||||
|
{ |
||||
|
return [ |
||||
|
'name' => 'required|max:60', |
||||
|
'worker_id' => 'required|numeric', |
||||
|
'price' => 'required|numeric', |
||||
|
'description' => 'max:255', |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,34 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Http\Requests\Features; |
||||
|
|
||||
|
use App\Entities\Projects\Project; |
||||
|
use App\Http\Requests\Request; |
||||
|
|
||||
|
class DeleteRequest extends Request { |
||||
|
|
||||
|
/** |
||||
|
* Determine if the user is authorized to make this request. |
||||
|
* |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function authorize() |
||||
|
{ |
||||
|
$project = Project::findOrFail($this->get('project_id')); |
||||
|
return auth()->user()->can('manage_features', $project); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Get the validation rules that apply to the request. |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function rules() |
||||
|
{ |
||||
|
return [ |
||||
|
'feature_id' => 'required', |
||||
|
'project_id' => 'required', |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Http\Requests\Features; |
||||
|
|
||||
|
use App\Entities\Projects\Project; |
||||
|
use App\Http\Requests\Request; |
||||
|
|
||||
|
class UpdateRequest extends Request { |
||||
|
|
||||
|
/** |
||||
|
* Determine if the user is authorized to make this request. |
||||
|
* |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function authorize() |
||||
|
{ |
||||
|
$project = Project::findOrFail($this->get('project_id')); |
||||
|
return auth()->user()->can('manage_features', $project); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Get the validation rules that apply to the request. |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function rules() |
||||
|
{ |
||||
|
return [ |
||||
|
'name' => 'required|max:60', |
||||
|
'worker_id' => 'required|numeric', |
||||
|
'price' => 'required|numeric', |
||||
|
'description' => 'max:255', |
||||
|
]; |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -1,28 +1,25 @@ |
|||||
@extends('layouts.app') |
@extends('layouts.app') |
||||
|
|
||||
@section('title', trans('master.delete')) |
|
||||
|
@section('title', trans('feature.delete')) |
||||
|
|
||||
@section('content') |
@section('content') |
||||
<h1 class="page-header"> |
<h1 class="page-header"> |
||||
<div class="pull-right"> |
<div class="pull-right"> |
||||
{!! delete_button(['route'=>['masters.destroy',$master->id]], trans('app.delete_confirm_button'), ['class'=>'btn btn-danger'], ['master_id'=>$master->id]) !!} |
|
||||
|
{!! FormField::delete([ |
||||
|
'route'=>['features.destroy',$feature->id]], |
||||
|
trans('app.delete_confirm_button'), |
||||
|
['class'=>'btn btn-danger'], |
||||
|
[ |
||||
|
'feature_id'=>$feature->id, |
||||
|
'project_id'=>$feature->project_id, |
||||
|
]) !!} |
||||
</div> |
</div> |
||||
{{ trans('app.delete_confirm') }} |
{{ trans('app.delete_confirm') }} |
||||
{!! link_to_route('masters.show', trans('app.cancel'), [$master->id], ['class' => 'btn btn-default']) !!} |
|
||||
|
{!! link_to_route('features.show', trans('app.cancel'), [$feature->id], ['class' => 'btn btn-default']) !!} |
||||
</h1> |
</h1> |
||||
<div class="row"> |
<div class="row"> |
||||
<div class="col-md-4"> |
<div class="col-md-4"> |
||||
<div class="panel panel-info"> |
|
||||
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.masters') }} Detail</h3></div> |
|
||||
<div class="panel-body"> |
|
||||
<table class="table table-condensed"> |
|
||||
<tbody> |
|
||||
<tr><th>{{ trans('app.name') }}</th><td>{{ $master->name }}</td></tr> |
|
||||
<tr><th>{{ trans('app.description') }}</th><td>{{ $master->description }}</td></tr> |
|
||||
</tbody> |
|
||||
</table> |
|
||||
</div> |
|
||||
</div> |
|
||||
|
@include('features.partials.feature-show') |
||||
</div> |
</div> |
||||
</div> |
</div> |
||||
@endsection |
@endsection |
||||
@ -1,26 +1,38 @@ |
|||||
@extends('layouts.app') |
@extends('layouts.app') |
||||
|
|
||||
@section('title', trans('master.edit')) |
|
||||
|
@section('title', trans('feature.edit')) |
||||
|
|
||||
@section('content') |
@section('content') |
||||
<div class="row"><br> |
<div class="row"><br> |
||||
<div class="col-md-4"> |
|
||||
{!! Form::model($master, ['route'=>['masters.update', $master->id], 'method' => 'patch']) !!} |
|
||||
|
<div class="col-md-6"> |
||||
|
{!! Form::model($feature, ['route'=>['features.update', $feature->id], 'method' => 'patch']) !!} |
||||
<div class="panel panel-default"> |
<div class="panel panel-default"> |
||||
<div class="panel-heading"><h3 class="panel-title">{{ $master->name }} <small>{{ trans('master.edit') }}</small></h3></div> |
|
||||
|
<div class="panel-heading"><h3 class="panel-title">{{ $feature->name }} <small>{{ trans('feature.edit') }}</small></h3></div> |
||||
<div class="panel-body"> |
<div class="panel-body"> |
||||
{!! FormField::text('name',['label'=> trans('app.name')]) !!} |
|
||||
{!! FormField::textarea('description',['label'=> trans('app.description')]) !!} |
|
||||
|
{!! FormField::text('name',['label'=> trans('feature.name')]) !!} |
||||
|
{!! FormField::textarea('description',['label'=> trans('feature.description')]) !!} |
||||
|
<div class="row"> |
||||
|
<div class="col-sm-6"> |
||||
|
{!! FormField::price('price', ['label'=> trans('feature.price')]) !!} |
||||
|
</div> |
||||
|
<div class="col-sm-6"> |
||||
|
{!! FormField::select('worker_id', $workers, ['label'=> trans('feature.worker'),'value' => 1]) !!} |
||||
|
</div> |
||||
|
</div> |
||||
</div> |
</div> |
||||
|
|
||||
<div class="panel-footer"> |
<div class="panel-footer"> |
||||
{!! Form::submit(trans('master.update'), ['class'=>'btn btn-primary']) !!} |
|
||||
{!! link_to_route('masters.show', trans('app.show'), [$master->id], ['class' => 'btn btn-info']) !!} |
|
||||
{!! link_to_route('masters.index', trans('master.back_to_index'), [], ['class' => 'btn btn-default']) !!} |
|
||||
{!! link_to_route('masters.delete', trans('app.delete'), [$master->id], ['class'=>'btn btn-danger pull-right']) !!} |
|
||||
|
{!! Form::hidden('project_id', $feature->project_id) !!} |
||||
|
{!! Form::submit(trans('feature.update'), ['class'=>'btn btn-primary']) !!} |
||||
|
{!! link_to_route('features.show', trans('app.show'), [$feature->id], ['class' => 'btn btn-info']) !!} |
||||
|
{!! link_to_route('projects.features', trans('feature.back_to_index'), [$feature->project_id], ['class' => 'btn btn-default']) !!} |
||||
|
{!! link_to_route('features.delete', trans('feature.delete'), [$feature->id], ['class'=>'btn btn-danger pull-right']) !!} |
||||
</div> |
</div> |
||||
</div> |
</div> |
||||
{!! Form::close() !!} |
{!! Form::close() !!} |
||||
</div> |
</div> |
||||
|
<div class="col-sm-6"> |
||||
|
@include('projects.partials.project-show', ['project' => $feature->project]) |
||||
|
</div> |
||||
</div> |
</div> |
||||
@endsection |
@endsection |
||||
@ -0,0 +1,18 @@ |
|||||
|
<div class="panel panel-default"> |
||||
|
<div class="panel-heading"><h3 class="panel-title">{{ trans('feature.show') }}</h3></div> |
||||
|
<div class="panel-body"> |
||||
|
<table class="table table-condensed"> |
||||
|
<tbody> |
||||
|
<tr><th>{{ trans('feature.name') }}</th><td>{{ $feature->name }}</td></tr> |
||||
|
<tr><th>{{ trans('feature.price') }}</th><td>{{ formatRp($feature->price) }}</td></tr> |
||||
|
<tr><th>{{ trans('feature.tasks_count') }}</th><td>10</td></tr> |
||||
|
<tr><th>{{ trans('feature.progress') }}</th><td>100%</td></tr> |
||||
|
<tr><th>{{ trans('feature.worker') }}</th><td>{{ $feature->worker->name }}</td></tr> |
||||
|
</tbody> |
||||
|
</table> |
||||
|
</div> |
||||
|
<div class="panel-footer"> |
||||
|
{!! link_to_route('features.edit', trans('feature.edit'), [$feature->id], ['class' => 'btn btn-warning']) !!} |
||||
|
{!! link_to_route('projects.features', trans('feature.back_to_index'), [$feature->project_id], ['class' => 'btn btn-default']) !!} |
||||
|
</div> |
||||
|
</div> |
||||
@ -1,26 +1,15 @@ |
|||||
@extends('layouts.app') |
@extends('layouts.app') |
||||
|
|
||||
@section('title', trans('master.show')) |
|
||||
|
@section('title', trans('feature.show')) |
||||
|
|
||||
@section('content') |
@section('content') |
||||
<h1 class="page-header">{{ $master->name }} <small>{{ trans('master.show') }}</small></h1> |
|
||||
|
<h1 class="page-header">{{ $feature->name }} <small>{{ trans('feature.show') }}</small></h1> |
||||
<div class="row"> |
<div class="row"> |
||||
<div class="col-md-4"> |
|
||||
<div class="panel panel-default"> |
|
||||
<div class="panel-heading"><h3 class="panel-title">{{ trans('master.show') }}</h3></div> |
|
||||
<div class="panel-body"> |
|
||||
<table class="table table-condensed"> |
|
||||
<tbody> |
|
||||
<tr><th>{{ trans('app.name') }}</th><td>{{ $master->name }}</td></tr> |
|
||||
<tr><th>{{ trans('app.description') }}</th><td>{{ $master->description }}</td></tr> |
|
||||
</tbody> |
|
||||
</table> |
|
||||
</div> |
|
||||
<div class="panel-footer"> |
|
||||
{!! link_to_route('masters.edit', trans('app.edit'), [$master->id], ['class' => 'btn btn-warning']) !!} |
|
||||
{!! link_to_route('masters.index', trans('master.back_to_index'), [], ['class' => 'btn btn-default']) !!} |
|
||||
</div> |
|
||||
</div> |
|
||||
|
<div class="col-md-6"> |
||||
|
@include('features.partials.feature-show') |
||||
|
</div> |
||||
|
<div class="col-sm-6"> |
||||
|
@include('projects.partials.project-show', ['project' => $feature->project]) |
||||
</div> |
</div> |
||||
</div> |
</div> |
||||
@endsection |
@endsection |
||||
@ -1,5 +1,5 @@ |
|||||
<ul class="breadcrumb hidden-print"> |
<ul class="breadcrumb hidden-print"> |
||||
<li>{{ link_to_route('projects.index',trans('project.projects')) }}</li> |
|
||||
|
<li>{{ link_to_route('projects.index',trans('project.projects'), ['status' => Request::get('status', $project->status_id)]) }}</li> |
||||
<li>{{ $project->present()->projectLink }}</li> |
<li>{{ $project->present()->projectLink }}</li> |
||||
<li class="active">{{ isset($title) ? $title : trans('project.show') }}</li> |
<li class="active">{{ isset($title) ? $title : trans('project.show') }}</li> |
||||
</ul> |
</ul> |
||||
@ -0,0 +1,135 @@ |
|||||
|
<?php |
||||
|
|
||||
|
use App\Entities\Projects\Feature; |
||||
|
use App\Entities\Projects\Project; |
||||
|
use App\Entities\Users\User; |
||||
|
use Illuminate\Foundation\Testing\DatabaseMigrations; |
||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions; |
||||
|
use Illuminate\Foundation\Testing\WithoutMiddleware; |
||||
|
|
||||
|
class ManageFeaturesTest extends TestCase |
||||
|
{ |
||||
|
use DatabaseTransactions; |
||||
|
|
||||
|
/** @test */ |
||||
|
public function admin_can_entry_feature() |
||||
|
{ |
||||
|
$user = factory(User::class)->create(); |
||||
|
$user->assignRole('admin'); |
||||
|
$this->actingAs($user); |
||||
|
|
||||
|
$project = factory(Project::class)->create(['owner_id' => $user->id]); |
||||
|
|
||||
|
$worker = factory(User::class)->create(); |
||||
|
$worker->assignRole('worker'); |
||||
|
|
||||
|
$this->visit('projects/' . $project->id . '/features'); |
||||
|
$this->seePageIs('projects/' . $project->id . '/features'); |
||||
|
$this->see(trans('project.features')); |
||||
|
$this->click(trans('feature.create')); |
||||
|
$this->seePageIs('projects/' . $project->id . '/features/create'); |
||||
|
|
||||
|
// Fill Form
|
||||
|
$this->type('Nama Fitur Baru','name'); |
||||
|
$this->type(100000,'price'); |
||||
|
$this->select($worker->id, 'worker_id'); |
||||
|
$this->type('Similique, eligendi fuga animi? Ipsam magnam laboriosam distinctio officia facere sapiente eius corporis','description'); |
||||
|
$this->press(trans('feature.create')); |
||||
|
|
||||
|
$this->seePageIs('projects/' . $project->id . '/features'); |
||||
|
$this->see(trans('feature.created')); |
||||
|
$this->seeInDatabase('features', [ |
||||
|
'name' => 'Nama Fitur Baru', |
||||
|
'price' => 100000, |
||||
|
'worker_id' => $worker->id, |
||||
|
'project_id' => $project->id |
||||
|
]); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function admin_can_edit_feature_data() |
||||
|
{ |
||||
|
$user = factory(User::class, 3)->create(); |
||||
|
$user[0]->assignRole('admin'); |
||||
|
$user[1]->assignRole('worker'); |
||||
|
$user[2]->assignRole('worker'); |
||||
|
$this->actingAs($user[0]); |
||||
|
|
||||
|
$project = factory(Project::class)->create(['owner_id' => $user[0]->id]); |
||||
|
|
||||
|
$feature = factory(Feature::class)->create(['worker_id' => $user[1]->id, 'project_id' => $project->id]); |
||||
|
|
||||
|
$this->visit('features/' . $feature->id . '/edit'); |
||||
|
$this->seePageIs('features/' . $feature->id . '/edit'); |
||||
|
|
||||
|
// Fill Form
|
||||
|
$this->type('Nama Fitur Edit','name'); |
||||
|
$this->type(33333,'price'); |
||||
|
$this->select($user[2]->id,'worker_id'); |
||||
|
$this->press(trans('feature.update')); |
||||
|
|
||||
|
$this->seePageIs('projects/' . $project->id . '/features'); |
||||
|
$this->see(trans('feature.updated')); |
||||
|
$this->seeInDatabase('features', [ |
||||
|
'name' => 'Nama Fitur Edit', |
||||
|
'price' => 33333, |
||||
|
'worker_id' => $user[2]->id, |
||||
|
'project_id' => $project->id |
||||
|
]); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function admin_can_delete_a_feature() |
||||
|
{ |
||||
|
$user = factory(User::class)->create(); |
||||
|
$user->assignRole('admin'); |
||||
|
$this->actingAs($user); |
||||
|
|
||||
|
$project = factory(Project::class)->create(['owner_id' => $user->id]); |
||||
|
$feature = factory(Feature::class)->create(['project_id' => $project->id]); |
||||
|
|
||||
|
$this->visit('projects/' . $feature->project_id . '/features'); |
||||
|
$this->click(trans('app.show')); |
||||
|
$this->click(trans('app.edit')); |
||||
|
$this->click(trans('feature.delete')); |
||||
|
$this->press(trans('app.delete_confirm_button')); |
||||
|
$this->seePageIs('projects/' . $project->id . '/features'); |
||||
|
$this->see(trans('feature.deleted')); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function admin_can_see_a_feature() |
||||
|
{ |
||||
|
$user = factory(User::class)->create(); |
||||
|
$user->assignRole('admin'); |
||||
|
$this->actingAs($user); |
||||
|
|
||||
|
$project = factory(Project::class)->create(['owner_id' => $user->id]); |
||||
|
$feature = factory(Feature::class)->create(['project_id' => $project->id]); |
||||
|
|
||||
|
$this->visit('projects/' . $project->id . '/features'); |
||||
|
$this->click(trans('app.show')); |
||||
|
$this->seePageIs('features/' . $feature->id); |
||||
|
$this->see(trans('feature.show')); |
||||
|
$this->see($feature->name); |
||||
|
$this->see(formatRp($feature->price)); |
||||
|
$this->see($feature->worker->name); |
||||
|
} |
||||
|
|
||||
|
/** @test */ |
||||
|
public function admin_can_see_all_features() |
||||
|
{ |
||||
|
$user = factory(User::class)->create(); |
||||
|
$user->assignRole('admin'); |
||||
|
$this->actingAs($user); |
||||
|
|
||||
|
$project = factory(Project::class)->create(['owner_id' => $user->id]); |
||||
|
$features = factory(Feature::class, 10)->create(['project_id' => $project->id]); |
||||
|
$this->assertEquals(10, $features->count()); |
||||
|
|
||||
|
$this->visit('projects/' . $project->id . '/features'); |
||||
|
$this->see($features[1]->name); |
||||
|
$this->see($features[1]->worker->name); |
||||
|
$this->see(formatRp($features[1]->price)); |
||||
|
} |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue