refinerycms-authentication 1.0.11 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
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,69 +1,69 @@
1
1
  zh-TW:
2
- plugins:
3
- refinery_users:
4
- title: 使用者
5
- description: 管理使用者
6
- admin:
2
+ refinery:
3
+ plugins:
4
+ refinery_users:
5
+ title: 使用者
6
+ description: 管理使用者
7
+ admin:
8
+ users:
9
+ delete: 永遠移除這位使用者
10
+ edit: 編輯這位使用者
11
+ update:
12
+ cannot_remove_user_plugin_from_current_user: 您無法從目前登入的帳號移除 '使用者' 插件.
13
+ form:
14
+ blank_password_keeps_current: 密碼處空白可維持現在的密碼
15
+ plugin_access: 插件存取權限
16
+ role_access: 角色存取權限
17
+ enable_all: 全部開啟
18
+ actions:
19
+ create_new_user: 新增使用者
20
+ user:
21
+ email_user: 發送電子郵件給這個使用者
22
+ preview: '(%{who}) 加入 %{created_at}'
23
+ sessions:
24
+ new:
25
+ hello_please_sign_in: 您好! 請登入
26
+ sign_in: 登入
27
+ forgot_password: 我忘記了密碼
7
28
  users:
8
- delete: 永遠移除這位使用者
9
- edit: 編輯這位使用者
10
- update:
11
- cannot_remove_user_plugin_from_current_user: 您無法從目前登入的帳號移除 '使用者' 插件.
12
- form:
13
- blank_password_keeps_current: 密碼處空白可維持現在的密碼
14
- plugin_access: 插件存取權限
15
- role_access: 角色存取權限
16
- enable_all: 全部開啟
17
- actions:
18
- create_new_user: 新增使用者
19
- user:
20
- email_user: 發送電子郵件給這個使用者
21
- preview: '(%{who}) 加入 %{created_at}'
22
- sessions:
23
- new:
24
- hello_please_sign_in: 您好! 請登入
25
- sign_in: 登入
26
- forgot_password: 我忘記了密碼
27
- users:
28
- setup_website_name_html: "先給這個網站一個名字吧. <a href='%{link}' name='%{title}'>到這裡</a>來編輯您的網站名稱"
29
- new:
30
- fill_form: 在底下填入您的資料好繼續之後的流程.
31
- sign_up: 登入
32
- create:
33
- welcome: '歡迎使用 Refinery, %{who}'
34
- forgot:
35
- email_address: 電子郵件地址
36
- enter_email_address: 請為您的帳號輸入電子郵件地址
37
- reset_password: 重設密碼
38
- blank_email: 您沒有輸入電子郵件地址.
39
- email_not_associated_with_account_html: "抱歉, '%{email}' 不是任何帳號的電子郵件地址.<br />您確定輸入了正確的電子郵件地址嗎?"
40
- email_reset_sent: 一封附上可重設您密碼的連結的電子郵件已經寄給您
41
- password_encryption: "因為 Refinery 有些密碼加密演算法的改變, 所以您必須重設您的密碼, 如此您的密碼會比以往更安全地儲存著."
42
- reset:
43
- code_invalid: "很抱歉, 但這個重設碼過期或是失效了. 如果您遇到問題, 試著複製貼上您電子郵件上的網址到您的瀏覽器或是重新啟動重設密碼的流程."
44
- successful: "成功地重設 '%{email}' 的密碼"
45
- pick_new_password_for: "為 %{email} 挑選新的密碼"
46
- reset_password: 重設密碼
47
- user_mailer:
48
- reset_notification:
49
- subject: 重設您的密碼的連結
50
- reset_request_received_for: '請求重設 %{username} 的密碼'
51
- visit_this_url: 到這個網址來設定新的密碼
52
- remain_same_if_no_action: '如果您不做任何動作, 您的密碼將會維持不變'
29
+ new:
30
+ fill_form: 在底下填入您的資料好繼續之後的流程.
31
+ sign_up: 登入
32
+ create:
33
+ welcome: '歡迎使用 Refinery, %{who}'
34
+ forgot:
35
+ email_address: 電子郵件地址
36
+ enter_email_address: 請為您的帳號輸入電子郵件地址
37
+ reset_password: 重設密碼
38
+ blank_email: 您沒有輸入電子郵件地址.
39
+ email_not_associated_with_account_html: "抱歉, '%{email}' 不是任何帳號的電子郵件地址.<br />您確定輸入了正確的電子郵件地址嗎?"
40
+ email_reset_sent: 一封附上可重設您密碼的連結的電子郵件已經寄給您
41
+ password_encryption: "因為 Refinery 有些密碼加密演算法的改變, 所以您必須重設您的密碼, 如此您的密碼會比以往更安全地儲存著."
42
+ reset:
43
+ code_invalid: "很抱歉, 但這個重設碼過期或是失效了. 如果您遇到問題, 試著複製貼上您電子郵件上的網址到您的瀏覽器或是重新啟動重設密碼的流程."
44
+ successful: "成功地重設 '%{email}' 的密碼"
45
+ pick_new_password_for: "為 %{email} 挑選新的密碼"
46
+ reset_password: 重設密碼
47
+ user_mailer:
48
+ reset_notification:
49
+ subject: 重設您的密碼的連結
50
+ reset_request_received_for: '請求重設 %{username} 的密碼'
51
+ visit_this_url: 到這個網址來設定新的密碼
52
+ remain_same_if_no_action: '如果您不做任何動作, 您的密碼將會維持不變'
53
+ roles:
54
+ superuser: 管理者
55
+ refinery: Refinery
53
56
  devise:
