happy_seed 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +4 -69
- data/bin/rails +12 -0
- data/bin/rspec +16 -0
- data/happy_seed.rb +5 -1
- data/happy_seed.txt +25 -18
- data/lib/generators/happy_seed/admin/admin_generator.rb +40 -5
- data/lib/generators/happy_seed/admin/templates/app/admin/campaigns.rb +10 -14
- data/lib/generators/happy_seed/admin/templates/app/admin/newsletter.rb +2 -2
- data/lib/generators/happy_seed/admin/templates/app/admin/user.rb +4 -1
- data/lib/generators/happy_seed/admin/templates/app/controllers/admin/stats_controller.rb +1 -1
- data/lib/generators/happy_seed/admin/templates/docs/README.07.admin.rdoc +33 -4
- data/lib/generators/happy_seed/angular_view/templates/docs/README.11.angular_view.rdoc +2 -4
- data/lib/generators/happy_seed/api/api_generator.rb +38 -39
- data/lib/generators/happy_seed/api/templates/app/controllers/api/v1/base_controller.rb +4 -5
- data/lib/generators/happy_seed/api/templates/app/controllers/api/v1/model_hash.rb +3 -20
- data/lib/generators/happy_seed/api/templates/app/controllers/api/v1/user_tokens_controller.rb +13 -36
- data/lib/generators/happy_seed/api/templates/app/controllers/api/v1/users_controller.rb +14 -40
- data/lib/generators/happy_seed/api/templates/config/initializers/apitome.rb +1 -1
- data/lib/generators/happy_seed/api/templates/docs/README.01.api.rdoc +4 -1
- data/lib/generators/happy_seed/api/templates/docs/api.md +2 -2
- data/lib/generators/happy_seed/api/templates/spec/acceptance/api/v1/user_tokens_spec.rb +10 -53
- data/lib/generators/happy_seed/api/templates/spec/acceptance/api/v1/users_spec.rb +17 -61
- data/lib/generators/happy_seed/base/base_generator.rb +47 -19
- data/lib/generators/happy_seed/base/templates/app/controllers/setup_controller.rb +1 -1
- data/lib/generators/happy_seed/base/templates/app/views/setup/index.html.haml +6 -3
- data/lib/generators/happy_seed/base/templates/application_controller.rb +1 -1
- data/lib/generators/happy_seed/base/templates/docs/README.00.base.rdoc +3 -3
- data/lib/generators/happy_seed/bootstrap/bootstrap_generator.rb +5 -2
- data/lib/generators/happy_seed/bootstrap/templates/app/assets/stylesheets/application.scss +5 -1
- data/lib/generators/happy_seed/bootstrap/templates/app/assets/stylesheets/components/_profile_panels.scss +62 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/assets/stylesheets/components/_slideup_header.scss +51 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/assets/stylesheets/shared/_grid.scss +0 -12
- data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_javascripts.html.haml +7 -4
- data/lib/generators/happy_seed/bootstrap/templates/docs/README.01.bootstrap.rdoc +3 -0
- data/lib/generators/happy_seed/ckeditor/ckeditor_generator.rb +31 -0
- data/lib/generators/happy_seed/ckeditor/templates/docs/README.01.ckeditor.rdoc +35 -0
- data/lib/generators/happy_seed/devise/devise_generator.rb +12 -19
- data/lib/generators/happy_seed/devise/templates/app/views/devise/confirmations/new.html.haml +17 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/mailer/confirmation_instructions.html.erb +14 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/mailer/confirmation_instructions.text.rhtml +7 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/mailer/password_change.html.erb +3 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/mailer/reset_password_instructions.html.erb +15 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/mailer/reset_password_instructions.text.erb +11 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/passwords/edit.html.haml +14 -13
- data/lib/generators/happy_seed/devise/templates/app/views/devise/passwords/new.html.haml +12 -16
- data/lib/generators/happy_seed/devise/templates/app/views/devise/registrations/edit.html.haml +28 -40
- data/lib/generators/happy_seed/devise/templates/app/views/devise/registrations/new.html.haml +16 -24
- data/lib/generators/happy_seed/devise/templates/app/views/devise/sessions/new.html.haml +13 -18
- data/lib/generators/happy_seed/devise/templates/app/views/devise/shared/_links.html.erb +25 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/unlocks/new.html.erb +16 -0
- data/lib/generators/happy_seed/devise/templates/docs/README.03.devise.rdoc +2 -2
- data/lib/generators/happy_seed/devise/templates/spec/factories/users.rb +5 -4
- data/lib/generators/happy_seed/devise/templates/spec/features/registration_spec.rb +149 -0
- data/lib/generators/happy_seed/devise/templates/spec/mailers/previews/devise_preview.rb +28 -0
- data/lib/generators/happy_seed/devise_confirmable/devise_confirmable_generator.rb +45 -0
- data/lib/generators/happy_seed/devise_confirmable/templates/add_confirmable_to_devise.rb +24 -0
- data/lib/generators/happy_seed/devise_confirmable/templates/app/controllers/confirmations_controller.rb +10 -0
- data/lib/generators/happy_seed/devise_confirmable/templates/app/views/devise/invitations/edit.html.haml +22 -0
- data/lib/generators/happy_seed/devise_confirmable/templates/app/views/devise/invitations/new.html.haml +20 -0
- data/lib/generators/happy_seed/devise_confirmable/templates/app/views/devise/mailer/invitation_instructions.html.erb +20 -0
- data/lib/generators/happy_seed/devise_confirmable/templates/docs/README.03.devise_confirmable.rdoc +23 -0
- data/lib/generators/happy_seed/devise_invitable/devise_invitable_generator.rb +3 -1
- data/lib/generators/happy_seed/devise_invitable/templates/app/views/devise/invitations/edit.html.haml +3 -2
- data/lib/generators/happy_seed/devise_invitable/templates/app/views/devise/invitations/new.html.haml +3 -2
- data/lib/generators/happy_seed/devise_invitable/templates/app/views/devise/mailer/invitation_instructions.html.erb +20 -0
- data/lib/generators/happy_seed/devise_invitable/templates/spec/features/invitations_spec.rb +61 -0
- data/lib/generators/happy_seed/facebook/facebook_generator.rb +2 -0
- data/lib/generators/happy_seed/facebook/templates/spec/features/facebook_registration_spec.rb +72 -0
- data/lib/generators/happy_seed/googleoauth/googleoauth_generator.rb +1 -1
- data/lib/generators/happy_seed/happy_seed_generator.rb +1 -3
- data/lib/generators/happy_seed/html_email/html_email_generator.rb +32 -0
- data/lib/generators/happy_seed/html_email/templates/app/views/layouts/mailer.html.erb +244 -0
- data/lib/generators/happy_seed/html_email/templates/docs/README.01.html_email.rdoc +25 -0
- data/lib/generators/happy_seed/omniauth/omniauth_generator.rb +4 -2
- data/lib/generators/happy_seed/omniauth/templates/app/controllers/omniauth_callbacks_controller.rb +3 -13
- data/lib/generators/happy_seed/omniauth/templates/app/models/identity.rb +13 -9
- data/lib/generators/happy_seed/omniauth/templates/docs/README.04.omniauth.rdoc +5 -5
- data/lib/generators/happy_seed/omniauth/templates/spec/factories/oauth.rb +6 -1
- data/lib/generators/happy_seed/omniauth/templates/spec/features/oauth_registration_spec.rb +80 -0
- data/lib/generators/happy_seed/omniauth/templates/spec/models/identity_spec.rb +39 -12
- data/lib/generators/happy_seed/omniauth/templates/{app/models/form_user.rb → user.rb} +4 -5
- data/lib/generators/happy_seed/plugin/plugin_generator.rb +13 -11
- data/lib/generators/happy_seed/react/react_generator.rb +36 -0
- data/lib/generators/happy_seed/react/templates/docs/README.10.react.rdoc +20 -0
- data/lib/generators/happy_seed/roles/roles_generator.rb +38 -0
- data/lib/generators/happy_seed/roles/templates/ability.rb +9 -0
- data/lib/generators/happy_seed/roles/templates/docs/README.03.roles.rdoc +23 -0
- data/lib/generators/happy_seed/simple_cms/simple_cms_generator.rb +41 -0
- data/lib/generators/happy_seed/simple_cms/templates/app/admin/simple_content.rb +42 -0
- data/lib/generators/happy_seed/simple_cms/templates/app/controllers/simple_content_controller.rb +7 -0
- data/lib/generators/happy_seed/simple_cms/templates/app/models/simple_content.rb +5 -0
- data/lib/generators/happy_seed/simple_cms/templates/app/views/splash/faq.html.haml +13 -0
- data/lib/generators/happy_seed/simple_cms/templates/app/views/splash/index.html.haml +79 -0
- data/lib/generators/happy_seed/simple_cms/templates/application_helper.rb +18 -0
- data/lib/generators/happy_seed/simple_cms/templates/create_simple_contents.rb +14 -0
- data/lib/generators/happy_seed/simple_cms/templates/docs/README.04.simple_cms.rdoc +32 -0
- data/lib/generators/happy_seed/simple_cms/templates/spec/factories/oauth.rb +10 -0
- data/lib/generators/happy_seed/simple_cms/templates/spec/features/oauth_registration_spec.rb +80 -0
- data/lib/generators/happy_seed/simple_cms/templates/spec/models/identity_spec.rb +49 -0
- data/lib/generators/happy_seed/splash/templates/app/assets/stylesheets/splash.css.scss +119 -84
- data/lib/generators/happy_seed/splash/templates/app/controllers/splash_controller.rb +1 -1
- data/lib/generators/happy_seed/splash/templates/app/views/layouts/splash.html.haml +15 -18
- data/lib/generators/happy_seed/splash/templates/app/views/splash/index.html.haml +54 -92
- data/lib/generators/happy_seed/splash/templates/docs/README.02.splash.rdoc +2 -2
- data/lib/generators/happy_seed/splash/templates/spec/controllers/splash_controller_spec.rb +11 -3
- data/lib/generators/happy_seed/static/templates/source/stylesheets/application.css.scss +1 -1
- data/lib/generators/happy_seed/static_blog/templates/Gemfile.lock +45 -49
- data/lib/generators/happy_seed/twitter/templates/spec/features/twitter_oauth_registration_spec.rb +57 -0
- data/lib/generators/happy_seed/twitter/twitter_generator.rb +2 -1
- data/lib/happy_seed/cli.rb +1 -1
- data/lib/happy_seed/engine.rb +12 -0
- data/lib/happy_seed/version.rb +1 -1
- data/lib/tasks/seed.rake +56 -0
- data/{test → spec}/dummy/Rakefile +0 -0
- data/spec/dummy/app/assets/config/manifest.js +5 -0
- data/{test → spec}/dummy/app/assets/javascripts/application.js +3 -3
- data/spec/dummy/app/assets/javascripts/cable.coffee +11 -0
- data/{test → spec}/dummy/app/assets/stylesheets/application.css +4 -4
- data/spec/dummy/app/channels/application_cable/channel.rb +5 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +5 -0
- data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
- data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/{test → spec}/dummy/bin/bundle +0 -0
- data/{test → spec}/dummy/bin/rails +1 -1
- data/{test → spec}/dummy/bin/rake +0 -0
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config.ru +8 -0
- data/spec/dummy/config/application.rb +21 -0
- data/{test → spec}/dummy/config/boot.rb +0 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/{test → spec}/dummy/config/database.yml +0 -0
- data/{test → spec}/dummy/config/environment.rb +0 -0
- data/{test → spec}/dummy/config/environments/development.rb +28 -3
- data/{test → spec}/dummy/config/environments/production.rb +29 -24
- data/{test → spec}/dummy/config/environments/test.rb +6 -3
- data/spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +6 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/{test → spec}/dummy/config/initializers/assets.rb +3 -0
- data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/spec/dummy/config/initializers/callback_terminator.rb +6 -0
- data/{test → spec}/dummy/config/initializers/cookies_serializer.rb +3 -1
- data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
- data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
- data/spec/dummy/config/initializers/per_form_csrf_tokens.rb +4 -0
- data/spec/dummy/config/initializers/request_forgery_protection.rb +4 -0
- data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
- data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +2 -2
- data/{test → spec}/dummy/config/locales/en.yml +0 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/{test → spec}/dummy/config/secrets.yml +3 -3
- data/spec/dummy/db/schema.rb +16 -0
- data/{test → spec}/dummy/public/404.html +0 -0
- data/{test → spec}/dummy/public/422.html +0 -0
- data/{test → spec}/dummy/public/500.html +0 -0
- data/{test/dummy/public/favicon.ico → spec/dummy/public/apple-touch-icon-precomposed.png} +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/rails_helper.rb +58 -0
- data/spec/spec_helper.rb +91 -0
- metadata +195 -89
- data/lib/generators/happy_seed/api/templates/app/controllers/api/v1/configurations_controller.rb +0 -11
- data/lib/generators/happy_seed/api/templates/spec/acceptance/api/v1/configurations_spec.rb +0 -21
- data/lib/generators/happy_seed/base/templates/config/puma.rb +0 -15
- data/lib/generators/happy_seed/base/templates/spec/support/controller_helpers.rb +0 -12
- data/lib/generators/happy_seed/bootstrap/templates/app/assets/stylesheets/sections/_profile_page.scss +0 -9
- data/lib/generators/happy_seed/bootstrap/templates/lib/templates/haml/scaffold/_form.html.haml +0 -5
- data/lib/generators/happy_seed/devise/templates/spec/features/forgot_password_spec.rb +0 -54
- data/lib/generators/happy_seed/devise/templates/test/mailers/previews/devise_preview.rb +0 -13
- data/lib/generators/happy_seed/omniauth/templates/spec/features/registration_spec.rb +0 -81
- data/lib/generators/happy_seed/static/templates/Gemfile.lock +0 -158
- data/lib/tasks/seed_tasks.rake +0 -4
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -23
- data/test/dummy/config/initializers/jazz_hands.rb +0 -5
- data/test/dummy/config/routes.rb +0 -56
- data/test/seed_test.rb +0 -7
- data/test/test_helper.rb +0 -15
@@ -1,15 +1,16 @@
|
|
1
1
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
2
|
|
3
3
|
FactoryGirl.define do
|
4
|
-
sequence
|
5
|
-
"person#{n}@example.com"
|
6
|
-
end
|
4
|
+
sequence(:email) { |n| Faker::Internet.safe_email 'User %d' % n }
|
7
5
|
end
|
8
6
|
|
9
7
|
FactoryGirl.define do
|
10
|
-
factory :user
|
8
|
+
factory :user do
|
11
9
|
email
|
12
10
|
password '12345678'
|
13
11
|
password_confirmation '12345678'
|
12
|
+
if User.devise_modules.include?(:confirmable)
|
13
|
+
confirmed_at Time.now
|
14
|
+
end
|
14
15
|
end
|
15
16
|
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
feature "Registration", :type => :feature do
|
4
|
+
it "should let you create a new user" do
|
5
|
+
visit new_user_registration_path
|
6
|
+
|
7
|
+
within "#new_user" do
|
8
|
+
fill_in "user_email", with: "test@example.com"
|
9
|
+
fill_in "user_password", with: "123456789"
|
10
|
+
fill_in "user_password_confirmation", with: "123456789"
|
11
|
+
end
|
12
|
+
|
13
|
+
click_button "Sign up"
|
14
|
+
|
15
|
+
if User.devise_modules.include? :confirmable
|
16
|
+
expect( page.body ).to include( 'A message with a confirmation link has been sent to your email address.' )
|
17
|
+
|
18
|
+
body = ActionMailer::Base.deliveries.last.body
|
19
|
+
|
20
|
+
md = body.encoded.match /(\/users\/confirmation.*) /
|
21
|
+
if !md
|
22
|
+
assert( false, "Confirmation URL not found in message" )
|
23
|
+
end
|
24
|
+
|
25
|
+
visit md[1]
|
26
|
+
|
27
|
+
expect( page.body ).to include( "Your email address has been successfully confirmed." )
|
28
|
+
else
|
29
|
+
expect( page.body ).to include( "Welcome! You have signed up successfully." )
|
30
|
+
end
|
31
|
+
|
32
|
+
click_link "Profile"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should require a user to have an email address" do
|
36
|
+
visit new_user_registration_path
|
37
|
+
|
38
|
+
within "#new_user" do
|
39
|
+
# fill_in "user_email", with: "test@example.com"
|
40
|
+
fill_in "user_password", with: "123456789"
|
41
|
+
fill_in "user_password_confirmation", with: "123456789"
|
42
|
+
end
|
43
|
+
|
44
|
+
click_button "Sign up"
|
45
|
+
|
46
|
+
expect( page.body ).to_not include( "Welcome! You have signed up successfully." )
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should let a user change their password if they enter in their existing password" do
|
50
|
+
visit new_user_registration_path
|
51
|
+
|
52
|
+
within "#new_user" do
|
53
|
+
fill_in "user_email", with: "test@example.com"
|
54
|
+
fill_in "user_password", with: "123456789"
|
55
|
+
fill_in "user_password_confirmation", with: "123456789"
|
56
|
+
end
|
57
|
+
|
58
|
+
click_button "Sign up"
|
59
|
+
|
60
|
+
if User.devise_modules.include? :confirmable
|
61
|
+
expect( page.body ).to include( 'A message with a confirmation link has been sent to your email address.' )
|
62
|
+
|
63
|
+
body = ActionMailer::Base.deliveries.last.body
|
64
|
+
|
65
|
+
md = body.encoded.match /(\/users\/confirmation.*) /
|
66
|
+
if !md
|
67
|
+
assert( false, "Confirmation URL not found in message" )
|
68
|
+
end
|
69
|
+
|
70
|
+
visit md[1]
|
71
|
+
|
72
|
+
expect( page.body ).to include( "Your email address has been successfully confirmed." )
|
73
|
+
else
|
74
|
+
expect( page.body ).to include( "Welcome! You have signed up successfully." )
|
75
|
+
end
|
76
|
+
|
77
|
+
click_link "Profile"
|
78
|
+
|
79
|
+
within "#edit_user" do
|
80
|
+
fill_in "user_password", with: "012345678"
|
81
|
+
fill_in "user_password_confirmation", with: "012345678"
|
82
|
+
end
|
83
|
+
|
84
|
+
click_button "Update"
|
85
|
+
|
86
|
+
expect( page.body ).to include( "we need your current password to confirm your changes" )
|
87
|
+
|
88
|
+
within "#edit_user" do
|
89
|
+
fill_in "user_password", with: "012345678"
|
90
|
+
fill_in "user_password_confirmation", with: "012345678"
|
91
|
+
fill_in "user_current_password", with: "123456789"
|
92
|
+
end
|
93
|
+
|
94
|
+
click_button "Update"
|
95
|
+
|
96
|
+
expect( page.body ).to include( "Your account has been updated successfully." )
|
97
|
+
end
|
98
|
+
|
99
|
+
it "following a forgot password link should let you reset your password and log in" do
|
100
|
+
user = create :user
|
101
|
+
|
102
|
+
visit new_user_password_path
|
103
|
+
|
104
|
+
within "#new_user" do
|
105
|
+
fill_in "user_email", with: user.email
|
106
|
+
end
|
107
|
+
|
108
|
+
click_button "Send me reset password instructions"
|
109
|
+
|
110
|
+
expect( page.body ).to include( "You will receive an email with instructions on how to reset your password in a few minutes." )
|
111
|
+
|
112
|
+
body = ActionMailer::Base.deliveries.last.body
|
113
|
+
|
114
|
+
md = body.encoded.match /(\/users\/password\/edit\?reset.*)/
|
115
|
+
if !md
|
116
|
+
assert( false, "URL NOT FOUND IN MESSAGE")
|
117
|
+
end
|
118
|
+
|
119
|
+
visit md[1]
|
120
|
+
|
121
|
+
within "#new_user" do
|
122
|
+
fill_in "user_password", with: "new_password"
|
123
|
+
fill_in "user_password_confirmation", with: "new_password"
|
124
|
+
end
|
125
|
+
|
126
|
+
click_button "Change my password"
|
127
|
+
|
128
|
+
expect( page.body ).to_not include( "Email can't be blank" )
|
129
|
+
|
130
|
+
visit edit_user_registration_path
|
131
|
+
|
132
|
+
expect( page.body ).to include( "Sign Out")
|
133
|
+
|
134
|
+
click_link "Sign Out"
|
135
|
+
|
136
|
+
expect( page.body ).to include( "Signed out successfully." )
|
137
|
+
|
138
|
+
visit new_user_session_path
|
139
|
+
|
140
|
+
within "#new_user" do
|
141
|
+
fill_in "user_email", with: user.email
|
142
|
+
fill_in "user_password", with: "new_password"
|
143
|
+
end
|
144
|
+
|
145
|
+
click_button "Log in"
|
146
|
+
|
147
|
+
expect( page.body ).to include( "Signed in successfully.")
|
148
|
+
end
|
149
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class DevisePreview < ActionMailer::Preview
|
2
|
+
if User.devise_modules.include? :confirmable
|
3
|
+
def confirmation_instructions
|
4
|
+
Devise::Mailer.confirmation_instructions(user, "tokentokentoken")
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def reset_password_instructions
|
9
|
+
Devise::Mailer.reset_password_instructions(user, "tokentokentoken")
|
10
|
+
end
|
11
|
+
|
12
|
+
if User.devise_modules.include? :lockable
|
13
|
+
def unlock_instructions
|
14
|
+
Devise::Mailer.unlock_instructions(user, "tokentokentoken")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
if User.devise_modules.include? :invitable
|
19
|
+
def invitation_instructions
|
20
|
+
Devise::Mailer.invitation_instructions(user, "tokentokentoken")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
def user
|
26
|
+
User.first || User.new( email: "will@happyfuncorp.com" )
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'generators/happy_seed/devise/devise_generator'
|
2
|
+
|
3
|
+
module HappySeed
|
4
|
+
module Generators
|
5
|
+
class DeviseConfirmableGenerator < HappySeedGenerator
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
|
10
|
+
def self.fingerprint
|
11
|
+
# gem_available? 'devise_invitable'
|
12
|
+
end
|
13
|
+
|
14
|
+
def install_device_invitable
|
15
|
+
# return if already_installed
|
16
|
+
|
17
|
+
require_generator DeviseGenerator
|
18
|
+
|
19
|
+
gsub_file "app/models/user.rb", "devise :", "devise :confirmable, :"
|
20
|
+
|
21
|
+
migration_template("add_confirmable_to_devise.rb", "db/migrate/add_confirmable_to_devise.rb" )
|
22
|
+
|
23
|
+
directory 'app'
|
24
|
+
directory 'docs'
|
25
|
+
directory 'spec'
|
26
|
+
|
27
|
+
gsub_file 'config/routes.rb', "devise_for :users, :controllers => {", "devise_for :users, :controllers => { confirmations: 'confirmations', "
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def gem_available?(name)
|
32
|
+
Gem::Specification.find_by_name(name)
|
33
|
+
rescue Gem::LoadError
|
34
|
+
false
|
35
|
+
rescue
|
36
|
+
Gem.available?(name)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.next_migration_number(dir)
|
40
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class AddConfirmableToDevise < ActiveRecord::Migration
|
2
|
+
# Note: You can't use change, as User.update_all will fail in the down migration
|
3
|
+
def up
|
4
|
+
add_column :users, :confirmation_token, :string
|
5
|
+
add_column :users, :confirmed_at, :datetime
|
6
|
+
add_column :users, :confirmation_sent_at, :datetime
|
7
|
+
add_column :users, :unconfirmed_email, :string # Only if using reconfirmable
|
8
|
+
add_index :users, :confirmation_token, unique: true
|
9
|
+
# User.reset_column_information # Need for some types of updates, but not for update_all.
|
10
|
+
# To avoid a short time window between running the migration and updating all existing
|
11
|
+
# users as confirmed, do the following
|
12
|
+
# execute("UPDATE users SET confirmed_at = NOW()")
|
13
|
+
# All existing user accounts should be able to log in after this.
|
14
|
+
# Remind: Rails using SQLite as default. And SQLite has no such function :NOW.
|
15
|
+
# Use :date('now') instead of :NOW when using SQLite.
|
16
|
+
# => execute("UPDATE users SET confirmed_at = date('now')")
|
17
|
+
# Or => User.all.update_all confirmed_at: Time.now
|
18
|
+
end
|
19
|
+
|
20
|
+
def down
|
21
|
+
remove_columns :users, :confirmation_token, :confirmed_at, :confirmation_sent_at
|
22
|
+
# remove_columns :users, :unconfirmed_email # Only if using reconfirmable
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
- @title = t 'devise.invitations.edit.header'
|
2
|
+
.container
|
3
|
+
.row
|
4
|
+
.center-panel
|
5
|
+
.panel.panel-default.only
|
6
|
+
|
7
|
+
.panel-heading
|
8
|
+
%h3.panel-title
|
9
|
+
= @title
|
10
|
+
|
11
|
+
.panel-body
|
12
|
+
|
13
|
+
= form_for resource, as: resource_name, url: invitation_path(resource_name), layout: :horizontal, html: { method: :put } do |f|
|
14
|
+
|
15
|
+
= devise_error_messages!
|
16
|
+
|
17
|
+
= f.hidden_field :invitation_token
|
18
|
+
|
19
|
+
= f.password_field :password
|
20
|
+
= f.password_field :password_confirmation
|
21
|
+
|
22
|
+
= f.submit "Add password"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
- @title = t "devise.invitations.new.header"
|
2
|
+
.container
|
3
|
+
.row
|
4
|
+
.center-panel
|
5
|
+
.panel.panel-default.only
|
6
|
+
|
7
|
+
.panel-heading
|
8
|
+
%h3.panel-title
|
9
|
+
= t "devise.invitations.new.header"
|
10
|
+
|
11
|
+
.panel-body
|
12
|
+
|
13
|
+
= form_for resource, as: resource_name, url: invitation_path(resource_name), layout: :horizontal, html: { method: :post } do |f|
|
14
|
+
|
15
|
+
/ = devise_error_messages!
|
16
|
+
|
17
|
+
- resource.class.invite_key_fields.each do |field|
|
18
|
+
= f.text_field field
|
19
|
+
|
20
|
+
= f.submit "Invite User"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<p class="center"><%= t("devise.mailer.invitation_instructions.hello", email: @resource.email) %></p>
|
2
|
+
|
3
|
+
<p><%= t("devise.mailer.invitation_instructions.someone_invited_you", url: root_url) %></p>
|
4
|
+
|
5
|
+
<!-- button -->
|
6
|
+
<table class="btn-primary center" cellpadding="0" cellspacing="0" border="0">
|
7
|
+
<tr>
|
8
|
+
<td>
|
9
|
+
<%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, :invitation_token => @token) %>
|
10
|
+
</td>
|
11
|
+
</tr>
|
12
|
+
</table>
|
13
|
+
|
14
|
+
<% if @resource.invitation_due_at %>
|
15
|
+
<p><%= t("devise.mailer.invitation_instructions.accept_until", due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format')) %></p>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<p><%= t("devise.mailer.invitation_instructions.ignore").html_safe %></p>
|
19
|
+
|
20
|
+
<p>Thanks, have a lovely day.</p>
|
data/lib/generators/happy_seed/devise_confirmable/templates/docs/README.03.devise_confirmable.rdoc
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
HappySeed Devise Confirmable Install
|
2
|
+
===================
|
3
|
+
|
4
|
+
### What does this do?
|
5
|
+
|
6
|
+
The `happy_seed:devise_confirmable` generator
|
7
|
+
|
8
|
+
* Installs devise_confirmable
|
9
|
+
* Adds columns to track if the user has been confirmed
|
10
|
+
* Copies over devise views
|
11
|
+
* Gives them bootstrap views
|
12
|
+
|
13
|
+
### Why do you want this?
|
14
|
+
|
15
|
+
This allows you to confirm users through an email link and checks to make sure they are confirmed when logging in. For more information on devise and confirmable, check out the docs [here.](https://github.com/plataformatec/devise)
|
16
|
+
|
17
|
+
### Environment Variables
|
18
|
+
|
19
|
+
na
|
20
|
+
|
21
|
+
### What needs to be done?
|
22
|
+
|
23
|
+
Be aware that if you are running this generator after you already have users, you may want to mark existing users as already confirmed. Please read the comments in the migration and uncomment the line `execute("UPDATE users SET confirmed_at = NOW()") ` before running the migration. For futher information consult [these docs.](https://github.com/plataformatec/devise/wiki/How-To:-Add-:confirmable-to-Users)
|
@@ -14,7 +14,7 @@ module HappySeed
|
|
14
14
|
|
15
15
|
require_generator DeviseGenerator
|
16
16
|
|
17
|
-
gem 'devise_invitable'
|
17
|
+
gem 'devise_invitable', github: "scambra/devise_invitable"
|
18
18
|
|
19
19
|
Bundler.with_clean_env do
|
20
20
|
run "bundle install --without production"
|
@@ -24,6 +24,8 @@ module HappySeed
|
|
24
24
|
run 'rails generate devise_invitable:install'
|
25
25
|
run 'rails generate devise_invitable User'
|
26
26
|
run 'rails generate devise_invitable:views'
|
27
|
+
|
28
|
+
remove_file 'app/views/devise/mailer/invitation_instructions.html.erb'
|
27
29
|
|
28
30
|
directory '.'
|
29
31
|
|
data/lib/generators/happy_seed/devise_invitable/templates/app/views/devise/invitations/new.html.haml
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
- @title = t "devise.invitations.new.header"
|
2
2
|
.container
|
3
3
|
.row
|
4
|
-
.
|
4
|
+
.center-panel
|
5
5
|
.panel.panel-default.only
|
6
6
|
|
7
7
|
.panel-heading
|
8
|
-
|
8
|
+
%h3.panel-title
|
9
|
+
= t "devise.invitations.new.header"
|
9
10
|
|
10
11
|
.panel-body
|
11
12
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<p class="center"><%= t("devise.mailer.invitation_instructions.hello", email: @resource.email) %></p>
|
2
|
+
|
3
|
+
<p><%= t("devise.mailer.invitation_instructions.someone_invited_you", url: root_url) %></p>
|
4
|
+
|
5
|
+
<!-- button -->
|
6
|
+
<table class="btn-primary center" cellpadding="0" cellspacing="0" border="0">
|
7
|
+
<tr>
|
8
|
+
<td>
|
9
|
+
<%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, :invitation_token => @token) %>
|
10
|
+
</td>
|
11
|
+
</tr>
|
12
|
+
</table>
|
13
|
+
|
14
|
+
<% if @resource.invitation_due_at %>
|
15
|
+
<p><%= t("devise.mailer.invitation_instructions.accept_until", due_date: l(@resource.invitation_due_at, format: :'devise.mailer.invitation_instructions.accept_until_format')) %></p>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<p><%= t("devise.mailer.invitation_instructions.ignore").html_safe %></p>
|
19
|
+
|
20
|
+
<p>Thanks, have a lovely day.</p>
|