alchemy_cms 2.6.3 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.simplecov +14 -0
- data/.travis.yml +1 -1
- data/Gemfile +7 -6
- data/README.md +15 -5
- data/alchemy_cms.gemspec +3 -2
- data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +9 -17
- data/app/assets/javascripts/alchemy/alchemy.dirty.js.coffee +70 -0
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js.coffee +80 -0
- data/app/assets/javascripts/alchemy/alchemy.element_editors.js.coffee +43 -19
- data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +3 -1
- data/app/assets/javascripts/alchemy/alchemy.js +4 -2
- data/app/assets/javascripts/alchemy/alchemy.onload.js.coffee +1 -1
- data/app/assets/javascripts/alchemy/alchemy.spinner.js.coffee +14 -0
- data/app/assets/javascripts/alchemy/alchemy.tinymce.js.coffee.erb +96 -0
- data/app/assets/javascripts/alchemy/alchemy.translations.js.coffee +22 -0
- data/app/assets/javascripts/alchemy/alchemy.windows.js.coffee +28 -17
- data/app/assets/stylesheets/alchemy/base.scss +6 -0
- data/app/assets/stylesheets/alchemy/elements.scss +2 -28
- data/app/assets/stylesheets/alchemy/errors.scss +1 -1
- data/app/assets/stylesheets/alchemy/menubar.css.scss +2 -0
- data/app/assets/stylesheets/alchemy/sitemap.scss +21 -34
- data/app/assets/stylesheets/alchemy/tables.scss +13 -3
- data/app/controllers/alchemy/admin/attachments_controller.rb +10 -5
- data/app/controllers/alchemy/admin/base_controller.rb +19 -0
- data/app/controllers/alchemy/admin/contents_controller.rb +1 -4
- data/app/controllers/alchemy/admin/dashboard_controller.rb +2 -1
- data/app/controllers/alchemy/admin/elements_controller.rb +1 -1
- data/app/controllers/alchemy/admin/essence_files_controller.rb +1 -1
- data/app/controllers/alchemy/admin/essence_pictures_controller.rb +70 -56
- data/app/controllers/alchemy/admin/pages_controller.rb +37 -114
- data/app/controllers/alchemy/admin/pictures_controller.rb +5 -12
- data/app/controllers/alchemy/admin/resources_controller.rb +3 -1
- data/app/controllers/alchemy/admin/trash_controller.rb +1 -1
- data/app/controllers/alchemy/attachments_controller.rb +1 -1
- data/app/controllers/alchemy/base_controller.rb +3 -15
- data/app/controllers/alchemy/messages_controller.rb +4 -10
- data/app/controllers/alchemy/pages_controller.rb +6 -6
- data/app/controllers/alchemy/passwords_controller.rb +1 -1
- data/app/controllers/alchemy/user_sessions_controller.rb +1 -1
- data/app/helpers/alchemy/admin/base_helper.rb +49 -230
- data/app/helpers/alchemy/admin/contents_helper.rb +5 -1
- data/app/helpers/alchemy/admin/elements_helper.rb +19 -47
- data/app/helpers/alchemy/admin/essences_helper.rb +59 -17
- data/app/helpers/alchemy/admin/navigation_helper.rb +204 -0
- data/app/helpers/alchemy/admin/pages_helper.rb +22 -79
- data/app/helpers/alchemy/admin/pictures_helper.rb +1 -1
- data/app/helpers/alchemy/admin/tags_helper.rb +42 -0
- data/app/helpers/alchemy/base_helper.rb +0 -11
- data/app/helpers/alchemy/elements_helper.rb +48 -25
- data/app/helpers/alchemy/essences_helper.rb +0 -20
- data/app/helpers/alchemy/pages_helper.rb +18 -14
- data/app/helpers/alchemy/url_helper.rb +1 -0
- data/app/mailers/alchemy/messages.rb +4 -6
- data/app/models/alchemy/attachment.rb +3 -0
- data/app/models/alchemy/cell.rb +33 -35
- data/app/models/alchemy/content.rb +20 -111
- data/app/models/alchemy/content/factory.rb +188 -0
- data/app/models/alchemy/element.rb +51 -200
- data/app/models/alchemy/element/definitions.rb +52 -0
- data/app/models/alchemy/element/presenters.rb +87 -0
- data/app/models/alchemy/essence_date.rb +1 -1
- data/app/models/alchemy/essence_file.rb +6 -7
- data/app/models/alchemy/essence_picture.rb +19 -4
- data/app/models/alchemy/message.rb +18 -14
- data/app/models/alchemy/page.rb +120 -214
- data/app/models/alchemy/page/elements.rb +145 -36
- data/app/models/alchemy/page/natures.rb +90 -0
- data/app/models/alchemy/page/scopes.rb +93 -0
- data/app/models/alchemy/page/users.rb +25 -0
- data/app/models/alchemy/picture.rb +15 -0
- data/app/models/alchemy/site.rb +15 -1
- data/app/models/alchemy/site/layout.rb +38 -0
- data/app/models/alchemy/user.rb +13 -3
- data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +7 -7
- data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +8 -8
- data/app/views/alchemy/admin/attachments/_tag_list.html.erb +1 -16
- data/app/views/alchemy/admin/attachments/destroy.js.erb +1 -4
- data/app/views/alchemy/admin/contents/create.js.erb +1 -1
- data/app/views/alchemy/admin/dashboard/index.html.erb +14 -13
- data/app/views/alchemy/admin/elements/_element_head.html.erb +7 -7
- data/app/views/alchemy/admin/elements/_refresh_editor.js.erb +10 -0
- data/app/views/alchemy/admin/elements/create.js.erb +44 -44
- data/app/views/alchemy/admin/elements/fold.js.erb +22 -26
- data/app/views/alchemy/admin/elements/trash.js.erb +1 -1
- data/app/views/alchemy/admin/elements/update.js.erb +22 -25
- data/app/views/alchemy/admin/essence_files/assign.js.erb +8 -3
- data/app/views/alchemy/admin/essence_pictures/crop.html.erb +14 -12
- data/app/views/alchemy/admin/essence_pictures/edit.html.erb +22 -39
- data/app/views/alchemy/admin/pages/_page.html.erb +73 -80
- data/app/views/alchemy/admin/pages/destroy.js.erb +2 -2
- data/app/views/alchemy/admin/pages/edit.html.erb +21 -18
- data/app/views/alchemy/admin/pages/fold.js.erb +1 -0
- data/app/views/alchemy/admin/pages/info.html.erb +32 -0
- data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +11 -13
- data/app/views/alchemy/admin/partials/_remote_search_form.html.erb +20 -20
- data/app/views/alchemy/admin/partials/_sub_navigation.html.erb +8 -0
- data/app/views/alchemy/admin/partials/_toolbar_button.html.erb +25 -0
- data/app/views/alchemy/admin/partials/_upload_form.html.erb +15 -15
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +39 -39
- data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +10 -10
- data/app/views/alchemy/admin/pictures/_tag_list.html.erb +1 -16
- data/app/views/alchemy/admin/resources/destroy.js.erb +1 -1
- data/app/views/alchemy/base/500.html.erb +1 -1
- data/app/views/alchemy/base/permission_denied.js.erb +1 -1
- data/app/views/alchemy/base/redirect.js.erb +1 -1
- data/app/views/alchemy/essences/_essence_link_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_picture_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_richtext_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_text_editor.html.erb +1 -1
- data/app/views/alchemy/essences/{_essence_picture_tools.html.erb → shared/_essence_picture_tools.html.erb} +5 -5
- data/app/views/alchemy/essences/{_linkable_essence_tools.html.erb → shared/_linkable_essence_tools.html.erb} +0 -0
- data/app/views/alchemy/messages/contact_form_mail.de.text.erb +12 -0
- data/app/views/alchemy/messages/contact_form_mail.en.text.erb +12 -0
- data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +1 -1
- data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +2 -2
- data/app/views/alchemy/pages/sitemap.xml.erb +3 -5
- data/app/views/alchemy/user_sessions/leave.html.erb +1 -1
- data/app/views/layouts/alchemy/admin.html.erb +4 -2
- data/app/views/layouts/alchemy/sitemap.xml.erb +1 -1
- data/bin/alchemy +7 -13
- data/config/alchemy/config.yml +1 -0
- data/config/authorization_rules.rb +2 -3
- data/config/initializers/dragonfly.rb +2 -0
- data/config/locales/alchemy.de.yml +8 -9
- data/config/locales/alchemy.en.yml +7 -4
- data/config/routes.rb +3 -0
- data/db/migrate/{20130214233001_alchemy_two_point_five.rb → 20130827094554_alchemy_two_point_six.rb} +29 -6
- data/lib/alchemy/auth/engine.rb +9 -0
- data/lib/alchemy/capistrano.rb +37 -12
- data/lib/alchemy/config.rb +48 -35
- data/lib/alchemy/engine.rb +35 -6
- data/lib/alchemy/essence.rb +25 -29
- data/lib/alchemy/ferret/search.rb +86 -0
- data/lib/alchemy/{scoped_pagination_url_helper.rb → kaminari/scoped_pagination_url_helper.rb} +0 -0
- data/lib/alchemy/logger.rb +3 -4
- data/lib/alchemy/page_layout.rb +124 -55
- data/lib/alchemy/resource.rb +0 -10
- data/lib/alchemy/resources_helper.rb +0 -5
- data/lib/alchemy/seeder.rb +1 -32
- data/lib/alchemy/shell.rb +6 -1
- data/lib/alchemy/tinymce.rb +41 -32
- data/lib/alchemy/upgrader.rb +3 -1
- data/lib/alchemy/upgrader/two_point_five.rb +15 -8
- data/lib/alchemy/upgrader/two_point_one.rb +10 -10
- data/lib/alchemy/upgrader/two_point_two.rb +96 -51
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy_cms.rb +5 -46
- data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +1 -1
- data/lib/rails/generators/alchemy/devise/devise_generator.rb +9 -4
- data/lib/rails/generators/alchemy/essence/essence_generator.rb +7 -6
- data/lib/rails/generators/alchemy/essence/templates/editor.html.erb +1 -1
- data/lib/rails/generators/alchemy/scaffold/files/_standard.html.erb +1 -0
- data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +1 -0
- data/lib/rails/generators/alchemy/site_layouts/site_layouts_generator.rb +23 -0
- data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.erb +1 -0
- data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.haml +1 -0
- data/lib/rails/generators/alchemy/site_layouts/templates/layout.html.slim +1 -0
- data/lib/rails/templates/alchemy.rb +2 -2
- data/lib/tasks/alchemy/db.rake +3 -1
- data/lib/tasks/alchemy/tidy.rake +82 -0
- data/lib/tasks/alchemy/upgrade.rake +2 -1
- data/spec/controllers/admin/attachments_controller_spec.rb +124 -0
- data/spec/controllers/admin/base_controller_spec.rb +35 -0
- data/spec/controllers/admin/clipboard_controller_spec.rb +1 -1
- data/spec/controllers/admin/contents_controller_spec.rb +17 -26
- data/spec/controllers/admin/dashboard_controller_spec.rb +121 -0
- data/spec/controllers/admin/elements_controller_spec.rb +1 -1
- data/spec/controllers/admin/essence_files_controller_spec.rb +67 -0
- data/spec/controllers/admin/essence_pictures_controller_spec.rb +161 -0
- data/spec/controllers/admin/languages_controller_spec.rb +1 -1
- data/spec/controllers/admin/layoutpages_controller_spec.rb +28 -0
- data/spec/controllers/admin/pages_controller_spec.rb +164 -118
- data/spec/controllers/admin/pictures_controller_spec.rb +89 -0
- data/spec/controllers/admin/trash_controller_spec.rb +21 -31
- data/spec/controllers/admin/users_controller_spec.rb +114 -85
- data/spec/controllers/attachments_controller_spec.rb +6 -2
- data/spec/controllers/base_controller_spec.rb +22 -0
- data/spec/controllers/elements_controller_spec.rb +1 -1
- data/spec/controllers/messages_controller_spec.rb +200 -0
- data/spec/controllers/pictures_controller_spec.rb +1 -1
- data/spec/controllers/user_sessions_controller_spec.rb +7 -6
- data/spec/controllers/users_controller_spec.rb +2 -2
- data/spec/dummy/config/alchemy/cells.yml +2 -0
- data/spec/dummy/config/application.rb +19 -8
- data/spec/dummy/db/migrate/{20130214233001_alchemy_two_point_five.rb → 20130827094554_alchemy_two_point_six.rb} +29 -6
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/fast_specs.rb +15 -0
- data/spec/helpers/admin/base_helper_spec.rb +53 -34
- data/spec/helpers/admin/contents_helper_spec.rb +15 -7
- data/spec/helpers/admin/elements_helper_spec.rb +79 -34
- data/spec/helpers/admin/essences_helper_spec.rb +45 -31
- data/spec/helpers/admin/navigation_helper_spec.rb +204 -0
- data/spec/helpers/admin/pages_helper_spec.rb +25 -15
- data/spec/helpers/admin/tags_helper_spec.rb +62 -2
- data/spec/helpers/elements_helper_spec.rb +202 -138
- data/spec/helpers/pages_helper_spec.rb +48 -0
- data/spec/helpers/url_helper_spec.rb +7 -0
- data/spec/libraries/config_spec.rb +110 -3
- data/spec/libraries/essence_spec.rb +29 -9
- data/spec/libraries/page_layout_spec.rb +134 -0
- data/spec/libraries/resource_spec.rb +3 -16
- data/spec/libraries/resources_helper_spec.rb +4 -8
- data/spec/libraries/shell_spec.rb +1 -0
- data/spec/libraries/tinymce_spec.rb +61 -0
- data/spec/mailers/messages_spec.rb +23 -0
- data/spec/models/attachment_spec.rb +45 -0
- data/spec/models/cell_spec.rb +62 -9
- data/spec/models/content_spec.rb +110 -28
- data/spec/models/element_spec.rb +275 -253
- data/spec/models/essence_date_spec.rb +25 -0
- data/spec/models/essence_file_spec.rb +23 -0
- data/spec/models/essence_html_spec.rb +13 -0
- data/spec/models/essence_picture_spec.rb +16 -0
- data/spec/models/essence_text_spec.rb +29 -0
- data/spec/models/language_spec.rb +34 -0
- data/spec/models/message_spec.rb +43 -0
- data/spec/models/page_spec.rb +726 -567
- data/spec/models/picture_spec.rb +98 -0
- data/spec/models/site_spec.rb +60 -2
- data/spec/models/tag_spec.rb +31 -0
- data/spec/models/user_spec.rb +4 -4
- data/spec/spec_helper.rb +49 -58
- data/spec/support/alchemy/controller_helpers.rb +35 -0
- data/spec/support/alchemy/{specs_helpers.rb → integration_helpers.rb} +4 -8
- data/spec/{factories.rb → support/factories.rb} +11 -1
- data/vendor/assets/javascripts/jquery_plugins/jquery.ui.nestedSortable.js +2 -8
- metadata +166 -106
- data/Guardfile +0 -16
- data/app/assets/javascripts/alchemy/alchemy.dirty.js +0 -93
- data/app/assets/javascripts/alchemy/alchemy.dragndrop.js +0 -122
- data/app/models/alchemy/tree_node.rb +0 -4
- data/app/views/alchemy/admin/pages/_page_infos.html.erb +0 -3
- data/app/views/alchemy/admin/partials/_sub_navigation_tab.html.erb +0 -8
- data/app/views/alchemy/messages/contact_form_mail.text.erb +0 -12
- data/config/initializers/kaminari_config.rb +0 -9
- data/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +0 -21
- data/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +0 -11
- data/lib/alchemy/auth_engine.rb +0 -7
- data/lib/alchemy/authentication_helpers.rb +0 -9
- data/lib/alchemy/ferret_search.rb +0 -84
- data/lib/extensions/array.rb +0 -25
- data/lib/extensions/hash.rb +0 -34
- data/spec/dummy/db/migrate/20130221200514_migrate_attachments_to_dragonfly.rb +0 -21
- data/spec/dummy/db/migrate/20130312205327_change_alchemy_users_role_to_roles.rb +0 -11
- data/spec/models/page_layout_spec.rb +0 -60
@@ -32,6 +32,23 @@ module Alchemy
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
describe '#render_site_layout' do
|
36
|
+
let(:default_site) { Alchemy::Site.default }
|
37
|
+
|
38
|
+
it "renders the partial for current site" do
|
39
|
+
helper.should_receive(:current_site).and_return(default_site)
|
40
|
+
helper.should_receive(:render).with(default_site)
|
41
|
+
helper.render_site_layout
|
42
|
+
end
|
43
|
+
|
44
|
+
context "with missing partial" do
|
45
|
+
it "returns empty string and logges warning" do
|
46
|
+
helper.should_receive(:current_site).twice.and_return(default_site)
|
47
|
+
expect(helper.render_site_layout).to eq("")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
35
52
|
describe "#render_navigation" do
|
36
53
|
before { visible_page }
|
37
54
|
|
@@ -280,6 +297,12 @@ module Alchemy
|
|
280
297
|
|
281
298
|
describe "#render_meta_data" do
|
282
299
|
|
300
|
+
context "@page is not set" do
|
301
|
+
it "should reutrn nil" do
|
302
|
+
expect(helper.render_meta_data.should).to eq(nil)
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
283
306
|
it "should render meta keywords of current page" do
|
284
307
|
@page = mock_model('Page', :language => language, :title => 'A Public Page', :meta_description => '', :meta_keywords => 'keyword1, keyword2', :robot_index? => false, :robot_follow? => false, :contains_feed? => false, :updated_at => '2011-11-29-23:00:00')
|
285
308
|
helper.render_meta_data.should have_selector('meta[name="keywords"][content="keyword1, keyword2"]')
|
@@ -388,5 +411,30 @@ module Alchemy
|
|
388
411
|
|
389
412
|
end
|
390
413
|
|
414
|
+
describe "#picture_essence_caption" do
|
415
|
+
let(:essence) { mock_model('EssencePicture', caption: 'my caption') }
|
416
|
+
let(:content) { mock_model('Content', essence: essence) }
|
417
|
+
|
418
|
+
it "should return the caption of the contents essence" do
|
419
|
+
expect(helper.picture_essence_caption(content)).to eq "my caption"
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
423
|
+
describe "#language_switches" do
|
424
|
+
it "should return a deprecation warning" do
|
425
|
+
ActiveSupport::Deprecation.should_receive(:warn)
|
426
|
+
helper.should_receive(:language_links).and_return(nil)
|
427
|
+
helper.language_switches
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
describe "#language_switcher" do
|
432
|
+
it "should return a deprecation warning" do
|
433
|
+
ActiveSupport::Deprecation.should_receive(:warn)
|
434
|
+
helper.should_receive(:language_links).and_return(nil)
|
435
|
+
helper.language_switcher
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
391
439
|
end
|
392
440
|
end
|
@@ -87,6 +87,13 @@ module Alchemy
|
|
87
87
|
|
88
88
|
end
|
89
89
|
|
90
|
+
describe "#page_path_for" do
|
91
|
+
it "is deprecated" do
|
92
|
+
ActiveSupport::Deprecation.should_receive(:warn)
|
93
|
+
helper.page_path_for
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
90
97
|
describe "#show_alchemy_page_url" do
|
91
98
|
|
92
99
|
context "when multi_language" do
|
@@ -1,7 +1,114 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Alchemy
|
4
|
+
describe Config do
|
5
|
+
|
6
|
+
describe ".get" do
|
7
|
+
it "should call #show" do
|
8
|
+
Config.should_receive(:show).and_return({})
|
9
|
+
Config.get(:mailer)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return the requested part of the config" do
|
13
|
+
Config.should_receive(:show).and_return({'mailer' => {'setting' => 'true'}})
|
14
|
+
expect(Config.get(:mailer)).to eq({'setting' => 'true'})
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.main_app_config' do
|
19
|
+
let(:main_app_config_path) { "#{Rails.root}/config/alchemy/config.yml" }
|
20
|
+
|
21
|
+
it "should call and return .read_file with the correct config path" do
|
22
|
+
Config.should_receive(:read_file).with(main_app_config_path).once.and_return({setting: 'true'})
|
23
|
+
expect(Config.send(:main_app_config)).to eq({setting: 'true'})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '.env_specific_config' do
|
28
|
+
let(:env_specific_config_path) { "#{Rails.root}/config/alchemy/#{Rails.env}.config.yml" }
|
29
|
+
|
30
|
+
it "should call and return .read_file with the correct config path" do
|
31
|
+
Config.should_receive(:read_file).with(env_specific_config_path).once.and_return({setting: 'true'})
|
32
|
+
expect(Config.send(:env_specific_config)).to eq({setting: 'true'})
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".show" do
|
37
|
+
context "when ivar @config was not set before" do
|
38
|
+
before { Config.instance_variable_set("@config", nil) }
|
39
|
+
|
40
|
+
it "should call and return .merge_configs!" do
|
41
|
+
Config.should_receive(:merge_configs!).once.and_return({setting: 'true'})
|
42
|
+
expect(Config.show).to eq({setting: 'true'})
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when ivar @config was already set" do
|
47
|
+
before { Config.instance_variable_set("@config", {setting: 'true'}) }
|
48
|
+
after { Config.instance_variable_set("@config", nil) }
|
49
|
+
|
50
|
+
it "should have memoized the return value of .merge_configs!" do
|
51
|
+
expect(Config.send(:show)).to eq({setting: 'true'})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '.read_file' do
|
57
|
+
context 'when given path to yml file exists' do
|
58
|
+
before { File.stub!(:exists?).and_return(true) }
|
59
|
+
|
60
|
+
it 'should call YAML.load_file with the given config path' do
|
61
|
+
YAML.should_receive(:load_file).once.with('path/to/config.yml').and_return({})
|
62
|
+
Config.send(:read_file, 'path/to/config.yml')
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'but its empty' do
|
66
|
+
before do
|
67
|
+
File.stub!(:exists?).with('empty_file.yml').and_return(true)
|
68
|
+
YAML.stub!(:load_file).and_return(false) # YAML.load_file returns false if file is empty.
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should return an empty Hash" do
|
72
|
+
expect(Config.send(:read_file, 'empty_file.yml')).to eq({})
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when given path to yml file does not exist' do
|
78
|
+
it 'should return an empty Hash' do
|
79
|
+
expect(Config.send(:read_file, 'does/not/exist.yml')).to eq({})
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe '.merge_configs!' do
|
85
|
+
let(:config_1) do
|
86
|
+
{setting_1: 'same', other_setting: 'something'}
|
87
|
+
end
|
88
|
+
|
89
|
+
let(:config_2) do
|
90
|
+
{setting_1: 'same', setting_2: 'anything'}
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should stringify the keys" do
|
94
|
+
expect(Config.send(:merge_configs!, config_1)).to eq(config_1.stringify_keys!)
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'when all passed configs are empty' do
|
98
|
+
it "should raise an error" do
|
99
|
+
expect { Config.send(:merge_configs!, {}) }.to raise_error
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'when configs containing same keys' do
|
104
|
+
it "should merge them together" do
|
105
|
+
expect(Config.send(:merge_configs!, config_1, config_2)).to eq(
|
106
|
+
{'setting_1' => 'same', 'other_setting' => 'something', 'setting_2' => 'anything'}
|
107
|
+
)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
6
112
|
end
|
113
|
+
|
7
114
|
end
|
@@ -1,18 +1,38 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
module Alchemy
|
4
|
+
describe "ActsAsEssence" do
|
5
|
+
#let(:element) { FactoryGirl.create(:element, :name => 'headline', :create_contents_after_create => true) }
|
6
|
+
let(:essence) { Alchemy::EssenceText.new }
|
4
7
|
|
5
|
-
|
8
|
+
describe '#ingredient=' do
|
9
|
+
it 'should set the value to ingredient column' do
|
10
|
+
essence.ingredient = 'Hallo'
|
11
|
+
expect(essence.ingredient).to eq('Hallo')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#open_link_in_new_window?' do
|
16
|
+
|
17
|
+
subject { essence.open_link_in_new_window? }
|
6
18
|
|
7
|
-
|
19
|
+
context 'essence responds to link_taget' do
|
20
|
+
context 'if link_target attribute is set to "blank"' do
|
8
21
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
22
|
+
before { essence.link_target = 'blank' }
|
23
|
+
|
24
|
+
it "should return true" do
|
25
|
+
expect(subject).to eq(true)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'if link_target attribute is not "blank"' do
|
30
|
+
it "should return false" do
|
31
|
+
expect(subject).to eq(false)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
14
35
|
end
|
15
36
|
|
16
37
|
end
|
17
|
-
|
18
38
|
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Alchemy
|
4
|
+
describe PageLayout do
|
5
|
+
|
6
|
+
describe ".all" do
|
7
|
+
# skip memoization
|
8
|
+
before { PageLayout.instance_variable_set("@definitions", nil) }
|
9
|
+
|
10
|
+
subject { PageLayout.all }
|
11
|
+
|
12
|
+
it "should return all page_layouts" do
|
13
|
+
should be_instance_of(Array)
|
14
|
+
subject.collect { |l| l['name'] }.should include('standard')
|
15
|
+
end
|
16
|
+
|
17
|
+
context "with empty layouts file" do
|
18
|
+
before { YAML.should_receive(:load_file).and_return(false) }
|
19
|
+
|
20
|
+
it "returns empty array" do
|
21
|
+
should == []
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "with missing layouts file" do
|
26
|
+
before { File.should_receive(:exists?).and_return(false) }
|
27
|
+
|
28
|
+
it "raises error empty array" do
|
29
|
+
expect { subject }.to raise_error(LoadError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '.add' do
|
35
|
+
it "adds a definition to all definitions" do
|
36
|
+
PageLayout.add({'name' => 'foo'})
|
37
|
+
PageLayout.all.should include({'name' => 'foo'})
|
38
|
+
end
|
39
|
+
|
40
|
+
it "adds a array of definitions to all definitions" do
|
41
|
+
PageLayout.add([{'name' => 'foo'}, {'name' => 'bar'}])
|
42
|
+
PageLayout.all.should include({'name' => 'foo'})
|
43
|
+
PageLayout.all.should include({'name' => 'bar'})
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe ".get" do
|
48
|
+
it "should return the page_layout description found by given name" do
|
49
|
+
PageLayout.stub(:all).and_return([{'name' => 'default'}, {'name' => 'contact'}])
|
50
|
+
expect(PageLayout.get('default')).to eq({'name' => 'default'})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '.layouts_with_own_for_select' do
|
55
|
+
it "should not hold a layout twice" do
|
56
|
+
layouts = PageLayout.layouts_with_own_for_select('standard', 1, false)
|
57
|
+
layouts = layouts.collect(&:last)
|
58
|
+
layouts.select { |l| l == "standard" }.length.should == 1
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '.selectable_layouts' do
|
63
|
+
let(:language) { Language.get_default }
|
64
|
+
before { language }
|
65
|
+
subject { PageLayout.selectable_layouts(language.id) }
|
66
|
+
|
67
|
+
it "should not display hidden page layouts" do
|
68
|
+
subject.each { |l| l['hide'].should_not == true }
|
69
|
+
end
|
70
|
+
|
71
|
+
context "with already taken layouts" do
|
72
|
+
before {
|
73
|
+
PageLayout.stub(:all).and_return([{'unique' => true}])
|
74
|
+
Page.stub_chain(:where, :pluck).and_return([1])
|
75
|
+
}
|
76
|
+
|
77
|
+
it "should not include unique layouts" do
|
78
|
+
subject.each { |l| l['unique'].should_not == true }
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "with sites layouts present" do
|
83
|
+
let(:site) { Site.new }
|
84
|
+
let(:definitions) { [{'name' => 'default_site', 'page_layouts' => %w(intro)}] }
|
85
|
+
before { Site.stub(:layout_definitions).and_return(definitions) }
|
86
|
+
|
87
|
+
it "should only return layouts for site" do
|
88
|
+
subject.length.should == 1
|
89
|
+
subject.first['name'].should == 'intro'
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe ".element_names_for" do
|
95
|
+
it "should return all element names for the given pagelayout" do
|
96
|
+
PageLayout.stub(:get).with('default').and_return({'name' => 'default', 'elements' => ['element_1', 'element_2']})
|
97
|
+
expect(PageLayout.element_names_for('default')).to eq(['element_1', 'element_2'])
|
98
|
+
end
|
99
|
+
|
100
|
+
context "when given page_layout name does not exist" do
|
101
|
+
it "should return an empty array" do
|
102
|
+
expect(PageLayout.element_names_for('layout_does_not_exist!')).to eq([])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "when page_layout description does not contain the elements key" do
|
107
|
+
it "should return an empty array" do
|
108
|
+
PageLayout.stub(:get).with('layout_without_elements_key').and_return({'name' => 'layout_without_elements_key'})
|
109
|
+
expect(PageLayout.element_names_for('layout_without_elements_key')).to eq([])
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe '.human_layout_name' do
|
115
|
+
let(:layout) { {'name' => 'contact'} }
|
116
|
+
subject { PageLayout.human_layout_name(layout['name']) }
|
117
|
+
|
118
|
+
context "with no translation present" do
|
119
|
+
it "returns the name capitalized" do
|
120
|
+
should == 'Contact'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context "with translation present" do
|
125
|
+
before { I18n.should_receive(:t).and_return('Kontakt') }
|
126
|
+
|
127
|
+
it "returns the translated name" do
|
128
|
+
should == 'Kontakt'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'rspec'
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/alchemy/resource'
|
3
|
+
require File.dirname(__FILE__) + '/../../lib/alchemy/errors'
|
2
4
|
|
3
5
|
class Event
|
4
6
|
end
|
@@ -152,13 +154,6 @@ module Alchemy
|
|
152
154
|
end
|
153
155
|
end
|
154
156
|
|
155
|
-
describe "#model_name" do
|
156
|
-
it "is deprecated" do
|
157
|
-
ActiveSupport::Deprecation.should_receive(:warn)
|
158
|
-
Resource.new("admin/events").model_name
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
157
|
describe "#namespaced_resource_name" do
|
163
158
|
|
164
159
|
it "returns resource_name with namespace (namespace_event for Namespace::Event), i.e. for use in forms" do
|
@@ -266,14 +261,6 @@ module Alchemy
|
|
266
261
|
end
|
267
262
|
end
|
268
263
|
|
269
|
-
describe "#namespaced_model_name" do
|
270
|
-
it "is deprecated" do
|
271
|
-
ActiveSupport::Deprecation.should_receive(:warn)
|
272
|
-
resource = Resource.new("admin/events")
|
273
|
-
resource.namespaced_model_name
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
264
|
end
|
278
265
|
end
|
279
266
|
end
|
@@ -1,4 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'rspec'
|
2
|
+
require 'ostruct'
|
3
|
+
require File.dirname(__FILE__) + "/../../lib/alchemy/resource"
|
4
|
+
require File.dirname(__FILE__) + "/../../lib/alchemy/resources_helper"
|
2
5
|
|
3
6
|
module Namespace
|
4
7
|
class MyResource
|
@@ -135,13 +138,6 @@ describe Alchemy::ResourcesHelper do
|
|
135
138
|
end
|
136
139
|
end
|
137
140
|
|
138
|
-
describe "#resource_model_name" do
|
139
|
-
it "is deprecated" do
|
140
|
-
ActiveSupport::Deprecation.should_receive(:warn)
|
141
|
-
@controller.resource_model_name
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
141
|
describe "#resource_name" do
|
146
142
|
it "returns resource_handler.resource_name" do
|
147
143
|
@controller.resource_name.should == "my_resource"
|