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
@@ -7,7 +7,7 @@ module HappySeed
|
|
7
7
|
source_root File.expand_path('../templates', __FILE__)
|
8
8
|
|
9
9
|
def self.fingerprint
|
10
|
-
gem_available?( 'omniauth')
|
10
|
+
gem_available?( 'omniauth' )
|
11
11
|
end
|
12
12
|
|
13
13
|
def install_omniauth
|
@@ -18,6 +18,7 @@ module HappySeed
|
|
18
18
|
migration_template("make_email_nullable.rb", "db/migrate/make_email_nullable.rb" )
|
19
19
|
|
20
20
|
gem 'omniauth'
|
21
|
+
gem 'omniauth-oauth2', '1.3.1'
|
21
22
|
|
22
23
|
Bundler.with_clean_env do
|
23
24
|
run "bundle install --without production"
|
@@ -36,11 +37,12 @@ module HappySeed
|
|
36
37
|
gsub_file "app/models/user.rb", ", :validatable", ""
|
37
38
|
inject_into_class "app/models/user.rb", "User", " has_many :identities, dependent: :destroy\n"
|
38
39
|
# insert_into_file "app/models/user.rb", File.read( find_in_source_paths( "user.rb" ) ), :before => "\nend\n"
|
40
|
+
inject_into_class "app/models/user.rb", "User", File.read( find_in_source_paths( "user.rb" ) )
|
39
41
|
rescue
|
40
42
|
say_status :user_model, "Unable to add omniauthable to app/models/users.rb", :red
|
41
43
|
end
|
42
44
|
|
43
|
-
gsub_file 'config/routes.rb', "devise_for :users
|
45
|
+
gsub_file 'config/routes.rb', "devise_for :users, :controllers => {", "devise_for :users, :controllers => { omniauth_callbacks: 'omniauth_callbacks', registrations: 'registrations', "
|
44
46
|
|
45
47
|
directory "docs"
|
46
48
|
end
|
data/lib/generators/happy_seed/omniauth/templates/app/controllers/omniauth_callbacks_controller.rb
CHANGED
@@ -1,18 +1,11 @@
|
|
1
1
|
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
2
|
-
def instagram
|
3
|
-
generic_callback( 'instagram' )
|
4
|
-
end
|
5
|
-
def facebook
|
6
|
-
generic_callback( 'facebook' )
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
2
|
def generic_callback( provider )
|
11
|
-
@identity = Identity.find_for_oauth env["omniauth.auth"]
|
3
|
+
@identity = Identity.find_for_oauth request.env["omniauth.auth"]
|
12
4
|
|
13
5
|
@user = @identity.user || current_user
|
6
|
+
|
14
7
|
if @user.nil?
|
15
|
-
@user = User.create( email: @identity.email
|
8
|
+
@user = User.create( email: @identity.email, oauth_callback: true )
|
16
9
|
@identity.update_attribute( :user_id, @user.id )
|
17
10
|
end
|
18
11
|
|
@@ -22,9 +15,6 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
22
15
|
|
23
16
|
if @user.persisted?
|
24
17
|
@identity.update_attribute( :user_id, @user.id )
|
25
|
-
# This is because we've created the user manually, and Device expects a
|
26
|
-
# FormUser class (with the validations)
|
27
|
-
@user = FormUser.find @user.id
|
28
18
|
sign_in_and_redirect @user, event: :authentication
|
29
19
|
set_flash_message(:notice, :success, kind: provider.capitalize) if is_navigational_format?
|
30
20
|
else
|
@@ -1,18 +1,22 @@
|
|
1
1
|
class Identity < ActiveRecord::Base
|
2
|
-
belongs_to :user
|
2
|
+
belongs_to :user, required: false
|
3
3
|
validates_presence_of :uid, :provider
|
4
|
-
validates_uniqueness_of :uid, :
|
4
|
+
validates_uniqueness_of :uid, scope: :provider
|
5
5
|
|
6
6
|
def self.find_for_oauth(auth)
|
7
7
|
identity = find_by(provider: auth.provider, uid: auth.uid)
|
8
8
|
identity = create(uid: auth.uid, provider: auth.provider) if identity.nil?
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
if auth.credentials
|
10
|
+
identity.accesstoken = auth.credentials.token
|
11
|
+
end
|
12
|
+
if auth.info
|
13
|
+
identity.name = auth.info.name
|
14
|
+
identity.email = auth.info.email
|
15
|
+
identity.nickname = auth.info.nickname
|
16
|
+
identity.image = auth.info.image
|
17
|
+
identity.phone = auth.info.phone
|
18
|
+
identity.urls = (auth.info.urls || "").to_json
|
19
|
+
end
|
16
20
|
identity.save
|
17
21
|
identity
|
18
22
|
end
|
@@ -5,24 +5,24 @@ HappySeed Omniauth Install
|
|
5
5
|
|
6
6
|
The `happy_seed:omniauth` generator depends upon `happy_seed:devise` and
|
7
7
|
|
8
|
-
* Generates an
|
8
|
+
* Generates an Indentity model, linked to User
|
9
9
|
* Installs omniauth
|
10
10
|
* Installs an omniauth_controller
|
11
11
|
* Updates devise configuration
|
12
12
|
* Adds routes
|
13
13
|
* Removes devise email/password validations, updates database
|
14
|
-
*
|
14
|
+
* Removes the :validatable option for devise and moves the login in class.
|
15
15
|
* Adds a registration controller to allow the user to add email and password for auth strategies that don't support it.
|
16
16
|
|
17
17
|
### Why do you want this?
|
18
18
|
|
19
|
-
This lets you easily add oauth authentication for 3rd party sites to
|
19
|
+
This lets you easily add oauth authentication for 3rd party sites to your application; the main ones being facebook and twitter. This sets up the infrastructure to make everything work with devise.
|
20
20
|
|
21
21
|
The Identity model is used to link up the user with the remote information. What information is given is stored, though you could go deeper with this. Additionally, the access token for the user is store in the Identity model for interacting with the remote service on behalf of the user.
|
22
22
|
|
23
23
|
It also creates the omniauth_callback controller. Devise as it's setup out of the box has the user's email address as the login, but not all services will give you the user's email address. (Twitter for example.) The controller in this case will check only set the email address if one is returned.
|
24
24
|
|
25
|
-
It also creates a registration controller to allow a user to set an email. If the user hasn't set a password, they can change email without it. If they set an password, then it is required to change things in the future.
|
25
|
+
It also creates a registration controller to allow a user to set an email. If the user hasn't set a password, they can change email without it. If they set an password, then it is required to change things in the future. This is done using conditional validators rather than a seperate model for the user.
|
26
26
|
|
27
27
|
Documented in spec/features/registration_spec.rb
|
28
28
|
|
@@ -33,4 +33,4 @@ Set up a $HOME/.seed_defaults file which contains development application keys.
|
|
33
33
|
|
34
34
|
### What needs to be done?
|
35
35
|
|
36
|
-
This is a base module which is used by `happy_seed:twitter`, `happy_seed:facebook` and `happy_seed:instagram
|
36
|
+
This is a base module which is used by `happy_seed:twitter`, `happy_seed:facebook` and `happy_seed:instagram` and more.
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
feature "OAuthRegistrations", :type => :feature do
|
4
|
+
include Warden::Test::Helpers
|
5
|
+
|
6
|
+
after{ Warden.test_reset! }
|
7
|
+
|
8
|
+
it "should require you to be logged in" do
|
9
|
+
visit edit_user_registration_path
|
10
|
+
|
11
|
+
expect( page.body ).to include( "You need to sign in or sign up before continuing." )
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "oauth users" do
|
15
|
+
it "should let you change add an email address without a password the don't have a password" do
|
16
|
+
login_as create( :oauth_user ), scope: :user
|
17
|
+
|
18
|
+
visit edit_user_registration_path
|
19
|
+
|
20
|
+
expect( page.body ).to_not include( "You need to sign in or sign up before continuing." )
|
21
|
+
|
22
|
+
within "#edit_user" do
|
23
|
+
fill_in "user[email]", with: "email@example.com"
|
24
|
+
end
|
25
|
+
|
26
|
+
click_button "Update"
|
27
|
+
|
28
|
+
expect( page.body ).to include( "Your account has been updated successfully")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should let you set your password initially" do
|
32
|
+
login_as create( :oauth_user ), scope: :user
|
33
|
+
|
34
|
+
visit edit_user_registration_path
|
35
|
+
|
36
|
+
within "#edit_user" do
|
37
|
+
fill_in "user[email]", with: "email@example.com"
|
38
|
+
fill_in "user[password]", with: "password"
|
39
|
+
fill_in "user[password_confirmation]", with: "password"
|
40
|
+
end
|
41
|
+
|
42
|
+
click_button "Update"
|
43
|
+
|
44
|
+
expect( page.body ).to include( "Your account has been updated successfully")
|
45
|
+
|
46
|
+
logout
|
47
|
+
|
48
|
+
visit edit_user_registration_path
|
49
|
+
|
50
|
+
expect( page.body ).to include( "You need to sign in or sign up before continuing." )
|
51
|
+
|
52
|
+
within "#new_user" do
|
53
|
+
fill_in "user[email]", with: "email@example.com"
|
54
|
+
fill_in "user[password]", with: "password"
|
55
|
+
end
|
56
|
+
|
57
|
+
click_button "Log in"
|
58
|
+
|
59
|
+
expect( page.body ).to include( "Signed in successfully." )
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "users with passwords" do
|
64
|
+
it "should require your current password if you have one set" do
|
65
|
+
login_as create( :user ), scope: :user
|
66
|
+
|
67
|
+
visit edit_user_registration_path
|
68
|
+
|
69
|
+
expect( page.body ).to_not include( "You need to sign in or sign up before continuing." )
|
70
|
+
|
71
|
+
within "#edit_user" do
|
72
|
+
fill_in "user[email]", with: "email@example.com"
|
73
|
+
end
|
74
|
+
|
75
|
+
click_button "Update"
|
76
|
+
|
77
|
+
expect( page.body ).to_not include( "Your account has been updated successfully")
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -1,22 +1,49 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
RSpec.describe Identity, :type => :model do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
describe "validations" do
|
5
|
+
before( :each ) do
|
6
|
+
@user = build :user
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
it "should always have a provider and uid" do
|
10
|
+
i = Identity.create user: @user
|
11
|
+
expect( i ).to_not be_valid
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
i = Identity.create user: @user, provider: "test"
|
14
|
+
expect( i ).to_not be_valid
|
15
|
+
|
16
|
+
i = Identity.create user: @user, provider: "test", uid: "1"
|
17
|
+
|
18
|
+
expect( i ).to be_valid
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have a unique uid per provider" do
|
22
|
+
i = Identity.create user: @user, provider: "test", uid: "1"
|
23
|
+
expect( i ).to be_valid
|
24
|
+
|
25
|
+
i = Identity.create user: @user, provider: "other test", uid: "1"
|
26
|
+
expect( i ).to be_valid
|
27
|
+
|
28
|
+
i = Identity.create user: @user, provider: "test", uid: "1"
|
29
|
+
expect( i ).to_not be_valid
|
30
|
+
end
|
13
31
|
end
|
14
32
|
|
15
|
-
|
16
|
-
|
17
|
-
|
33
|
+
describe "construction" do
|
34
|
+
it "should create an identity from a hash" do
|
35
|
+
data = OmniAuth::AuthHash.new({
|
36
|
+
:provider => 'twitter',
|
37
|
+
:uid => '123545'
|
38
|
+
})
|
39
|
+
|
40
|
+
i = Identity.find_for_oauth data
|
41
|
+
|
42
|
+
expect( i ).to be_valid
|
43
|
+
|
44
|
+
i2 = Identity.find_for_oauth data
|
18
45
|
|
19
|
-
|
20
|
-
|
46
|
+
expect( i.id ).to eq(i2.id)
|
47
|
+
end
|
21
48
|
end
|
22
49
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
attr_accessor :oauth_callback
|
2
2
|
attr_accessor :current_password
|
3
|
-
|
3
|
+
|
4
4
|
validates_presence_of :email, if: :email_required?
|
5
5
|
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
|
6
6
|
validates_format_of :email, with: Devise.email_regexp, allow_blank: true, if: :email_changed?
|
@@ -10,11 +10,10 @@ class FormUser < User
|
|
10
10
|
validates_length_of :password, within: Devise.password_length, allow_blank: true
|
11
11
|
|
12
12
|
def password_required?
|
13
|
-
return false if email.blank?
|
13
|
+
return false if email.blank? || !email_required?
|
14
14
|
!persisted? || !password.nil? || !password_confirmation.nil?
|
15
15
|
end
|
16
16
|
|
17
17
|
def email_required?
|
18
|
-
true
|
18
|
+
@oauth_callback != true
|
19
19
|
end
|
20
|
-
end
|
@@ -14,20 +14,22 @@ module HappySeed
|
|
14
14
|
|
15
15
|
insert_into_file "#{app_name}/#{app_name}.gemspec", File.read( "#{source_root}/gemspec" ), :before => "\nend\n"
|
16
16
|
|
17
|
-
|
17
|
+
Bundler.with_clean_env do
|
18
|
+
system( "cd #{app_name} && bundle" )
|
18
19
|
|
19
|
-
|
20
|
+
system( "cd #{app_name}/spec/dummy && rails g rspec:install")
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
gsub_file "#{app_name}/spec/dummy/.rspec", "--warnings\n", ""
|
23
|
+
append_to_file "#{app_name}/spec/dummy/.rspec", "--format documentation\n"
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
self.destination_root = app_name
|
26
|
+
|
27
|
+
remove_file "Rakefile"
|
28
|
+
copy_file "Rakefile"
|
29
|
+
copy_file ".rspec"
|
30
|
+
copy_file ".autotest"
|
31
|
+
directory "spec"
|
32
|
+
end
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'generators/happy_seed/happy_seed_generator'
|
2
|
+
|
3
|
+
module HappySeed
|
4
|
+
module Generators
|
5
|
+
class ReactGenerator < HappySeedGenerator
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def self.fingerprint
|
9
|
+
gem_available?( 'react_on_rails' )
|
10
|
+
end
|
11
|
+
|
12
|
+
def install_react
|
13
|
+
return if already_installed
|
14
|
+
|
15
|
+
gem 'react_on_rails'
|
16
|
+
|
17
|
+
Bundler.with_clean_env do
|
18
|
+
run "bundle install --without production"
|
19
|
+
end
|
20
|
+
|
21
|
+
say_status :react, "Adding files to git", :green
|
22
|
+
|
23
|
+
git add: "."
|
24
|
+
git commit: "-a -m 'Adding react_on_rails'"
|
25
|
+
|
26
|
+
generate 'react_on_rails:install'
|
27
|
+
|
28
|
+
system "npm install"
|
29
|
+
|
30
|
+
directory "."
|
31
|
+
|
32
|
+
say_status :react, "Now run: foreman start -f Procfile.dev", :green
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
HappySeed React Install
|
2
|
+
=========================
|
3
|
+
|
4
|
+
### What does this do?
|
5
|
+
|
6
|
+
The happy_seed react generator
|
7
|
+
|
8
|
+
* Installs `react_on_rails` as well as npm.
|
9
|
+
|
10
|
+
### Why do you want this?
|
11
|
+
|
12
|
+
You want to be able to use react within your rails project and `react_on_rails` is great. Consult the docs for this gem [here.](https://github.com/shakacode/react_on_rails). Check out the Hello World react app at `http://localhost:3000/hello_world`. Reference the react_on_rails docs for a detailed explanation. You can start by looking in the `client` folder to see how the Hello World app was built.
|
13
|
+
|
14
|
+
### Environment Variables
|
15
|
+
|
16
|
+
na
|
17
|
+
|
18
|
+
### What needs to be done?
|
19
|
+
|
20
|
+
When running the generator, if you notice npm throwing errors like `npmERR! Error: EACCES: permission denied, mkdir`. Run `sudo chown -R $USER:$GROUP ~/.npm`.
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'generators/happy_seed/happy_seed_generator'
|
2
|
+
require 'generators/happy_seed/devise/devise_generator'
|
3
|
+
|
4
|
+
module HappySeed
|
5
|
+
module Generators
|
6
|
+
class RolesGenerator < HappySeedGenerator
|
7
|
+
source_root File.expand_path('../templates', __FILE__)
|
8
|
+
|
9
|
+
def self.fingerprint
|
10
|
+
gem_available? 'cancancan'
|
11
|
+
end
|
12
|
+
|
13
|
+
def install_roles
|
14
|
+
return if already_installed
|
15
|
+
|
16
|
+
require_generator DeviseGenerator
|
17
|
+
|
18
|
+
gem 'cancancan'
|
19
|
+
|
20
|
+
Bundler.with_clean_env do
|
21
|
+
run "bundle install --without production"
|
22
|
+
run 'rake db:migrate'
|
23
|
+
end
|
24
|
+
|
25
|
+
template "ability.rb", "app/models/ability.rb"
|
26
|
+
directory "docs"
|
27
|
+
|
28
|
+
generate 'migration add_role_to_users role:integer'
|
29
|
+
|
30
|
+
inject_into_class "app/models/user.rb", "User", " enum role: [:user, :admin]\n"
|
31
|
+
|
32
|
+
inject_into_file 'app/controllers/application_controller.rb',
|
33
|
+
"\n\n def access_denied(exception)\n redirect_to root_path, alert: exception.message\n end\n",
|
34
|
+
before: /\nend/
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|