refinerycms-authentication 1.0.11 → 2.0.0

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.
Files changed (105) hide show
  1. data/app/controllers/refinery/admin/users_controller.rb +100 -0
  2. data/app/controllers/refinery/passwords_controller.rb +51 -0
  3. data/app/controllers/refinery/sessions_controller.rb +26 -0
  4. data/app/controllers/refinery/users_controller.rb +42 -0
  5. data/app/helpers/refinery/sessions_helper.rb +4 -0
  6. data/app/helpers/refinery/users_helper.rb +4 -0
  7. data/app/mailers/refinery/user_mailer.rb +22 -0
  8. data/app/models/refinery/role.rb +18 -0
  9. data/app/models/refinery/roles_users.rb +8 -0
  10. data/app/models/refinery/user.rb +94 -0
  11. data/app/models/refinery/user_plugin.rb +8 -0
  12. data/app/views/refinery/admin/users/_actions.html.erb +6 -0
  13. data/app/views/{admin → refinery/admin}/users/_form.html.erb +15 -19
  14. data/app/views/{admin → refinery/admin}/users/_records.html.erb +1 -1
  15. data/app/views/refinery/admin/users/_user.html.erb +21 -0
  16. data/app/views/refinery/admin/users/_users.html.erb +4 -0
  17. data/app/views/refinery/admin/users/edit.html.erb +1 -0
  18. data/app/views/refinery/admin/users/index.html.erb +6 -0
  19. data/app/views/refinery/admin/users/new.html.erb +1 -0
  20. data/app/views/{layouts → refinery/layouts}/login.html.erb +3 -4
  21. data/app/views/refinery/passwords/edit.html.erb +26 -0
  22. data/app/views/refinery/passwords/new.html.erb +17 -0
  23. data/app/views/{sessions → refinery/sessions}/new.html.erb +6 -8
  24. data/app/views/refinery/user_mailer/reset_notification.html.erb +12 -0
  25. data/app/views/refinery/user_mailer/reset_notification.text.plain.erb +7 -0
  26. data/app/views/refinery/users/new.html.erb +29 -0
  27. data/config/locales/bg.yml +55 -55
  28. data/config/locales/cs.yml +58 -58
  29. data/config/locales/da.yml +55 -55
  30. data/config/locales/de.yml +55 -55
  31. data/config/locales/el.yml +55 -55
  32. data/config/locales/en.yml +55 -55
  33. data/config/locales/es.yml +55 -60
  34. data/config/locales/fi.yml +55 -55
  35. data/config/locales/fr.yml +55 -55
  36. data/config/locales/it.yml +51 -57
  37. data/config/locales/ja.yml +72 -0
  38. data/config/locales/ko.yml +72 -0
  39. data/config/locales/lt.yml +46 -46
  40. data/config/locales/lv.yml +55 -55
  41. data/config/locales/nb.yml +55 -55
  42. data/config/locales/nl.yml +55 -55
  43. data/config/locales/pl.yml +53 -59
  44. data/config/locales/pt-BR.yml +52 -52
  45. data/config/locales/rs.yml +62 -61
  46. data/config/locales/ru.yml +52 -52
  47. data/config/locales/sk.yml +55 -55
  48. data/config/locales/sl.yml +55 -54
  49. data/config/locales/sv.yml +52 -52
  50. data/config/locales/vi.yml +55 -55
  51. data/config/locales/zh-CN.yml +55 -55
  52. data/config/locales/zh-TW.yml +55 -55
  53. data/config/routes.rb +30 -24
  54. data/db/migrate/20100913234705_create_refinerycms_authentication_schema.rb +30 -30
  55. data/lib/refinery/authenticated_system.rb +40 -0
  56. data/lib/refinery/authentication/configuration.rb +9 -0
  57. data/lib/refinery/authentication/engine.rb +36 -0
  58. data/lib/refinery/authentication.rb +29 -0
  59. data/lib/refinerycms-authentication.rb +1 -54
  60. data/refinerycms-authentication.gemspec +14 -109
  61. data/spec/controllers/refinery/admin/users_controller_spec.rb +73 -0
  62. data/spec/factories/user.rb +38 -0
  63. data/spec/models/refinery/user_spec.rb +220 -0
  64. data/spec/requests/refinery/admin/users_spec.rb +49 -0
  65. data/spec/requests/refinery/passwords_spec.rb +84 -0
  66. data/spec/requests/refinery/sessions_spec.rb +62 -0
  67. metadata +109 -124
  68. data/app/controllers/admin/users_controller.rb +0 -86
  69. data/app/controllers/passwords_controller.rb +0 -42
  70. data/app/controllers/sessions_controller.rb +0 -23
  71. data/app/controllers/users_controller.rb +0 -67
  72. data/app/helpers/sessions_helper.rb +0 -2
  73. data/app/helpers/users_helper.rb +0 -2
  74. data/app/mailers/user_mailer.rb +0 -20
  75. data/app/models/role.rb +0 -16
  76. data/app/models/roles_users.rb +0 -6
  77. data/app/models/user.rb +0 -65
  78. data/app/models/user_plugin.rb +0 -6
  79. data/app/views/admin/users/_actions.html.erb +0 -5
  80. data/app/views/admin/users/_user.html.erb +0 -19
  81. data/app/views/admin/users/_users.html.erb +0 -4
  82. data/app/views/admin/users/edit.html.erb +0 -1
  83. data/app/views/admin/users/index.html.erb +0 -6
  84. data/app/views/admin/users/new.html.erb +0 -1
  85. data/app/views/passwords/edit.html.erb +0 -31
  86. data/app/views/passwords/new.html.erb +0 -18
  87. data/app/views/user_mailer/reset_notification.html.erb +0 -12
  88. data/app/views/user_mailer/reset_notification.text.plain.erb +0 -7
  89. data/app/views/users/new.html.erb +0 -41
  90. data/config/locales/jp.yml +0 -72
  91. data/config/locales/lolcat.yml +0 -55
  92. data/db/migrate/20100929035252_add_missing_indexes_to_roles_users.rb +0 -11
  93. data/db/migrate/20101206013505_change_to_devise_users_table.rb +0 -27
  94. data/db/migrate/20110106184757_add_remember_created_at_to_users.rb +0 -9
  95. data/db/migrate/20110325213325_remove_password_salt_from_users.rb +0 -13
  96. data/features/lost_password.feature +0 -49
  97. data/features/manage_users.feature +0 -88
  98. data/features/step_definitions/lost_password.rb +0 -8
  99. data/features/step_definitions/user_steps.rb +0 -41
  100. data/features/support/factories.rb +0 -32
  101. data/features/support/paths.rb +0 -24
  102. data/lib/authenticated_system.rb +0 -29
  103. data/lib/gemspec.rb +0 -38
  104. data/lib/generators/refinerycms_authentication_generator.rb +0 -8
  105. data/spec/models/user_spec.rb +0 -152
