Browse files

remove home controller

  • Loading branch information...
1 parent 566f0a9 commit d7a96effe1f2f0bafd6fd15327a42ba1973399d0 @FuriKuri committed Nov 7, 2012
View
3 app/assets/javascripts/home.js.coffee
@@ -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/
View
3 app/assets/stylesheets/home.css.scss
@@ -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/
View
7 app/controllers/application_controller.rb
@@ -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
View
1 app/controllers/books_controller.rb
@@ -1,4 +1,5 @@
class BooksController < ApplicationController
+ before_filter :authorize
# GET /books
# GET /books.json
def index
View
13 app/controllers/home_controller.rb
@@ -1,13 +0,0 @@
-class HomeController < ApplicationController
- def index
- end
-
- def login
- end
-
- def register
- end
-
- def logout
- end
-end
View
2 app/helpers/home_helper.rb
@@ -1,2 +0,0 @@
-module HomeHelper
-end
View
2 app/views/home/index.html.erb
@@ -1,2 +0,0 @@
-<h1>Home#index</h1>
-<p>Find me in app/views/home/index.html.erb</p>
View
2 app/views/home/login.html.erb
@@ -1,2 +0,0 @@
-<h1>Home#login</h1>
-<p>Find me in app/views/home/login.html.erb</p>
View
2 app/views/home/logout.html.erb
@@ -1,2 +0,0 @@
-<h1>Home#logout</h1>
-<p>Find me in app/views/home/logout.html.erb</p>
View
2 app/views/home/register.html.erb
@@ -1,2 +0,0 @@
-<h1>Home#register</h1>
-<p>Find me in app/views/home/register.html.erb</p>
View
12 config/routes.rb
@@ -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
View
2 test/fixtures/users.yml
@@ -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
View
1 test/functional/books_controller_test.rb
@@ -3,6 +3,7 @@
class BooksControllerTest < ActionController::TestCase
setup do
@book = books(:clean_code)
+ login_as(:one)
end
test "should get index" do
View
24 test/functional/home_controller_test.rb
@@ -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
View
1 test/functional/users_controller_test.rb
@@ -7,7 +7,6 @@ class UsersControllerTest < ActionController::TestCase
password: "private",
password_confirmation: "private"
}
-
@user = users(:one)
end
View
4 test/test_helper.rb
@@ -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
View
4 test/unit/helpers/home_helper_test.rb
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class HomeHelperTest < ActionView::TestCase
-end

0 comments on commit d7a96ef

Please sign in to comment.