Sha256: b7adc0690b3e9939317555720c52c713a0295de01d67ee295c5e8de56c0e217c

Contents?: true

Size: 1.12 KB

Versions: 24

Compression:

Stored size: 1.12 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

24 entries across 15 versions & 4 rubygems

Version Path
kickoff-0.0.2 lib/generators/kickoff/authentication/templates/tests/testunit/sessions_controller.rb
nifty-generators-improved-0.5 lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.12 lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.12 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
nifty-generators-0.4.6 lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb
nifty-generators-0.4.6 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.11 lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.11 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.10 lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.10 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.9 lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.9 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
nifty-generators-0.4.5 lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb
nifty-generators-0.4.5 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.8 lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.8 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.7 lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.7 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.6 lib/generators/nifty/authentication/templates/tests/testunit/sessions_controller.rb
flockonus-nifty-generators-0.0.6 rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb