rails3_devise_wizard 0.2.5 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +2 -2
- data/recipes/add_user.rb +87 -0
- data/recipes/add_user_name.rb +13 -16
- data/recipes/cucumber.rb +3 -6
- data/recipes/devise.rb +2 -5
- data/recipes/git.rb +1 -1
- data/recipes/haml.rb +1 -1
- data/recipes/home_page_users.rb +0 -1
- data/recipes/jquery.rb +2 -2
- data/recipes/navigation.rb +68 -0
- data/recipes/omniauth.rb +132 -6
- data/recipes/omniauth_email.rb +81 -0
- data/recipes/rspec.rb +13 -14
- data/recipes/seed_database.rb +11 -2
- data/recipes/users_page.rb +3 -1
- data/version.rb +1 -1
- metadata +7 -4
data/README.textile
CHANGED
@@ -205,8 +205,8 @@ RSpec, Cucumber, and Yard recipes were contributed by "Ramon Brooker":http://cog
|
|
205
205
|
|
206
206
|
Additional recipes by Daniel Kehoe, "http://danielkehoe.com/":http://danielkehoe.com/, to implement the "rails3-mongoid-devise":http://github.com/fortuity/rails3-mongoid-devise/ example application.
|
207
207
|
|
208
|
-
Is the gem useful to you? Follow
|
209
|
-
"http://twitter.com/
|
208
|
+
Is the gem useful to you? Follow the project on Twitter:
|
209
|
+
"http://twitter.com/rails_apps":http://twitter.com/rails_apps
|
210
210
|
and tweet some praise. I'd love to know you were helped out by the gem.
|
211
211
|
|
212
212
|
h2. License
|
data/recipes/add_user.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Application template recipe for the rails3_devise_wizard. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/add_user.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "AddUser recipe running 'after bundler'"
|
7
|
+
|
8
|
+
if recipes.include? 'omniauth'
|
9
|
+
generate(:model, "user provider:string uid:string name:string email:string")
|
10
|
+
gsub_file 'app/models/user.rb', /end/ do
|
11
|
+
<<-RUBY
|
12
|
+
attr_accessible :provider, :uid, :name, :email
|
13
|
+
end
|
14
|
+
RUBY
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
if recipes.include? 'devise'
|
19
|
+
|
20
|
+
# Generate models and routes for a User
|
21
|
+
generate 'devise user'
|
22
|
+
|
23
|
+
# Add a 'name' attribute to the User model
|
24
|
+
if recipes.include? 'mongoid'
|
25
|
+
gsub_file 'app/models/user.rb', /end/ do
|
26
|
+
<<-RUBY
|
27
|
+
field :name
|
28
|
+
validates_presence_of :name
|
29
|
+
validates_uniqueness_of :name, :email, :case_sensitive => false
|
30
|
+
attr_accessible :name, :email, :password, :password_confirmation, :remember_me
|
31
|
+
end
|
32
|
+
RUBY
|
33
|
+
end
|
34
|
+
else
|
35
|
+
# for ActiveRecord
|
36
|
+
# Devise created a Users database, we'll modify it
|
37
|
+
generate 'migration AddNameToUsers name:string'
|
38
|
+
# Devise created a Users model, we'll modify it
|
39
|
+
gsub_file 'app/models/user.rb', /attr_accessible :email/, 'attr_accessible :name, :email'
|
40
|
+
inject_into_file 'app/models/user.rb', :before => 'validates_uniqueness_of' do
|
41
|
+
"validates_presence_of :name\n"
|
42
|
+
end
|
43
|
+
gsub_file 'app/models/user.rb', /validates_uniqueness_of :email/, 'validates_uniqueness_of :name, :email'
|
44
|
+
end
|
45
|
+
|
46
|
+
unless recipes.include? 'haml'
|
47
|
+
|
48
|
+
# Generate Devise views (unless you are using Haml)
|
49
|
+
run 'rails generate devise:views'
|
50
|
+
|
51
|
+
# Modify Devise views to add 'name'
|
52
|
+
inject_into_file "app/views/devise/registrations/edit.html.erb", :after => "<%= devise_error_messages! %>\n" do
|
53
|
+
<<-ERB
|
54
|
+
<p><%= f.label :name %><br />
|
55
|
+
<%= f.text_field :name %></p>
|
56
|
+
ERB
|
57
|
+
end
|
58
|
+
|
59
|
+
inject_into_file "app/views/devise/registrations/new.html.erb", :after => "<%= devise_error_messages! %>\n" do
|
60
|
+
<<-ERB
|
61
|
+
<p><%= f.label :name %><br />
|
62
|
+
<%= f.text_field :name %></p>
|
63
|
+
ERB
|
64
|
+
end
|
65
|
+
|
66
|
+
else
|
67
|
+
|
68
|
+
# copy Haml versions of modified Devise views
|
69
|
+
inside 'app/views/devise/registrations' do
|
70
|
+
get 'https://github.com/fortuity/rails3-application-templates/raw/master/files/rails3-mongoid-devise/app/views/devise/registrations/edit.html.haml', 'edit.html.haml'
|
71
|
+
get 'https://github.com/fortuity/rails3-application-templates/raw/master/files/rails3-mongoid-devise/app/views/devise/registrations/new.html.haml', 'new.html.haml'
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
__END__
|
81
|
+
|
82
|
+
name: AddUser
|
83
|
+
description: "Add a User model including 'name' and 'email' attributes."
|
84
|
+
author: fortuity
|
85
|
+
|
86
|
+
category: other
|
87
|
+
tags: [utilities, configuration]
|
data/recipes/add_user_name.rb
CHANGED
@@ -14,21 +14,18 @@ after_bundler do
|
|
14
14
|
validates_uniqueness_of :name, :email, :case_sensitive => false
|
15
15
|
attr_accessible :name, :email, :password, :password_confirmation, :remember_me
|
16
16
|
end
|
17
|
-
RUBY
|
18
|
-
end
|
19
|
-
elsif recipes.include? 'mongo_mapper'
|
20
|
-
# Using MongoMapper? Create an issue, suggest some code, and I'll add it
|
21
|
-
elsif recipes.include? 'active_record'
|
22
|
-
gsub_file 'app/models/user.rb', /end/ do
|
23
|
-
<<-RUBY
|
24
|
-
validates_presence_of :name
|
25
|
-
validates_uniqueness_of :name, :email, :case_sensitive => false
|
26
|
-
attr_accessible :name, :email, :password, :password_confirmation, :remember_me
|
27
|
-
end
|
28
17
|
RUBY
|
29
18
|
end
|
30
19
|
else
|
31
|
-
#
|
20
|
+
# for ActiveRecord
|
21
|
+
# Devise created a Users database, we'll modify it
|
22
|
+
generate 'migration AddNameToUsers name:string'
|
23
|
+
# Devise created a Users model, we'll modify it
|
24
|
+
gsub_file 'app/models/user.rb', /attr_accessible :email/, 'attr_accessible :name, :email'
|
25
|
+
inject_into_file 'app/models/user.rb', :before => 'validates_uniqueness_of' do
|
26
|
+
"validates_presence_of :name\n"
|
27
|
+
end
|
28
|
+
gsub_file 'app/models/user.rb', /validates_uniqueness_of :email/, 'validates_uniqueness_of :name, :email'
|
32
29
|
end
|
33
30
|
|
34
31
|
if recipes.include? 'devise'
|
@@ -40,15 +37,15 @@ RUBY
|
|
40
37
|
# Modify Devise views to add 'name'
|
41
38
|
inject_into_file "app/views/devise/registrations/edit.html.erb", :after => "<%= devise_error_messages! %>\n" do
|
42
39
|
<<-ERB
|
43
|
-
|
44
|
-
|
40
|
+
<p><%= f.label :name %><br />
|
41
|
+
<%= f.text_field :name %></p>
|
45
42
|
ERB
|
46
43
|
end
|
47
44
|
|
48
45
|
inject_into_file "app/views/devise/registrations/new.html.erb", :after => "<%= devise_error_messages! %>\n" do
|
49
46
|
<<-ERB
|
50
|
-
|
51
|
-
|
47
|
+
<p><%= f.label :name %><br />
|
48
|
+
<%= f.text_field :name %></p>
|
52
49
|
ERB
|
53
50
|
end
|
54
51
|
|
data/recipes/cucumber.rb
CHANGED
@@ -3,11 +3,8 @@
|
|
3
3
|
|
4
4
|
if config['cucumber']
|
5
5
|
gem 'cucumber-rails', ">= 0.4.1", :group => :test
|
6
|
-
gem 'capybara', ">= 0.
|
7
|
-
|
8
|
-
# we already added database_cleaner if we ran the rspec recipe
|
9
|
-
gem 'database_cleaner', '>= 0.6.6', :group => :test
|
10
|
-
end
|
6
|
+
gem 'capybara', ">= 1.0.0.beta1", :group => :test
|
7
|
+
gem 'database_cleaner', '>= 0.6.7', :group => :test
|
11
8
|
gem 'launchy', ">= 0.4.0", :group => :test
|
12
9
|
else
|
13
10
|
recipes.delete('cucumber')
|
@@ -16,7 +13,7 @@ end
|
|
16
13
|
if config['cucumber']
|
17
14
|
after_bundler do
|
18
15
|
say_wizard "Cucumber recipe running 'after bundler'"
|
19
|
-
generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D'
|
16
|
+
generate "cucumber:install --capybara#{' --rspec' if recipes.include?('rspec')}#{' -D' if recipes.include?('mongoid')}"
|
20
17
|
if recipes.include? 'mongoid'
|
21
18
|
gsub_file 'features/support/env.rb', /transaction/, "truncation"
|
22
19
|
inject_into_file 'features/support/env.rb', :after => 'begin' do
|
data/recipes/devise.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/devise.rb
|
3
3
|
|
4
4
|
if config['devise']
|
5
|
-
gem "devise", ">= 1.3.
|
5
|
+
gem "devise", ">= 1.3.3"
|
6
6
|
else
|
7
7
|
recipes.delete('devise')
|
8
8
|
end
|
@@ -24,13 +24,10 @@ if config['devise']
|
|
24
24
|
# Nothing to do (Devise changes its initializer automatically when Mongoid is detected)
|
25
25
|
# gsub_file 'config/initializers/devise.rb', 'devise/orm/active_record', 'devise/orm/mongoid'
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
# Prevent logging of password_confirmation
|
29
29
|
gsub_file 'config/application.rb', /:password/, ':password, :password_confirmation'
|
30
30
|
|
31
|
-
# Generate models and routes for a User
|
32
|
-
generate 'devise user'
|
33
|
-
|
34
31
|
end
|
35
32
|
|
36
33
|
after_everything do
|
data/recipes/git.rb
CHANGED
@@ -9,7 +9,7 @@ after_everything do
|
|
9
9
|
# Initialize new Git repo
|
10
10
|
git :init
|
11
11
|
git :add => '.'
|
12
|
-
git :commit => "-aqm '
|
12
|
+
git :commit => "-aqm 'new Rails app generated by rails3_devise_wizard'"
|
13
13
|
# Create a git branch
|
14
14
|
git :checkout => ' -b working_branch'
|
15
15
|
git :add => '.'
|
data/recipes/haml.rb
CHANGED
data/recipes/home_page_users.rb
CHANGED
data/recipes/jquery.rb
CHANGED
@@ -16,9 +16,9 @@ if config['jquery']
|
|
16
16
|
# add jQuery files
|
17
17
|
inside "public/javascripts" do
|
18
18
|
get "https://github.com/rails/jquery-ujs/raw/master/src/rails.js", "rails.js"
|
19
|
-
get "
|
19
|
+
get "http://code.jquery.com/jquery-1.6.min.js", "jquery.js"
|
20
20
|
if config['ui']
|
21
|
-
get "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.
|
21
|
+
get "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js", "jqueryui.js"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
# adjust the Javascript defaults
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# Application template recipe for the rails3_devise_wizard. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/navigation.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "Navigation recipe running 'after bundler'"
|
7
|
+
|
8
|
+
# Create navigation links
|
9
|
+
if recipes.include? 'haml'
|
10
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
11
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
12
|
+
create_file "app/views/shared/_navigation.html.haml" do <<-'HAML'
|
13
|
+
- if user_signed_in?
|
14
|
+
%li
|
15
|
+
Logged in as #{current_user.name}
|
16
|
+
%li
|
17
|
+
= link_to('Logout', signout_path)
|
18
|
+
- else
|
19
|
+
%li
|
20
|
+
= link_to('Login', signin_path)
|
21
|
+
HAML
|
22
|
+
end
|
23
|
+
else
|
24
|
+
create_file "app/views/shared/_navigation.html.erb" do <<-ERB
|
25
|
+
<% if user_signed_in? %>
|
26
|
+
<li>
|
27
|
+
Logged in as <%= current_user.name %>
|
28
|
+
</li>
|
29
|
+
<li>
|
30
|
+
<%= link_to('Logout', signout_path) %>
|
31
|
+
</li>
|
32
|
+
<% else %>
|
33
|
+
<li>
|
34
|
+
<%= link_to('Login', signin_path) %>
|
35
|
+
</li>
|
36
|
+
<% end %>
|
37
|
+
ERB
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Add navigation links to the default application layout
|
42
|
+
if recipes.include? 'haml'
|
43
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
44
|
+
inject_into_file 'app/views/layouts/application.html.haml', :after => "%body\n" do <<-HAML
|
45
|
+
%ul.hmenu
|
46
|
+
= render 'shared/navigation'
|
47
|
+
HAML
|
48
|
+
end
|
49
|
+
else
|
50
|
+
inject_into_file 'app/views/layouts/application.html.erb', :after => "<body>\n" do
|
51
|
+
<<-ERB
|
52
|
+
<ul class="hmenu">
|
53
|
+
<%= render 'shared/navigation' %>
|
54
|
+
</ul>
|
55
|
+
ERB
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
__END__
|
62
|
+
|
63
|
+
name: Navigation
|
64
|
+
description: "Add navigation links."
|
65
|
+
author: fortuity
|
66
|
+
|
67
|
+
category: other
|
68
|
+
tags: [utilities, configuration]
|
data/recipes/omniauth.rb
CHANGED
@@ -1,15 +1,141 @@
|
|
1
|
-
|
1
|
+
# Application template recipe for the rails3_devise_wizard. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/omniauth.rb
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
if config['omniauth']
|
5
|
+
gem 'omniauth', '>= 0.2.4'
|
6
|
+
else
|
7
|
+
recipes.delete('omniauth')
|
8
|
+
end
|
9
|
+
|
10
|
+
if config['omniauth']
|
11
|
+
after_bundler do
|
12
|
+
|
13
|
+
create_file 'config/initializers/omniauth.rb', <<-RUBY
|
14
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
15
|
+
provider :provider, 'KEY', 'SECRET'
|
16
|
+
end
|
17
|
+
RUBY
|
18
|
+
end
|
19
|
+
|
20
|
+
append_file '.gitignore' do <<-TXT
|
21
|
+
\n
|
22
|
+
# keep OmniAuth service provider secrets out of the Git repo
|
23
|
+
config/initializers/omniauth.rb
|
24
|
+
TXT
|
25
|
+
end
|
26
|
+
|
27
|
+
inject_into_file 'config/routes.rb', :before => 'end' do
|
28
|
+
"resources :users, :only => [ :show, :edit, :update ]\n"
|
29
|
+
end
|
30
|
+
inject_into_file 'config/routes.rb', :before => 'end' do
|
31
|
+
"match '/auth/:provider/callback' => 'sessions#create'\n"
|
32
|
+
end
|
33
|
+
inject_into_file 'config/routes.rb', :before => 'end' do
|
34
|
+
"match '/signout' => 'sessions#destroy', :as => :signout\n"
|
35
|
+
end
|
36
|
+
inject_into_file 'config/routes.rb', :before => 'end' do
|
37
|
+
"match '/signin' => 'sessions#new', :as => :signin\n"
|
38
|
+
end
|
39
|
+
inject_into_file 'config/routes.rb', :before => 'end' do
|
40
|
+
"match '/auth/failure' => 'sessions#failure'\n"
|
41
|
+
end
|
42
|
+
|
43
|
+
inject_into_file 'app/models/user.rb', :before => 'end' do <<-RUBY
|
44
|
+
def self.create_with_omniauth(auth)
|
45
|
+
create! do |user|
|
46
|
+
user.provider = auth['provider']
|
47
|
+
user.uid = auth['uid']
|
48
|
+
user.name = auth['user_info']['name'] if auth['user_info']['name'] # Twitter, Google, Yahoo, GitHub
|
49
|
+
user.email = auth['user_info']['email'] if auth['user_info']['email'] # Google, Yahoo, GitHub
|
50
|
+
user.name = auth['extra']['user_hash']['name'] if auth['extra']['user_hash']['name'] # Facebook
|
51
|
+
user.email = auth['extra']['user_hash']['email'] if auth['extra']['user_hash']['email'] # Facebook
|
52
|
+
end
|
53
|
+
end
|
54
|
+
RUBY
|
55
|
+
end
|
56
|
+
|
57
|
+
create_file 'app/controllers/sessions_controller.rb', <<-RUBY
|
58
|
+
class SessionsController < ApplicationController
|
59
|
+
|
60
|
+
def new
|
61
|
+
redirect_to '/auth/provider}'
|
62
|
+
end
|
63
|
+
|
64
|
+
def create
|
65
|
+
auth = request.env["omniauth.auth"]
|
66
|
+
user = User.where(:provider => auth['provider'],
|
67
|
+
:uid => auth['uid']).first || User.create_with_omniauth(auth)
|
68
|
+
session[:user_id] = user.id
|
69
|
+
if !user.email
|
70
|
+
redirect_to edit_user_path(user), :alert => "Please enter your email address."
|
71
|
+
else
|
72
|
+
redirect_to root_url, :notice => 'Signed in!'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def destroy
|
77
|
+
session[:user_id] = nil
|
78
|
+
redirect_to root_url, :notice => 'Signed out!'
|
79
|
+
end
|
80
|
+
|
81
|
+
def failure
|
82
|
+
redirect_to root_url, :alert => "Authentication error: #{params[:message].humanize}"
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
RUBY
|
87
|
+
end
|
88
|
+
|
89
|
+
inject_into_file 'app/controllers/application_controller.rb', :before => 'end' do <<-RUBY
|
90
|
+
helper_method :current_user
|
91
|
+
helper_method :user_signed_in?
|
92
|
+
helper_method :correct_user?
|
93
|
+
|
94
|
+
private
|
95
|
+
def current_user
|
96
|
+
begin
|
97
|
+
@current_user ||= User.find(session[:user_id]) if session[:user_id]
|
98
|
+
rescue Mongoid::Errors::DocumentNotFound
|
99
|
+
nil
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def user_signed_in?
|
104
|
+
return true if current_user
|
105
|
+
end
|
106
|
+
|
107
|
+
def correct_user?
|
108
|
+
@user = User.find(params[:id])
|
109
|
+
unless current_user == @user
|
110
|
+
redirect_to root_url, :alert => "Access denied."
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def authenticate_user!
|
115
|
+
if !current_user
|
116
|
+
redirect_to root_url, :alert => 'You need to sign in for access to this page.'
|
117
|
+
end
|
118
|
+
end
|
119
|
+
RUBY
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
6
123
|
end
|
7
124
|
|
8
125
|
__END__
|
9
126
|
|
10
127
|
name: OmniAuth
|
11
|
-
description: "
|
12
|
-
author:
|
128
|
+
description: "Utilize OmniAuth for authentication."
|
129
|
+
author: fortuity
|
13
130
|
|
14
131
|
exclusive: authentication
|
15
132
|
category: authentication
|
133
|
+
|
134
|
+
config:
|
135
|
+
- omniauth:
|
136
|
+
type: boolean
|
137
|
+
prompt: Would you like to use OmniAuth for authentication?
|
138
|
+
- provider:
|
139
|
+
type: multiple_choice
|
140
|
+
prompt: "Which service provider will you use?"
|
141
|
+
choices: [["Twitter", twitter], ["Facebook", facebook], ["GitHub", github], ["LinkedIn", linked_in], ["Other", provider]]
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# Application template recipe for the rails3_devise_wizard. Check for a newer version here:
|
2
|
+
# https://github.com/fortuity/rails3_devise_wizard/blob/master/recipes/omniauth_email.rb
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
|
6
|
+
say_wizard "OmniAuthEmail recipe running 'after bundler'"
|
7
|
+
|
8
|
+
#----------------------------------------------------------------------------
|
9
|
+
# Modify a users controller
|
10
|
+
#----------------------------------------------------------------------------
|
11
|
+
inject_into_file 'app/controllers/users_controller.rb', :after => "before_filter :authenticate_user!\n" do <<-RUBY
|
12
|
+
before_filter :correct_user?\n
|
13
|
+
RUBY
|
14
|
+
end
|
15
|
+
|
16
|
+
inject_into_file 'app/controllers/users_controller.rb', :before => 'end' do <<-RUBY
|
17
|
+
def edit
|
18
|
+
@user = User.find(params[:id])
|
19
|
+
end
|
20
|
+
|
21
|
+
def update
|
22
|
+
@user = User.find(params[:id])
|
23
|
+
if @user.update_attributes(params[:user])
|
24
|
+
redirect_to @user
|
25
|
+
else
|
26
|
+
render :edit
|
27
|
+
end
|
28
|
+
end
|
29
|
+
RUBY
|
30
|
+
end
|
31
|
+
|
32
|
+
#----------------------------------------------------------------------------
|
33
|
+
# Create a users edit page
|
34
|
+
#----------------------------------------------------------------------------
|
35
|
+
if recipes.include? 'haml'
|
36
|
+
remove_file 'app/views/users/edit.html.haml'
|
37
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
38
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
39
|
+
create_file 'app/views/users/edit.html.haml' do <<-'HAML'
|
40
|
+
= form_for(@user) do |f|
|
41
|
+
= f.label :email
|
42
|
+
= f.text_field :email
|
43
|
+
%br/
|
44
|
+
= f.submit "Sign in"
|
45
|
+
HAML
|
46
|
+
end
|
47
|
+
else
|
48
|
+
create_file 'app/views/users/edit.html.erb' do <<-ERB
|
49
|
+
<%= form_for(@user) do |f| %>
|
50
|
+
<%= f.label :email %>
|
51
|
+
<%= f.text_field :email %>
|
52
|
+
<br />
|
53
|
+
<%= f.submit "Sign in" %>
|
54
|
+
<% end %>
|
55
|
+
ERB
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
#----------------------------------------------------------------------------
|
60
|
+
# Modify a Sessions controller
|
61
|
+
#----------------------------------------------------------------------------
|
62
|
+
gsub_file 'app/controllers/sessions_controller.rb', /redirect_to root_url, :notice => 'Signed in!'/ do
|
63
|
+
<<-RUBY
|
64
|
+
if !user.email
|
65
|
+
redirect_to edit_user_path(user), :alert => "Please enter your email address."
|
66
|
+
else
|
67
|
+
redirect_to root_url, :notice => 'Signed in!'
|
68
|
+
end
|
69
|
+
RUBY
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
__END__
|
75
|
+
|
76
|
+
name: OmniAuthEmail
|
77
|
+
description: "Request a user's email address for an OmniAuth example app."
|
78
|
+
author: fortuity
|
79
|
+
|
80
|
+
category: other
|
81
|
+
tags: [utilities, configuration]
|
data/recipes/rspec.rb
CHANGED
@@ -7,9 +7,9 @@ if config['rspec']
|
|
7
7
|
gem 'rspec-rails', '>= 2.5.0', :group => [:development, :test]
|
8
8
|
if recipes.include? 'mongoid'
|
9
9
|
# use the database_cleaner gem to reset the test database
|
10
|
-
gem 'database_cleaner', '>= 0.6.
|
10
|
+
gem 'database_cleaner', '>= 0.6.7', :group => :test
|
11
11
|
# include RSpec matchers from the mongoid-rspec gem
|
12
|
-
gem 'mongoid-rspec', ">= 1.4.
|
12
|
+
gem 'mongoid-rspec', ">= 1.4.2", :group => :test
|
13
13
|
end
|
14
14
|
if config['factory_girl']
|
15
15
|
# use the factory_girl gem for test fixtures
|
@@ -25,12 +25,16 @@ if config['rspec']
|
|
25
25
|
after_bundler do
|
26
26
|
say_wizard "RSpec recipe running 'after bundler'"
|
27
27
|
generate 'rspec:install'
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures/, '# config.use_transactional_fixtures'
|
28
|
+
|
29
|
+
say_wizard "Removing test folder (not needed for RSpec)"
|
30
|
+
run 'rm -rf test/'
|
32
31
|
|
33
32
|
if recipes.include? 'mongoid'
|
33
|
+
|
34
|
+
# remove ActiveRecord artifacts
|
35
|
+
gsub_file 'spec/spec_helper.rb', /config.fixture_path/, '# config.fixture_path'
|
36
|
+
gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures/, '# config.use_transactional_fixtures'
|
37
|
+
|
34
38
|
# reset your application database to a pristine state during testing
|
35
39
|
inject_into_file 'spec/spec_helper.rb', :before => "\nend" do
|
36
40
|
<<-RUBY
|
@@ -47,16 +51,11 @@ if config['rspec']
|
|
47
51
|
end
|
48
52
|
RUBY
|
49
53
|
end
|
50
|
-
end
|
51
|
-
|
52
|
-
# remove either possible occurrence of "require rails/test_unit/railtie"
|
53
|
-
gsub_file 'config/application.rb', /require 'rails\/test_unit\/railtie'/, '# require "rails/test_unit/railtie"'
|
54
|
-
gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"'
|
55
54
|
|
56
|
-
|
57
|
-
|
55
|
+
# remove either possible occurrence of "require rails/test_unit/railtie"
|
56
|
+
gsub_file 'config/application.rb', /require 'rails\/test_unit\/railtie'/, '# require "rails/test_unit/railtie"'
|
57
|
+
gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"'
|
58
58
|
|
59
|
-
if recipes.include? 'mongoid'
|
60
59
|
# configure RSpec to use matchers from the mongoid-rspec gem
|
61
60
|
create_file 'spec/support/mongoid.rb' do
|
62
61
|
<<-RUBY
|
data/recipes/seed_database.rb
CHANGED
@@ -6,11 +6,21 @@ after_bundler do
|
|
6
6
|
|
7
7
|
say_wizard "SeedDatabase recipe running 'after bundler'"
|
8
8
|
|
9
|
+
unless recipes.include? 'mongoid'
|
10
|
+
run 'rake db:migrate'
|
11
|
+
end
|
12
|
+
|
9
13
|
if recipes.include? 'mongoid'
|
10
|
-
# create a default user
|
11
14
|
append_file 'db/seeds.rb' do <<-FILE
|
12
15
|
puts 'EMPTY THE MONGODB DATABASE'
|
13
16
|
Mongoid.master.collections.reject { |c| c.name =~ /^system/}.each(&:drop)
|
17
|
+
FILE
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if recipes.include? 'devise'
|
22
|
+
# create a default user
|
23
|
+
append_file 'db/seeds.rb' do <<-FILE
|
14
24
|
puts 'SETTING UP DEFAULT USER LOGIN'
|
15
25
|
user = User.create! :name => 'First User', :email => 'user@test.com', :password => 'please', :password_confirmation => 'please'
|
16
26
|
puts 'New user created: ' << user.name
|
@@ -28,6 +38,5 @@ name: SeedDatabase
|
|
28
38
|
description: "Create a database seed file with a default user."
|
29
39
|
author: fortuity
|
30
40
|
|
31
|
-
requires: [devise]
|
32
41
|
category: other
|
33
42
|
tags: [utilities, configuration]
|
data/recipes/users_page.rb
CHANGED
@@ -40,11 +40,14 @@ RUBY
|
|
40
40
|
create_file 'app/views/users/show.html.haml' do <<-'HAML'
|
41
41
|
%p
|
42
42
|
User: #{@user.name}
|
43
|
+
%p
|
44
|
+
Email: #{@user.email if @user.email}
|
43
45
|
HAML
|
44
46
|
end
|
45
47
|
else
|
46
48
|
append_file 'app/views/users/show.html.erb' do <<-ERB
|
47
49
|
<p>User: <%= @user.name %></p>
|
50
|
+
<p>Email: <%= @user.email if @user.email %></p>
|
48
51
|
ERB
|
49
52
|
end
|
50
53
|
end
|
@@ -96,6 +99,5 @@ name: UsersPage
|
|
96
99
|
description: "Add a users controller and user show page with links from the home page."
|
97
100
|
author: fortuity
|
98
101
|
|
99
|
-
requires: [devise]
|
100
102
|
category: other
|
101
103
|
tags: [utilities, configuration]
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rails3_devise_wizard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.8
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Daniel Kehoe
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-05-05 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: i18n
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/rails_wizard.rb
|
108
108
|
- recipes/action_mailer.rb
|
109
109
|
- recipes/activerecord.rb
|
110
|
+
- recipes/add_user.rb
|
110
111
|
- recipes/add_user_name.rb
|
111
112
|
- recipes/application_layout.rb
|
112
113
|
- recipes/ban_spiders.rb
|
@@ -130,7 +131,9 @@ files:
|
|
130
131
|
- recipes/mongohq.rb
|
131
132
|
- recipes/mongoid.rb
|
132
133
|
- recipes/mootools.rb
|
134
|
+
- recipes/navigation.rb
|
133
135
|
- recipes/omniauth.rb
|
136
|
+
- recipes/omniauth_email.rb
|
134
137
|
- recipes/pow.rb
|
135
138
|
- recipes/prototype.rb
|
136
139
|
- recipes/rails_admin.rb
|
@@ -172,7 +175,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
172
175
|
requirements:
|
173
176
|
- - ">="
|
174
177
|
- !ruby/object:Gem::Version
|
175
|
-
hash: -
|
178
|
+
hash: -2109356593565776162
|
176
179
|
segments:
|
177
180
|
- 0
|
178
181
|
version: "0"
|
@@ -181,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
184
|
requirements:
|
182
185
|
- - ">="
|
183
186
|
- !ruby/object:Gem::Version
|
184
|
-
hash: -
|
187
|
+
hash: -2109356593565776162
|
185
188
|
segments:
|
186
189
|
- 0
|
187
190
|
version: "0"
|