Sha256: 7564125554a91e7d56fb69018abbaae2bfac5cffd462dbd386fd7ce3958eab80

Contents?: true

Size: 1.13 KB

Versions: 19

Compression:

Stored size: 1.13 KB

Contents

require 'test_helper'

class <%= session_plural_class_name %>ControllerTest < ActionController::TestCase
  def test_new
    get :new
    assert_template 'new'
  end
  
<%- if options[:authlogic] -%>
  def test_create_invalid
    post :create, :<%= session_singular_name %> => { :username => "foo", :password => "badpassword" }
    assert_template 'new'
    assert_nil <%= session_class_name %>.find
  end
  
  def test_create_valid
    post :create, :<%= session_singular_name %> => { :username => "foo", :password => "secret" }
    assert_redirected_to root_url
    assert_equal <%= user_plural_name %>(:foo), <%= session_class_name %>.find.<%= user_singular_name %>
  end
<%- else -%>
  def test_create_invalid
    <%= user_class_name %>.stubs(:authenticate).returns(nil)
    post :create
    assert_template 'new'
    assert_nil session['<%= user_singular_name %>_id']
  end
  
  def test_create_valid
    <%= user_class_name %>.stubs(:authenticate).returns(<%= user_class_name %>.first)
    post :create
    assert_redirected_to root_url
    assert_equal <%= user_class_name %>.first.id, session['<%= user_singular_name %>_id']
  end
<%- end -%>
end

Version data entries

19 entries across 19 versions & 9 rubygems

Version Path
corntrace-nifty-generators-0.4.1 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
corntrace-nifty-generators-0.4.0 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
nifty-generators-0.4.0 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
splendeo-generators-0.3.1 rails_generators/splendeo_authentication/templates/tests/testunit/sessions_controller.rb
splendeo-generators-0.3.0 rails_generators/splendeo_authentication/templates/tests/testunit/sessions_controller.rb
splendeo-generators-0.2.1 rails_generators/splendeo_authentication/templates/tests/testunit/sessions_controller.rb
splendeo-generators-0.2.0 rails_generators/splendeo_authentication/templates/tests/testunit/sessions_controller.rb
splendeo-generators-0.1.3 rails_generators/splendeo_authentication/templates/tests/testunit/sessions_controller.rb
splendeo-generators-0.1.2 rails_generators/splendeo_authentication/templates/tests/testunit/sessions_controller.rb
splendeo-generators-0.1.1 rails_generators/splendeo_authentication/templates/tests/testunit/sessions_controller.rb
splendeo-generators-0.1.0 rails_generators/splendeo_authentication/templates/tests/testunit/sessions_controller.rb
splendeo-nifty-generators-0.3.2 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
nifty-generators-0.3.2 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
linki-nifty-generators-0.3.1 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
linki-nifty_generators-0.3.1 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
minerva-nifty-generators-0.3.0 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
xenda-nifty-generators-0.3.2 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
ghart-nifty-generators-0.3.0.1 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
nifty-generators-0.3.0 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb