Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing #8

Merged
merged 32 commits into from
Jan 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7c3e74e
(chore) Ignore the files in .gitignore
sachungo Dec 16, 2015
0b2eea0
(chore)Updated the README from the default Laravel's one.
sachungo Dec 16, 2015
f70fc9f
(chore) Add the php version to circle.yml file
sachungo Dec 16, 2015
762dbae
(fix) Added a shield style circleci status badge.
sachungo Dec 16, 2015
bab3c8d
(fix) Changed the repo name to soma-tech from php-checkpoints.
sachungo Dec 16, 2015
18b402e
(chore) Add Procfile to tell Heroku to run the app from the public di…
sachungo Dec 16, 2015
05064c4
(feature)Added Heroku deployment settings to circle.yml.
sachungo Dec 16, 2015
ff05299
(feature) Added the coveralls badge to README.md.
sachungo Dec 16, 2015
fe830ce
(feature) Integrate coveralls.
sachungo Dec 16, 2015
09fae5d
(fix)Removed test override configuration in circle.yml
sachungo Dec 16, 2015
7006d5d
(fix) Added directories to the whitelist exclude of phpunit.xml
sachungo Dec 16, 2015
d393b31
(feature) Added .styleci.yml
sachungo Dec 16, 2015
653feeb
(fix) Fixedc styleci errors.
sachungo Dec 16, 2015
79d39f3
(fix) Fixedc styleci errors.
sachungo Dec 16, 2015
b859de5
Merge branch 'develop' of github.com:andela-sachungo/soma-tech into d…
sachungo Dec 16, 2015
0b93e50
(chore) Add styleci status badge.
sachungo Dec 16, 2015
5bd94ea
(feature) Basic traditional and social authentication.
sachungo Dec 20, 2015
1fc0d27
(feature)Add videos, categories and access dashboard.
sachungo Dec 23, 2015
03a4e59
(feature) Building the UI and linking the pages.
sachungo Dec 23, 2015
0f76d1b
fixing styleci errors
sachungo Dec 23, 2015
247fc0b
Added sidebar to videos/create and tried to color sidebar
sachungo Dec 23, 2015
a72512a
(feature) Display category within a panel, and flush footer to bottom…
sachungo Jan 4, 2016
0c8434d
(feature) Basic Homepage UI completed.
sachungo Jan 5, 2016
349e393
(feature) Videos can be viewed based on categories.
sachungo Jan 5, 2016
374ca80
(feature) When the 'More info' button is clicked, a page is loaded wi…
sachungo Jan 6, 2016
b4f8ac1
(feature)User can click on edit button of categories panel on dashboa…
sachungo Jan 6, 2016
b25aa7f
(fix)Fixing StyleCI and CircleCI errors on develop branch.
sachungo Jan 6, 2016
61a63d5
(feature) PHPUnit tests for the homepage and HomeController.
sachungo Jan 6, 2016
281ae10
(feature) Tests related to the homepage, dashboard and videos wriiten.
sachungo Jan 7, 2016
621d558
(fix)Remove the DB_CONNECTION variable from phpunit.xml.
sachungo Jan 7, 2016
e382379
(fix) Changed the way of testing destroy routes of the restful contro…
sachungo Jan 7, 2016
452de3d
(fix) Fixed StyleCI errors
sachungo Jan 12, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto
*.css linguist-vendored
*.less linguist-vendored
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/vendor
/node_modules
Homestead.yaml
Homestead.json
.env
*.log
.DS_Store
7 changes: 7 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
preset: laravel

linting: true

finder:
exclude:
- "tests"
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: vendor/bin/heroku-php-apache2 public
45 changes: 45 additions & 0 deletions app/Categories.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Soma;

use Illuminate\Database\Eloquent\Model;

class Categories extends Model
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'categories';

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'user_id',
'title',
];