@@ -1,152 +0,0 @@
1
- require 'spec_helper'
2
-
3
- Dir[File.expand_path('../../../features/support/factories.rb', __FILE__)].each {|f| require f}
4
-
5
- describe User do
6
-
7
- let(:user) { Factory(:user) }
8
- let(:refinery_user) { Factory(:refinery_user) }
9
-
10
- context "Roles" do
11
- context "add_role" do
12
- it "raises Exception when Role object is passed" do
13
- proc {user.add_role(Role.new)}.should raise_exception
14
- end
15
-
16
- it "adds a Role to the User when role not yet assigned to User" do
17
- proc {
18
- user.add_role(:new_role)
19
- }.should change(user.roles, :count).by(1)
20
- user.roles.collect(&:title).should include("NewRole")
21
- end
22
-
23
- it "does not add a Role to the User when this Role is already assigned to User" do
24
- proc {
25
- refinery_user.add_role(:refinery)
26
- }.should_not change(refinery_user.roles, :count).by(1)
27
- refinery_user.roles.collect(&:title).should include("Refinery")
28
- end
29
- end
30
-
31
- context "has_role" do
32
- it "raises Exception when Role object is passed" do
33
- proc{ user.has_role?(Role.new)}.should raise_exception
34
- end
35
-
36
- it "returns the true if user has Role" do
37
- refinery_user.has_role?(:refinery).should be_true
38
- end
39
-
40
- it "returns false if user hasn't the Role" do
41
- refinery_user.has_role?(:refinery_fail).should be_false
42
- end
43
- end
44
-
45
- describe "role association" do
46
- it "have a roles attribute" do
47
- user.should respond_to(:roles)
48
- end
49
- end
50
- end
51
-
52
- context "validations" do
53
- # email and password validations are done by including devises validatable
54
- # module so those validations are not tested here
55
- let(:attr) do
56
- {
57
- :username => "RefineryCMS",
58
- :email => "refinery@cms.com",
59
- :password => "123456",
60
- :password_confirmation => "123456"
61
- }
62
- end
63
-
64
- it "requires username" do
65
- User.new(attr.merge(:username => "")).should_not be_valid
66
- end
67
-
68
- it "rejects duplicate usernames" do
69
- User.create!(attr)
70
- User.new(attr.merge(:email => "another@email.com")).should_not be_valid
71
- end
72
- end
73
-
74
- describe ".find_for_database_authentication" do
75
- it "finds user either by username or email" do
76
- User.find_for_database_authentication(:login => user.username).should == user
77
- User.find_for_database_authentication(:login => user.email).should == user
78
- end
79
- end
80
-
81
- describe "#can_delete?" do
82
- let(:user_not_persisted) { Factory.build(:refinery_user) }
83
- let(:super_user) do
84
- super_user = Factory(:refinery_user)
85
- super_user.add_role(:superuser)
86
- super_user
87
- end
88
-
89
- context "won't allow to delete" do
90
- it "not persisted user record" do
91
- refinery_user.can_delete?(user_not_persisted).should be_false
92
- end
93
-
94
- it "user with superuser role" do
95
- refinery_user.can_delete?(super_user).should be_false
96
- end
97
-
98
- it "if user count with refinery role <= 1" do
99
- Role[:refinery].users.delete(refinery_user)
100
- super_user.can_delete?(refinery_user).should be_false
101
- end
102
-
103
- it "user himself" do
104
- refinery_user.can_delete?(refinery_user).should be_false
105
- end
106
- end
107
-
108
- context "allow to delete" do
109
- it "if all conditions return true" do
110
- super_user.can_delete?(refinery_user).should be_true
111
- end
112
- end
113
- end
114
-
115
- describe "#plugins=" do
116
- it "assigns plugins to user" do
117
- plugin_list = ["refinery_one", "refinery_two", "refinery_three"]
118
- user.plugins = plugin_list
119
- user.plugins.collect { |p| p.name }.should == plugin_list
120
- end
121
- end
122
-
123
- describe "#authorized_plugins" do
124
- it "returns array of user and always allowd plugins" do
125
- ["refinery_one", "refinery_two", "refinery_three"].each_with_index do |name, index|
126
- user.plugins.create!(:name => name, :position => index)
127
- end
128
- user.authorized_plugins.should == user.plugins.collect { |p| p.name } | Refinery::Plugins.always_allowed.names
129
- end
130
- end
131
-
132
- describe "plugins association" do
133
- let(:plugin_list) { ["refinery_one", "refinery_two", "refinery_three"] }
134
- before { user.plugins = plugin_list }
135
-
136
- it "have a plugins attribute" do
137
- user.should respond_to(:plugins)
138
- end
139
-
140
- it "returns plugins in ASC order" do
141
- user.plugins[0].name.should == plugin_list[0]
142
- user.plugins[1].name.should == plugin_list[1]
143
- user.plugins[2].name.should == plugin_list[2]
144
- end
145
-
146
- it "deletes associated plugins" do
147
- user.destroy
148
- UserPlugin.find_by_user_id(user.id).should be_nil
149
- end
150
- end
151
-
152
- end