Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
fidrelity committed Jan 25, 2011
2 parents 58e47da + 736dd55 commit 6965945
Show file tree
Hide file tree
Showing 15 changed files with 1,168 additions and 41 deletions.
1 change: 0 additions & 1 deletion Gemfile
Expand Up @@ -23,7 +23,6 @@ group :test do
gem 'webrat', '0.7.1'
gem 'factory_girl_rails', '1.0'
gem 'faker'

end


Expand Down
10 changes: 0 additions & 10 deletions app/controllers/pages_controller.rb
@@ -1,18 +1,8 @@
class PagesController < ApplicationController

before_filter :authenticate, :only => [:about, :help]

def home
@title = "Home"
end

def about
@title = "About"
end

def help
@title = "Help"
end

def imprint
@title = "Imprint"
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/sessions_helper.rb
Expand Up @@ -51,9 +51,9 @@ def correct_user

def admin_user
if (current_user)
redirect_to(home_path) unless current_user.admin?
redirect_to(current_user) unless current_user.admin?
else
redirect_to(home_path)
redirect_to(root_path)
end
end

Expand Down
4 changes: 0 additions & 4 deletions app/views/pages/help.html.erb

This file was deleted.

10 changes: 0 additions & 10 deletions app/views/pages/home.html.erb

This file was deleted.

2 changes: 0 additions & 2 deletions config/routes.rb
Expand Up @@ -6,8 +6,6 @@
resources :maps, :only => [:new, :show, :create, :destroy, :protect_index, :destroy_index]

match '/about', :to => 'pages#about'
match '/help', :to => 'pages#help'
match '/home', :to => 'pages#home'
match '/imprint', :to => 'pages#imprint'

match '/signup', :to => 'users#new'
Expand Down
Binary file added db/development.sqlite3_test
Binary file not shown.
12 changes: 0 additions & 12 deletions public/javascripts/renderengine/lastplantgame/.project

This file was deleted.

36 changes: 36 additions & 0 deletions spec/controllers/pages_controller_spec.rb
@@ -0,0 +1,36 @@
require 'spec_helper'

describe PagesController do
render_views

before(:each) do
@base_title = "Last Plant"
end

describe "GET 'about'" do
it "should be successful" do
get 'about'
response.should be_success
end

it "should have the right title" do
get 'about'
response.should have_selector("title",
:content => @base_title + " | About")
end
end

describe "GET 'imprint'" do
it "should be successful" do
get 'imprint'
response.should be_success
end

it "should have the right title" do
get 'imprint'
response.should have_selector("title",
:content => @base_title + " | Imprint")
end
end
end

80 changes: 80 additions & 0 deletions spec/controllers/sessions_controller_spec.rb
@@ -0,0 +1,80 @@
require 'spec_helper'

describe SessionsController do
render_views

describe "GET 'new'" do

it "should be successful" do
get :new
response.should be_success
end

it "should have the right title" do
get :new
response.should have_selector("title", :content => "Sign in")
end
end


describe "POST 'create'" do

describe "invalid signin" do

before(:each) do
@attr = { :email => "email@example.com", :password => "invalid" }
end

it "should re-render the new page" do
post :create, :session => @attr
response.should redirect_to(root_path)
end

it "should have a flash.now message" do
post :create, :session => @attr
flash.now[:error].should =~ /invalid/i
end
end


describe "with valid email and password" do

before(:each) do
@user = Factory(:user)
@attr = { :email => @user.email, :password => @user.password }
end

it "should sign the user in" do
post :create, :session => @attr
controller.current_user.should == @user
controller.should be_signed_in
end

it "should redirect to the user show page" do
post :create, :session => @attr
response.should redirect_to(user_path(@user))
end
end
end


describe "DELETE 'destroy'" do

before(:each) do
@user = Factory(:user)
@attr = { :email => @user.email, :password => @user.password }
end

it "should sign the user in" do
post :create, :session => @attr
controller.current_user.should == @user
controller.should be_signed_in
end

it "should sign a user out" do
delete :destroy
controller.should_not be_signed_in
response.should redirect_to(root_path)
end
end
end

0 comments on commit 6965945

Please sign in to comment.