54
57
  failure:
55
58
  unauthenticated: 您必須登入之後才能繼續.
56
59
  invalid: '抱歉, 您輸入的帳號或是密碼不正確.'
57
60
  sessions:
58
61
  signed_in: 登入成功.
59
- roles:
60
- superuser: 管理者
61
- refinery: Refinery
62
62
  activerecord:
63
63
  models:
64
- user: 使用者
64
+ refinery/user: 使用者
65
65
  attributes:
66
- user:
66
+ refinery/user:
67
67
  login: 登入
68
68
  username: 使用者名稱
69
69
  password: 密碼
data/config/routes.rb CHANGED
@@ -1,29 +1,35 @@
1
- ::Refinery::Application.routes.draw do
1
+ Refinery::Core::Engine.routes.draw do
2
+ begin
3
+ devise_for :refinery_user,
4
+ :class_name => 'Refinery::User',
5
+ :path => 'refinery/users',
6
+ :controllers => { :registrations => 'refinery/users' },
7
+ :skip => [:registrations],
8
+ :path_names => { :sign_out => 'logout',
9
+ :sign_in => 'login',
10
+ :sign_up => 'register' }
2
11
 
3
- # Add Devise necessary routes.
4
- # For Devise routes, see: https://github.com/plataformatec/devise
5
- devise_for :users, :controllers => {
6
- :sessions => 'sessions',
7
- :registrations => 'users',
8
- :passwords => 'passwords'
9
- }, :path_names => {
10
- :sign_out => 'logout',
11
- :sign_in => 'login',
12
- :sign_up => 'register'
13
- }
14
-
15
- # Override Devise's default after login redirection route. This will pushed a logged in user to the dashboard.
16
- get 'refinery', :to => 'admin/dashboard#index', :as => :refinery_root
17
- get 'refinery', :to => 'admin/dashboard#index', :as => :user_root
18
-
19
- # Override Devise's other routes for convenience methods.
20
- #get 'refinery/login', :to => "sessions#new", :as => :new_user_session
21
- #get 'refinery/login', :to => "sessions#new", :as => :refinery_login
22
- #get 'refinery/logout', :to => "sessions#destroy", :as => :destroy_user_session
23
- #get 'refinery/logout', :to => "sessions#destroy", :as => :logout
12
+ # Override Devise's other routes for convenience methods.
13
+ devise_scope :refinery_user do
14
+ get '/refinery/login', :to => "sessions#new", :as => :new_refinery_user_session
15
+ get '/refinery/logout', :to => "sessions#destroy", :as => :destroy_refinery_user_session
16
+ get '/refinery/users/register' => 'users#new', :as => :new_refinery_user_registration
17
+ post '/refinery/users/register' => 'users#create', :as => :refinery_user_registration
18
+ end
19
+ rescue RuntimeError => exc
20
+ if exc.message =~ /ORM/
21
+ # We don't want to complain on a fresh installation.
22
+ if (ARGV || []).exclude?('--fresh-installation')
23
+ puts "---\nYou can safely ignore the following warning if you're currently installing Refinery as Devise support files have not yet been copied to your application:\n\n"
24
+ puts exc.message
25
+ puts '---'
26
+ end
27
+ else
28
+ raise exc
29
+ end
30
+ end
24
31
 
