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,252 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Alchemy
4
- describe User do
5
-
6
- let(:user) { FactoryGirl.build(:user) }
7
- let(:page) { FactoryGirl.create(:page) }
8
-
9
- it "should have at least registered role" do
10
- user.save!
11
- user.roles.should_not be_blank
12
- user.roles.should include('registered')
13
- end
14
-
15
- context ".after_save" do
16
- let(:user) { FactoryGirl.build(:admin_user) }
17
-
18
- context "with send_credentials set to '1'" do
19
- before { user.send_credentials = '1' }
20
-
21
- it "delivers the admin welcome mail." do
22
- Notifications.should_receive(:admin_user_created).and_return(OpenStruct.new(deliver: true))
23
- user.save!
24
- end
25
-
26
- context "of author user" do
27
- before { user.roles = %w(author) }
28
-
29
- it "delivers the admin welcome mail." do
30
- Notifications.should_receive(:admin_user_created).and_return(OpenStruct.new(deliver: true))
31
- user.save!
32
- end
33
- end
34
-
35
- context "of registered user" do
36
- before { user.roles = %w(registered) }
37
-
38
- it "delivers the welcome mail." do
39
- Notifications.should_receive(:registered_user_created).and_return(OpenStruct.new(deliver: true))
40
- user.save!
41
- end
42
- end
43
- end
44
-
45
- context "with send_credentials set to false" do
46
- before { user.send_credentials = false }
47
-
48
- it "does not deliver any mail" do
49
- Notifications.should_not_receive(:admin_user_created)
50
- user.save!
51
- end
52
- end
53
- end
54
-
55
- describe 'scopes' do
56
- describe '.admins' do
57
- before do
58
- user.roles = 'admin'
59
- user.save!
60
- end
61
-
62
- it "should only return users with admin role" do
63
- User.admins.should include(user)
64
- end
65
- end
66
- end
67
-
68
- describe ".human_rolename" do
69
- it "return a translated role name" do
70
- ::I18n.locale = :de
71
- User.human_rolename('registered').should == "Registriert"
72
- end
73
- end
74
-
75
- describe "#human_roles_string" do
76
- it "should return a humanized roles string." do
77
- ::I18n.locale = :de
78
- user.roles = ['registered', 'admin']
79
- user.human_roles_string.should == "Registriert und Administrator"
80
- end
81
- end
82
-
83
- describe '#role_symbols' do
84
- it "should return an array of user role symbols" do
85
- user.role_symbols.should == [:registered]
86
- end
87
- end
88
-
89
- describe '#has_role?' do
90
-
91
- context "with given role" do
92
- it "should return true." do
93
- user.has_role?('registered').should be_true
94
- end
95
- end
96
-
97
- context "with role given as symbol" do
98
- it "should return true." do
99
- user.has_role?(:registered).should be_true
100
- end
101
- end
102
-
103
- context "without given role" do
104
- it "should return true." do
105
- user.has_role?('admin').should be_false
106
- end
107
- end
108
-
109
- end
110
-
111
- describe '#role' do
112
- context "when user doesn't have any roles" do
113
- before { user.roles = [] }
114
-
115
- it 'should return nil' do
116
- user.role.should be_nil
117
- end
118
- end
119
-
120
- context "when user has multiple roles" do
121
- before { user.roles = ["admin", "registered"] }
122
-
123
- it 'should return the first role' do
124
- user.role.should == "admin"
125
- end
126
- end
127
- end
128
-
129
- describe '#roles' do
130
- it "should return an array of user roles" do
131
- user.roles.should == ["registered"]
132
- end
133
- end
134
-
135
- describe '#roles=' do
136
-
137
- it "should accept an array of user roles" do
138
- user.roles = ["admin"]
139
- user.roles.should == ["admin"]
140
- end
141
-
142
- it "should accept a string of user roles" do
143
- user.roles = "admin registered"
144
- user.roles.should == ["admin", "registered"]
145
- end
146
-
147
- it "should store the user roles as space seperated string" do
148
- user.roles = ["admin", "registered"]
149
- user.read_attribute(:roles).should == "admin registered"
150
- end
151
-
152
- end
153
-
154
- describe "#add_role" do
155
- it "should add the given role to roles array" do
156
- user.add_role "member"
157
- user.roles.should == ["registered", "member"]
158
- end
159
-
160
- it "should not add the given role twice" do
161
- user.add_role "registered"
162
- user.roles.should == ["registered"]
163
- end
164
- end
165
-
166
- describe '#logged_in?' do
167
- before { Config.stub!(:get).and_return 60 }
168
-
169
- it "should return logged in status" do
170
- user.last_request_at = 30.minutes.ago
171
- user.save!
172
- user.logged_in?.should be_true
173
- end
174
- end
175
-
176
- describe '#logged_out?' do
177
- before { Config.stub!(:get).and_return 60 }
178
-
179
- it "should return logged in status" do
180
- user.last_request_at = 2.hours.ago
181
- user.save!
182
- user.logged_out?.should be_true
183
- end
184
- end
185
-
186
- describe "#pages_locked_by_me" do
187
- it "should return all pages that are locked by user" do
188
- user.save!
189
- page.lock!(user)
190
- user.locked_pages.should include(page)
191
- end
192
- end
193
-
194
- describe '#unlock_pages' do
195
- before do
196
- user.save!
197
- page.lock!(user)
198
- end
199
-
200
- it "should unlock all users lockes pages" do
201
- user.unlock_pages!
202
- user.locked_pages.should be_empty
203
- end
204
- end
205
-
206
- describe '#is_admin?' do
207
- it "should return true if the user has admin role" do
208
- user.roles = "admin"
209
- user.save!
210
- user.is_admin?.should be_true
211
- end
212
- end
213
-
214
- describe '#fullname' do
215
- it "should return the firstname and lastname" do
216
- user.fullname.should == "John Doe"
217
- end
218
-
219
- context "user without firstname and lastname" do
220
- it "should return the login" do
221
- user.firstname = nil
222
- user.lastname = nil
223
- user.fullname.should == "jdoe"
224
- end
225
- end
226
-
227
- context "with flipped option set to true" do
228
- it "should return the lastname and firstname comma seperated" do
229
- user.fullname(flipped: true).should == "Doe, John"
230
- end
231
- end
232
-
233
- context "with blank firstname" do
234
- it "should not have whitespace" do
235
- user.firstname = nil
236
- user.fullname.should == "Doe"
237
- end
238
- end
239
- end
240
-
241
- describe '#store_request_time!' do
242
- it "should store the timestamp of the request" do
243
- last_request_at = 2.hours.ago
244
- user.last_request_at = last_request_at
245
- user.save!
246
- user.store_request_time!
247
- user.last_request_at.should_not == last_request_at
248
- end
249
- end
250
-
251
- end
252
- end
@@ -1,35 +0,0 @@
1
- module Alchemy
2
- module Specs
3
-
4
- # Helpers for controller specs
5
- #
6
- # This file is included in rspec controller tests.
7
- #
8
- module ControllerHelpers
9
-
10
- def sign_in(user=admin_user)
11
- request.env['warden'].stub :authenticate! => user
12
- request.env['warden'].set_user(user, store: false, run_callbacks: false)
13
- controller.stub :current_user => user
14
- end
15
-
16
- def admin_user
17
- mock_user([:admin])
18
- end
19
-
20
- def registered_user
21
- mock_user([:registered])
22
- end
23
-
24
- def mock_user(roles)
25
- mock_model(User,
26
- name: 'Hermes Trismegistus',
27
- roles: roles.map(&:to_sym),
28
- store_request_time!: nil
29
- )
30
- end
31
-
32
- end
33
-
34
- end
35
- end