Sha256: 59d08767e7aac1bd123130383e498a4bce5a4572410390d476351a4f38d83c9d

Contents?: true

Size: 1.46 KB

Versions: 19

Compression:

Stored size: 1.46 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'
 
describe <%= session_plural_class_name %>Controller do
  fixtures :all
  integrate_views
  
  it "new action should render new template" do
    get :new
    response.should render_template(:new)
  end
  
<%- if options[:authlogic] -%>
  it "create action should render new template when authentication is invalid" do
    post :create, :<%= session_singular_name %> => { :username => "foo", :password => "badpassword" }
    response.should render_template(:new)
    <%= session_class_name %>.find.should be_nil
  end
  
  it "create action should redirect when authentication is valid" do
    post :create, :<%= session_singular_name %> => { :username => "foo", :password => "secret" }
    response.should redirect_to(root_url)
    <%= session_class_name %>.find.<%= user_singular_name %>.should == <%= user_plural_name %>(:foo)
  end
<%- else -%>
  it "create action should render new template when authentication is invalid" do
    <%= user_class_name %>.stubs(:authenticate).returns(nil)
    post :create
    response.should render_template(:new)
    session['<%= user_singular_name %>_id'].should be_nil
  end
  
  it "create action should redirect when authentication is valid" do
    <%= user_class_name %>.stubs(:authenticate).returns(<%= user_class_name %>.first)
    post :create
    response.should redirect_to(root_url)
    session['<%= user_singular_name %>_id'].should == <%= user_class_name %>.first.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/rspec/sessions_controller.rb
corntrace-nifty-generators-0.4.0 rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb
nifty-generators-0.4.0 rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb
splendeo-generators-0.3.1 rails_generators/splendeo_authentication/templates/tests/rspec/sessions_controller.rb
splendeo-generators-0.3.0 rails_generators/splendeo_authentication/templates/tests/rspec/sessions_controller.rb
splendeo-generators-0.2.1 rails_generators/splendeo_authentication/templates/tests/rspec/sessions_controller.rb
splendeo-generators-0.2.0 rails_generators/splendeo_authentication/templates/tests/rspec/sessions_controller.rb
splendeo-generators-0.1.3 rails_generators/splendeo_authentication/templates/tests/rspec/sessions_controller.rb
splendeo-generators-0.1.2 rails_generators/splendeo_authentication/templates/tests/rspec/sessions_controller.rb
splendeo-generators-0.1.1 rails_generators/splendeo_authentication/templates/tests/rspec/sessions_controller.rb
splendeo-generators-0.1.0 rails_generators/splendeo_authentication/templates/tests/rspec/sessions_controller.rb
splendeo-nifty-generators-0.3.2 rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb
nifty-generators-0.3.2 rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb
linki-nifty-generators-0.3.1 rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb
linki-nifty_generators-0.3.1 rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb
minerva-nifty-generators-0.3.0 rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb
xenda-nifty-generators-0.3.2 rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb
ghart-nifty-generators-0.3.0.1 rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb
nifty-generators-0.3.0 rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb