Sha256: f3e03df1a9e1045c7c58f789aefcac4826eb32e7ca08e0564d16cff99c370352

Contents?: true

Size: 1.44 KB

Versions: 11

Compression:

Stored size: 1.44 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'

describe <%= session_plural_class_name %>Controller do
  fixtures :all
  render_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

11 entries across 11 versions & 4 rubygems

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