alchemy_cms 2.8.3 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/README.md +108 -25
  4. data/alchemy_cms.gemspec +0 -1
  5. data/app/assets/stylesheets/alchemy/archive.scss +2 -2
  6. data/app/assets/stylesheets/alchemy/base.scss +0 -37
  7. data/app/assets/stylesheets/alchemy/elements.scss +1 -1
  8. data/app/assets/stylesheets/alchemy/flash.scss +1 -1
  9. data/app/assets/stylesheets/alchemy/form_elements.scss +1 -1
  10. data/app/assets/stylesheets/alchemy/icon-font.css.scss +40 -40
  11. data/app/assets/stylesheets/alchemy/icons.scss +4 -32
  12. data/app/assets/stylesheets/alchemy/jquery-ui.scss +4 -4
  13. data/app/assets/stylesheets/alchemy/menubar.css.scss +20 -12
  14. data/app/assets/stylesheets/alchemy/modules.scss +0 -4
  15. data/app/assets/stylesheets/alchemy/search.scss +1 -1
  16. data/app/assets/stylesheets/alchemy/sitemap.scss +1 -1
  17. data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy-tinymce-dialog/window.css.scss +3 -3
  18. data/app/controllers/alchemy/admin/base_controller.rb +12 -8
  19. data/app/controllers/alchemy/admin/dashboard_controller.rb +10 -5
  20. data/app/controllers/alchemy/admin/elements_controller.rb +1 -1
  21. data/app/controllers/alchemy/admin/essence_pictures_controller.rb +8 -1
  22. data/app/controllers/alchemy/admin/layoutpages_controller.rb +1 -1
  23. data/app/controllers/alchemy/admin/pages_controller.rb +11 -6
  24. data/app/controllers/alchemy/admin/resources_controller.rb +2 -2
  25. data/app/controllers/alchemy/admin/users_controller.rb +1 -1
  26. data/app/controllers/alchemy/base_controller.rb +71 -37
  27. data/app/controllers/alchemy/elements_controller.rb +1 -1
  28. data/app/controllers/alchemy/pages_controller.rb +9 -3
  29. data/app/controllers/alchemy/pictures_controller.rb +1 -0
  30. data/app/helpers/alchemy/admin/base_helper.rb +2 -10
  31. data/app/helpers/alchemy/admin/pages_helper.rb +1 -1
  32. data/app/helpers/alchemy/base_helper.rb +1 -1
  33. data/app/helpers/alchemy/pages_helper.rb +1 -1
  34. data/app/models/alchemy/attachment.rb +3 -4
  35. data/app/models/alchemy/cell.rb +1 -1
  36. data/app/models/alchemy/content.rb +3 -4
  37. data/app/models/alchemy/element.rb +5 -6
  38. data/app/models/alchemy/folded_page.rb +1 -1
  39. data/app/models/alchemy/language.rb +1 -1
  40. data/app/models/alchemy/message.rb +1 -7
  41. data/app/models/alchemy/page.rb +12 -10
  42. data/app/models/alchemy/page/{cells.rb → page_cells.rb} +2 -2
  43. data/app/models/alchemy/page/{elements.rb → page_elements.rb} +2 -2
  44. data/app/models/alchemy/page/{naming.rb → page_naming.rb} +1 -1
  45. data/app/models/alchemy/page/{natures.rb → page_natures.rb} +3 -3
  46. data/app/models/alchemy/page/{scopes.rb → page_scopes.rb} +3 -3
  47. data/app/models/alchemy/page/page_users.rb +33 -0
  48. data/app/models/alchemy/picture.rb +3 -3
  49. data/app/models/alchemy/site.rb +2 -2
  50. data/app/views/alchemy/admin/dashboard/_locked_pages.html.erb +1 -1
  51. data/app/views/alchemy/admin/dashboard/_recent_pages.html.erb +1 -1
  52. data/app/views/alchemy/admin/dashboard/_sites.html.erb +1 -1
  53. data/app/views/alchemy/admin/dashboard/index.html.erb +10 -4
  54. data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
  55. data/app/views/alchemy/admin/pages/update.js.erb +1 -1
  56. data/app/views/alchemy/{user_sessions → base}/leave.html.erb +2 -2
  57. data/app/views/alchemy/base/permission_denied.js.erb +3 -2
  58. data/app/views/layouts/alchemy/admin.html.erb +6 -3
  59. data/config/alchemy/config.yml +1 -11
  60. data/config/alchemy/modules.yml +0 -12
  61. data/config/locales/alchemy.de.yml +3 -40
  62. data/config/locales/alchemy.en.yml +2 -22
  63. data/config/routes.rb +2 -27
  64. data/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
  65. data/lib/alchemy/auth_accessors.rb +54 -0
  66. data/lib/alchemy/capistrano.rb +5 -17
  67. data/lib/alchemy/engine.rb +7 -7
  68. data/lib/alchemy/errors.rb +6 -0
  69. data/lib/alchemy/essence.rb +2 -2
  70. data/lib/alchemy/seeder.rb +1 -1
  71. data/lib/alchemy/tasks/helpers.rb +83 -0
  72. data/lib/alchemy/test_support/auth_helpers.rb +35 -0
  73. data/lib/alchemy/test_support/controller_requests.rb +37 -0
  74. data/{spec/support → lib/alchemy/test_support}/factories.rb +7 -28
  75. data/{spec/support/alchemy → lib/alchemy/test_support}/integration_helpers.rb +9 -36
  76. data/lib/alchemy/upgrader.rb +8 -7
  77. data/lib/alchemy/upgrader/two_point_nine.rb +33 -0
  78. data/lib/alchemy/userstamp.rb +10 -0
  79. data/lib/alchemy/version.rb +1 -3
  80. data/lib/rails/templates/alchemy.rb +1 -0
  81. data/lib/tasks/alchemy/db.rake +5 -5
  82. data/spec/controllers/admin/attachments_controller_spec.rb +3 -3
  83. data/spec/controllers/admin/dashboard_controller_spec.rb +55 -34
  84. data/spec/controllers/admin/elements_controller_spec.rb +1 -1
  85. data/spec/controllers/admin/essence_pictures_controller_spec.rb +22 -6
  86. data/spec/controllers/admin/pages_controller_spec.rb +41 -58
  87. data/spec/controllers/admin/resources_controller_spec.rb +30 -5
  88. data/spec/controllers/admin/trash_controller_spec.rb +1 -1
  89. data/spec/controllers/attachments_controller_spec.rb +26 -44
  90. data/spec/controllers/base_controller_spec.rb +8 -33
  91. data/spec/controllers/elements_controller_spec.rb +1 -1
  92. data/spec/controllers/pages_controller_spec.rb +7 -15
  93. data/spec/controllers/pictures_controller_spec.rb +44 -5
  94. data/spec/dummy/app/controllers/application_controller.rb +9 -1
  95. data/spec/dummy/app/models/user.rb +14 -0
  96. data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
  97. data/spec/dummy/db/schema.rb +0 -31
  98. data/spec/features/admin/language_tree_feature_spec.rb +34 -0
  99. data/spec/features/admin/pages_controller_spec.rb +1 -1
  100. data/spec/features/pages_controller_spec.rb +5 -12
  101. data/spec/features/picture_security_spec.rb +2 -2
  102. data/spec/features/security_spec.rb +6 -45
  103. data/spec/features/translation_integration_spec.rb +11 -20
  104. data/spec/{support → fixtures}/80x60.png +0 -0
  105. data/spec/support/image with spaces.png b/data/spec/fixtures/image with → spaces.png +0 -0
  106. data/spec/{support → fixtures}/image.png +0 -0
  107. data/spec/{support → fixtures}/image2.PNG +0 -0
  108. data/spec/{support → fixtures}/image3.jpeg +0 -0
  109. data/spec/helpers/admin/base_helper_spec.rb +31 -43
  110. data/spec/helpers/admin/pages_helper_spec.rb +4 -2
  111. data/spec/helpers/base_helper_spec.rb +10 -3
  112. data/spec/helpers/pages_helper_spec.rb +32 -22
  113. data/spec/models/attachment_spec.rb +1 -1
  114. data/spec/models/element_spec.rb +33 -57
  115. data/spec/models/message_spec.rb +0 -16
  116. data/spec/models/page_spec.rb +62 -26
  117. data/spec/models/picture_spec.rb +5 -5
  118. data/spec/spec_helper.rb +13 -4
  119. data/spec/tasks/helpers_spec.rb +213 -0
  120. metadata +33 -75
  121. data/app/controllers/alchemy/passwords_controller.rb +0 -35
  122. data/app/controllers/alchemy/user_sessions_controller.rb +0 -67
  123. data/app/controllers/alchemy/users_controller.rb +0 -46
  124. data/app/mailers/alchemy/notifications.rb +0 -33
  125. data/app/models/alchemy/page/users.rb +0 -25
  126. data/app/models/alchemy/user.rb +0 -183
  127. data/app/views/alchemy/admin/users/_table.html.erb +0 -69
  128. data/app/views/alchemy/admin/users/_user.html.erb +0 -39
  129. data/app/views/alchemy/admin/users/edit.html.erb +0 -6
  130. data/app/views/alchemy/admin/users/index.html.erb +0 -58
  131. data/app/views/alchemy/admin/users/new.html.erb +0 -6
  132. data/app/views/alchemy/notifications/admin_user_created.de.text.erb +0 -15
  133. data/app/views/alchemy/notifications/admin_user_created.en.text.erb +0 -15
  134. data/app/views/alchemy/notifications/registered_user_created.de.text.erb +0 -13
  135. data/app/views/alchemy/notifications/registered_user_created.en.text.erb +0 -13
  136. data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +0 -8
  137. data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +0 -8
  138. data/app/views/alchemy/passwords/edit.html.erb +0 -35
  139. data/app/views/alchemy/passwords/new.html.erb +0 -30
  140. data/app/views/alchemy/user_sessions/new.html.erb +0 -48
  141. data/app/views/alchemy/users/new.html.erb +0 -14
  142. data/config/initializers/devise.rb +0 -242
  143. data/config/locales/devise.de.yml +0 -58
  144. data/config/locales/devise.en.yml +0 -60
  145. data/lib/rails/generators/alchemy/devise/devise_generator.rb +0 -29
  146. data/spec/controllers/admin/users_controller_spec.rb +0 -132
  147. data/spec/controllers/passwords_controller_spec.rb +0 -16
  148. data/spec/controllers/user_sessions_controller_spec.rb +0 -22
  149. data/spec/controllers/users_controller_spec.rb +0 -66
  150. data/spec/mailers/notifications_spec.rb +0 -67
  151. data/spec/models/user_spec.rb +0 -252
  152. data/spec/support/alchemy/controller_helpers.rb +0 -35
