-
Notifications
You must be signed in to change notification settings - Fork 0
Organization
Clearance works by mixing behavior into tests, controllers, and models. For any file that you do not want to overwrite, include the corresponding Clearance module. They are namespaced exactly like the directory structure of a Rails app.
Application controller example:
class ApplicationController < ActionController::Base include Clearance::App::Controllers::ApplicationController endUser model example:
class User < ActiveRecord::Base include Clearance::App::Models::User endUser test example:
class UserTest < Test::Unit::TestCase include Clearance::Test::Unit::UserTest endThe generator will also create a migration to add a “users” table and run it. If the table already exists in the database, the migration will just add fields and indexes that are missing and required by Clearance. If the migration fails, the generator will revert all changes back.
Clearance will add these routes:
Users:
get ‘users/new’ post ‘users’Confirmations:
get ‘users/:user_id/confirmation/new’ post ‘users/:user_id/confirmation’Session:
get ‘session/new’ post ‘session’ delete ‘session’Passwords:
get ‘users/:user_id/password/new’ post ‘users/:user_id/password’ get ‘users/:user_id/password/edit’ put ‘users/:user_id/password’Please note that Clearance depends on root_url, so please make sure that it is defined to something in your config/routes.rb:
map.root :controller => ‘home’Please note that Clearance depends on root_url, so please make sure that it is defined to something in your config/routes.rb:
map.root :controller => ‘users’, :action => ‘new’You will need to display the success, failure, and notice flash messages in your layout. We recommend creating an app/layouts/_flashes.html.erb partial similar to the _flashes partial in Suspenders:
<div id="flash">
<% flash.each do |key, value| -%>
<div id="flash_<%= key -%>"><%= html_escape(value) %></div>
<% end -%>
</div>
which is then rendered inside the body tag of your application layout:
<%= render :partial => ‘layouts/flashes’ -%>The tests use Factory Girl >= 1.2.0.
The generator will create a user factory in test/factories/clearance.rb.