/**
* A category belongs to a user.
*
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('Soma\User');
}

/**
* A category has many videos.
*
* @return Illuminate\Database\Eloquent\Relations\HasMany
*/
public function videos()
{
return $this->hasMany('Soma\Videos', 'category_id');
}
}
2 changes: 1 addition & 1 deletion app/Console/Commands/Inspire.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Console\Commands;
namespace Soma\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Console;
namespace Soma\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
Expand Down
2 changes: 1 addition & 1 deletion app/Events/Event.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Events;
namespace Soma\Events;

abstract class Event
{
Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Exceptions;
namespace Soma\Exceptions;

use Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
Expand Down
13 changes: 8 additions & 5 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace App\Http\Controllers\Auth;
namespace Soma\Http\Controllers\Auth;

use App\User;
use Soma\User;
use Validator;
use App\Http\Controllers\Controller;
use Soma\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;

Expand All @@ -23,6 +23,8 @@ class AuthController extends Controller

use AuthenticatesAndRegistersUsers, ThrottlesLogins;

protected $redirectPath = '/dashboard';

/**
* Create a new authentication controller instance.
*
Expand All @@ -43,8 +45,9 @@ protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
'email' => 'required|email|max:255|max:255',
'password' => 'required|min:6',
'confirm-password' => 'required|same:password',
]);
}

Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Auth/PasswordController.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace App\Http\Controllers\Auth;
namespace Soma\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Soma\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;

class PasswordController extends Controller
Expand Down
63 changes: 63 additions & 0 deletions app/Http/Controllers/Auth/SocialAuthController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Soma\Http\Controllers\Auth;

use Auth;
use Socialite;
use Soma\User;
use Soma\Http\Controllers\Controller;

class SocialAuthController extends Controller
{
/**
* Redirect the user to the provider authentication page.
*
* @return Response
*/
public function redirectToProvider($provider)
{
return Socialite::driver($provider)->redirect();
}

/**
* Obtain the user information from the provider.
*
* Specify true as the second parameter to "Auth::login()"
* " to set the "remember me" cookie.
*
* @return Response
*/
public function handleProviderCallback($provider)
{
try {
$user = Socialite::driver($provider)->user();
} catch (\Exception $e) {
return redirect()->route('register');
}

$authUser = $this->findOrCreateUser($user);
Auth::login($authUser, true);

return redirect()->route('dashboard');
}

/**
* Return user if exists; create and return if doesn't.
*
* @param $socialUser
* @return User
*/
private function findOrCreateUser($socialUser)
{
if ($authUser = User::where('email', $socialUser->getEmail())->first()) {
return $authUser;
}

return User::create([
'name' => $socialUser->getName(),
'email' => $socialUser->getEmail(),
'provider_id' => $socialUser->getAvatar(),
'avatar' => $socialUser->getAvatar(),
]);
}
}
124 changes: 124 additions & 0 deletions app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?php

namespace Soma\Http\Controllers;

use Soma\User;
use Soma\Categories;
use Soma\Http\Requests\CategoriesRequest;

class CategoryController extends Controller
{
/**
* A constructor.
*/
public function __construct()
{
$this->middleware('auth', [
'except' => [
'getVideosByCategory',
],
]);
}

/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
/*public function index()
{
$categories = Categories::all();
return view('categories.index')->with('categories', $categories);
}*/

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('categories.create');
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(CategoriesRequest $request)
{
$user = User::authorizedUser($request->email)->first();
$user->categories()->create([
'title' => $request->title,
]);

// FLASH MESSAGE

return redirect()->back();
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$category = Categories::find($id);

return view('categories.edit')->with('category', $category);
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(CategoriesRequest $request, $id)
{
$category = Categories::find($id);
$category->update([
'title' => $request->title,
]);

// FLASH MESSAGE
return redirect()->route('own.categories');
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$category = Categories::find($id);
if ($category) {
Categories::destroy($id);

return redirect()->back();
}

// REDIRECT WITH MESSAGE CATEGORY NOT FOUND
return redirect()->route('dashboard');
}

/**
* Get the categories of a particular user.
*
* @return \Illuminate\Http\Response
*/
public function getCategories()
{
$categories = Categories::where('user_id', auth()->user()->id)->get();

return view('categories.own')->with('categories', $categories);
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Http\Controllers;
namespace Soma\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
Expand Down
Loading