@@ -1,58 +0,0 @@
1
- de:
2
- errors:
3
- messages:
4
- expired: "ist abgelaufen, bitte neu anfordern"
5
- not_found: "nicht gefunden"
6
- already_confirmed: "wurde bereits bestätigt"
7
- not_locked: "ist nicht gesperrt"
8
- not_saved:
9
- one: "Es konnte nicht fortfahren werden:"
10
- other: "Es konnte nicht fortfahren werden:"
11
-
12
- devise:
13
- failure:
14
- already_authenticated: 'Sie sind bereits angemeldet.'
15
- unauthenticated: 'Sie müssen sich anmelden oder registrieren, bevor Sie fortfahren können.'
16
- unconfirmed: 'Sie müssen Ihren Account bestätigen, bevor Sie fortfahren können.'
17
- locked: 'Ihr Account ist gesperrt.'
18
- invalid: 'Ungültige Anmeldedaten.'
19
- invalid_token: 'Der Anmelde-Token ist ungültig.'
20
- timeout: 'Ihre Sitzung ist abgelaufen, bitte melden Sie sich erneut an.'
21
- inactive: 'Ihr Account ist nicht aktiv.'
22
- user:
23
- not_found_in_database: 'Ungültige Anmeldedaten.'
24
- sessions:
25
- signed_in: 'Erfolgreich angemeldet.'
26
- signed_out: 'Erfolgreich abgemeldet.'
27
- passwords:
28
- send_instructions: 'Sie erhalten in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie ihr Passwort zurücksetzen können.'
29
- updated: 'Ihr Passwort wurde geändert. Sie sind jetzt angemeldet.'
30
- updated_not_active: 'Ihr Passwort wurde geändert.'
31
- send_paranoid_instructions: "Falls Ihre E-Mail-Adresse in unserer Datenbank existiert erhalten Sie in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie Ihr Passwort zurücksetzen können."
32
- no_token: "Es wurde nicht alle benötigten Parameter übergeben. Bitte überprüfen Sie, ob die komplette URL aus der E-Mail benutzt wurde."
33
- confirmations:
34
- send_instructions: 'Sie erhalten in wenigen Minuten eine E-Mail, mit der Sie Ihre Registrierung bestätigen können.'
35
- send_paranoid_instructions: 'Falls Ihre E-Mail-Adresse in unserer Datenbank existiert erhalten Sie in wenigen Minuten eine E-Mail mit der die Sie Ihre Registrierung bestätigen können.'
36
- confirmed: 'Vielen Dank für Ihre Registrierung. Sie sind jetzt angemeldet.'
37
- registrations:
38
- signed_up: 'Sie haben sich erfolgreich registriert.'
39
- signed_up_but_unconfirmed: 'Sie haben sich erfolgreich registriert. Wir konnten Sie noch nicht anmelden, da Ihr Account noch nicht bestätigt ist. Sie erhalten in Kürze eine E-Mail mit der Anleitung, wie Sie Ihren Account freischalten können.'
40
- signed_up_but_inactive: 'Sie haben sich erfolgreich registriert. Wir konnten Sie noch nicht anmelden, da Ihr Account inaktiv ist.'
41
- signed_up_but_locked: 'Sie haben sich erfolgreich registriert. Wir konnten Sie noch nicht anmelden, da Ihr Account gesperrt ist.'
42
- updated: 'Ihre Daten wurden aktualisiert.'
43
- update_needs_confirmation: "Ihre Daten wurden aktualisiert, aber Sie müssen Ihre neue E-Mail-Adresse bestätigen. Sie erhalten in wenigen Minuten eine E-Mail, mit der Sie die Änderung Ihrer E-Mail-Adresse abschließen können."
44
- destroyed: 'Ihr Account wurde gelöscht.'
45
- unlocks:
46
- send_instructions: 'Sie erhalten in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie Ihren Account entsperren können.'
47
- unlocked: 'Ihr Account wurde entsperrt. Sie sind jetzt angemeldet.'
48
- send_paranoid_instructions: "Falls Ihre E-Mail-Adresse in unserer Datenbank existiert erhalten Sie in wenigen Minuten eine E-Mail mit der Anleitung, wie Sie Ihren Account entsperren können."
49
- omniauth_callbacks:
50
- success: 'Die haben sich erfolgreich mit Ihrem %{kind}-Account angemeldet.'
51
- failure: 'Sie konnten nicht mit Ihrem %{kind}-Account angemeldet werden, weil "%{reason}".'
52
- mailer:
53
- confirmation_instructions:
54
- subject: 'Anleitung zur Bestätigung Ihres Accounts'
55
- reset_password_instructions:
56
- subject: 'Anleitung um Ihr Passwort zurückzusetzen'
57
- unlock_instructions:
58
- subject: 'Anleitung um Ihren Account freizuschalten'
@@ -1,60 +0,0 @@
1
- # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
-
3
- en:
4
- errors:
5
- messages:
6
- expired: "has expired, please request a new one"
7
- not_found: "not found"
8
- already_confirmed: "was already confirmed, please try signing in"
9
- not_locked: "was not locked"
10
- not_saved:
11
- one: "1 error prohibited this %{resource} from being saved:"
12
- other: "%{count} errors prohibited this %{resource} from being saved:"
13
- confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
14
-
15
- devise:
16
- failure:
17
- already_authenticated: 'You are already signed in.'
18
- unauthenticated: 'You need to sign in or sign up before continuing.'
19
- unconfirmed: 'You have to confirm your account before continuing.'
20
- locked: 'Your account is locked.'
21
- not_found_in_database: 'Invalid email or password.'
22
- invalid: 'Invalid email or password.'
23
- invalid_token: 'Invalid authentication token.'
24
- timeout: 'Your session expired, please sign in again to continue.'
25
- inactive: 'Your account was not activated yet.'
26
- sessions:
27
- signed_in: 'Signed in successfully.'
28
- signed_out: 'Signed out successfully.'
29
- passwords:
30
- send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
31
- updated: 'Your password was changed successfully. You are now signed in.'
32
- updated_not_active: 'Your password was changed successfully.'
33
- send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
34
- no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
35
- confirmations:
36
- send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
37
- send_paranoid_instructions: 'If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
38
- confirmed: 'Your account was successfully confirmed. You are now signed in.'
39
- registrations:
40
- signed_up: 'Welcome! You have signed up successfully.'
41
- signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
42
- signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
43
- signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
44
- updated: 'You updated your account successfully.'
45
- update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
46
- destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
47
- unlocks:
48
- send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
49
- unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
50
- send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
51
- omniauth_callbacks:
52
- success: 'Successfully authenticated from %{kind} account.'
53
- failure: 'Could not authenticate you from %{kind} because "%{reason}".'
54
- mailer:
55
- confirmation_instructions:
56
- subject: 'Confirmation instructions'
57
- reset_password_instructions:
58
- subject: 'Reset password instructions'
59
- unlock_instructions:
60
- subject: 'Unlock Instructions'
@@ -1,29 +0,0 @@
1
- require 'rails'
2
-
3
- module Alchemy
4
- module Generators
5
- class DeviseGenerator < ::Rails::Generators::Base
6
- desc "This generator copies the Alchemy Devise configuration into your app."
7
- source_root File.expand_path('../../../../../config/initializers', File.dirname(__FILE__))
8
-
9
- def copy_devise_config
10
- copy_file "devise.rb", "#{Rails.root}/config/initializers/devise.rb"
11
- msg = <<-MSG
12
- If your are upgrading from Alchemy < 2.5.0:
13
-
14
- 1. Add `gem 'devise-encryptable'` into your Gemfile
15
- 2. Run `bundle install`
16
- 3. Alter the encryptor and the stretches value in your devise config:
17
-
18
- # config/initializers/devise.rb
19
- ...
20
- config.stretches = Rails.env.test? ? 1 : 20
21
- config.encryptor = :authlogic_sha512
22
-
23
- MSG
24
- puts msg
25
- end
26
-
27
- end
28
- end
29
- end
@@ -1,132 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe Admin::UsersController do
5
-
6
- let(:admin) { FactoryGirl.build_stubbed(:admin_user) }
7
-
8
- before do
9
- controller.stub!(:store_user_request_time)
10
- User.stub!(:find).and_return(admin)
11
- admin.stub!(:update_without_password).and_return(true)
12
- admin.stub!(:update_attributes).and_return(true)
13
- sign_in(admin)
14
- end
15
-
16
- describe '#new' do
17
- render_views
18
-
19
- it "has send_credentials checkbox activated" do
20
- get :new
21
- response.body.should match /<input checked="checked" id="user_send_credentials" name="user\[send_credentials\]" type="checkbox"/
22
- end
23
- end
24
-
25
- describe '#edit' do
26
- render_views
27
-
28
- it "has send_credentials checkbox deactivated" do
29
- get :edit, id: admin.id
30
- response.body.should match /<input id="user_send_credentials" name="user\[send_credentials\]" type="checkbox"/
31
- end
32
- end
33
-
34
- describe '#create' do
35
- before { ActionMailer::Base.deliveries = [] }
36
-
37
- it "creates an user record" do
38
- post :create, user: FactoryGirl.attributes_for(:user).merge(send_credentials: '1')
39
- Alchemy::User.count.should == 1
40
- end
41
-
42
- context "with send_credentials set to '1'" do
43
- it "should send an email notification" do
44
- post :create, user: FactoryGirl.attributes_for(:user).merge(send_credentials: '1')
45
- ActionMailer::Base.deliveries.should_not be_empty
46
- end
47
- end
48
-
49
- context "with send_credentials set to true" do
50
- it "should not send an email notification" do
51
- post :create, user: FactoryGirl.attributes_for(:user).merge(send_credentials: true)
52
- ActionMailer::Base.deliveries.should be_empty
53
- end
54
- end
55
-
56
- context "with send_credentials left blank" do
57
- it "should not send an email notification" do
58
- post :create, user: FactoryGirl.attributes_for(:user)
59
- ActionMailer::Base.deliveries.should be_empty
60
- end
61
- end
62
- end
63
-
64
- describe '#update' do
65
- before do
66
- ActionMailer::Base.deliveries = []
67
- end
68
-
69
- it "assigns user to @user" do
70
- post :update, id: admin.id, user: {}, format: :js
71
- assigns(:user).should eq(admin)
72
- end
73
-
74
- context "with empty password passed" do
75
- it "should update the user" do
76
- params_hash = {'firstname' => 'Johnny', 'password' => '', 'password_confirmation' => ''}
77
- admin.should_receive(:update_without_password).with(params_hash).and_return(true)
78
- post :update, id: admin.id, user: params_hash, format: :js
79
- end
80
- end
81
-
82
- context "with new password passed" do
83
- it "should update the user" do
84
- params_hash = {'firstname' => 'Johnny', 'password' => 'newpassword', 'password_confirmation' => 'newpassword'}
85
- admin.should_receive(:update_attributes).with(params_hash)
86
- post :update, id: admin.id, user: params_hash, format: :js
87
- end
88
- end
89
-
90
- context "with send_credentials set to '1'" do
91
- let(:user) { FactoryGirl.build(:user) }
92
- before { User.stub!(:find).and_return(user) }
93
-
94
- it "should send an email notification" do
95
- post :update, id: user.id, user: {send_credentials: '1'}
96
- ActionMailer::Base.deliveries.should_not be_empty
97
- end
98
- end
99
-
100
- context "with send_credentials left blank" do
101
- it "should not send an email notification" do
102
- post :update, id: admin.id, user: {}, format: :js
103
- ActionMailer::Base.deliveries.should be_empty
104
- end
105
- end
106
-
107
- context "if user is permitted to update roles" do
108
- before do
109
- controller.stub!(:permitted_to?).with(:update_roles).and_return(true)
110
- end
111
-
112
- it "updates the user including role" do
113
- admin.should_receive(:update_without_password).with({'roles' => ['Administrator']})
114
- post :update, id: admin.id, user: {roles: ['Administrator']}, format: :js
115
- end
116
- end
117
-
118
- context "if the user is not permitted to update roles" do
119
- before do
120
- controller.stub!(:permitted_to?).with(:update_roles).and_return(false)
121
- end
122
-
123
- it "updates user without role" do
124
- admin.should_receive(:update_without_password).with({})
125
- post :update, id: admin.id, user: {'roles' => ['Administrator']}, format: :js
126
- end
127
- end
128
-
129
- end
130
-
131
- end
132
- end
@@ -1,16 +0,0 @@
1
- require "spec_helper"
2
-
3
- module Alchemy
4
- describe PasswordsController do
5
- let(:user) { FactoryGirl.create(:admin_user) }
6
-
7
- describe '#post' do
8
- it "should send email with reset password instructions" do
9
- ActionMailer::Base.deliveries = []
10
- @request.env["devise.mapping"] = Devise.mappings[:user]
11
- post :create, :user => {:email => user.email}
12
- ActionMailer::Base.deliveries.should_not be_empty
13
- end
14
- end
15
- end
16
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe UserSessionsController do
5
-
6
- let(:user) { FactoryGirl.build_stubbed(:admin_user) }
7
-
8
- before do
9
- controller.stub!(:store_user_request_time)
10
- sign_in(user)
11
- end
12
-
13
- describe "#destroy" do
14
- it "should unlock all pages" do
15
- @request.env["devise.mapping"] = Devise.mappings[:user]
16
- user.should_receive(:unlock_pages!)
17
- delete :destroy
18
- end
19
- end
20
-
21
- end
22
- end
@@ -1,66 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe UsersController do
5
-
6
- context "with users present" do
7
- before { FactoryGirl.create(:admin_user) }
8
-
9
- it "should redirect to admin dashboard" do
10
- get :new
11
- response.should redirect_to(admin_dashboard_path)
12
- end
13
- end
14
-
15
- describe '#new' do
16
- render_views
17
-
18
- before { get :new }
19
-
20
- it "should not render tag list input" do
21
- response.body.should_not have_selector('.autocomplete_tag_list')
22
- end
23
-
24
- it "should render hidden field for role" do
25
- response.body.should have_selector('input[type="hidden"]#user_roles')
26
- end
27
-
28
- it "should set the role to admin" do
29
- assigns(:user).roles.should include("admin")
30
- end
31
- end
32
-
33
- describe '#create' do
34
- before { ActionMailer::Base.deliveries = [] }
35
-
36
- context "with send_credentials set to '1'" do
37
- it "should send an email notification" do
38
- post :create, {
39
- :user => FactoryGirl.attributes_for(:admin_user).merge(send_credentials: '1')
40
- }
41
- ActionMailer::Base.deliveries.should_not be_empty
42
- end
43
- end
44
-
45
- context "with send_credentials left blank" do
46
- it "should not send an email notification" do
47
- post :create, {
48
- :user => FactoryGirl.attributes_for(:admin_user)
49
- }
50
- ActionMailer::Base.deliveries.should be_empty
51
- end
52
- end
53
-
54
- context "with valid params" do
55
- it "should sign in the user" do
56
- post :create, {
57
- :user => FactoryGirl.attributes_for(:admin_user)
58
- }
59
- controller.send(:user_signed_in?).should be_true
60
- end
61
- end
62
-
63
- end
64
-
65
- end
66
- end
@@ -1,67 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe Notifications do
5
-
6
- context "when a registered user was created" do
7
- let(:user) { FactoryGirl.build_stubbed(:user) }
8
- let(:mail) { Notifications.registered_user_created(user) }
9
-
10
- it "delivers a mail to user" do
11
- mail.to.should == [user.email]
12
- mail.subject.should == 'Your user credentials'
13
- end
14
-
15
- it "mail body includes users name" do
16
- mail.body.should match /#{user.name}/
17
- end
18
-
19
- it "mail body includes users login" do
20
- mail.body.should match /#{user.login}/
21
- end
22
-
23
- it "mail body includes password instructions" do
24
- mail.body.should match /#{Regexp.escape(new_password_url(email: user.email, use_route: 'alchemy', only_path: true))}/
25
- end
26
- end
27
-
28
- context "when an admin user was created" do
29
- let(:user) { FactoryGirl.build_stubbed(:admin_user) }
30
- let(:mail) { Notifications.admin_user_created(user) }
31
-
32
- it "delivers a mail to user" do
33
- mail.to.should == [user.email]
34
- mail.subject.should == 'Your Alchemy Login'
35
- end
36
-
37
- it "mail body includes users login" do
38
- mail.body.should match /#{user.login}/
39
- end
40
-
41
- it "mail body includes password instructions" do
42
- mail.body.should match /#{Regexp.escape(new_password_url(use_route: 'alchemy', only_path: true))}/
43
- end
44
- end
45
-
46
- describe '#reset_password_instructions' do
47
- let(:user) { FactoryGirl.build_stubbed(:user) }
48
- let(:mail) { Notifications.reset_password_instructions(user) }
49
-
50
- before { user.stub!(:reset_password_token).and_return('123') }
51
-
52
- it "delivers a mail to user" do
53
- mail.to.should == [user.email]
54
- mail.subject.should == 'Reset password instructions'
55
- end
56
-
57
- it "mail body includes users name" do
58
- mail.body.should match /#{user.name}/
59
- end
60
-
61
- it "mail body includes reset instructions" do
62
- mail.body.should match /#{Regexp.escape(edit_password_url(user, reset_password_token: user.reset_password_token, use_route: 'alchemy', only_path: true))}/
63
- end
64
- end
65
-
66
- end
67
- end