Skip to content

Commit

Permalink
convert to a rails 3 engines, routes, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad Pytel committed Jun 9, 2010
1 parent 395b589 commit c347cd2
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 78 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ test/rails_root/log/*.log
*.swp
.rake_tasks
test/rails_root/*
test/rails3_root
!test/rails_root/vendor/gems/justinfrench-formtastic-0.2.1
*.gem
7 changes: 3 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace :test do
"generator:clearance"]) do |task|
task.libs << "lib"
task.libs << "test"
task.pattern = "test/**/user_test.rb"
task.pattern = "test/**/*_test.rb"
task.verbose = false
end

Expand Down Expand Up @@ -55,13 +55,12 @@ namespace :generator do
FileUtils.mkdir_p("test/rails3_root/vendor/plugins")
clearance_root = File.expand_path(File.dirname(__FILE__))
system("ln -s #{clearance_root} test/rails3_root/vendor/plugins/clearance")
FileUtils.rm_rf("test/rails3_root/features")
end

desc "Run the clearance generator"
task :clearance do
clearance_command = "cd test/rails3_root && ./script/rails generate clearance && rake db:migrate db:test:prepare"
p clearance_command
system clearance_command
system "cd test/rails3_root && ./script/rails generate clearance && rake db:migrate db:test:prepare"
end

desc "Run the clearance features generator"
Expand Down
30 changes: 30 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Rails.application.routes.draw do |map|
map.resources :passwords,
:controller => 'clearance/passwords',
:only => [:new, :create]

map.resource :session,
:controller => 'clearance/sessions',
:only => [:new, :create, :destroy]

map.resources :users, :controller => 'clearance/users' do |users|
users.resource :password,
:controller => 'clearance/passwords',
:only => [:create, :edit, :update]

users.resource :confirmation,
:controller => 'clearance/confirmations',
:only => [:new, :create]
end

map.sign_up 'sign_up',
:controller => 'clearance/users',
:action => 'new'
map.sign_in 'sign_in',
:controller => 'clearance/sessions',
:action => 'new'
map.sign_out 'sign_out',
:controller => 'clearance/sessions',
:action => 'destroy',
:method => :delete
end
3 changes: 2 additions & 1 deletion lib/clearance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'clearance/extensions/rescue'

require 'clearance/configuration'
require 'clearance/routes'
require 'clearance/authentication'
require 'clearance/user'

require 'clearance/engine'
8 changes: 8 additions & 0 deletions lib/clearance/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "clearance"
require "rails"

module Clearance
class Engine < Rails::Engine
engine_name :clearance
end
end
49 changes: 0 additions & 49 deletions lib/clearance/routes.rb

This file was deleted.

11 changes: 11 additions & 0 deletions lib/rails/generators/clearance_features_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ClearanceFeaturesGenerator < Rails::Generators::Base
desc "Put the clearance features in place"

def self.source_root
@_clearance_source_root ||= File.expand_path("../../../../../../../../../generators/clearance_features/templates", __FILE__)
end

def install
directory "features"
end
end
2 changes: 0 additions & 2 deletions lib/rails/generators/clearance_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def install
template "user.rb", user_model
end

route "Clearance::Routes.draw(map)"

template "factories.rb", "test/factories/clearance.rb"

migration_template "migrations/#{migration_source_name}.rb",
Expand Down
3 changes: 2 additions & 1 deletion test/rails3_root/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Rails3Root::Application.routes.draw do |map|
Clearance::Routes.draw(map)
map.resource :account
map.root :controller => 'accounts', :action => 'edit'

# The priority is based upon order of creation:
# first created -> highest priority.
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion test/rails3_root/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20100609194816) do
ActiveRecord::Schema.define(:version => 20100609202802) do

create_table "users", :force => true do |t|
t.string "email"
Expand Down

0 comments on commit c347cd2

Please sign in to comment.