Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove home controller

  • Loading branch information...
commit d7a96effe1f2f0bafd6fd15327a42ba1973399d0 1 parent 566f0a9
Theo Pack authored
3  app/assets/javascripts/home.js.coffee
View
@@ -1,3 +0,0 @@
-# Place all the behaviors and hooks related to the matching controller here.
-# All this logic will automatically be available in application.js.
-# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
3  app/assets/stylesheets/home.css.scss
View
@@ -1,3 +0,0 @@
-// Place all the styles related to the home controller here.
-// They will automatically be included in application.css.
-// You can use Sass (SCSS) here: http://sass-lang.com/
7 app/controllers/application_controller.rb
View
@@ -1,3 +1,10 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+
+ def authorize
+ unless User.find_by_id(session[:user_id])
+ puts 'bla'
+ redirect_to login_url, notice: 'Please log in'
+ end
+ end
end
1  app/controllers/books_controller.rb
View
@@ -1,4 +1,5 @@
class BooksController < ApplicationController
+ before_filter :authorize
# GET /books
# GET /books.json
def index
13 app/controllers/home_controller.rb
View
@@ -1,13 +0,0 @@
-class HomeController < ApplicationController
- def index
- end
-
- def login
- end
-
- def register
- end
-
- def logout
- end
-end
2  app/helpers/home_helper.rb
View
@@ -1,2 +0,0 @@
-module HomeHelper
-end
2  app/views/home/index.html.erb
View
@@ -1,2 +0,0 @@
-<h1>Home#index</h1>
-<p>Find me in app/views/home/index.html.erb</p>
2  app/views/home/login.html.erb
View
@@ -1,2 +0,0 @@
-<h1>Home#login</h1>
-<p>Find me in app/views/home/login.html.erb</p>
2  app/views/home/logout.html.erb
View
@@ -1,2 +0,0 @@
-<h1>Home#logout</h1>
-<p>Find me in app/views/home/logout.html.erb</p>
2  app/views/home/register.html.erb
View
@@ -1,2 +0,0 @@
-<h1>Home#register</h1>
-<p>Find me in app/views/home/register.html.erb</p>
12 config/routes.rb
View
@@ -1,13 +1,13 @@
ShareYourBooks::Application.routes.draw do
- resources :users
-
- get "home/index"
- get "home/login"
- get "home/register"
+ controller :sessions do
+ get 'login' => :new
+ post 'login' => :create
+ delete 'logout' => :destroy
+ end
- get "home/logout"
+ resources :users
resources :books
2  test/fixtures/users.yml
View
@@ -1,9 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one:
+ id: 1
name: MyString
password_digest: MyString
two:
+ id: 2
name: MyString
password_digest: MyString
1  test/functional/books_controller_test.rb
View
@@ -3,6 +3,7 @@
class BooksControllerTest < ActionController::TestCase
setup do
@book = books(:clean_code)
+ login_as(:one)
end
test "should get index" do
24 test/functional/home_controller_test.rb
View
@@ -1,24 +0,0 @@
-require 'test_helper'
-
-class HomeControllerTest < ActionController::TestCase
- test "should get index" do
- get :index
- assert_response :success
- end
-
- test "should get login" do
- get :login
- assert_response :success
- end
-
- test "should get register" do
- get :register
- assert_response :success
- end
-
- test "should get logout" do
- get :logout
- assert_response :success
- end
-
-end
1  test/functional/users_controller_test.rb
View
@@ -7,7 +7,6 @@ class UsersControllerTest < ActionController::TestCase
password: "private",
password_confirmation: "private"
}
-
@user = users(:one)
end
4 test/test_helper.rb
View
@@ -9,5 +9,9 @@ class ActiveSupport::TestCase
# -- they do not yet inherit this setting
fixtures :all
+ def login_as(user)
+ session[:user_id] = users(user).id
+ end
+
# Add more helper methods to be used by all tests here...
end
4 test/unit/helpers/home_helper_test.rb
View
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class HomeHelperTest < ActionView::TestCase
-end
Please sign in to comment.
Something went wrong with that request. Please try again.