25
- scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
32
+ namespace :admin, :path => 'refinery' do
26
33
  resources :users, :except => :show
27
34
  end
28
-
29
35
  end
@@ -1,43 +1,43 @@
1
1
  class CreateRefinerycmsAuthenticationSchema < ActiveRecord::Migration
2
- def self.up
2
+ def change
3
3
  # Postgres apparently requires the roles_users table to exist before creating the roles table.
4
- create_table ::RolesUsers.table_name, :id => false, :force => true do |t|
5
- t.integer "user_id"
6
- t.integer "role_id"
4
+ create_table :refinery_roles_users, :id => false do |t|
5
+ t.integer :user_id
6
+ t.integer :role_id
7
7
  end
8
8
 
9
- create_table ::Role.table_name, :force => true do |t|
10
- t.string "title"
11
- end
9
+ add_index :refinery_roles_users, [:role_id, :user_id]
10
+ add_index :refinery_roles_users, [:user_id, :role_id]
12
11
 
13
- create_table ::UserPlugin.table_name, :force => true do |t|
14
- t.integer "user_id"
15
- t.string "name"
16
- t.integer "position"
12
+ create_table :refinery_roles do |t|
13
+ t.string :title
17
14
  end
18
15
 
19
- add_index ::UserPlugin.table_name, ["name"], :name => "index_#{::UserPlugin.table_name}_on_title"
20
- add_index ::UserPlugin.table_name, ["user_id", "name"], :name => "index_unique_#{::UserPlugin.table_name}", :unique => true
21
-
22
- create_table ::User.table_name, :force => true do |t|
23
- t.string "login", :null => false
24
- t.string "email", :null => false
25
- t.string "crypted_password", :null => false
26
- t.string "password_salt", :null => false
27
- t.string "persistence_token"
28
- t.datetime "created_at"
29
- t.datetime "updated_at"
30
- t.string "perishable_token"
16
+ create_table :refinery_user_plugins do |t|
17
+ t.integer :user_id
18
+ t.string :name
19
+ t.integer :position
31
20
  end
32
21
 
33
- add_index ::User.table_name, ["id"], :name => "index_#{::User.table_name}_on_id"
34
- end
22
+ add_index :refinery_user_plugins, :name
23
+ add_index :refinery_user_plugins, [:user_id, :name], :unique => true
35
24
 
36
- def self.down
37
- [::User].reject{|m|
38
- !(defined?(m) and m.respond_to?(:table_name))
39
- }.each do |model|
40
- drop_table model.table_name
25
+ create_table :refinery_users do |t|
26
+ t.string :username, :null => false
27
+ t.string :email, :null => false
28
+ t.string :encrypted_password, :null => false
29
+ t.datetime :current_sign_in_at
30
+ t.datetime :last_sign_in_at
31
+ t.string :current_sign_in_ip
32
+ t.string :last_sign_in_ip
33
+ t.integer :sign_in_count
34
+ t.datetime :remember_created_at
35
+ t.string :reset_password_token
36
+ t.datetime :reset_password_sent_at
37
+
38
+ t.timestamps
41
39
  end
40
+
41
+ add_index :refinery_users, :id
42
42
  end
43
43
  end
