Skip to content
ultrasaurus edited this page Feb 1, 2012 · 9 revisions
  1. Run a test rake spec

spec/requests/user_spec.rb

describe "existing user", :js => true do

it "should see sign in link on the home page" do visit '/' page.should have_link("Sign In") end

it "should see be able to sign in from the home page" do visit '/' click_link("Sign In") current_path.should == new_user_session_path end

    • create a new directory "menu" under "views/devise/menu/"
  • create a new file, call it: "views/devise/menu/_login_items.html.erb"

file content:
<% if user_signed_in? %>

  • <%= link_to('Logout', destroy_user_session_path, :method => :delete) %>
  • <% else %>
  • <%= link_to('Login', new_user_session_path) %>
  • <% end %>

    as described in: https://github.com/plataformatec/devise/wiki/How-To:-Add-sign_in,-sign_out,-and-sign_up-links-to-your-layout-template

    1. Add to the file: views/layout/application.html.erb the following content: Add it inside the body tag, right at the top of the tag: <%= render :partial => 'devise/menu/login_items' %>

    2. Run another test rake spec