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.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/README.md +108 -25
- data/alchemy_cms.gemspec +0 -1
- data/app/assets/stylesheets/alchemy/archive.scss +2 -2
- data/app/assets/stylesheets/alchemy/base.scss +0 -37
- data/app/assets/stylesheets/alchemy/elements.scss +1 -1
- data/app/assets/stylesheets/alchemy/flash.scss +1 -1
- data/app/assets/stylesheets/alchemy/form_elements.scss +1 -1
- data/app/assets/stylesheets/alchemy/icon-font.css.scss +40 -40
- data/app/assets/stylesheets/alchemy/icons.scss +4 -32
- data/app/assets/stylesheets/alchemy/jquery-ui.scss +4 -4
- data/app/assets/stylesheets/alchemy/menubar.css.scss +20 -12
- data/app/assets/stylesheets/alchemy/modules.scss +0 -4
- data/app/assets/stylesheets/alchemy/search.scss +1 -1
- data/app/assets/stylesheets/alchemy/sitemap.scss +1 -1
- data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy-tinymce-dialog/window.css.scss +3 -3
- data/app/controllers/alchemy/admin/base_controller.rb +12 -8
- data/app/controllers/alchemy/admin/dashboard_controller.rb +10 -5
- data/app/controllers/alchemy/admin/elements_controller.rb +1 -1
- data/app/controllers/alchemy/admin/essence_pictures_controller.rb +8 -1
- data/app/controllers/alchemy/admin/layoutpages_controller.rb +1 -1
- data/app/controllers/alchemy/admin/pages_controller.rb +11 -6
- data/app/controllers/alchemy/admin/resources_controller.rb +2 -2
- data/app/controllers/alchemy/admin/users_controller.rb +1 -1
- data/app/controllers/alchemy/base_controller.rb +71 -37
- data/app/controllers/alchemy/elements_controller.rb +1 -1
- data/app/controllers/alchemy/pages_controller.rb +9 -3
- data/app/controllers/alchemy/pictures_controller.rb +1 -0
- data/app/helpers/alchemy/admin/base_helper.rb +2 -10
- data/app/helpers/alchemy/admin/pages_helper.rb +1 -1
- data/app/helpers/alchemy/base_helper.rb +1 -1
- data/app/helpers/alchemy/pages_helper.rb +1 -1
- data/app/models/alchemy/attachment.rb +3 -4
- data/app/models/alchemy/cell.rb +1 -1
- data/app/models/alchemy/content.rb +3 -4
- data/app/models/alchemy/element.rb +5 -6
- data/app/models/alchemy/folded_page.rb +1 -1
- data/app/models/alchemy/language.rb +1 -1
- data/app/models/alchemy/message.rb +1 -7
- data/app/models/alchemy/page.rb +12 -10
- data/app/models/alchemy/page/{cells.rb → page_cells.rb} +2 -2
- data/app/models/alchemy/page/{elements.rb → page_elements.rb} +2 -2
- data/app/models/alchemy/page/{naming.rb → page_naming.rb} +1 -1
- data/app/models/alchemy/page/{natures.rb → page_natures.rb} +3 -3
- data/app/models/alchemy/page/{scopes.rb → page_scopes.rb} +3 -3
- data/app/models/alchemy/page/page_users.rb +33 -0
- data/app/models/alchemy/picture.rb +3 -3
- data/app/models/alchemy/site.rb +2 -2
- data/app/views/alchemy/admin/dashboard/_locked_pages.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/_recent_pages.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/_sites.html.erb +1 -1
- data/app/views/alchemy/admin/dashboard/index.html.erb +10 -4
- data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
- data/app/views/alchemy/admin/pages/update.js.erb +1 -1
- data/app/views/alchemy/{user_sessions → base}/leave.html.erb +2 -2
- data/app/views/alchemy/base/permission_denied.js.erb +3 -2
- data/app/views/layouts/alchemy/admin.html.erb +6 -3
- data/config/alchemy/config.yml +1 -11
- data/config/alchemy/modules.yml +0 -12
- data/config/locales/alchemy.de.yml +3 -40
- data/config/locales/alchemy.en.yml +2 -22
- data/config/routes.rb +2 -27
- data/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
- data/lib/alchemy/auth_accessors.rb +54 -0
- data/lib/alchemy/capistrano.rb +5 -17
- data/lib/alchemy/engine.rb +7 -7
- data/lib/alchemy/errors.rb +6 -0
- data/lib/alchemy/essence.rb +2 -2
- data/lib/alchemy/seeder.rb +1 -1
- data/lib/alchemy/tasks/helpers.rb +83 -0
- data/lib/alchemy/test_support/auth_helpers.rb +35 -0
- data/lib/alchemy/test_support/controller_requests.rb +37 -0
- data/{spec/support → lib/alchemy/test_support}/factories.rb +7 -28
- data/{spec/support/alchemy → lib/alchemy/test_support}/integration_helpers.rb +9 -36
- data/lib/alchemy/upgrader.rb +8 -7
- data/lib/alchemy/upgrader/two_point_nine.rb +33 -0
- data/lib/alchemy/userstamp.rb +10 -0
- data/lib/alchemy/version.rb +1 -3
- data/lib/rails/templates/alchemy.rb +1 -0
- data/lib/tasks/alchemy/db.rake +5 -5
- data/spec/controllers/admin/attachments_controller_spec.rb +3 -3
- data/spec/controllers/admin/dashboard_controller_spec.rb +55 -34
- data/spec/controllers/admin/elements_controller_spec.rb +1 -1
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +22 -6
- data/spec/controllers/admin/pages_controller_spec.rb +41 -58
- data/spec/controllers/admin/resources_controller_spec.rb +30 -5
- data/spec/controllers/admin/trash_controller_spec.rb +1 -1
- data/spec/controllers/attachments_controller_spec.rb +26 -44
- data/spec/controllers/base_controller_spec.rb +8 -33
- data/spec/controllers/elements_controller_spec.rb +1 -1
- data/spec/controllers/pages_controller_spec.rb +7 -15
- data/spec/controllers/pictures_controller_spec.rb +44 -5
- data/spec/dummy/app/controllers/application_controller.rb +9 -1
- data/spec/dummy/app/models/user.rb +14 -0
- data/spec/dummy/db/migrate/20130827094554_alchemy_two_point_six.rb +0 -31
- data/spec/dummy/db/schema.rb +0 -31
- data/spec/features/admin/language_tree_feature_spec.rb +34 -0
- data/spec/features/admin/pages_controller_spec.rb +1 -1
- data/spec/features/pages_controller_spec.rb +5 -12
- data/spec/features/picture_security_spec.rb +2 -2
- data/spec/features/security_spec.rb +6 -45
- data/spec/features/translation_integration_spec.rb +11 -20
- data/spec/{support → fixtures}/80x60.png +0 -0
- data/spec/support/image with spaces.png b/data/spec/fixtures/image with → spaces.png +0 -0
- data/spec/{support → fixtures}/image.png +0 -0
- data/spec/{support → fixtures}/image2.PNG +0 -0
- data/spec/{support → fixtures}/image3.jpeg +0 -0
- data/spec/helpers/admin/base_helper_spec.rb +31 -43
- data/spec/helpers/admin/pages_helper_spec.rb +4 -2
- data/spec/helpers/base_helper_spec.rb +10 -3
- data/spec/helpers/pages_helper_spec.rb +32 -22
- data/spec/models/attachment_spec.rb +1 -1
- data/spec/models/element_spec.rb +33 -57
- data/spec/models/message_spec.rb +0 -16
- data/spec/models/page_spec.rb +62 -26
- data/spec/models/picture_spec.rb +5 -5
- data/spec/spec_helper.rb +13 -4
- data/spec/tasks/helpers_spec.rb +213 -0
- metadata +33 -75
- data/app/controllers/alchemy/passwords_controller.rb +0 -35
- data/app/controllers/alchemy/user_sessions_controller.rb +0 -67
- data/app/controllers/alchemy/users_controller.rb +0 -46
- data/app/mailers/alchemy/notifications.rb +0 -33
- data/app/models/alchemy/page/users.rb +0 -25
- data/app/models/alchemy/user.rb +0 -183
- data/app/views/alchemy/admin/users/_table.html.erb +0 -69
- data/app/views/alchemy/admin/users/_user.html.erb +0 -39
- data/app/views/alchemy/admin/users/edit.html.erb +0 -6
- data/app/views/alchemy/admin/users/index.html.erb +0 -58
- data/app/views/alchemy/admin/users/new.html.erb +0 -6
- data/app/views/alchemy/notifications/admin_user_created.de.text.erb +0 -15
- data/app/views/alchemy/notifications/admin_user_created.en.text.erb +0 -15
- data/app/views/alchemy/notifications/registered_user_created.de.text.erb +0 -13
- data/app/views/alchemy/notifications/registered_user_created.en.text.erb +0 -13
- data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +0 -8
- data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +0 -8
- data/app/views/alchemy/passwords/edit.html.erb +0 -35
- data/app/views/alchemy/passwords/new.html.erb +0 -30
- data/app/views/alchemy/user_sessions/new.html.erb +0 -48
- data/app/views/alchemy/users/new.html.erb +0 -14
- data/config/initializers/devise.rb +0 -242
- data/config/locales/devise.de.yml +0 -58
- data/config/locales/devise.en.yml +0 -60
- data/lib/rails/generators/alchemy/devise/devise_generator.rb +0 -29
- data/spec/controllers/admin/users_controller_spec.rb +0 -132
- data/spec/controllers/passwords_controller_spec.rb +0 -16
- data/spec/controllers/user_sessions_controller_spec.rb +0 -22
- data/spec/controllers/users_controller_spec.rb +0 -66
- data/spec/mailers/notifications_spec.rb +0 -67
- data/spec/models/user_spec.rb +0 -252
- data/spec/support/alchemy/controller_helpers.rb +0 -35
@@ -3,16 +3,24 @@ require 'spec_helper'
|
|
3
3
|
module Alchemy
|
4
4
|
describe BaseHelper do
|
5
5
|
|
6
|
+
describe "#render_icon" do
|
7
|
+
subject { render_icon(:user) }
|
8
|
+
|
9
|
+
it "renders an span with icon and the icon name as class name" do
|
10
|
+
should have_selector('span.icon.user')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
6
14
|
describe "#render_message" do
|
7
15
|
context "if no argument is passed" do
|
8
16
|
it "should render a div with an info icon and the given content" do
|
9
|
-
helper.render_message{ content_tag(:p, "my notice") }.should match(/<div class="info message"><span class="icon info"><\/span><p>my notice/)
|
17
|
+
helper.render_message { content_tag(:p, "my notice") }.should match(/<div class="info message"><span class="icon info"><\/span><p>my notice/)
|
10
18
|
end
|
11
19
|
end
|
12
20
|
|
13
21
|
context "if an argument is passed" do
|
14
22
|
it "should render the passed argument as the css classname for the icon container" do
|
15
|
-
helper.render_message(:error){ content_tag(:p, "my notice") }.should match(/<div class="error message"><span class="icon error">/)
|
23
|
+
helper.render_message(:error) { content_tag(:p, "my notice") }.should match(/<div class="error message"><span class="icon error">/)
|
16
24
|
end
|
17
25
|
end
|
18
26
|
end
|
@@ -83,7 +91,6 @@ module Alchemy
|
|
83
91
|
expect(helper.page_or_find(page)).to eq(page)
|
84
92
|
end
|
85
93
|
end
|
86
|
-
|
87
94
|
end
|
88
95
|
|
89
96
|
end
|
@@ -21,7 +21,7 @@ module Alchemy
|
|
21
21
|
let(:klingonian_public_page) { FactoryGirl.create(:public_page, :language => klingonian, :parent_id => klingonian_language_root.id) }
|
22
22
|
|
23
23
|
before do
|
24
|
-
Config.stub
|
24
|
+
Config.stub(:get) { |arg| arg == :url_nesting ? true : Config.parameter(arg) }
|
25
25
|
@root_page = language_root # We need this instance variable in the helpers
|
26
26
|
end
|
27
27
|
|
@@ -78,9 +78,11 @@ module Alchemy
|
|
78
78
|
end
|
79
79
|
|
80
80
|
context "as registered user" do
|
81
|
+
let(:user) { mock_model('User', alchemy_roles: %w(registered), role_symbols: [:registered]) }
|
82
|
+
|
81
83
|
before do
|
82
84
|
restricted_page
|
83
|
-
Authorization.
|
85
|
+
Authorization.current_user = user
|
84
86
|
end
|
85
87
|
|
86
88
|
it "should render also restricted pages" do
|
@@ -88,12 +90,16 @@ module Alchemy
|
|
88
90
|
helper.render_navigation.should match(/#{restricted_page.name}/)
|
89
91
|
helper.render_navigation.should match(/#{not_restricted_page.name}/)
|
90
92
|
end
|
93
|
+
|
94
|
+
after do
|
95
|
+
Authorization.current_user = nil
|
96
|
+
end
|
91
97
|
end
|
92
98
|
|
93
99
|
context "with enabled url nesting" do
|
94
100
|
|
95
101
|
before do
|
96
|
-
helper.stub
|
102
|
+
helper.stub(:configuration).and_return(true)
|
97
103
|
level_3_page
|
98
104
|
end
|
99
105
|
|
@@ -262,12 +268,18 @@ module Alchemy
|
|
262
268
|
end
|
263
269
|
|
264
270
|
context "with options[:restricted_only] set to true" do
|
265
|
-
before
|
271
|
+
before do
|
272
|
+
Authorization.current_user = mock_model('User', alchemy_roles: %w(registered), role_symbols: [:registered])
|
273
|
+
end
|
266
274
|
|
267
275
|
it "should render a breadcrumb of restricted pages only" do
|
268
276
|
page.update_attributes!(restricted: true, urlname: 'a-restricted-public-page', name: 'A restricted Public Page', title: 'A restricted Public Page')
|
269
277
|
helper.render_breadcrumb(page: page, restricted_only: true).strip.should match(/^(<span(.[^>]+)>)A restricted Public Page/)
|
270
278
|
end
|
279
|
+
|
280
|
+
after do
|
281
|
+
Authorization.current_user = nil
|
282
|
+
end
|
271
283
|
end
|
272
284
|
|
273
285
|
it "should render a breadcrumb of visible pages only" do
|
@@ -303,35 +315,37 @@ module Alchemy
|
|
303
315
|
end
|
304
316
|
end
|
305
317
|
|
306
|
-
|
307
|
-
|
308
|
-
helper.
|
309
|
-
|
318
|
+
context "@page is set" do
|
319
|
+
let(:page) { mock_model('Page', language: language, title: 'A Public Page', meta_description: 'blah blah', meta_keywords: 'keyword1, keyword2', robot_index?: false, robot_follow?: false, contains_feed?: false, updated_at: '2011-11-29-23:00:00') }
|
320
|
+
before { helper.instance_variable_set('@page', page) }
|
321
|
+
subject { helper.render_meta_data }
|
322
|
+
|
323
|
+
it "should render meta keywords of current page" do
|
324
|
+
should match /meta name="keywords" content="keyword1, keyword2"/
|
325
|
+
end
|
310
326
|
|
311
|
-
|
312
|
-
|
313
|
-
|
327
|
+
it "should render meta description 'blah blah' of current page" do
|
328
|
+
should match /meta name="description" content="blah blah"/
|
329
|
+
end
|
314
330
|
end
|
315
331
|
end
|
316
332
|
|
317
333
|
describe "#render_title_tag" do
|
334
|
+
let(:page) { mock_model('Page', title: 'A Public Page') }
|
335
|
+
before { helper.instance_variable_set('@page', page) }
|
318
336
|
|
319
337
|
it "should render a title tag for current page" do
|
320
|
-
|
321
|
-
helper.render_title_tag.should have_selector('title[contains("A Public Page")]')
|
338
|
+
helper.render_title_tag.should match /<title>A Public Page<\/title>/
|
322
339
|
end
|
323
340
|
|
324
341
|
it "should render a title tag for current page with a prefix and a seperator" do
|
325
|
-
|
326
|
-
helper.render_title_tag(:prefix => 'Peters Petshop', :seperator => ' ### ').should have_selector('title[contains("Peters Petshop ### A Public Page")]')
|
342
|
+
helper.render_title_tag(prefix: 'Peters Petshop', seperator: ' ### ').should match /<title>Peters Petshop ### A Public Page<\/title>/
|
327
343
|
end
|
328
344
|
|
329
345
|
end
|
330
346
|
|
331
347
|
describe "#language_links" do
|
332
|
-
|
333
348
|
context "with two public languages" do
|
334
|
-
|
335
349
|
# Always create second language
|
336
350
|
before { klingonian }
|
337
351
|
|
@@ -342,7 +356,6 @@ module Alchemy
|
|
342
356
|
end
|
343
357
|
|
344
358
|
context "with two language root pages" do
|
345
|
-
|
346
359
|
# Always create a language root page for klingonian
|
347
360
|
before { klingonian_language_root }
|
348
361
|
|
@@ -393,7 +406,7 @@ module Alchemy
|
|
393
406
|
context "with options[:show_title]" do
|
394
407
|
context "set to true" do
|
395
408
|
it "should render the language links with titles" do
|
396
|
-
helper.stub
|
409
|
+
helper.stub(:_t).and_return("my title")
|
397
410
|
expect(helper.language_links(show_title: true)).to have_selector('a[title="my title"]')
|
398
411
|
end
|
399
412
|
end
|
@@ -404,11 +417,8 @@ module Alchemy
|
|
404
417
|
end
|
405
418
|
end
|
406
419
|
end
|
407
|
-
|
408
420
|
end
|
409
|
-
|
410
421
|
end
|
411
|
-
|
412
422
|
end
|
413
423
|
|
414
424
|
describe "#picture_essence_caption" do
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
module Alchemy
|
5
5
|
describe Attachment do
|
6
|
-
let(:file) { File.new(File.expand_path('../../
|
6
|
+
let(:file) { File.new(File.expand_path('../../fixtures/image with spaces.png', __FILE__)) }
|
7
7
|
let(:attachment) { Attachment.new(:file => file) }
|
8
8
|
|
9
9
|
describe 'after create' do
|
data/spec/models/element_spec.rb
CHANGED
@@ -34,7 +34,7 @@ module Alchemy
|
|
34
34
|
|
35
35
|
describe '.definitions' do
|
36
36
|
context "without existing yml files" do
|
37
|
-
before { File.stub
|
37
|
+
before { File.stub(:exists?).and_return(false) }
|
38
38
|
|
39
39
|
it "should raise an error" do
|
40
40
|
expect { Element.definitions }.to raise_error(LoadError)
|
@@ -42,7 +42,7 @@ module Alchemy
|
|
42
42
|
end
|
43
43
|
|
44
44
|
context "without any definitions in elements.yml" do
|
45
|
-
before { YAML.stub
|
45
|
+
before { YAML.stub(:load_file).and_return(false) } # Yes, YAML.load_file returns false if an empty file exists.
|
46
46
|
|
47
47
|
it "should return an empty array" do
|
48
48
|
Element.definitions.should == []
|
@@ -66,7 +66,7 @@ module Alchemy
|
|
66
66
|
FactoryGirl.create(:element, :name => 'article')
|
67
67
|
FactoryGirl.create(:element, :name => 'article')
|
68
68
|
excluded = FactoryGirl.create(:element, :name => 'claim')
|
69
|
-
Element.excluded(['claim']).
|
69
|
+
Element.excluded(['claim']).should_not include(excluded)
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -74,7 +74,7 @@ module Alchemy
|
|
74
74
|
it "should return all elements by name" do
|
75
75
|
element_1 = FactoryGirl.create(:element, :name => 'article')
|
76
76
|
element_2 = FactoryGirl.create(:element, :name => 'article')
|
77
|
-
elements = Element.named(['article'])
|
77
|
+
elements = Element.named(['article'])
|
78
78
|
elements.should include(element_1)
|
79
79
|
elements.should include(element_2)
|
80
80
|
end
|
@@ -100,25 +100,21 @@ module Alchemy
|
|
100
100
|
end
|
101
101
|
|
102
102
|
context 'trash' do
|
103
|
+
let(:element) { FactoryGirl.create(:element, page_id: 1) }
|
104
|
+
|
103
105
|
describe '.not_trashed' do
|
104
|
-
|
105
|
-
FactoryGirl.create(:element, :page_id => 1)
|
106
|
-
end
|
106
|
+
before { element }
|
107
107
|
|
108
108
|
it "should return a collection of not trashed elements" do
|
109
|
-
Element.not_trashed.
|
109
|
+
expect(Element.not_trashed.to_a).to eq([element])
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
113
|
describe ".trashed" do
|
114
|
-
|
115
|
-
FactoryGirl.create(:element, :page_id => 1)
|
116
|
-
end
|
114
|
+
before { element.trash! }
|
117
115
|
|
118
116
|
it "should return a collection of trashed elements" do
|
119
|
-
|
120
|
-
element.trash
|
121
|
-
Element.trashed.should include(element)
|
117
|
+
expect(Element.trashed.to_a).to eq([element])
|
122
118
|
end
|
123
119
|
end
|
124
120
|
end
|
@@ -178,7 +174,7 @@ module Alchemy
|
|
178
174
|
|
179
175
|
context "with page having cells defining the correct elements" do
|
180
176
|
before do
|
181
|
-
Cell.stub
|
177
|
+
Cell.stub(:definitions).and_return([
|
182
178
|
{'name' => 'header', 'elements' => ['article', 'headline']},
|
183
179
|
{'name' => 'footer', 'elements' => ['article', 'text']},
|
184
180
|
{'name' => 'sidebar', 'elements' => ['teaser']}
|
@@ -203,7 +199,7 @@ module Alchemy
|
|
203
199
|
|
204
200
|
context "with page having cells defining the wrong elements" do
|
205
201
|
before do
|
206
|
-
Cell.stub
|
202
|
+
Cell.stub(:definitions).and_return([
|
207
203
|
{'name' => 'header', 'elements' => ['download', 'headline']},
|
208
204
|
{'name' => 'footer', 'elements' => ['contactform', 'text']},
|
209
205
|
{'name' => 'sidebar', 'elements' => ['teaser']}
|
@@ -298,7 +294,7 @@ module Alchemy
|
|
298
294
|
|
299
295
|
context "without a content marked as preview" do
|
300
296
|
let(:contents) { [content, content_2] }
|
301
|
-
before { element.stub
|
297
|
+
before { element.stub(:contents).and_return(contents) }
|
302
298
|
|
303
299
|
it "returns the preview text of first content found" do
|
304
300
|
content.should_receive(:preview_text).with(30)
|
@@ -308,7 +304,7 @@ module Alchemy
|
|
308
304
|
|
309
305
|
context "with a content marked as preview" do
|
310
306
|
let(:contents) { [content, preview_content] }
|
311
|
-
before { element.stub
|
307
|
+
before { element.stub(:contents).and_return(contents) }
|
312
308
|
|
313
309
|
it "should return the preview_text of this content" do
|
314
310
|
preview_content.should_receive(:preview_text).with(30)
|
@@ -317,7 +313,7 @@ module Alchemy
|
|
317
313
|
end
|
318
314
|
|
319
315
|
context "without any contents present" do
|
320
|
-
before { element.stub
|
316
|
+
before { element.stub(:contents).and_return([]) }
|
321
317
|
|
322
318
|
it "should return nil" do
|
323
319
|
element.preview_text.should be_nil
|
@@ -375,34 +371,6 @@ module Alchemy
|
|
375
371
|
end
|
376
372
|
end
|
377
373
|
|
378
|
-
describe '#save' do
|
379
|
-
let(:time) { Time.now }
|
380
|
-
let(:locker) { FactoryGirl.build_stubbed(:user) }
|
381
|
-
let(:page) { FactoryGirl.create(:page, updated_at: time) }
|
382
|
-
let(:element) { FactoryGirl.create(:element, page: page) }
|
383
|
-
|
384
|
-
before { User.stub(:stamper).and_return(locker.id) }
|
385
|
-
|
386
|
-
it "updates page timestamps" do
|
387
|
-
element.save
|
388
|
-
page.reload
|
389
|
-
page.updated_at.should_not eq(time)
|
390
|
-
end
|
391
|
-
|
392
|
-
it "updates page userstamps" do
|
393
|
-
element.save
|
394
|
-
page.reload
|
395
|
-
page.updater_id.should eq(locker.id)
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
describe '#save_contents' do
|
400
|
-
it "should return true if attributes hash is nil" do
|
401
|
-
element = FactoryGirl.create(:element, create_contents_after_create: true)
|
402
|
-
element.save_contents(nil).should be_true
|
403
|
-
end
|
404
|
-
end
|
405
|
-
|
406
374
|
describe '#taggable?' do
|
407
375
|
let(:element) { FactoryGirl.build(:element) }
|
408
376
|
|
@@ -428,20 +396,28 @@ module Alchemy
|
|
428
396
|
end
|
429
397
|
end
|
430
398
|
|
431
|
-
describe '#trash' do
|
432
|
-
let(:element) { FactoryGirl.create(:element, :
|
433
|
-
let(:trashed_element) { element.trash ; element }
|
399
|
+
describe '#trash!' do
|
400
|
+
let(:element) { FactoryGirl.create(:element, page_id: 1, cell_id: 1) }
|
401
|
+
let(:trashed_element) { element.trash! ; element }
|
434
402
|
subject { trashed_element }
|
435
403
|
|
436
404
|
it { should_not be_public }
|
405
|
+
it { should be_folded }
|
437
406
|
its(:position) { should be_nil }
|
438
|
-
specify { expect { element.trash }.to_not change(element, :page_id) }
|
439
|
-
specify { expect { element.trash }.to_not change(element, :cell_id) }
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
407
|
+
specify { expect { element.trash! }.to_not change(element, :page_id) }
|
408
|
+
specify { expect { element.trash! }.to_not change(element, :cell_id) }
|
409
|
+
|
410
|
+
context "with already one trashed element on the same page" do
|
411
|
+
let(:element_2) { FactoryGirl.create(:element, page_id: 1) }
|
412
|
+
before {
|
413
|
+
trashed_element
|
414
|
+
element_2
|
415
|
+
}
|
416
|
+
|
417
|
+
it "it should be possible to trash another" do
|
418
|
+
element_2.trash!
|
419
|
+
expect(Element.trashed.to_a).to include(trashed_element, element_2)
|
420
|
+
end
|
445
421
|
end
|
446
422
|
end
|
447
423
|
|
data/spec/models/message_spec.rb
CHANGED
@@ -23,21 +23,5 @@ module Alchemy
|
|
23
23
|
message.attributes
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
27
|
-
describe '#email_is_filled' do
|
28
|
-
context 'if email attribute is filled' do
|
29
|
-
it "should return true" do
|
30
|
-
message.stub!(:email).and_return('me@you.com')
|
31
|
-
expect(message.send(:email_is_filled)).to eq(true)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'if email attribute is not filled' do
|
36
|
-
it "should return false" do
|
37
|
-
message.stub!(:email).and_return('')
|
38
|
-
expect(message.send(:email_is_filled)).to eq(false)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
26
|
end
|
43
27
|
end
|
data/spec/models/page_spec.rb
CHANGED
@@ -356,7 +356,7 @@ module Alchemy
|
|
356
356
|
context "page with trashed elements" do
|
357
357
|
before do
|
358
358
|
page.elements << FactoryGirl.create(:element)
|
359
|
-
page.elements.first.trash
|
359
|
+
page.elements.first.trash!
|
360
360
|
end
|
361
361
|
|
362
362
|
it "the copy should not hold a copy of the trashed elements" do
|
@@ -421,7 +421,7 @@ module Alchemy
|
|
421
421
|
|
422
422
|
it "should add a user stamper" do
|
423
423
|
page = FactoryGirl.create(:page, :name => 'A', :language => language, :parent_id => language_root.id)
|
424
|
-
page.class.stamper_class.to_s.should == '
|
424
|
+
page.class.stamper_class.to_s.should == 'User'
|
425
425
|
end
|
426
426
|
end
|
427
427
|
end
|
@@ -609,7 +609,7 @@ module Alchemy
|
|
609
609
|
describe '#destroy' do
|
610
610
|
context "with trashed but still assigned elements" do
|
611
611
|
|
612
|
-
before { news_page.elements.map(&:trash) }
|
612
|
+
before { news_page.elements.map(&:trash!) }
|
613
613
|
|
614
614
|
it "should not delete the trashed elements" do
|
615
615
|
news_page.destroy
|
@@ -824,19 +824,25 @@ module Alchemy
|
|
824
824
|
describe '#folded?' do
|
825
825
|
let(:page) { Page.new }
|
826
826
|
|
827
|
-
context '
|
827
|
+
context 'with user is a active record model' do
|
828
828
|
before do
|
829
|
-
|
829
|
+
Alchemy.user_class.should_receive(:'<').and_return(true)
|
830
830
|
end
|
831
831
|
|
832
|
-
|
833
|
-
|
832
|
+
context 'if page is folded' do
|
833
|
+
before do
|
834
|
+
page.stub_chain(:folded_pages, :where, :any?).and_return(true)
|
835
|
+
end
|
836
|
+
|
837
|
+
it "should return true" do
|
838
|
+
expect(page.folded?(user.id)).to eq(true)
|
839
|
+
end
|
834
840
|
end
|
835
|
-
end
|
836
841
|
|
837
|
-
|
838
|
-
|
839
|
-
|
842
|
+
context 'if page is not folded' do
|
843
|
+
it "should return false" do
|
844
|
+
expect(page.folded?(101093)).to eq(false)
|
845
|
+
end
|
840
846
|
end
|
841
847
|
end
|
842
848
|
end
|
@@ -1291,32 +1297,62 @@ module Alchemy
|
|
1291
1297
|
|
1292
1298
|
context 'indicate page editors' do
|
1293
1299
|
let(:page) { Page.new }
|
1294
|
-
let(:user) { User.new(firstname: 'Paul', lastname: 'Page') }
|
1295
1300
|
|
1296
|
-
|
1297
|
-
|
1301
|
+
context 'with user class having a name accessor' do
|
1302
|
+
let(:user) { Alchemy.user_class_name = double(name: 'Paul Page') }
|
1303
|
+
|
1304
|
+
describe '#creator_name' do
|
1305
|
+
before { page.stub(:creator).and_return(user) }
|
1298
1306
|
|
1299
|
-
|
1300
|
-
|
1307
|
+
it "returns the name of the creator" do
|
1308
|
+
expect(page.creator_name).to eq('Paul Page')
|
1309
|
+
end
|
1301
1310
|
end
|
1302
|
-
end
|
1303
1311
|
|
1304
|
-
|
1305
|
-
|
1312
|
+
describe '#updater_name' do
|
1313
|
+
before { page.stub(:updater).and_return(user) }
|
1306
1314
|
|
1307
|
-
|
1308
|
-
|
1315
|
+
it "returns the name of the updater" do
|
1316
|
+
expect(page.updater_name).to eq('Paul Page')
|
1317
|
+
end
|
1309
1318
|
end
|
1310
|
-
end
|
1311
1319
|
|
1312
|
-
|
1313
|
-
|
1320
|
+
describe '#locker_name' do
|
1321
|
+
before { page.stub(:locker).and_return(user) }
|
1314
1322
|
|
1315
|
-
|
1316
|
-
|
1323
|
+
it "returns the name of the current page editor" do
|
1324
|
+
expect(page.locker_name).to eq('Paul Page')
|
1325
|
+
end
|
1317
1326
|
end
|
1318
1327
|
end
|
1319
1328
|
|
1329
|
+
context 'with user class not having a name accessor' do
|
1330
|
+
let(:user) { Alchemy.user_class.new }
|
1331
|
+
|
1332
|
+
describe '#creator_name' do
|
1333
|
+
before { page.stub(:creator).and_return(user) }
|
1334
|
+
|
1335
|
+
it "returns unknown" do
|
1336
|
+
expect(page.creator_name).to eq('unknown')
|
1337
|
+
end
|
1338
|
+
end
|
1339
|
+
|
1340
|
+
describe '#updater_name' do
|
1341
|
+
before { page.stub(:updater).and_return(user) }
|
1342
|
+
|
1343
|
+
it "returns unknown" do
|
1344
|
+
expect(page.updater_name).to eq('unknown')
|
1345
|
+
end
|
1346
|
+
end
|
1347
|
+
|
1348
|
+
describe '#locker_name' do
|
1349
|
+
before { page.stub(:locker).and_return(user) }
|
1350
|
+
|
1351
|
+
it "returns unknown" do
|
1352
|
+
expect(page.locker_name).to eq('unknown')
|
1353
|
+
end
|
1354
|
+
end
|
1355
|
+
end
|
1320
1356
|
end
|
1321
1357
|
|
1322
1358
|
describe '#controller_and_action' do
|