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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +16 -4
  3. data/app/controllers/hello/concerns/management/forgot_password.rb +1 -1
  4. data/app/controllers/hello/concerns/registration/sign_up.rb +7 -3
  5. data/app/controllers/hello/registration/sign_up_controller.rb +9 -1
  6. data/app/models/access.rb +2 -1
  7. data/app/models/credential.rb +2 -1
  8. data/app/models/email_credential.rb +2 -1
  9. data/app/models/password_credential.rb +2 -1
  10. data/app/models/user.rb +2 -1
  11. data/app/views/hello/shared/_nav_pills.html.erb +0 -2
  12. data/config/locales/hello.fr.yml +2 -4
  13. data/db/migrate/3_create_users.rb +10 -15
  14. data/lib/data/locales.yml +228 -0
  15. data/lib/generators/hello/install/install_generator.rb +8 -29
  16. data/lib/generators/hello/install/templates/initializer.rb +1 -1
  17. data/lib/generators/hello/install/templates/models/concerns/user/authorization.rb +8 -13
  18. data/lib/generators/hello/install/templates/models/user.rb +2 -1
  19. data/lib/generators/hello/users/USAGE +10 -0
  20. data/lib/generators/hello/{install/templates/users → users/templates/app}/controllers/users_controller.rb +2 -4
  21. data/lib/generators/hello/{install/templates/users → users/templates/app}/views/users/index.html.erb +1 -1
  22. data/lib/generators/hello/{install/templates/users → users/templates/app}/views/users/list.html.erb +3 -1
  23. data/lib/generators/hello/{install/templates/users → users/templates/app}/views/users/new.html.erb +2 -2
  24. data/lib/generators/hello/{install/templates/users → users/templates/app}/views/users/show.html.erb +0 -0
  25. data/lib/generators/hello/users/users_generator.rb +21 -0
  26. data/lib/hello/business/registration/sign_up.rb +30 -122
  27. data/lib/hello/locales.rb +1 -232
  28. data/lib/hello/rails_active_record/access.rb +12 -10
  29. data/lib/hello/rails_active_record/credential.rb +22 -18
  30. data/lib/hello/rails_active_record/email_credential.rb +12 -20
  31. data/lib/hello/rails_active_record/password_credential.rb +11 -32
  32. data/lib/hello/rails_active_record/user.rb +75 -54
  33. data/lib/hello/rails_controller.rb +1 -3
  34. data/lib/hello/rails_controller/restrict_by_role.rb +2 -2
  35. data/lib/hello/version.rb +1 -1
  36. data/spec/bdd/hello/authentication/classic_sign_in_spec.rb +2 -2
  37. data/spec/bdd/hello/internalionalization/anyone_can_change_their_locale/change_locale_on_the_sign_in_form_spec.rb +1 -1
  38. data/spec/bdd/hello/management/manage_email_credentials/manage_email_credentials_emails_page_spec.rb +7 -7
  39. data/spec/bdd/hello/management/manage_password_credentials/manage_password_forgot_password_spec.rb +1 -1
  40. data/spec/bdd/hello/management/manage_password_credentials/manage_password_reset_password_spec.rb +1 -1
  41. data/spec/bdd/hello/management/manage_profile/manage_profile_page_spec.rb +0 -2
  42. data/spec/bdd/hello/other/create_user_spec.rb +1 -3
  43. data/spec/bdd/hello/other/impersonate_user_spec.rb +1 -2
  44. data/spec/bdd/hello/other/list_users_spec.rb +2 -4
  45. data/spec/bdd/hello/registration/classic_sign_up_spec.rb +3 -4
  46. data/spec/bdd/hello/support.rb +0 -4
  47. data/spec/business/hello/registration/sign_up_spec.rb +10 -2
  48. data/spec/controllers/authentication_spec.rb +3 -3
  49. data/spec/models/create_and_destroy/email_credential_create_and_destroy_spec.rb +81 -0
  50. data/spec/models/create_and_destroy/password_credential_create_and_destroy_spec.rb +60 -0
  51. data/spec/models/create_and_destroy/user_create_and_destroy_spec.rb +124 -0
  52. data/spec/models/credential_spec.rb +12 -3
  53. data/spec/models/email_credential_spec.rb +1 -2
  54. data/spec/models/password_credential_spec.rb +1 -2
  55. data/spec/models/user_spec.rb +87 -27
  56. data/spec/requests/forgot_password_spec.rb +1 -1
  57. data/spec/support/factories.rb +10 -14
  58. data/spec/support/helpers/given.rb +8 -16
  59. data/spec/support/helpers/when.rb +0 -1
  60. metadata +42 -38
  61. data/lib/generators/hello/from_devise/USAGE +0 -8
  62. data/lib/generators/hello/from_devise/from_devise_generator.rb +0 -13
  63. data/lib/generators/hello/from_devise/templates/from_devise.migration.rb +0 -39
  64. data/spec/models/hello/sign_up_model_spec.rb +0 -64
@@ -1,8 +0,0 @@
1
- Description:
2
- Explain the generator
3
-
4
- Example:
5
- rails generate hello:from_devise
6
-
7
- This will create:
8
- what/will/it/create
@@ -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