hello-rails 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -4
- data/app/controllers/hello/concerns/management/forgot_password.rb +1 -1
- data/app/controllers/hello/concerns/registration/sign_up.rb +7 -3
- data/app/controllers/hello/registration/sign_up_controller.rb +9 -1
- data/app/models/access.rb +2 -1
- data/app/models/credential.rb +2 -1
- data/app/models/email_credential.rb +2 -1
- data/app/models/password_credential.rb +2 -1
- data/app/models/user.rb +2 -1
- data/app/views/hello/shared/_nav_pills.html.erb +0 -2
- data/config/locales/hello.fr.yml +2 -4
- data/db/migrate/3_create_users.rb +10 -15
- data/lib/data/locales.yml +228 -0
- data/lib/generators/hello/install/install_generator.rb +8 -29
- data/lib/generators/hello/install/templates/initializer.rb +1 -1
- data/lib/generators/hello/install/templates/models/concerns/user/authorization.rb +8 -13
- data/lib/generators/hello/install/templates/models/user.rb +2 -1
- data/lib/generators/hello/users/USAGE +10 -0
- data/lib/generators/hello/{install/templates/users → users/templates/app}/controllers/users_controller.rb +2 -4
- data/lib/generators/hello/{install/templates/users → users/templates/app}/views/users/index.html.erb +1 -1
- data/lib/generators/hello/{install/templates/users → users/templates/app}/views/users/list.html.erb +3 -1
- data/lib/generators/hello/{install/templates/users → users/templates/app}/views/users/new.html.erb +2 -2
- data/lib/generators/hello/{install/templates/users → users/templates/app}/views/users/show.html.erb +0 -0
- data/lib/generators/hello/users/users_generator.rb +21 -0
- data/lib/hello/business/registration/sign_up.rb +30 -122
- data/lib/hello/locales.rb +1 -232
- data/lib/hello/rails_active_record/access.rb +12 -10
- data/lib/hello/rails_active_record/credential.rb +22 -18
- data/lib/hello/rails_active_record/email_credential.rb +12 -20
- data/lib/hello/rails_active_record/password_credential.rb +11 -32
- data/lib/hello/rails_active_record/user.rb +75 -54
- data/lib/hello/rails_controller.rb +1 -3
- data/lib/hello/rails_controller/restrict_by_role.rb +2 -2
- data/lib/hello/version.rb +1 -1
- data/spec/bdd/hello/authentication/classic_sign_in_spec.rb +2 -2
- data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_sign_in_form_spec.rb +1 -1
- data/spec/bdd/hello/management/manage_email_credentials/manage_email_credentials_emails_page_spec.rb +7 -7
- data/spec/bdd/hello/management/manage_password_credentials/manage_password_forgot_password_spec.rb +1 -1
- data/spec/bdd/hello/management/manage_password_credentials/manage_password_reset_password_spec.rb +1 -1
- data/spec/bdd/hello/management/manage_profile/manage_profile_page_spec.rb +0 -2
- data/spec/bdd/hello/other/create_user_spec.rb +1 -3
- data/spec/bdd/hello/other/impersonate_user_spec.rb +1 -2
- data/spec/bdd/hello/other/list_users_spec.rb +2 -4
- data/spec/bdd/hello/registration/classic_sign_up_spec.rb +3 -4
- data/spec/bdd/hello/support.rb +0 -4
- data/spec/business/hello/registration/sign_up_spec.rb +10 -2
- data/spec/controllers/authentication_spec.rb +3 -3
- data/spec/models/create_and_destroy/email_credential_create_and_destroy_spec.rb +81 -0
- data/spec/models/create_and_destroy/password_credential_create_and_destroy_spec.rb +60 -0
- data/spec/models/create_and_destroy/user_create_and_destroy_spec.rb +124 -0
- data/spec/models/credential_spec.rb +12 -3
- data/spec/models/email_credential_spec.rb +1 -2
- data/spec/models/password_credential_spec.rb +1 -2
- data/spec/models/user_spec.rb +87 -27
- data/spec/requests/forgot_password_spec.rb +1 -1
- data/spec/support/factories.rb +10 -14
- data/spec/support/helpers/given.rb +8 -16
- data/spec/support/helpers/when.rb +0 -1
- metadata +42 -38
- data/lib/generators/hello/from_devise/USAGE +0 -8
- data/lib/generators/hello/from_devise/from_devise_generator.rb +0 -13
- data/lib/generators/hello/from_devise/templates/from_devise.migration.rb +0 -39
- data/spec/models/hello/sign_up_model_spec.rb +0 -64
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'rails/generators/active_record'
|
2
|
-
|
3
|
-
class Hello::FromDeviseGenerator < ActiveRecord::Generators::Base
|
4
|
-
# ActiveRecord::Generators::Base inherits from Rails::Generators::NamedBase which requires a NAME parameter for the
|
5
|
-
# new table name. Our generator doesn't need it.
|
6
|
-
argument :name, type: :string, default: 'not-needed'
|
7
|
-
|
8
|
-
source_root File.expand_path('../templates', __FILE__)
|
9
|
-
|
10
|
-
def create_the_migration
|
11
|
-
migration_template 'from_devise.migration.rb', 'db/migrate/from_devise.hello.rb'
|
12
|
-
end
|
13
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# customize this migration if you need, PRs accepted
|
2
|
-
class FromDevise < ActiveRecord::Migration
|
3
|
-
def up
|
4
|
-
from_users_to_credentials
|
5
|
-
remove_devise_columns
|
6
|
-
end
|
7
|
-
|
8
|
-
def down
|
9
|
-
fail "you can't roll this back, use a backup"
|
10
|
-
end
|
11
|
-
|
12
|
-
private
|
13
|
-
|
14
|
-
def from_users_to_credentials
|
15
|
-
puts "before Credential.count (#{Credential.count.to_s.red})"
|
16
|
-
User.find_each do |user|
|
17
|
-
puts "starting User ##{user.id} #{user.email}"
|
18
|
-
username = extract_username(user)
|
19
|
-
credential_fields = { email: user.email, username: username, password: Hello::Encryptors::Simple.instance.single }
|
20
|
-
user.email_credentials.create!(credential_fields)
|
21
|
-
end
|
22
|
-
puts "after Credential.count (#{Credential.count.to_s.green})"
|
23
|
-
end
|
24
|
-
|
25
|
-
def extract_username(user)
|
26
|
-
username = user.try(:username).to_s
|
27
|
-
username = username.gsub('.', '_dot_')
|
28
|
-
end
|
29
|
-
|
30
|
-
def remove_devise_columns
|
31
|
-
columns = [:username, :encrypted_password, :reset_password_token, :reset_password_sent_at, :remember_created_at, :sign_in_count, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip, :last_sign_in_ip, :confirmation_token, :confirmed_at, :confirmation_sent_at, :unconfirmed_email, :failed_attempts, :unlock_token, :locked_at]
|
32
|
-
columns.each { |column_name| remove_users_column_safe(column_name) }
|
33
|
-
end
|
34
|
-
|
35
|
-
def remove_users_column_safe(column_name)
|
36
|
-
return unless column_exists?(:users, column_name)
|
37
|
-
remove_column(:users, column_name)
|
38
|
-
end
|
39
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# require 'spec_helper'
|
2
|
-
|
3
|
-
# module Hello
|
4
|
-
# describe SignUp do
|
5
|
-
|
6
|
-
# before(:each) do
|
7
|
-
# # @sign_up = SignUp.new
|
8
|
-
# end
|
9
|
-
|
10
|
-
# describe "validations" do
|
11
|
-
# # describe "email" do
|
12
|
-
|
13
|
-
# # it "presence" do
|
14
|
-
# # @sign_up.valid?
|
15
|
-
# # @sign_up.errors[:email].should include "can't be blank"
|
16
|
-
# # end
|
17
|
-
|
18
|
-
# # it "format" do
|
19
|
-
# # @sign_up.email = 'aaa'
|
20
|
-
# # @sign_up.valid?
|
21
|
-
# # @sign_up.errors[:email].should == ["does not appear to be valid"]
|
22
|
-
|
23
|
-
# # @sign_up.email = 'email@hello.com'
|
24
|
-
# # @sign_up.valid?
|
25
|
-
# # @sign_up.errors[:email].should be_empty
|
26
|
-
# # end
|
27
|
-
|
28
|
-
# # it "uniqueness" do
|
29
|
-
# # pending "todo"
|
30
|
-
# # end
|
31
|
-
|
32
|
-
# # end
|
33
|
-
|
34
|
-
# # describe "password" do
|
35
|
-
|
36
|
-
# # it "presence" do
|
37
|
-
# # @sign_up.valid?
|
38
|
-
# # @sign_up.errors[:password].should include "can't be blank"
|
39
|
-
# # end
|
40
|
-
|
41
|
-
# # it "length" do
|
42
|
-
# # @sign_up.password = '1' * 1
|
43
|
-
# # @sign_up.valid?
|
44
|
-
# # @sign_up.errors[:password].should == ["pick a shorter password"]
|
45
|
-
|
46
|
-
# # @sign_up.password = '1' * 4
|
47
|
-
# # @sign_up.valid?
|
48
|
-
# # @sign_up.errors[:password].should be_empty
|
49
|
-
|
50
|
-
# # @sign_up.password = '1' * 201
|
51
|
-
# # @sign_up.valid?
|
52
|
-
# # @sign_up.errors[:password].should == ["pick a longer password"]
|
53
|
-
# # end
|
54
|
-
|
55
|
-
# # end
|
56
|
-
# end
|
57
|
-
|
58
|
-
# it "saves" do
|
59
|
-
# pending "creates user"
|
60
|
-
|
61
|
-
# end
|
62
|
-
|
63
|
-
# end
|
64
|
-
# end
|