alchemy_cms 2.2.4 → 2.3.rc5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/.travis.yml +3 -4
- data/Gemfile +1 -0
- data/README.md +10 -6
- data/alchemy_cms.gemspec +5 -2
- data/app/assets/images/alchemy/icons.png +0 -0
- data/app/assets/images/sassy-ie-overlay.png +0 -0
- data/app/assets/javascripts/alchemy/alchemy.base.js +50 -59
- data/app/assets/javascripts/alchemy/alchemy.buttons.js +14 -4
- data/app/assets/javascripts/alchemy/alchemy.datepicker.js +8 -2
- data/app/assets/javascripts/alchemy/alchemy.elements_window.js +11 -3
- data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +1 -1
- data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +14 -1
- data/app/assets/javascripts/alchemy/alchemy.preview.js +1 -1
- data/app/assets/javascripts/alchemy/alchemy.preview_window.js +12 -4
- data/app/assets/javascripts/alchemy/alchemy.uploader.js +4 -1
- data/app/assets/javascripts/alchemy/alchemy.windows.js +18 -8
- data/app/assets/stylesheets/alchemy/_defaults.scss +84 -120
- data/app/assets/stylesheets/alchemy/alchemy.css +2 -2
- data/app/assets/stylesheets/alchemy/archive.css.scss +288 -0
- data/app/assets/stylesheets/alchemy/base.css.scss +95 -390
- data/app/assets/stylesheets/alchemy/dashboard.css.scss +4 -4
- data/app/assets/stylesheets/alchemy/elements.css.scss +83 -118
- data/app/assets/stylesheets/alchemy/flash.css.scss +1 -1
- data/app/assets/stylesheets/alchemy/form_elements.css.scss +528 -0
- data/app/assets/stylesheets/alchemy/frame.css.scss +13 -39
- data/app/assets/stylesheets/alchemy/icons.css.scss +217 -228
- data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +48 -50
- data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
- data/app/assets/stylesheets/alchemy/login.css.scss +1 -5
- data/app/assets/stylesheets/alchemy/menubar.css.scss +19 -29
- data/app/assets/stylesheets/alchemy/pagination.css.scss +3 -4
- data/app/assets/stylesheets/alchemy/sitemap.css.scss +81 -81
- data/app/assets/stylesheets/alchemy/tables.css.scss +63 -57
- data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +57 -57
- data/app/assets/stylesheets/alchemy/upload.css.scss +6 -6
- data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.scss +6 -10
- data/app/controllers/alchemy/admin/attachments_controller.rb +5 -4
- data/app/controllers/alchemy/admin/base_controller.rb +1 -9
- data/app/controllers/alchemy/admin/contents_controller.rb +4 -6
- data/app/controllers/alchemy/admin/elements_controller.rb +2 -2
- data/app/controllers/alchemy/admin/pages_controller.rb +2 -2
- data/app/controllers/alchemy/admin/pictures_controller.rb +74 -15
- data/app/controllers/alchemy/attachments_controller.rb +8 -2
- data/app/controllers/alchemy/base_controller.rb +47 -5
- data/app/controllers/alchemy/elements_controller.rb +1 -1
- data/app/controllers/alchemy/messages_controller.rb +12 -12
- data/app/controllers/alchemy/pages_controller.rb +5 -1
- data/app/controllers/alchemy/pictures_controller.rb +9 -4
- data/app/controllers/alchemy/user_sessions_controller.rb +2 -4
- data/app/helpers/alchemy/admin/base_helper.rb +98 -19
- data/app/helpers/alchemy/admin/contents_helper.rb +2 -2
- data/app/helpers/alchemy/admin/elements_helper.rb +2 -3
- data/app/helpers/alchemy/base_helper.rb +6 -5
- data/app/helpers/alchemy/elements_helper.rb +2 -2
- data/app/helpers/alchemy/essences_helper.rb +4 -5
- data/app/helpers/alchemy/pages_helper.rb +15 -79
- data/app/helpers/alchemy/url_helper.rb +67 -0
- data/app/mailers/alchemy/messages.rb +1 -1
- data/app/mailers/alchemy/notifications.rb +1 -1
- data/app/models/alchemy/attachment.rb +11 -2
- data/app/models/alchemy/cell.rb +20 -10
- data/app/models/alchemy/content.rb +4 -3
- data/app/models/alchemy/element.rb +170 -178
- data/app/models/alchemy/language/code.rb +4 -1
- data/app/models/alchemy/message.rb +19 -3
- data/app/models/alchemy/page.rb +45 -40
- data/app/models/alchemy/picture.rb +24 -2
- data/app/models/alchemy/user.rb +2 -3
- data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +12 -12
- data/app/views/alchemy/admin/attachments/_attachment.html.erb +1 -1
- data/app/views/alchemy/admin/attachments/create.js.erb +1 -0
- data/app/views/alchemy/admin/attachments/edit.html.erb +9 -3
- data/app/views/alchemy/admin/attachments/index.html.erb +3 -2
- data/app/views/alchemy/admin/contents/_missing.html.erb +1 -1
- data/app/views/alchemy/admin/contents/create.js.erb +54 -0
- data/app/views/alchemy/admin/contents/new.html.erb +9 -4
- data/app/views/alchemy/admin/elements/{_add_content.html.erb → _add_picture.html.erb} +4 -4
- data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -1
- data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -1
- data/app/views/alchemy/admin/elements/{_picture_editor.html.erb → _picture_gallery_editor.html.erb} +7 -11
- data/app/views/alchemy/admin/elements/fold.js.erb +46 -0
- data/app/views/alchemy/admin/elements/index.html.erb +24 -24
- data/app/views/alchemy/admin/elements/list.js.erb +11 -9
- data/app/views/alchemy/admin/essence_files/assign.js.erb +3 -1
- data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +28 -0
- data/app/views/alchemy/admin/pages/_contactform_links.html.erb +8 -6
- data/app/views/alchemy/admin/pages/_external_link.html.erb +11 -9
- data/app/views/alchemy/admin/pages/_file_link.html.erb +10 -8
- data/app/views/alchemy/admin/pages/_internal_link.html.erb +14 -10
- data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_page_for_links.html.erb +32 -21
- data/app/views/alchemy/admin/pages/configure.html.erb +2 -2
- data/app/views/alchemy/admin/pages/configure_external.html.erb +13 -13
- data/app/views/alchemy/admin/pages/edit.html.erb +2 -2
- data/app/views/alchemy/admin/pages/index.html.erb +26 -24
- data/app/views/alchemy/admin/pages/link.html.erb +2 -5
- data/app/views/alchemy/admin/partials/_upload_form.html.erb +28 -12
- data/app/views/alchemy/admin/pictures/_archive.html.erb +54 -0
- data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +10 -7
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +21 -22
- data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +31 -0
- data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +9 -0
- data/app/views/alchemy/admin/pictures/_picture.html.erb +36 -6
- data/app/views/alchemy/admin/pictures/_tag_list.html.erb +27 -0
- data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +3 -1
- data/app/views/alchemy/admin/pictures/create.js.erb +4 -5
- data/app/views/alchemy/admin/pictures/edit.html.erb +26 -0
- data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +39 -0
- data/app/views/alchemy/admin/pictures/index.html.erb +81 -70
- data/app/views/alchemy/admin/pictures/index.js.erb +3 -0
- data/app/views/alchemy/admin/pictures/new.html.erb +1 -0
- data/app/views/alchemy/admin/resources/index.html.erb +3 -1
- data/app/views/alchemy/admin/users/_table.html.erb +1 -1
- data/app/views/alchemy/admin/users/index.html.erb +27 -23
- data/app/views/alchemy/elements/_article_editor.html.erb +7 -2
- data/app/views/alchemy/elements/_bild_editor.html.erb +1 -1
- data/app/views/alchemy/elements/_bild_text_editor.html.erb +6 -1
- data/app/views/alchemy/elements/_bild_text_view.html.erb +3 -3
- data/app/views/alchemy/elements/_image_mosaic_editor.html.erb +1 -1
- data/app/views/alchemy/elements/_image_mosaic_view.html.erb +2 -2
- data/app/views/alchemy/elements/_intro_image_text_view.html.erb +4 -4
- data/app/views/alchemy/elements/_searchresult_editor.html.erb +4 -1
- data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_picture_editor.html.erb +2 -3
- data/app/views/alchemy/essences/_essence_picture_tools.html.erb +1 -1
- data/app/views/alchemy/search/_form.html.erb +8 -0
- data/app/views/alchemy/search/_result.html.erb +3 -2
- data/app/views/alchemy/search/_results.html.erb +28 -0
- data/app/views/alchemy/user_sessions/leave.html.erb +4 -4
- data/app/views/alchemy/user_sessions/login.html.erb +1 -2
- data/app/views/layouts/alchemy/admin.html.erb +30 -10
- data/app/views/layouts/alchemy/login.html.erb +2 -39
- data/config/alchemy/elements.yml +1 -2
- data/config/alchemy/page_layouts.yml +8 -5
- data/config/authorization_rules.rb +27 -18
- data/config/initializers/localeapp.rb +9 -0
- data/config/locales/alchemy.de.yml +93 -56
- data/config/locales/alchemy.en.yml +73 -50
- data/config/routes.rb +3 -1
- data/db/migrate/20120704181529_add_upload_hash_to_alchemy_picture.rb +5 -0
- data/db/migrate/20120705214247_acts_as_taggable_on_migration.rb +28 -0
- data/db/migrate/20120728185830_add_cached_tag_list_to_alchemy_pictures.rb +5 -0
- data/db/migrate/20120831135441_set_alchemy_languages_country_code_default_to_empty_string.rb +9 -0
- data/lib/alchemy/capistrano.rb +2 -2
- data/lib/alchemy/essence.rb +14 -0
- data/lib/alchemy/page_layout.rb +0 -6
- data/lib/alchemy/resource.rb +9 -15
- data/lib/alchemy/upgrader.rb +18 -3
- data/lib/alchemy/version.rb +5 -1
- data/lib/alchemy_cms.rb +4 -1
- data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +16 -6
- data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +17 -3
- data/lib/rails/generators/alchemy/elements/elements_generator.rb +6 -1
- data/lib/rails/generators/alchemy/elements/templates/editor.html.erb +10 -1
- data/lib/rails/generators/alchemy/elements/templates/view.html.erb +17 -18
- data/lib/rails/generators/alchemy/scaffold/files/pages.html.erb +4 -2
- data/lib/tasks/fleximage.rake +2 -2
- data/spec/controllers/admin/contents_controller_spec.rb +2 -2
- data/spec/controllers/admin/elements_controller_spec.rb +30 -1
- data/spec/controllers/admin/pages_controller_spec.rb +35 -18
- data/spec/controllers/admin/trash_controller_spec.rb +40 -16
- data/spec/controllers/attachments_controller_spec.rb +62 -0
- data/spec/controllers/base_controller_spec.rb +43 -42
- data/spec/controllers/elements_controller_spec.rb +30 -0
- data/spec/controllers/pages_controller_spec.rb +22 -5
- data/spec/controllers/pictures_controller_spec.rb +82 -0
- data/spec/dummy/app/models/event.rb +2 -1
- data/spec/dummy/config/database.yml +3 -2
- data/spec/dummy/db/schema.rb +51 -27
- data/spec/factories.rb +29 -8
- data/spec/helpers/admin/base_helper_spec.rb +134 -21
- data/spec/helpers/admin/contents_helper_spec.rb +2 -2
- data/spec/helpers/admin/elements_helper_spec.rb +17 -9
- data/spec/helpers/admin/essences_helper_spec.rb +7 -6
- data/spec/helpers/essences_helper_spec.rb +8 -7
- data/spec/helpers/pages_helper_spec.rb +208 -325
- data/spec/helpers/url_helper_spec.rb +171 -0
- data/spec/integration/admin/link_overlay_spec.rb +53 -0
- data/spec/integration/admin/modules_integration_spec.rb +22 -26
- data/spec/integration/admin/pages_controller_spec.rb +10 -19
- data/spec/integration/admin/picture_library_integration_spec.rb +52 -0
- data/spec/integration/admin/resources_integration_spec.rb +68 -75
- data/spec/integration/pages_controller_spec.rb +70 -61
- data/spec/integration/security_spec.rb +3 -5
- data/spec/integration/translation_integration_spec.rb +56 -0
- data/spec/libraries/essence_spec.rb +18 -0
- data/spec/libraries/resource_spec.rb +101 -79
- data/spec/libraries/resources_helper_spec.rb +3 -0
- data/spec/models/content_spec.rb +63 -60
- data/spec/models/element_spec.rb +203 -93
- data/spec/models/language_spec.rb +90 -65
- data/spec/models/page_layout_spec.rb +37 -0
- data/spec/models/page_spec.rb +181 -113
- data/spec/models/picture_spec.rb +73 -26
- data/spec/models/resource_spec.rb +52 -23
- data/spec/support/alchemy/specs_helpers.rb +2 -0
- data/spec/support/image.png +0 -0
- data/spec/{helpers/url_helpers_spec.rb → url_helpers_spec.rb} +0 -0
- data/vendor/assets/javascripts/jquery_plugins/jquery.selectBoxIt.js +1909 -0
- data/vendor/assets/javascripts/jquery_plugins/preloadCssImages.jQuery_v5.js +152 -0
- metadata +106 -33
- data/app/assets/stylesheets/alchemy/buttons.css.scss +0 -361
- data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +0 -260
- data/app/views/alchemy/admin/contents/create.js.coffee +0 -49
- data/app/views/alchemy/admin/elements/fold.js.coffee +0 -37
- data/app/views/alchemy/admin/essence_pictures/destroy.js.coffee +0 -19
- data/app/views/alchemy/admin/pictures/_pictures_list.html.erb +0 -16
- data/app/views/alchemy/admin/pictures/update.js.erb +0 -3
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/locales/fo.yml +0 -5
- data/spec/page_layout_spec.rb +0 -35
- data/vendor/assets/javascripts/jquery_plugins/jquery.in-place-edit.js +0 -172
- data/vendor/assets/javascripts/jquery_plugins/jquery.sb.min.js +0 -14
@@ -4,17 +4,21 @@ module Alchemy
|
|
4
4
|
module Generators
|
5
5
|
class DeployScriptGenerator < ::Rails::Generators::Base
|
6
6
|
|
7
|
-
desc "This generator generates a Capistrano
|
8
|
-
class_option :scm, :type => :string, :desc => "Set the type of scm you use for deployment.", :default => '
|
7
|
+
desc "This generator generates a Capistrano receipt for deploying Alchemy CMS."
|
8
|
+
class_option :scm, :type => :string, :desc => "Set the type of scm you use for deployment.", :default => 'git'
|
9
9
|
class_option :db, :type => :string, :desc => "Set the type of database you use on your server.", :default => 'mysql'
|
10
10
|
source_root File.expand_path('templates', File.dirname(__FILE__))
|
11
11
|
|
12
12
|
def copy_script
|
13
|
-
@ssh_user = ask('Please enter SSH username:')
|
14
|
-
@ssh_password = ask('Please enter SSH password:')
|
15
|
-
port = ask('Please enter SSH port (22):')
|
16
|
-
@ssh_port = port.blank? ? 22 : port
|
17
13
|
@server = ask('Please enter server ip or domain:')
|
14
|
+
if !yes?('Do you use ssh public keys to connect to your server? (y/N)')
|
15
|
+
if @store_credentials = yes?('Do want to store the ssh credentials? (PLEASE DO NOT STORE THEM IF THE REPOSITORY IS PUBLIC) (y/N)')
|
16
|
+
@ssh_user = ask('Please enter ssh username:')
|
17
|
+
@ssh_password = ask('Please enter ssh password:')
|
18
|
+
port = ask('Please enter ssh port (22):')
|
19
|
+
@ssh_port = port.blank? ? "22" : port
|
20
|
+
end
|
21
|
+
end
|
18
22
|
@deploy_path = ask('Please enter the path to the public html folder:')
|
19
23
|
@scm = options[:scm]
|
20
24
|
@repository_url = ask('Please enter the URL to your projects repository:')
|
@@ -24,6 +28,12 @@ module Alchemy
|
|
24
28
|
end
|
25
29
|
@database_type = options[:db]
|
26
30
|
template "deploy.rb.tt", Rails.root.join('config', 'deploy.rb')
|
31
|
+
puts "\nSetting up Capistrano"
|
32
|
+
`capify .`
|
33
|
+
puts "\nWe are done!\n"
|
34
|
+
puts "\nPlease run 'cap deploy:setup'\n to setup the server for deployment."
|
35
|
+
puts "\nIf you want to deploy Alchemy the first time type:\ncap deploy:cold"
|
36
|
+
puts "\nAfter the first deploy you just need to type:\ncap deploy"
|
27
37
|
end
|
28
38
|
|
29
39
|
end
|
@@ -3,9 +3,21 @@ require 'alchemy/capistrano'
|
|
3
3
|
load 'deploy/assets'
|
4
4
|
|
5
5
|
# ssh settings
|
6
|
+
<%- if @ssh_user.blank? -%>
|
7
|
+
set(:user) { Capistrano::CLI.ui.ask('Enter your ssh username: ') }
|
8
|
+
<%- else -%>
|
6
9
|
set :user, "<%= @ssh_user %>"
|
10
|
+
<%- end -%>
|
11
|
+
<%- if @ssh_password.blank? -%>
|
12
|
+
set(:password) { Capistrano::CLI.password_prompt("Enter the password for #{user}: ") }
|
13
|
+
<%- else -%>
|
7
14
|
set :password, "<%= @ssh_password %>"
|
8
|
-
|
15
|
+
<%- end -%>
|
16
|
+
<%- if @ssh_port != "22" && !@store_credentials -%>
|
17
|
+
set(:port) { Capistrano::CLI.ui.ask('Enter the ssh port: ') }
|
18
|
+
<%- elsif @ssh_port != "22" && @store_credentials -%>
|
19
|
+
set :port, <%= @ssh_port %>
|
20
|
+
<%- end -%>
|
9
21
|
|
10
22
|
# domain names
|
11
23
|
role :app, "<%= @server %>"
|
@@ -45,9 +57,10 @@ after "deploy", "deploy:cleanup"
|
|
45
57
|
|
46
58
|
# special tasks
|
47
59
|
|
48
|
-
namespace :
|
60
|
+
namespace :log do
|
61
|
+
|
49
62
|
desc "show last 100 lines of log"
|
50
|
-
task :
|
63
|
+
task :show do
|
51
64
|
run "tail -n100 #{shared_path}/log/#{rails_env}.log"
|
52
65
|
end
|
53
66
|
|
@@ -55,6 +68,7 @@ namespace :logs do
|
|
55
68
|
task :watch do
|
56
69
|
stream("tail -f #{shared_path}/log/#{rails_env}.log")
|
57
70
|
end
|
71
|
+
|
58
72
|
end
|
59
73
|
|
60
74
|
namespace :deploy do
|
@@ -15,7 +15,12 @@ module Alchemy
|
|
15
15
|
@elements = get_elements_from_yaml
|
16
16
|
@elements.each do |element|
|
17
17
|
@element = element
|
18
|
-
@
|
18
|
+
if @element['available_contents']
|
19
|
+
@available_contents_names = @element['available_contents'].collect { |c| c['name'] }
|
20
|
+
@contents = (element["contents"].delete_if { |c| @available_contents_names.include?(c['name']) } or [])
|
21
|
+
else
|
22
|
+
@contents = (element["contents"] or [])
|
23
|
+
end
|
19
24
|
@element_name = element["name"].underscore
|
20
25
|
template "editor.html.erb", "#{@elements_dir}/_#{@element_name}_editor.html.erb"
|
21
26
|
template "view.html.erb", "#{@elements_dir}/_#{@element_name}_view.html.erb"
|
@@ -1,3 +1,12 @@
|
|
1
|
-
<%- @
|
1
|
+
<%- if @element['picture_gallery'] -%>
|
2
|
+
<%%= render_picture_gallery_editor(element, :max_images => nil, :crop => true) %>
|
3
|
+
<%- end -%>
|
4
|
+
<% @contents.each do |content| -%>
|
2
5
|
<%%= render_essence_editor_by_name(element, '<%= content["name"] %>') %>
|
6
|
+
<% end -%>
|
7
|
+
<%- if @element['available_contents'] -%>
|
8
|
+
<%% element.contents.where(:name => ['<%= @available_contents_names.join("', '") %>']).each do |content| %>
|
9
|
+
<%%= render_essence_editor content %>
|
10
|
+
<%% end %>
|
11
|
+
<p><%%= render_new_content_link(element) %></p>
|
3
12
|
<%- end -%>
|
@@ -1,21 +1,20 @@
|
|
1
|
-
<div class="<%= @element_name %>" id="<%%= element_dom_id(element) %>"<%%= element_preview_code(element)
|
2
|
-
<%-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
<%- end -%>
|
1
|
+
<div class="<%= @element_name %>" id="<%%= element_dom_id(element) %>"<%%= element_preview_code(element) %>>
|
2
|
+
<%- if @element["picture_gallery"] -%>
|
3
|
+
<div class="<%= @element_name %>_images">
|
4
|
+
<%%- element.contents.gallery_pictures.each do |image| -%>
|
5
|
+
<div class="<%= @element_name %>_image <%%= image.essence.css_class %>">
|
6
|
+
<%%= render_essence_view(image, :image_size => "160x120") %>
|
7
|
+
</div>
|
8
|
+
<%%- end -%>
|
9
|
+
</div>
|
10
|
+
<%- end -%>
|
11
|
+
<%- @contents.each do |content| -%>
|
12
|
+
<%- if @contents.length > 1 -%>
|
13
|
+
<div class="<%= content["name"] %>">
|
14
|
+
<%%= render_essence_view_by_name(element, '<%= content["name"] %>') %>
|
15
|
+
</div>
|
16
|
+
<%- else -%>
|
17
|
+
<%%= render_essence_view_by_name(element, '<%= content["name"] %>') %>
|
19
18
|
<%- end -%>
|
20
19
|
<%- end -%>
|
21
20
|
</div>
|
data/lib/tasks/fleximage.rake
CHANGED
@@ -11,8 +11,8 @@ namespace :fleximage do
|
|
11
11
|
model_class.find(:all).each do |obj|
|
12
12
|
if obj.has_image?
|
13
13
|
img = obj.load_image
|
14
|
-
obj.
|
15
|
-
obj.
|
14
|
+
obj.update_column :image_width, img.columns if obj.respond_to?(:image_width=)
|
15
|
+
obj.update_column :image_height, img.rows if obj.respond_to?(:image_height=)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -23,7 +23,7 @@ describe Alchemy::Admin::ContentsController do
|
|
23
23
|
describe '#update' do
|
24
24
|
|
25
25
|
it "should update a content via ajax" do
|
26
|
-
@element = FactoryGirl.create(:element)
|
26
|
+
@element = FactoryGirl.create(:element, :create_contents_after_create => true)
|
27
27
|
post :update, {:id => @element.contents.find_by_name('intro').id, :content => {:body => 'Peters Petshop'}, :format => :js}
|
28
28
|
@element.ingredient('intro').should == "Peters Petshop"
|
29
29
|
end
|
@@ -35,7 +35,7 @@ describe Alchemy::Admin::ContentsController do
|
|
35
35
|
context "with content_ids in params" do
|
36
36
|
|
37
37
|
before(:each) do
|
38
|
-
@element = FactoryGirl.create(:element)
|
38
|
+
@element = FactoryGirl.create(:element, :create_contents_after_create => true)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should reorder the contents" do
|
@@ -73,10 +73,39 @@ module Alchemy
|
|
73
73
|
|
74
74
|
describe '#create' do
|
75
75
|
|
76
|
-
|
76
|
+
context "with cells" do
|
77
|
+
|
78
|
+
before do
|
79
|
+
@page = FactoryGirl.create(:public_page, :do_not_autogenerate => false)
|
80
|
+
@cell = FactoryGirl.create(:cell, :name => 'header', :page => @page)
|
81
|
+
Page.any_instance.stub(:can_have_cells?).and_return(true)
|
82
|
+
Cell.stub!(:definition_for).and_return({'name' => 'header', 'elements' => ['article']})
|
83
|
+
end
|
84
|
+
|
85
|
+
context "and cell name in element name" do
|
86
|
+
|
87
|
+
it "should put the element in the correct cell" do
|
88
|
+
post :create, {:element => {:name => "article#header", :page_id => @page.id}}
|
89
|
+
@cell.elements.first.should be_an_instance_of(Element)
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
context "and no cell name in element name" do
|
95
|
+
|
96
|
+
it "should put the element in the main cell" do
|
97
|
+
post :create, {:element => {:name => "article", :page_id => @page.id}}
|
98
|
+
@page.elements.not_in_cell.first.should be_an_instance_of(Element)
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
77
104
|
|
78
105
|
context "with paste_from_clipboard in parameters" do
|
79
106
|
|
107
|
+
render_views
|
108
|
+
|
80
109
|
let(:clipboard) { session[:clipboard] = Clipboard.new }
|
81
110
|
let(:element_in_clipboard) { @element ||= FactoryGirl.create(:element, :page_id => page.id) }
|
82
111
|
|
@@ -44,8 +44,8 @@ module Alchemy
|
|
44
44
|
context "with paste_from_clipboard in parameters" do
|
45
45
|
|
46
46
|
let(:clipboard) { session[:clipboard] = Clipboard.new }
|
47
|
-
let(:page_in_clipboard) {
|
48
|
-
let(:parent) {
|
47
|
+
let(:page_in_clipboard) { FactoryGirl.create(:public_page) }
|
48
|
+
let(:parent) { FactoryGirl.create(:public_page) }
|
49
49
|
|
50
50
|
before(:each) do
|
51
51
|
clipboard[:pages] = [{:id => page_in_clipboard.id, :action => 'cut'}]
|
@@ -63,32 +63,49 @@ module Alchemy
|
|
63
63
|
|
64
64
|
describe '#copy_language_tree' do
|
65
65
|
|
66
|
+
let(:language) { Language.get_default }
|
67
|
+
let(:new_language) { FactoryGirl.create(:klingonian) }
|
68
|
+
let(:language_root) { FactoryGirl.create(:language_root_page, :language => language) }
|
69
|
+
let(:new_lang_root) { Page.language_root_for(new_language.id) }
|
70
|
+
|
66
71
|
before(:each) do
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
session[:language_code] = @new_language.code
|
75
|
-
session[:language_id] = @new_language.id
|
76
|
-
post :copy_language_tree, {:languages => {:new_lang_id => @new_language.id, :old_lang_id => @language.id}}
|
77
|
-
@new_lang_root = Page.language_root_for(@new_language.id)
|
72
|
+
level_1 = FactoryGirl.create(:public_page, :parent_id => language_root.id, :visible => true, :name => 'Level 1')
|
73
|
+
level_2 = FactoryGirl.create(:public_page, :parent_id => level_1.id, :visible => true, :name => 'Level 2')
|
74
|
+
level_3 = FactoryGirl.create(:public_page, :parent_id => level_2.id, :visible => true, :name => 'Level 3')
|
75
|
+
level_4 = FactoryGirl.create(:public_page, :parent_id => level_3.id, :visible => true, :name => 'Level 4')
|
76
|
+
session[:language_code] = new_language.code
|
77
|
+
session[:language_id] = new_language.id
|
78
|
+
post :copy_language_tree, {:languages => {:new_lang_id => new_language.id, :old_lang_id => language.id}}
|
78
79
|
end
|
79
80
|
|
80
81
|
it "should copy all pages" do
|
81
|
-
|
82
|
-
|
83
|
-
|
82
|
+
new_lang_root.should_not be_nil
|
83
|
+
new_lang_root.descendants.count.should == 4
|
84
|
+
new_lang_root.descendants.collect(&:name).should == ["Level 1 (Copy)", "Level 2 (Copy)", "Level 3 (Copy)", "Level 4 (Copy)"]
|
84
85
|
end
|
85
86
|
|
86
87
|
it "should not set layoutpage attribute to nil" do
|
87
|
-
|
88
|
+
new_lang_root.layoutpage.should_not be_nil
|
88
89
|
end
|
89
90
|
|
90
91
|
it "should not set layoutpage attribute to true" do
|
91
|
-
|
92
|
+
new_lang_root.layoutpage.should_not be_true
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#destroy' do
|
98
|
+
|
99
|
+
let(:clipboard) { session[:clipboard] = Clipboard.new }
|
100
|
+
let(:page) { FactoryGirl.create(:public_page) }
|
101
|
+
|
102
|
+
before do
|
103
|
+
clipboard[:pages] = [{:id => page.id}]
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should also remove the page from clipboard" do
|
107
|
+
post :destroy, {:id => page.id, :_method => :delete}
|
108
|
+
clipboard[:pages].should be_empty
|
92
109
|
end
|
93
110
|
|
94
111
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
3
|
module Alchemy
|
6
4
|
module Admin
|
7
5
|
|
@@ -9,38 +7,64 @@ module Alchemy
|
|
9
7
|
|
10
8
|
render_views
|
11
9
|
|
12
|
-
before(:each) do
|
13
|
-
activate_authlogic
|
14
|
-
UserSession.create FactoryGirl.create(:admin_user)
|
15
|
-
end
|
16
|
-
|
17
10
|
let(:page) do
|
18
11
|
FactoryGirl.create(:page, :parent_id => Page.rootpage.id)
|
19
12
|
end
|
20
13
|
|
21
14
|
let(:element) do
|
22
|
-
FactoryGirl.create(:element, :public => false)
|
15
|
+
FactoryGirl.create(:element, :public => false, :page => page)
|
23
16
|
end
|
24
17
|
|
25
|
-
|
26
|
-
|
18
|
+
before do
|
19
|
+
activate_authlogic
|
20
|
+
UserSession.create FactoryGirl.create(:admin_user)
|
27
21
|
element.trash
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should hold trashed elements" do
|
28
25
|
get :index, :page_id => page.id
|
29
|
-
response.body.should have_selector("#
|
26
|
+
response.body.should have_selector("#element_#{element.id}.element_editor")
|
30
27
|
end
|
31
28
|
|
32
29
|
it "should not hold elements that are not trashed" do
|
33
|
-
element = FactoryGirl.create(:element, :
|
30
|
+
element = FactoryGirl.create(:element, :page => page, :public => false)
|
34
31
|
get :index, :page_id => page.id
|
35
|
-
response.body.should_not have_selector("#
|
32
|
+
response.body.should_not have_selector("#element_#{element.id}.element_editor")
|
33
|
+
end
|
34
|
+
|
35
|
+
context "with unique elements inside the trash" do
|
36
|
+
|
37
|
+
before do
|
38
|
+
Element.stub!(:all_definitions_for).and_return([
|
39
|
+
{'name' => element.name, 'unique' => true}
|
40
|
+
])
|
41
|
+
end
|
42
|
+
|
43
|
+
context "and no unique elements on the page" do
|
44
|
+
|
45
|
+
it "unique elements should be draggable" do
|
46
|
+
get :index, :page_id => page.id
|
47
|
+
response.body.should have_selector("#element_#{element.id}.element_editor.draggable")
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
context "and with an unique element on the page" do
|
53
|
+
|
54
|
+
it "unique elements should not be draggable" do
|
55
|
+
FactoryGirl.create(:element, :page => page, :public => false)
|
56
|
+
get :index, :page_id => page.id
|
57
|
+
response.body.should have_selector("#element_#{element.id}.element_editor.not-draggable")
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
36
62
|
end
|
37
63
|
|
38
64
|
context "#clear" do
|
39
65
|
|
40
66
|
it "should destroy all containing elements" do
|
41
|
-
|
42
|
-
element.trash
|
43
|
-
post :clear, {:page_id => 1}
|
67
|
+
post :clear, {:page_id => page.id}
|
44
68
|
Element.trashed.should be_empty
|
45
69
|
end
|
46
70
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Fixes missing method tempfile error
|
4
|
+
class Rack::Test::UploadedFile
|
5
|
+
attr_reader :tempfile
|
6
|
+
end
|
7
|
+
|
8
|
+
module Alchemy
|
9
|
+
describe AttachmentsController do
|
10
|
+
|
11
|
+
let(:page) { FactoryGirl.create(:public_page, :restricted => true) }
|
12
|
+
let(:element) { FactoryGirl.create(:element, :page => page, :name => 'download', :create_contents_after_create => true) }
|
13
|
+
let(:attachment) { Attachment.create(:uploaded_data => fixture_file_upload(File.expand_path('../../support/image.png', __FILE__), 'image/png')) }
|
14
|
+
|
15
|
+
before do
|
16
|
+
essence = element.contents.where(:name => 'file').first.essence
|
17
|
+
essence.attachment_id = attachment.id
|
18
|
+
essence.save
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should not be possible to download attachments from restricted pages" do
|
22
|
+
get :download, :id => attachment.id
|
23
|
+
response.status.should == 302
|
24
|
+
response.should redirect_to(login_path)
|
25
|
+
end
|
26
|
+
|
27
|
+
context "as registered user" do
|
28
|
+
|
29
|
+
before do
|
30
|
+
activate_authlogic
|
31
|
+
UserSession.create(FactoryGirl.create(:registered_user))
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should be possible to download attachments from restricted pages" do
|
35
|
+
get :download, :id => attachment.id
|
36
|
+
response.status.should == 200
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should not be possible to see attachments from restricted pages" do
|
42
|
+
get :show, :id => attachment.id
|
43
|
+
response.status.should == 302
|
44
|
+
response.should redirect_to(login_path)
|
45
|
+
end
|
46
|
+
|
47
|
+
context "as registered user" do
|
48
|
+
|
49
|
+
before do
|
50
|
+
activate_authlogic
|
51
|
+
UserSession.create(FactoryGirl.create(:registered_user))
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should be possible to see attachments from restricted pages" do
|
55
|
+
get :show, :id => attachment.id
|
56
|
+
response.status.should == 200
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|