lucy_cms 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +19 -0
- data/Gemfile.lock +88 -0
- data/LICENSE +24 -0
- data/README.md +161 -0
- data/Rakefile +26 -0
- data/VERSION +1 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/cms_admin/base_controller.rb +43 -0
- data/app/controllers/cms_admin/layouts_controller.rb +66 -0
- data/app/controllers/cms_admin/pages_controller.rb +111 -0
- data/app/controllers/cms_admin/sessions_controller.rb +25 -0
- data/app/controllers/cms_admin/sites_controller.rb +69 -0
- data/app/controllers/cms_admin/snippets_controller.rb +62 -0
- data/app/controllers/cms_admin/upload_dirs_controller.rb +79 -0
- data/app/controllers/cms_admin/users_controller.rb +129 -0
- data/app/controllers/cms_content_controller.rb +51 -0
- data/app/models/cms_block.rb +28 -0
- data/app/models/cms_layout.rb +118 -0
- data/app/models/cms_page.rb +163 -0
- data/app/models/cms_site.rb +38 -0
- data/app/models/cms_snippet.rb +70 -0
- data/app/models/cms_upload.rb +19 -0
- data/app/models/cms_upload_dir.rb +11 -0
- data/app/models/cms_user.rb +93 -0
- data/app/views/cms_admin/layouts/_form.html.erb +10 -0
- data/app/views/cms_admin/layouts/_index_branch.html.erb +24 -0
- data/app/views/cms_admin/layouts/edit.html.erb +6 -0
- data/app/views/cms_admin/layouts/index.html.erb +6 -0
- data/app/views/cms_admin/layouts/new.html.erb +6 -0
- data/app/views/cms_admin/pages/_form.html.erb +37 -0
- data/app/views/cms_admin/pages/_form_blocks.html.erb +7 -0
- data/app/views/cms_admin/pages/_index_branch.html.erb +40 -0
- data/app/views/cms_admin/pages/edit.html.erb +5 -0
- data/app/views/cms_admin/pages/form_blocks.js.erb +2 -0
- data/app/views/cms_admin/pages/index.html.erb +6 -0
- data/app/views/cms_admin/pages/new.html.erb +5 -0
- data/app/views/cms_admin/pages/toggle_branch.js.erb +11 -0
- data/app/views/cms_admin/sessions/new.html.erb +12 -0
- data/app/views/cms_admin/sites/_form.html.erb +16 -0
- data/app/views/cms_admin/sites/edit.html.erb +6 -0
- data/app/views/cms_admin/sites/new.html.erb +6 -0
- data/app/views/cms_admin/sites/setup.html.erb +16 -0
- data/app/views/cms_admin/snippets/_form.html.erb +4 -0
- data/app/views/cms_admin/snippets/edit.html.erb +6 -0
- data/app/views/cms_admin/snippets/index.html.erb +23 -0
- data/app/views/cms_admin/snippets/new.html.erb +6 -0
- data/app/views/cms_admin/upload_dirs/_file.html.erb +15 -0
- data/app/views/cms_admin/upload_dirs/_form.html.erb +2 -0
- data/app/views/cms_admin/upload_dirs/conflict.html.erb +12 -0
- data/app/views/cms_admin/upload_dirs/index.html.erb +23 -0
- data/app/views/cms_admin/upload_dirs/new.html.erb +6 -0
- data/app/views/cms_admin/upload_dirs/show.html.erb +26 -0
- data/app/views/cms_admin/upload_dirs/uploads_destroy.js.erb +3 -0
- data/app/views/cms_admin/users/_form.html.erb +9 -0
- data/app/views/cms_admin/users/_index_branch.html.erb +16 -0
- data/app/views/cms_admin/users/change_password.html.erb +14 -0
- data/app/views/cms_admin/users/edit.html.erb +17 -0
- data/app/views/cms_admin/users/index.html.erb +6 -0
- data/app/views/cms_admin/users/new.html.erb +14 -0
- data/app/views/layouts/cms_admin.html.erb +52 -0
- data/config/application.rb +48 -0
- data/config/boot.rb +13 -0
- data/config/database.yml +22 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +22 -0
- data/config/environments/production.rb +49 -0
- data/config/environments/test.rb +35 -0
- data/config/initializers/LucyCMS.rb +37 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +45 -0
- data/config.ru +4 -0
- data/db/cms_seeds/example.local/layouts/default.yml +8 -0
- data/db/cms_seeds/example.local/layouts/nested.yml +6 -0
- data/db/cms_seeds/example.local/pages/child/subchild.yml +14 -0
- data/db/cms_seeds/example.local/pages/child.yml +10 -0
- data/db/cms_seeds/example.local/pages/index.yml +11 -0
- data/db/cms_seeds/example.local/snippets/example.yml +4 -0
- data/db/migrate/01_create_cms.rb +114 -0
- data/db/seeds.rb +7 -0
- data/lib/LucyCMS/acts_as_tree.rb +102 -0
- data/lib/LucyCMS/cms_tag/field_datetime.rb +26 -0
- data/lib/LucyCMS/cms_tag/field_integer.rb +26 -0
- data/lib/LucyCMS/cms_tag/field_string.rb +26 -0
- data/lib/LucyCMS/cms_tag/field_text.rb +26 -0
- data/lib/LucyCMS/cms_tag/helper.rb +20 -0
- data/lib/LucyCMS/cms_tag/page_datetime.rb +22 -0
- data/lib/LucyCMS/cms_tag/page_integer.rb +22 -0
- data/lib/LucyCMS/cms_tag/page_rich_text.rb +22 -0
- data/lib/LucyCMS/cms_tag/page_string.rb +22 -0
- data/lib/LucyCMS/cms_tag/page_text.rb +22 -0
- data/lib/LucyCMS/cms_tag/partial.rb +21 -0
- data/lib/LucyCMS/cms_tag/snippet.rb +22 -0
- data/lib/LucyCMS/cms_tag.rb +119 -0
- data/lib/LucyCMS/configuration.rb +36 -0
- data/lib/LucyCMS/controller_methods.rb +42 -0
- data/lib/LucyCMS/engine.rb +12 -0
- data/lib/LucyCMS/form_builder.rb +129 -0
- data/lib/LucyCMS/rails_extensions.rb +22 -0
- data/lib/LucyCMS/site_form_builder.rb +129 -0
- data/lib/LucyCMS/view_hooks.rb +30 -0
- data/lib/LucyCMS/view_methods.rb +68 -0
- data/lib/LucyCMS.rb +40 -0
- data/lib/generators/README +17 -0
- data/lib/generators/cms_generator.rb +44 -0
- data/lib/tasks/LucyCMS.rake +283 -0
- data/lucy_cms.gemspec +100 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +26 -0
- data/public/favicon.ico +0 -0
- data/public/images/LucyCMS/arrow_bottom.gif +0 -0
- data/public/images/LucyCMS/arrow_right.gif +0 -0
- data/public/images/LucyCMS/icon_folder.png +0 -0
- data/public/images/LucyCMS/icon_layout.gif +0 -0
- data/public/images/LucyCMS/icon_move.gif +0 -0
- data/public/images/LucyCMS/icon_regular.gif +0 -0
- data/public/images/LucyCMS/icon_snippet.gif +0 -0
- data/public/images/LucyCMS/icon_upload.png +0 -0
- data/public/images/LucyCMS/icon_user.jpg +0 -0
- data/public/javascripts/LucyCMS/cms.js +204 -0
- data/public/javascripts/LucyCMS/codemirror/codemirror.css +102 -0
- data/public/javascripts/LucyCMS/codemirror/codemirror.js +23 -0
- data/public/javascripts/LucyCMS/codemirror/codemirror_base.js +88 -0
- data/public/javascripts/LucyCMS/codemirror/parse_css.js +4 -0
- data/public/javascripts/LucyCMS/codemirror/parse_html_mixed.js +3 -0
- data/public/javascripts/LucyCMS/codemirror/parse_js.js +12 -0
- data/public/javascripts/LucyCMS/codemirror/parse_xml.js +7 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_222222_256x240.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_2e83ff_256x240.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_454545_256x240.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_888888_256x240.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/public/javascripts/LucyCMS/jquery-ui/jquery-ui.css +362 -0
- data/public/javascripts/LucyCMS/jquery-ui/jquery-ui.js +190 -0
- data/public/javascripts/LucyCMS/jquery.js +154 -0
- data/public/javascripts/LucyCMS/plupload/plupload.full.min.js +1 -0
- data/public/javascripts/LucyCMS/plupload/plupload.html5.min.js +1 -0
- data/public/javascripts/LucyCMS/plupload/plupload.min.js +1 -0
- data/public/javascripts/LucyCMS/rails.js +132 -0
- data/public/javascripts/LucyCMS/tiny_mce/jquery.tinymce.js +1 -0
- data/public/javascripts/LucyCMS/tiny_mce/langs/en.js +170 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/about.htm +54 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/anchor.htm +26 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/charmap.htm +52 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/color_picker.htm +73 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/editor_template.js +1 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/image.htm +80 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/img/colorpicker.jpg +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/img/icons.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/about.js +72 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/anchor.js +37 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/charmap.js +335 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/color_picker.js +253 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/image.js +245 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/link.js +156 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/source_editor.js +56 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/langs/en.js +62 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/langs/en_dlg.js +51 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/link.htm +58 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/content.css +36 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/dialog.css +117 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/buttons.png +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/items.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/menu_check.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/progress.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/tabs.gif +0 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/ui.css +213 -0
- data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/source_editor.htm +25 -0
- data/public/javascripts/LucyCMS/tiny_mce/tiny_mce.js +1 -0
- data/public/javascripts/LucyCMS/tiny_mce/tiny_mce_popup.js +5 -0
- data/public/robots.txt +5 -0
- data/public/stylesheets/LucyCMS/content.css +196 -0
- data/public/stylesheets/LucyCMS/form.css +125 -0
- data/public/stylesheets/LucyCMS/reset.css +1 -0
- data/public/stylesheets/LucyCMS/site_form.css +82 -0
- data/public/stylesheets/LucyCMS/structure.css +125 -0
- data/public/stylesheets/LucyCMS/typography.css +25 -0
- data/script/rails +6 -0
- data/test/cms_seeds/test.host/layouts/broken.yml +1 -0
- data/test/cms_seeds/test.host/layouts/default.yml +3 -0
- data/test/cms_seeds/test.host/layouts/nested.yml +4 -0
- data/test/cms_seeds/test.host/pages/broken.yml +1 -0
- data/test/cms_seeds/test.host/pages/child/subchild.yml +10 -0
- data/test/cms_seeds/test.host/pages/child.yml +10 -0
- data/test/cms_seeds/test.host/pages/index.yml +10 -0
- data/test/cms_seeds/test.host/snippets/broken.yml +1 -0
- data/test/cms_seeds/test.host/snippets/default.yml +3 -0
- data/test/fixtures/cms_blocks.yml +12 -0
- data/test/fixtures/cms_layouts.yml +36 -0
- data/test/fixtures/cms_pages.yml +39 -0
- data/test/fixtures/cms_sites.yml +3 -0
- data/test/fixtures/cms_snippets.yml +5 -0
- data/test/fixtures/cms_upload_dirs.yml +9 -0
- data/test/fixtures/cms_uploads.yml +4 -0
- data/test/fixtures/cms_users.yml +11 -0
- data/test/fixtures/files/invalid_file.gif +9 -0
- data/test/fixtures/files/valid_image.jpg +0 -0
- data/test/fixtures/views/_nav_hook.html.erb +1 -0
- data/test/fixtures/views/_nav_hook_2.html.erb +1 -0
- data/test/functional/cms_admin/layouts_controller_test.rb +103 -0
- data/test/functional/cms_admin/pages_controller_test.rb +334 -0
- data/test/functional/cms_admin/sites_controller_test.rb +99 -0
- data/test/functional/cms_admin/snippets_controller_test.rb +102 -0
- data/test/functional/cms_admin/uploads_controller_test.rb +26 -0
- data/test/functional/cms_content_controller_test.rb +134 -0
- data/test/integration/rake_tasks_test.rb +65 -0
- data/test/integration/render_cms_seed_test.rb +34 -0
- data/test/integration/render_cms_test.rb +81 -0
- data/test/integration/sites_test.rb +63 -0
- data/test/integration/view_hooks_test.rb +33 -0
- data/test/test_helper.rb +86 -0
- data/test/unit/cms_block_test.rb +43 -0
- data/test/unit/cms_configuration_test.rb +17 -0
- data/test/unit/cms_layout_test.rb +146 -0
- data/test/unit/cms_page_test.rb +257 -0
- data/test/unit/cms_site_test.rb +41 -0
- data/test/unit/cms_snippet_test.rb +77 -0
- data/test/unit/cms_tag_test.rb +206 -0
- data/test/unit/cms_tags/field_datetime_test.rb +34 -0
- data/test/unit/cms_tags/field_integer_test.rb +33 -0
- data/test/unit/cms_tags/field_string_test.rb +34 -0
- data/test/unit/cms_tags/field_text_test.rb +32 -0
- data/test/unit/cms_tags/helper_test.rb +38 -0
- data/test/unit/cms_tags/page_datetime_test.rb +34 -0
- data/test/unit/cms_tags/page_integer_test.rb +33 -0
- data/test/unit/cms_tags/page_rich_text.rb +33 -0
- data/test/unit/cms_tags/page_string_test.rb +33 -0
- data/test/unit/cms_tags/page_text_test.rb +34 -0
- data/test/unit/cms_tags/partial_test.rb +44 -0
- data/test/unit/cms_tags/snippet_test.rb +33 -0
- data/test/unit/cms_upload_dir_test.rb +8 -0
- data/test/unit/cms_upload_test.rb +26 -0
- data/test/unit/cms_user_test.rb +8 -0
- data/test/unit/view_methods_test.rb +21 -0
- metadata +488 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class CmsAdmin::SnippetsControllerTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
def test_get_index
|
|
6
|
+
get :index
|
|
7
|
+
assert_response :success
|
|
8
|
+
assert assigns(:cms_snippets)
|
|
9
|
+
assert_template :index
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_get_index_with_no_snippets
|
|
13
|
+
CmsSnippet.delete_all
|
|
14
|
+
get :index
|
|
15
|
+
assert_response :redirect
|
|
16
|
+
assert_redirected_to :action => :new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_get_new
|
|
20
|
+
get :new
|
|
21
|
+
assert_response :success
|
|
22
|
+
assert assigns(:cms_snippet)
|
|
23
|
+
assert_template :new
|
|
24
|
+
assert_select 'form[action=/cms-admin/snippets]'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_get_edit
|
|
28
|
+
snippet = cms_snippets(:default)
|
|
29
|
+
get :edit, :id => snippet
|
|
30
|
+
assert_response :success
|
|
31
|
+
assert assigns(:cms_snippet)
|
|
32
|
+
assert_template :edit
|
|
33
|
+
assert_select "form[action=/cms-admin/snippets/#{snippet.id}]"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def test_get_edit_failure
|
|
37
|
+
get :edit, :id => 'not_found'
|
|
38
|
+
assert_response :redirect
|
|
39
|
+
assert_redirected_to :action => :index
|
|
40
|
+
assert_equal 'Snippet not found', flash[:error]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_creation
|
|
44
|
+
assert_difference 'CmsSnippet.count' do
|
|
45
|
+
post :create, :cms_snippet => {
|
|
46
|
+
:label => 'Test Snippet',
|
|
47
|
+
:slug => 'test-snippet',
|
|
48
|
+
:content => 'Test Content'
|
|
49
|
+
}
|
|
50
|
+
assert_response :redirect
|
|
51
|
+
snippet = CmsSnippet.last
|
|
52
|
+
assert_equal cms_sites(:default), snippet.cms_site
|
|
53
|
+
assert_redirected_to :action => :edit, :id => snippet
|
|
54
|
+
assert_equal 'Snippet created', flash[:notice]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_creation_failure
|
|
59
|
+
assert_no_difference 'CmsSnippet.count' do
|
|
60
|
+
post :create, :cms_snippet => { }
|
|
61
|
+
assert_response :success
|
|
62
|
+
assert_template :new
|
|
63
|
+
assert_equal 'Failed to create snippet', flash[:error]
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_update
|
|
68
|
+
snippet = cms_snippets(:default)
|
|
69
|
+
put :update, :id => snippet, :cms_snippet => {
|
|
70
|
+
:label => 'New-Snippet',
|
|
71
|
+
:content => 'New Content'
|
|
72
|
+
}
|
|
73
|
+
assert_response :redirect
|
|
74
|
+
assert_redirected_to :action => :edit, :id => snippet
|
|
75
|
+
assert_equal 'Snippet updated', flash[:notice]
|
|
76
|
+
snippet.reload
|
|
77
|
+
assert_equal 'New-Snippet', snippet.label
|
|
78
|
+
assert_equal 'New Content', snippet.content
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def test_update_failure
|
|
82
|
+
snippet = cms_snippets(:default)
|
|
83
|
+
put :update, :id => snippet, :cms_snippet => {
|
|
84
|
+
:label => ''
|
|
85
|
+
}
|
|
86
|
+
assert_response :success
|
|
87
|
+
assert_template :edit
|
|
88
|
+
snippet.reload
|
|
89
|
+
assert_not_equal '', snippet.label
|
|
90
|
+
assert_equal 'Failed to update snippet', flash[:error]
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def test_destroy
|
|
94
|
+
assert_difference 'CmsSnippet.count', -1 do
|
|
95
|
+
delete :destroy, :id => cms_snippets(:default)
|
|
96
|
+
assert_response :redirect
|
|
97
|
+
assert_redirected_to :action => :index
|
|
98
|
+
assert_equal 'Snippet deleted', flash[:notice]
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require File.expand_path('../../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class CmsAdmin::UploadsControllerTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
def test_create
|
|
6
|
+
assert_difference 'CmsUpload.count', 1 do
|
|
7
|
+
xhr :post, :create, :file => fixture_file_upload('files/valid_image.jpg')
|
|
8
|
+
assert_response :success
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_create_fails
|
|
13
|
+
assert_no_difference 'CmsUpload.count' do
|
|
14
|
+
xhr :post, :create, :file => nil
|
|
15
|
+
assert_response :bad_request
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_destroy
|
|
20
|
+
assert_difference 'CmsUpload.count', -1 do
|
|
21
|
+
xhr :delete, :destroy, :id => cms_uploads(:default)
|
|
22
|
+
assert_response :success
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class CmsContentControllerTest < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
def test_render_page
|
|
6
|
+
get :render_html, :cms_path => ''
|
|
7
|
+
assert_equal assigns(:cms_page), cms_pages(:default)
|
|
8
|
+
assert_response :success
|
|
9
|
+
assert_equal rendered_content_formatter(
|
|
10
|
+
'
|
|
11
|
+
layout_content_a
|
|
12
|
+
default_page_text_content_a
|
|
13
|
+
default_snippet_content
|
|
14
|
+
default_page_text_content_b
|
|
15
|
+
layout_content_b
|
|
16
|
+
default_snippet_content
|
|
17
|
+
layout_content_c'
|
|
18
|
+
), response.body
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_render_page_with_app_layout
|
|
22
|
+
cms_layouts(:default).update_attribute(:app_layout, 'cms_admin.html.erb')
|
|
23
|
+
get :render_html, :cms_path => ''
|
|
24
|
+
assert_response :success
|
|
25
|
+
assert_select "body[class='c_cms_content a_render_html']"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_render_page_not_found
|
|
29
|
+
get :render_html, :cms_path => 'doesnotexist'
|
|
30
|
+
assert_response 404
|
|
31
|
+
assert_equal 'Page Not Found', response.body
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_render_page_not_found_with_custom_404
|
|
35
|
+
page = cms_sites(:default).cms_pages.create!(
|
|
36
|
+
:label => '404',
|
|
37
|
+
:slug => '404',
|
|
38
|
+
:parent_id => cms_pages(:default).id,
|
|
39
|
+
:cms_layout_id => cms_layouts(:default).id,
|
|
40
|
+
:is_published => '1',
|
|
41
|
+
:cms_blocks_attributes => [
|
|
42
|
+
{ :label => 'default_page_text',
|
|
43
|
+
:type => 'CmsTag::PageText',
|
|
44
|
+
:content => 'custom 404 page content' }
|
|
45
|
+
]
|
|
46
|
+
)
|
|
47
|
+
assert_equal '/404', page.full_path
|
|
48
|
+
assert page.is_published?
|
|
49
|
+
get :render_html, :cms_path => 'doesnotexist'
|
|
50
|
+
assert_response 404
|
|
51
|
+
assert assigns(:cms_page)
|
|
52
|
+
assert_match /custom 404 page content/, response.body
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def test_render_page_with_redirect
|
|
56
|
+
cms_pages(:child).update_attribute(:target_page, cms_pages(:default))
|
|
57
|
+
assert_equal cms_pages(:default), cms_pages(:child).target_page
|
|
58
|
+
get :render_html, :cms_path => 'child-page'
|
|
59
|
+
assert_response :redirect
|
|
60
|
+
assert_redirected_to '/'
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_render_page_unpublished
|
|
64
|
+
page = cms_pages(:default)
|
|
65
|
+
page.update_attribute(:is_published, false)
|
|
66
|
+
get :render_html, :cms_path => ''
|
|
67
|
+
assert_response 404
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_render_page_with_irb_disabled
|
|
71
|
+
assert LucyCMS.config.disable_irb
|
|
72
|
+
|
|
73
|
+
irb_page = cms_sites(:default).cms_pages.create!(
|
|
74
|
+
:label => 'irb',
|
|
75
|
+
:slug => 'irb',
|
|
76
|
+
:parent_id => cms_pages(:default).id,
|
|
77
|
+
:cms_layout_id => cms_layouts(:default).id,
|
|
78
|
+
:is_published => '1',
|
|
79
|
+
:cms_blocks_attributes => [
|
|
80
|
+
{ :label => 'default_page_text',
|
|
81
|
+
:type => 'CmsTag::PageText',
|
|
82
|
+
:content => 'text <%= 2 + 2 %> text' }
|
|
83
|
+
]
|
|
84
|
+
)
|
|
85
|
+
get :render_html, :cms_path => 'irb'
|
|
86
|
+
assert_response :success
|
|
87
|
+
assert_match "text <%= 2 + 2 %> text", response.body
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def test_render_page_with_irb_enabled
|
|
91
|
+
LucyCMS.config.disable_irb = false
|
|
92
|
+
|
|
93
|
+
irb_page = cms_sites(:default).cms_pages.create!(
|
|
94
|
+
:label => 'irb',
|
|
95
|
+
:slug => 'irb',
|
|
96
|
+
:parent_id => cms_pages(:default).id,
|
|
97
|
+
:cms_layout_id => cms_layouts(:default).id,
|
|
98
|
+
:is_published => '1',
|
|
99
|
+
:cms_blocks_attributes => [
|
|
100
|
+
{ :label => 'default_page_text',
|
|
101
|
+
:type => 'CmsTag::PageText',
|
|
102
|
+
:content => 'text <%= 2 + 2 %> text' }
|
|
103
|
+
]
|
|
104
|
+
)
|
|
105
|
+
get :render_html, :cms_path => 'irb'
|
|
106
|
+
assert_response :success
|
|
107
|
+
assert_match "text 4 text", response.body
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_render_css
|
|
111
|
+
get :render_css, :id => cms_layouts(:default).slug
|
|
112
|
+
assert_response :success
|
|
113
|
+
assert_match %r{text\/css}, response.headers["Content-Type"]
|
|
114
|
+
assert_equal cms_layouts(:default).css, response.body
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_render_css_not_found
|
|
118
|
+
get :render_css, :id => 'bogus'
|
|
119
|
+
assert_response 404
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def test_render_js
|
|
123
|
+
get :render_js, :id => cms_layouts(:default).slug
|
|
124
|
+
assert_response :success
|
|
125
|
+
assert_match %r{text\/javascript}, response.headers["Content-Type"]
|
|
126
|
+
assert_equal cms_layouts(:default).js, response.body
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def test_render_js_not_found
|
|
130
|
+
get :render_js, :id => 'bogus'
|
|
131
|
+
assert_response 404
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
require 'rake'
|
|
4
|
+
require 'rake/rdoctask'
|
|
5
|
+
require 'rake/testtask'
|
|
6
|
+
|
|
7
|
+
Rake.application.rake_require '../lib/tasks/LucyCMS'
|
|
8
|
+
|
|
9
|
+
class RakeTasksTest < ActionDispatch::IntegrationTest
|
|
10
|
+
|
|
11
|
+
def test_layouts_import
|
|
12
|
+
CmsLayout.destroy_all
|
|
13
|
+
LucyCMS.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
|
14
|
+
|
|
15
|
+
assert_difference 'CmsLayout.count', 2 do
|
|
16
|
+
capture_rake_output{
|
|
17
|
+
Rake.application['LucyCMS:import:check_for_requirements'].execute(
|
|
18
|
+
:from => 'test.host', :to => 'test.host' )
|
|
19
|
+
Rake.application['LucyCMS:import:layouts'].execute(
|
|
20
|
+
:from => 'test.host', :to => 'test.host' )
|
|
21
|
+
}
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_pages_import
|
|
26
|
+
CmsPage.destroy_all
|
|
27
|
+
LucyCMS.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
|
28
|
+
|
|
29
|
+
assert_difference ['CmsPage.count', 'CmsBlock.count'], 3 do
|
|
30
|
+
capture_rake_output{
|
|
31
|
+
Rake.application['LucyCMS:import:check_for_requirements'].execute(
|
|
32
|
+
:from => 'test.host', :to => 'test.host' )
|
|
33
|
+
Rake.application['LucyCMS:import:pages'].execute(
|
|
34
|
+
:from => 'test.host', :to => 'test.host' )
|
|
35
|
+
}
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def test_snippets_import
|
|
40
|
+
CmsSnippet.destroy_all
|
|
41
|
+
LucyCMS.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
|
42
|
+
|
|
43
|
+
assert_difference 'CmsSnippet.count', 1 do
|
|
44
|
+
capture_rake_output{
|
|
45
|
+
Rake.application['LucyCMS:import:check_for_requirements'].execute(
|
|
46
|
+
:from => 'test.host', :to => 'test.host' )
|
|
47
|
+
Rake.application['LucyCMS:import:snippets'].execute(
|
|
48
|
+
:from => 'test.host', :to => 'test.host' )
|
|
49
|
+
}
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
protected
|
|
54
|
+
|
|
55
|
+
def capture_rake_output
|
|
56
|
+
s = StringIO.new
|
|
57
|
+
oldstdout = $stdout
|
|
58
|
+
$stdout = s
|
|
59
|
+
yield
|
|
60
|
+
s.string
|
|
61
|
+
ensure
|
|
62
|
+
$stdout = oldstdout
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class RenderCmsSeedTest < ActionDispatch::IntegrationTest
|
|
4
|
+
|
|
5
|
+
def test_render_with_seed_data_enabled
|
|
6
|
+
get '/child/subchild'
|
|
7
|
+
assert_response 404
|
|
8
|
+
|
|
9
|
+
LucyCMS.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
|
10
|
+
|
|
11
|
+
get '/child/subchild'
|
|
12
|
+
assert_response :success
|
|
13
|
+
assert_equal '<html><div>Sub Child Page Content Content for Default Snippet</div></html>', response.body
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_get_seed_data_page
|
|
17
|
+
LucyCMS.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
|
18
|
+
|
|
19
|
+
get '/'
|
|
20
|
+
assert_response :success
|
|
21
|
+
assert assigns(:cms_page)
|
|
22
|
+
assert assigns(:cms_page).new_record?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_get_seed_data_css
|
|
26
|
+
LucyCMS.configuration.seed_data_path = File.expand_path('../cms_seeds', File.dirname(__FILE__))
|
|
27
|
+
|
|
28
|
+
get '/cms-css/default'
|
|
29
|
+
assert_response :success
|
|
30
|
+
assert assigns(:cms_layout)
|
|
31
|
+
assert assigns(:cms_layout).new_record?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class RenderCmsTest < ActionDispatch::IntegrationTest
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
Rails.application.routes.draw do
|
|
7
|
+
get '/render-implicit' => 'render_test#implicit'
|
|
8
|
+
get '/render-explicit' => 'render_test#explicit'
|
|
9
|
+
get '/seed-data-page' => 'render_test#seed_data_page'
|
|
10
|
+
get '/render-text' => 'render_test#render_text'
|
|
11
|
+
get '/render-update' => 'render_test#render_update'
|
|
12
|
+
end
|
|
13
|
+
super
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def teardown
|
|
17
|
+
load(File.expand_path('config/routes.rb', Rails.root))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class ::RenderTestController < ApplicationController
|
|
21
|
+
def implicit
|
|
22
|
+
render
|
|
23
|
+
end
|
|
24
|
+
def explicit
|
|
25
|
+
render :cms_page => '/render-explicit-page'
|
|
26
|
+
end
|
|
27
|
+
def seed_data_page
|
|
28
|
+
render :cms_page => '/'
|
|
29
|
+
end
|
|
30
|
+
def render_text
|
|
31
|
+
render :text => 'rendered text'
|
|
32
|
+
end
|
|
33
|
+
def render_update
|
|
34
|
+
render :update do |page|
|
|
35
|
+
page.alert('rendered text')
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_get_with_no_template
|
|
41
|
+
assert_exception_raised ActionView::MissingTemplate do
|
|
42
|
+
get '/render-implicit'
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_get_with_implicit_cms_template
|
|
47
|
+
page = cms_pages(:child)
|
|
48
|
+
page.slug = 'render-implicit'
|
|
49
|
+
page.save!
|
|
50
|
+
get '/render-implicit'
|
|
51
|
+
assert_response :success
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_get_with_explicit_cms_template
|
|
55
|
+
page = cms_pages(:child)
|
|
56
|
+
page.slug = 'render-explicit-page'
|
|
57
|
+
page.save!
|
|
58
|
+
get '/render-explicit'
|
|
59
|
+
assert_response :success
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_get_with_explicit_cms_template_failure
|
|
63
|
+
page = cms_pages(:child)
|
|
64
|
+
page.slug = 'render-explicit-404'
|
|
65
|
+
page.save!
|
|
66
|
+
assert_exception_raised ActionView::MissingTemplate do
|
|
67
|
+
get '/render-explicit'
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_get_render_text
|
|
72
|
+
get '/render-text'
|
|
73
|
+
assert_response :success
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_get_render_update
|
|
77
|
+
get '/render-update'
|
|
78
|
+
assert_response :success
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class SitesTest < ActionDispatch::IntegrationTest
|
|
4
|
+
|
|
5
|
+
def test_get_admin
|
|
6
|
+
http_auth :get, cms_admin_pages_path
|
|
7
|
+
assert_response :success
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_get_admin_with_no_site
|
|
11
|
+
CmsSite.delete_all
|
|
12
|
+
assert_difference 'CmsSite.count' do
|
|
13
|
+
http_auth :get, cms_admin_pages_path
|
|
14
|
+
assert_response :redirect
|
|
15
|
+
assert_redirected_to new_cms_admin_page_path
|
|
16
|
+
site = CmsSite.first
|
|
17
|
+
assert_equal 'test.host', site.hostname
|
|
18
|
+
assert_equal 'Default Site', site.label
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def test_get_admin_with_wrong_site
|
|
23
|
+
site = cms_sites(:default)
|
|
24
|
+
site.update_attribute(:hostname, 'remote.host')
|
|
25
|
+
assert_no_difference 'CmsSite.count' do
|
|
26
|
+
http_auth :get, cms_admin_pages_path
|
|
27
|
+
assert_response :success
|
|
28
|
+
site.reload
|
|
29
|
+
assert_equal 'test.host', site.hostname
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_get_admin_with_two_wrong_sites
|
|
34
|
+
CmsSite.delete_all
|
|
35
|
+
CmsSite.create!(:label => 'Site1', :hostname => 'site1.host')
|
|
36
|
+
CmsSite.create!(:label => 'Site2', :hostname => 'site2.host')
|
|
37
|
+
assert_no_difference 'CmsSite.count' do
|
|
38
|
+
http_auth :get, cms_admin_pages_path
|
|
39
|
+
assert_response :redirect
|
|
40
|
+
assert_redirected_to cms_admin_sites_path
|
|
41
|
+
assert_equal 'No Site defined for this hostname. Create it now.', flash[:error]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_get_admin_with_no_site_and_no_auto_manage
|
|
46
|
+
LucyCMS.config.auto_manage_sites = false
|
|
47
|
+
CmsSite.delete_all
|
|
48
|
+
assert_no_difference 'CmsSite.count' do
|
|
49
|
+
http_auth :get, cms_admin_pages_path
|
|
50
|
+
assert_response :redirect
|
|
51
|
+
assert_redirected_to cms_admin_sites_path
|
|
52
|
+
assert_equal 'No Site defined for this hostname. Create it now.', flash[:error]
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_get_public_page_for_non_existent_site
|
|
57
|
+
host! 'bogus.host'
|
|
58
|
+
get '/'
|
|
59
|
+
assert_response 404
|
|
60
|
+
assert_equal 'Site Not Found', response.body
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class ViewHooksTest < ActionDispatch::IntegrationTest
|
|
4
|
+
|
|
5
|
+
def test_hooks_rendering
|
|
6
|
+
CmsAdmin::SitesController.append_view_path(File.expand_path('../fixtures/views', File.dirname(__FILE__)))
|
|
7
|
+
LucyCMS::ViewHooks.add(:navigation, '/nav_hook')
|
|
8
|
+
|
|
9
|
+
http_auth :get, cms_admin_sites_path
|
|
10
|
+
assert_response :success
|
|
11
|
+
assert_match /hook_content/, response.body
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_hooks_rendering_with_multiples
|
|
15
|
+
CmsAdmin::SitesController.append_view_path(File.expand_path('../fixtures/views', File.dirname(__FILE__)))
|
|
16
|
+
LucyCMS::ViewHooks.add(:navigation, '/nav_hook')
|
|
17
|
+
LucyCMS::ViewHooks.add(:navigation, '/nav_hook_2')
|
|
18
|
+
|
|
19
|
+
http_auth :get, cms_admin_sites_path
|
|
20
|
+
assert_response :success
|
|
21
|
+
assert_match /hook_content/, response.body
|
|
22
|
+
assert_match /<hook_content_2>/, response.body
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_hooks_rendering_with_no_hook
|
|
26
|
+
LucyCMS::ViewHooks.remove(:navigation)
|
|
27
|
+
|
|
28
|
+
http_auth :get, cms_admin_sites_path
|
|
29
|
+
assert_response :success
|
|
30
|
+
assert_no_match /hook_content/, response.body
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
ENV['RAILS_ENV'] = 'test'
|
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
|
3
|
+
require 'rails/test_help'
|
|
4
|
+
|
|
5
|
+
class ActiveSupport::TestCase
|
|
6
|
+
|
|
7
|
+
fixtures :all
|
|
8
|
+
include ActionDispatch::TestProcess
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
reset_config
|
|
12
|
+
@cms_site = CmsSite.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# resetting default configuration
|
|
16
|
+
def reset_config
|
|
17
|
+
LucyCMS.configure do |config|
|
|
18
|
+
config.seed_data_path = nil
|
|
19
|
+
config.admin_route_prefix = 'cms-admin'
|
|
20
|
+
config.admin_route_redirect = "/cms-admin/pages"
|
|
21
|
+
config.disable_irb = true
|
|
22
|
+
config.enable_caching = true
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Example usage:
|
|
27
|
+
# assert_has_errors_on( @record, [:field_1, :field_2] )
|
|
28
|
+
# assert_has_errors_on( @record, {:field_1 => 'Message1', :field_2 => 'Message 2'} )
|
|
29
|
+
def assert_has_errors_on(record, fields)
|
|
30
|
+
fields = [fields].flatten unless fields.is_a?(Hash)
|
|
31
|
+
fields.each do |field, message|
|
|
32
|
+
assert record.errors.has_key?(field.to_sym), "#{record.class.name} should error on invalid #{field}"
|
|
33
|
+
if message && record.errors[field].is_a?(Array) && !message.is_a?(Array)
|
|
34
|
+
assert_not_nil record.errors[field].index(message)
|
|
35
|
+
elsif message
|
|
36
|
+
assert_equal message, record.errors[field]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Example usage:
|
|
42
|
+
# assert_exception_raised do ... end
|
|
43
|
+
# assert_exception_raised ActiveRecord::RecordInvalid do ... end
|
|
44
|
+
# assert_exception_raised Plugin::Error, 'error_message' do ... end
|
|
45
|
+
def assert_exception_raised(exception_class = nil, error_message = nil, &block)
|
|
46
|
+
exception_raised = nil
|
|
47
|
+
yield
|
|
48
|
+
rescue => exception_raised
|
|
49
|
+
ensure
|
|
50
|
+
if exception_raised
|
|
51
|
+
if exception_class
|
|
52
|
+
assert_equal exception_class, exception_raised.class, exception_raised.to_s
|
|
53
|
+
else
|
|
54
|
+
assert true
|
|
55
|
+
end
|
|
56
|
+
assert_equal error_message, exception_raised.to_s if error_message
|
|
57
|
+
else
|
|
58
|
+
flunk 'Exception was not raised'
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Small method that allows for better formatting in tests
|
|
63
|
+
def rendered_content_formatter(string)
|
|
64
|
+
string.gsub(/^[ ]+/, '')
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
class ActionController::TestCase
|
|
69
|
+
def setup
|
|
70
|
+
@request.env['HTTP_AUTHORIZATION'] = "Basic #{Base64.encode64('username:password')}"
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
class ActionDispatch::IntegrationTest
|
|
75
|
+
|
|
76
|
+
def setup
|
|
77
|
+
host! 'test.host'
|
|
78
|
+
reset_config
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Attaching http_auth stuff with request. Example use:
|
|
82
|
+
# http_auth :get, '/cms-admin/pages'
|
|
83
|
+
def http_auth(method, path, options = {}, username = 'username', password = 'password')
|
|
84
|
+
send(method, path, options, {'HTTP_AUTHORIZATION' => "Basic #{Base64.encode64(username + ':' + password)}"})
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class CmsBlockTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
def test_fixtures_validity
|
|
6
|
+
CmsBlock.all.each do |block|
|
|
7
|
+
assert block.valid?, block.errors.full_messages.to_s
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def test_new_via_page_nested_attributes
|
|
12
|
+
assert_difference ['CmsPage.count', 'CmsBlock.count'] do
|
|
13
|
+
page = CmsPage.create!(
|
|
14
|
+
:cms_site => cms_sites(:default),
|
|
15
|
+
:cms_layout => cms_layouts(:default),
|
|
16
|
+
:label => 'test page',
|
|
17
|
+
:slug => 'test_page',
|
|
18
|
+
:parent_id => cms_pages(:default).id,
|
|
19
|
+
:cms_blocks_attributes => [
|
|
20
|
+
{
|
|
21
|
+
:label => 'test_block',
|
|
22
|
+
:content => 'test_content'
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
)
|
|
26
|
+
assert_equal 1, page.cms_blocks.count
|
|
27
|
+
block = page.cms_blocks.first
|
|
28
|
+
assert_equal 'test_block', block.label
|
|
29
|
+
assert_equal 'test_content', block.content
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_initialize_or_find
|
|
34
|
+
tag = CmsTag::PageText.initialize_or_find(cms_pages(:default), :default_field_text)
|
|
35
|
+
assert_equal 'default_field_text', tag.label
|
|
36
|
+
assert_equal 'default_field_text_content', tag.content
|
|
37
|
+
|
|
38
|
+
tag = CmsTag::PageText.initialize_or_find(cms_pages(:default), :new_block)
|
|
39
|
+
assert_equal 'new_block', tag.label
|
|
40
|
+
assert tag.content.blank?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require File.expand_path('../test_helper', File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
class CmsConfigurationTest < ActiveSupport::TestCase
|
|
4
|
+
|
|
5
|
+
def test_configuration_presense
|
|
6
|
+
assert config = LucyCMS.configuration
|
|
7
|
+
assert_equal nil, config.seed_data_path
|
|
8
|
+
assert_equal 'cms-admin', config.admin_route_prefix
|
|
9
|
+
assert_equal '/cms-admin/pages', config.admin_route_redirect
|
|
10
|
+
assert_equal true, config.disable_irb
|
|
11
|
+
assert_equal true, config.enable_caching
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_initialization_overrides
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|