@@ -0,0 +1,40 @@
1
+ module Refinery
2
+ module AuthenticatedSystem
3
+ # Store the URI of the current request in the session.
4
+ #
5
+ # We can return to this location by calling #redirect_back_or_default.
6
+ def store_location
7
+ session[:return_to] = request.fullpath.sub("//", "/")
8
+ end
9
+
10
+ # Redirect to the URI stored by the most recent store_location call or
11
+ # to the passed default.
12
+ def redirect_back_or_default(default)
13
+ redirect_to(session[:return_to] || default)
14
+ session[:return_to] = nil
15
+ end
16
+
17
+ # This just defines the devise method for after sign in to support
18
+ # extension namespace isolation...
19
+ def after_sign_in_path_for(resource_or_scope)
20
+ scope = Devise::Mapping.find_scope!(resource_or_scope)
21
+ home_path = "#{scope}_root_path"
22
+ respond_to?(home_path, true) ? refinery.send(home_path) : refinery.admin_root_path
23
+ end
24
+
25
+ def after_sign_out_path_for(resource_or_scope)
26
+ refinery.root_path
27
+ end
28
+
29
+ def refinery_user?
30
+ refinery_user_signed_in? && current_refinery_user.has_role?(:refinery)
31
+ end
32
+
33
+ protected :store_location, :redirect_back_or_default, :refinery_user?
34
+
35
+ def self.included(base)
36
+ base.send :helper_method, :current_refinery_user, :current_user_session,
37
+ :refinery_user_signed_in?, :refinery_user? if base.respond_to? :helper_method
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,9 @@
1
+ module Refinery
2
+ module Authentication
3
+ include ActiveSupport::Configurable
4
+
5
+ config_accessor :superuser_can_assign_roles
6
+
7
+ self.superuser_can_assign_roles = false
8
+ end
9
+ end
@@ -0,0 +1,36 @@
1
+ module Refinery
2
+ module Authentication
3
+ class Engine < ::Rails::Engine
4
+ include Refinery::Engine
5
+
6
+ isolate_namespace Refinery
7
+ engine_name :refinery_authentication
8
+
9
+ config.autoload_paths += %W( #{config.root}/lib )
10
+
11
+ initializer "register refinery_user plugin" do
12
+ Refinery::Plugin.register do |plugin|
13
+ plugin.pathname = root
14
+ plugin.name = 'refinery_users'
15
+ plugin.version = %q{2.0.0}
16
+ plugin.menu_match = %r{refinery/users$}
17
+ plugin.activity = {
18
+ :class_name => :'refinery/user',
19
+ :title => 'username'
20
+ }
21
+ plugin.url = { :controller => '/refinery/admin/users' }
22
+ end
23
+ end
24
+
25
+ before_inclusion do
26
+ [Refinery::ApplicationController, Refinery::AdminController, ::ApplicationHelper].each do |c|
27
+ c.send :include, Refinery::AuthenticatedSystem
28
+ end
29
+ end
30
+
31
+ config.after_initialize do
32
+ Refinery.register_extension(Refinery::Authentication)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,29 @@
1
+ require 'refinerycms-core'
2
+ require 'devise'
3
+ require 'friendly_id'
4
+
5
+ module Refinery
6
+ autoload :AuthenticatedSystem, 'refinery/authenticated_system'
7
+
8
+ class << self
9
+ attr_accessor :authentication_login_field
10
+ def authentication_login_field
11
+ @authentication_login_field ||= 'login'
12
+ end
13
+ end
14
+
15
+ module Authentication
16
+ require 'refinery/authentication/engine'
17
+ require 'refinery/authentication/configuration'
18
+
19
+ class << self
20
+ def factory_paths
21
+ @factory_paths ||= [ root.join("spec/factories").to_s ]
22
+ end
23
+
24
+ def root
25
+ @root ||= Pathname.new(File.expand_path('../../../', __FILE__))
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,54 +1 @@
1
- require 'devise'
2
- require 'refinerycms-core'
3
- require 'friendly_id'
4
-
5
- module Refinery
6
- module Authentication
7
-
8
- class Engine < ::Rails::Engine
9
-
10
- initializer 'serve static assets' do |app|
11
- app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
12
- end
13
-
14
- config.autoload_paths += %W( #{config.root}/lib )
15
-
16
- config.after_initialize do
17
- ::Refinery::Plugin.register do |plugin|
18
- plugin.pathname = root
19
- plugin.name = 'refinery_users'
20
- plugin.version = %q{1.0.0}
21
- plugin.menu_match = /(refinery|admin)\/users$/
22
- plugin.activity = {
23
- :class => User,
24
- :title => 'username'
25
- }
26
- plugin.url = {:controller => '/admin/users'}
27
- end
28
- end
29
-
30
- refinery.before_inclusion do
31
- [::Refinery::ApplicationController, ::Refinery::ApplicationHelper].each do |c|
32
- c.send :require, File.expand_path('../authenticated_system', __FILE__)
33
- c.send :include, AuthenticatedSystem
34
- end
35
- end
36
- end
37
-
38
- class << self
39
- attr_accessor :root
40
- def root
41
- @root ||= Pathname.new(File.expand_path('../../', __FILE__))
42
- end
43
- end
44
- end
45
-
46
- class << self
47
- attr_accessor :authentication_login_field
48
- def authentication_login_field
49
- @authentication_login_field ||= 'login'
50
- end
51
- end
52
- end
53
-
54
- ::Refinery.engines << 'authentication'
1
+ require 'refinery/authentication'
@@ -1,121 +1,26 @@
1
1
  # Encoding: UTF-8
2
- # DO NOT EDIT THIS FILE DIRECTLY! Instead, use lib/gemspec.rb to generate it.
2
+ $:.push File.expand_path('../../core/lib', __FILE__)
3
+ require 'refinery/version'
4
+
5
+ version = Refinery::Version.to_s
3
6
 
4
7
  Gem::Specification.new do |s|
8
+ s.platform = Gem::Platform::RUBY
5
9
  s.name = %q{refinerycms-authentication}
6
- s.version = %q{1.0.11}
7
- s.summary = %q{Authentication engine for Refinery CMS}
8
- s.description = %q{The default authentication engine for Refinery CMS}
9
- s.date = %q{2012-05-18}
10
+ s.version = version
11
+ s.summary = %q{Authentication extension for Refinery CMS}
12
+ s.description = %q{The default authentication extension for Refinery CMS}
10
13
  s.email = %q{info@refinerycms.com}
11
14
  s.homepage = %q{http://refinerycms.com}
12
15
  s.rubyforge_project = %q{refinerycms}
13
- s.authors = ['Resolve Digital', 'Philip Arndt', 'David Jones', 'Steven Heidel', 'Uģis Ozols']
16
+ s.authors = ['Philip Arndt', 'Uģis Ozols', 'David Jones', 'Steven Heidel']
14
17
  s.license = %q{MIT}
15
18
  s.require_paths = %w(lib)
16
- s.executables = %w()
17
19
 
18
- s.add_dependency 'refinerycms-core', '= 1.0.11'
19
- s.add_dependency 'activerecord', '~> 3.0.10'
20
- s.add_dependency 'devise', '~> 1.4.3'
21
- s.add_dependency 'friendly_id_globalize3', '~> 3.2.1'
20
+ s.files = `git ls-files`.split("\n")
21
+ s.test_files = `git ls-files -- spec/*`.split("\n")
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
22
23
 
23
- s.files = [
24
- 'app',
25
- 'app/controllers',
26
- 'app/controllers/admin',
27
- 'app/controllers/admin/users_controller.rb',
28
- 'app/controllers/passwords_controller.rb',
29
- 'app/controllers/sessions_controller.rb',
30
- 'app/controllers/users_controller.rb',
31
- 'app/helpers',
32
- 'app/helpers/sessions_helper.rb',
33
- 'app/helpers/users_helper.rb',
34
- 'app/mailers',
35
- 'app/mailers/user_mailer.rb',
36
- 'app/models',
37
- 'app/models/role.rb',
38
- 'app/models/roles_users.rb',
39
- 'app/models/user.rb',
40
- 'app/models/user_plugin.rb',
41
- 'app/views',
42
- 'app/views/admin',
43
- 'app/views/admin/users',
44
- 'app/views/admin/users/_actions.html.erb',
45
- 'app/views/admin/users/_form.html.erb',
46
- 'app/views/admin/users/_records.html.erb',
47
- 'app/views/admin/users/_user.html.erb',
48
- 'app/views/admin/users/_users.html.erb',
49
- 'app/views/admin/users/edit.html.erb',
50
- 'app/views/admin/users/index.html.erb',
51
- 'app/views/admin/users/new.html.erb',
52
- 'app/views/layouts',
53
- 'app/views/layouts/login.html.erb',
54
- 'app/views/passwords',
55
- 'app/views/passwords/edit.html.erb',
56
- 'app/views/passwords/new.html.erb',
57
- 'app/views/sessions',
58
- 'app/views/sessions/new.html.erb',
59
- 'app/views/user_mailer',
60
- 'app/views/user_mailer/reset_notification.html.erb',
61
- 'app/views/user_mailer/reset_notification.text.plain.erb',
62
- 'app/views/users',
63
- 'app/views/users/new.html.erb',
64
- 'config',
65
- 'config/locales',
66
- 'config/locales/bg.yml',
67
- 'config/locales/cs.yml',
68
- 'config/locales/da.yml',
69
- 'config/locales/de.yml',
70
- 'config/locales/el.yml',
71
- 'config/locales/en.yml',
72
- 'config/locales/es.yml',
73
- 'config/locales/fi.yml',
74
- 'config/locales/fr.yml',
75
- 'config/locales/it.yml',
76
- 'config/locales/jp.yml',
77
- 'config/locales/lolcat.yml',
78
- 'config/locales/lt.yml',
79
- 'config/locales/lv.yml',
80
- 'config/locales/nb.yml',
81
- 'config/locales/nl.yml',
82
- 'config/locales/pl.yml',
83
- 'config/locales/pt-BR.yml',
84
- 'config/locales/rs.yml',
85
- 'config/locales/ru.yml',
86
- 'config/locales/sk.yml',
87
- 'config/locales/sl.yml',
88
- 'config/locales/sv.yml',
89
- 'config/locales/vi.yml',
90
- 'config/locales/zh-CN.yml',
91
- 'config/locales/zh-TW.yml',
92
- 'config/routes.rb',
93
- 'db',
94
- 'db/migrate',
95
- 'db/migrate/20100913234705_create_refinerycms_authentication_schema.rb',
96
- 'db/migrate/20100929035252_add_missing_indexes_to_roles_users.rb',
97
- 'db/migrate/20101206013505_change_to_devise_users_table.rb',
98
- 'db/migrate/20110106184757_add_remember_created_at_to_users.rb',
99
- 'db/migrate/20110325213325_remove_password_salt_from_users.rb',
100
- 'features',
101
- 'features/lost_password.feature',
102
- 'features/manage_users.feature',
103
- 'features/step_definitions',
104
- 'features/step_definitions/lost_password.rb',
105
- 'features/step_definitions/user_steps.rb',
106
- 'features/support',
107
- 'features/support/factories.rb',
108
- 'features/support/paths.rb',
109
- 'lib',
110
- 'lib/authenticated_system.rb',
111
- 'lib/gemspec.rb',
112
- 'lib/generators',
113
- 'lib/generators/refinerycms_authentication_generator.rb',
114
- 'lib/refinerycms-authentication.rb',
115
- 'license.md',
116
- 'refinerycms-authentication.gemspec',
117
- 'spec',
118
- 'spec/models',
119
- 'spec/models/user_spec.rb'
120
- ]
24
+ s.add_dependency 'devise', '~> 2.0.0'
25
+ s.add_dependency 'refinerycms-core', version
121
26
  end
@@ -0,0 +1,73 @@
1
+ require "spec_helper"
2
+
3
+ describe Refinery::Admin::UsersController do
4
+ login_refinery_superuser
5
+
6
+ shared_examples_for "new, create, update, edit and update actions" do
7
+ it "should load roles" do
8
+ Refinery::Role.should_receive(:all).once{ [] }
9
+ get :new
10
+ end
11
+
12
+ it "should load plugins" do
13
+ plugins = Refinery::Plugins.new
14
+ plugins.should_receive(:in_menu).once{ [] }
15
+
16
+ Refinery::Plugins.should_receive(:registered).at_least(1).times{ plugins }
17
+ get :new
18
+ end
19
+ end
20
+
21
+ describe "#new" do
22
+ it "should render the new template" do
23
+ get :new
24
+ response.should be_success
25
+ response.should render_template("refinery/admin/users/new")
26
+ end
27
+
28
+ it_should_behave_like "new, create, update, edit and update actions"
29
+ end
30
+
31
+ describe "#create" do
32
+ it "should create a new user with valid params" do
33
+ user = Refinery::User.new :username => "bob"
34
+ user.should_receive(:save).once{ true }
35
+ Refinery::User.should_receive(:new).once.with(instance_of(HashWithIndifferentAccess)){ user }
36
+ post :create, :user => {}
37
+ response.should be_redirect
38
+ end
39
+
40
+ it_should_behave_like "new, create, update, edit and update actions"
41
+
42
+ it "should re-render #new if there are errors" do
43
+ user = Refinery::User.new :username => "bob"
44
+ user.should_receive(:save).once{ false }
45
+ Refinery::User.should_receive(:new).once.with(instance_of(HashWithIndifferentAccess)){ user }
46
+ post :create, :user => {}
47
+ response.should be_success
48
+ response.should render_template("refinery/admin/users/new")
49
+ end
50
+ end
51
+
52
+ describe "#edit" do
53
+ it "should render the edit template" do
54
+ Refinery::User.should_receive(:find).at_least(1).times{ @refinery_superuser }
55
+ get :edit, :id => "1"
56
+ response.should be_success
57
+ response.should render_template("refinery/admin/users/edit")
58
+ end
59
+
60
+ it_should_behave_like "new, create, update, edit and update actions"
61
+ end
62
+
63
+ describe "#update" do
64
+ it "should update a user" do
65
+ user = FactoryGirl.create(:refinery_user)
66
+ Refinery::User.should_receive(:find).at_least(1).times{ user }
67
+ put "update", :id => user.id.to_s, :user => {}
68
+ response.should be_redirect
69
+ end
70
+
71
+ it_should_behave_like "new, create, update, edit and update actions"
72
+ end
73
+ end