Sha256: 57e185e4b0f19e4fcca18c2e16eb2bea7ff3e31c9d718a8509b2094d26677f6e

Contents?: true

Size: 1.4 KB

Versions: 49

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'
describe Spud::UserSessionsController do
  before(:each) do
    # activate_authlogic
    # SpudUserSession.create(FactoryGirl.build(:spud_user))
  end

  describe :new do
  	it "should redirect to setup url if no users exist" do
  		get :new
		response.should redirect_to(spud_setup_url)
  	end

  	it "should render login form if users do exist" do
  		u = FactoryGirl.create(:spud_user)
  		u.save
  		get :new
		response.should be_success
  	end
  end

  describe :create do
  	it "should rerender form when login is invalid" do
  		post :create
  	  	response.should be_success
  	end
  	it "should redirect to root url if login is valid" do
  		u = FactoryGirl.create(:spud_user,:login => "testuser")
  		u.save
  		user_session = {:login => "testuser", :password => "password"}
  		post :create,:spud_user_session => user_session
  	  	response.should redirect_to(root_url)
  	end
  end

  describe :destroy do
  	it "should redirect to login after logout when no referer" do
  		activate_authlogic
	    SpudUserSession.create(FactoryGirl.build(:spud_user))
	    delete :destroy
	    response.should redirect_to(new_spud_user_session_url)
  	end
  	it "should redirect to previous page after logout" do
        request.env["HTTP_REFERER"] = "/"
        activate_authlogic
	    SpudUserSession.create(FactoryGirl.build(:spud_user))
	    delete :destroy
	    response.should redirect_to("/")
  	end
  end
end

Version data entries

49 entries across 49 versions & 2 rubygems

Version Path
spud_core-1.0.6 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-1.0.5 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-1.0.4 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-1.0.3 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-1.0.2 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-1.0.1 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-1.0.0 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-1.0.0.rc2 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-1.0.0.rc1.1 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-1.0.0.rc1 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-0.9.22 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-0.9.21 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-0.9.20 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-0.9.19 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-0.9.18 spec/controllers/spud/user_sessions_controller_spec.rb
tb_core-1.0 spec/controllers/spud/user_sessions_controller_spec.rb
tb_core-0.9.19 spec/controllers/spud/user_sessions_controller_spec.rb
tb_core-0.9.18 spec/controllers/spud/user_sessions_controller_spec.rb
tb_core-0.9.17 spec/controllers/spud/user_sessions_controller_spec.rb
spud_core-0.9.17 spec/controllers/spud/user_sessions_controller_spec.rb