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
@@ -3,17 +3,18 @@ require 'spec_helper'
|
|
3
3
|
module Alchemy
|
4
4
|
describe UserSessionsController do
|
5
5
|
|
6
|
-
let(:user)
|
7
|
-
let(:alchemy_page) { FactoryGirl.create(:page) }
|
6
|
+
let(:user) { FactoryGirl.build_stubbed(:admin_user) }
|
8
7
|
|
9
|
-
before
|
8
|
+
before do
|
9
|
+
controller.stub!(:store_user_request_time)
|
10
|
+
sign_in(user)
|
11
|
+
end
|
10
12
|
|
11
|
-
describe "
|
13
|
+
describe "#destroy" do
|
12
14
|
it "should unlock all pages" do
|
13
15
|
@request.env["devise.mapping"] = Devise.mappings[:user]
|
14
|
-
|
16
|
+
user.should_receive(:unlock_pages!)
|
15
17
|
delete :destroy
|
16
|
-
user.locked_pages.should be_empty
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
@@ -33,10 +33,10 @@ module Alchemy
|
|
33
33
|
describe '#create' do
|
34
34
|
before { ActionMailer::Base.deliveries = [] }
|
35
35
|
|
36
|
-
context "with send_credentials set to
|
36
|
+
context "with send_credentials set to '1'" do
|
37
37
|
it "should send an email notification" do
|
38
38
|
post :create, {
|
39
|
-
:user => FactoryGirl.attributes_for(:admin_user).merge(send_credentials:
|
39
|
+
:user => FactoryGirl.attributes_for(:admin_user).merge(send_credentials: '1')
|
40
40
|
}
|
41
41
|
ActionMailer::Base.deliveries.should_not be_empty
|
42
42
|
end
|
@@ -1,18 +1,29 @@
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
2
2
|
|
3
3
|
# Pick the frameworks you want:
|
4
|
-
|
5
|
-
require "
|
6
|
-
require "
|
7
|
-
require "
|
8
|
-
require "
|
9
|
-
|
4
|
+
if ENV['FAST_SPECS']
|
5
|
+
require "active_record/railtie"
|
6
|
+
require "action_controller/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
require "active_resource/railtie"
|
9
|
+
require "alchemy_cms"
|
10
|
+
else
|
11
|
+
require "active_record/railtie"
|
12
|
+
require "action_controller/railtie"
|
13
|
+
require "action_mailer/railtie"
|
14
|
+
require "active_resource/railtie"
|
15
|
+
require "sprockets/railtie"
|
16
|
+
end
|
10
17
|
|
11
18
|
if defined?(Bundler)
|
12
19
|
# If you precompile assets before deploying to production, use this line
|
13
|
-
Bundler.require(*Rails.groups(:assets => %w(development test)))
|
20
|
+
# Bundler.require(*Rails.groups(:assets => %w(development test)))
|
14
21
|
# If you want your assets lazily compiled in production, use this line
|
15
|
-
|
22
|
+
if ENV['FAST_SPECS']
|
23
|
+
Bundler.require(:test)
|
24
|
+
else
|
25
|
+
Bundler.require(:default, :assets, Rails.env)
|
26
|
+
end
|
16
27
|
end
|
17
28
|
|
18
29
|
module Dummy
|
@@ -1,27 +1,30 @@
|
|
1
|
-
# This is a compressed migration for creating all Alchemy 2.
|
1
|
+
# This is a compressed migration for creating all Alchemy 2.6 tables at once.
|
2
2
|
#
|
3
3
|
# === Notice
|
4
4
|
#
|
5
5
|
# In order to upgrade from an old version of Alchemy, you have to run all migrations from
|
6
6
|
# each version you missed up to the version you want to upgrade to, before running this migration.
|
7
7
|
#
|
8
|
-
class
|
8
|
+
class AlchemyTwoPointSix < ActiveRecord::Migration
|
9
9
|
def up
|
10
10
|
# Do not run if Alchemy tables are already present
|
11
11
|
return if table_exists?(:alchemy_pages)
|
12
12
|
|
13
13
|
create_table "alchemy_attachments", :force => true do |t|
|
14
14
|
t.string "name"
|
15
|
-
t.string "
|
16
|
-
t.string "
|
17
|
-
t.integer "
|
15
|
+
t.string "file_name"
|
16
|
+
t.string "file_mime_type"
|
17
|
+
t.integer "file_size"
|
18
18
|
t.integer "creator_id"
|
19
19
|
t.integer "updater_id"
|
20
20
|
t.datetime "created_at", :null => false
|
21
21
|
t.datetime "updated_at", :null => false
|
22
22
|
t.text "cached_tag_list"
|
23
|
+
t.string "file_uid"
|
23
24
|
end
|
24
25
|
|
26
|
+
add_index "alchemy_attachments", ["file_uid"], :name => "index_alchemy_attachments_on_file_uid"
|
27
|
+
|
25
28
|
create_table "alchemy_cells", :force => true do |t|
|
26
29
|
t.integer "page_id"
|
27
30
|
t.string "name"
|
@@ -268,7 +271,7 @@ class AlchemyTwoPointFive < ActiveRecord::Migration
|
|
268
271
|
t.string "login"
|
269
272
|
t.string "email"
|
270
273
|
t.string "gender"
|
271
|
-
t.string "
|
274
|
+
t.string "roles", :default => "registered"
|
272
275
|
t.string "language"
|
273
276
|
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
274
277
|
t.string "password_salt", :limit => 128, :default => "", :null => false
|
@@ -291,6 +294,26 @@ class AlchemyTwoPointFive < ActiveRecord::Migration
|
|
291
294
|
add_index "alchemy_users", ["email"], :name => "index_alchemy_users_on_email", :unique => true
|
292
295
|
add_index "alchemy_users", ["login"], :name => "index_alchemy_users_on_login", :unique => true
|
293
296
|
add_index "alchemy_users", ["reset_password_token"], :name => "index_alchemy_users_on_reset_password_token", :unique => true
|
297
|
+
add_index "alchemy_users", ["roles"], :name => "index_alchemy_users_on_roles"
|
298
|
+
|
299
|
+
create_table "events", :force => true do |t|
|
300
|
+
t.string "name"
|
301
|
+
t.string "hidden_name"
|
302
|
+
t.datetime "starts_at"
|
303
|
+
t.datetime "ends_at"
|
304
|
+
t.text "description"
|
305
|
+
t.decimal "entrance_fee", :precision => 6, :scale => 2
|
306
|
+
t.boolean "published"
|
307
|
+
t.integer "location_id"
|
308
|
+
t.datetime "created_at", :null => false
|
309
|
+
t.datetime "updated_at", :null => false
|
310
|
+
end
|
311
|
+
|
312
|
+
create_table "locations", :force => true do |t|
|
313
|
+
t.string "name"
|
314
|
+
t.datetime "created_at", :null => false
|
315
|
+
t.datetime "updated_at", :null => false
|
316
|
+
end
|
294
317
|
|
295
318
|
create_table "taggings", :force => true do |t|
|
296
319
|
t.integer "tag_id"
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended to check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(:version =>
|
14
|
+
ActiveRecord::Schema.define(:version => 20130827094554) do
|
15
15
|
|
16
16
|
create_table "alchemy_attachments", :force => true do |t|
|
17
17
|
t.string "name"
|
data/spec/fast_specs.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Include this file insted of spec_helper, if you don't need database and other slow stuff
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
ENV["FAST_SPECS"] = 'true'
|
4
|
+
|
5
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
6
|
+
require "rails/test_help"
|
7
|
+
require "rspec/rails"
|
8
|
+
|
9
|
+
Rails.logger.level = 4
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
+
config.run_all_when_everything_filtered = true
|
14
|
+
config.filter_run :focus
|
15
|
+
end
|
@@ -96,54 +96,73 @@ module Alchemy
|
|
96
96
|
|
97
97
|
end
|
98
98
|
|
99
|
-
describe '#
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
helper.session[:language_id] = 1
|
99
|
+
describe '#toolbar_button' do
|
100
|
+
context "with permission" do
|
101
|
+
before {
|
102
|
+
helper.stub(:permitted_to?).and_return(true)
|
103
|
+
}
|
104
|
+
|
105
|
+
it "renders a toolbar button" do
|
106
|
+
helper.toolbar_button(
|
107
|
+
url: admin_users_path
|
108
|
+
).should match /<div.+class="button_with_label/
|
109
|
+
end
|
111
110
|
end
|
112
111
|
|
113
|
-
context "
|
112
|
+
context "without permission" do
|
113
|
+
before {
|
114
|
+
helper.stub(:permitted_to?).and_return(false)
|
115
|
+
}
|
114
116
|
|
115
|
-
it "
|
116
|
-
helper.
|
117
|
+
it "returns empty string" do
|
118
|
+
helper.toolbar_button(
|
119
|
+
url: admin_users_path
|
120
|
+
).should be_empty
|
117
121
|
end
|
122
|
+
end
|
118
123
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
124
|
+
context "with disabled permission check" do
|
125
|
+
before {
|
126
|
+
helper.stub(:permitted_to?).and_return(false)
|
127
|
+
}
|
124
128
|
|
129
|
+
it "returns the button" do
|
130
|
+
helper.toolbar_button(
|
131
|
+
url: admin_users_path,
|
132
|
+
skip_permission_check: true
|
133
|
+
).should match /<div.+class="button_with_label/
|
134
|
+
end
|
125
135
|
end
|
126
136
|
|
127
|
-
context "with
|
137
|
+
context "with empty permission option" do
|
138
|
+
before {
|
139
|
+
helper.stub(:permitted_to?).and_return(true)
|
140
|
+
}
|
128
141
|
|
129
|
-
|
130
|
-
|
131
|
-
|
142
|
+
it "returns reads the permission from url" do
|
143
|
+
helper.should_receive(:permission_array_from_url)
|
144
|
+
helper.toolbar_button(
|
145
|
+
url: admin_users_path,
|
146
|
+
if_permitted_to: ''
|
147
|
+
).should_not be_empty
|
132
148
|
end
|
149
|
+
end
|
133
150
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
151
|
+
context "with overlay option set to false" do
|
152
|
+
before {
|
153
|
+
helper.stub(:permitted_to?).and_return(true)
|
154
|
+
helper.should_receive(:permission_array_from_url)
|
155
|
+
}
|
139
156
|
|
140
|
-
it "
|
141
|
-
|
142
|
-
|
157
|
+
it "renders a normal link" do
|
158
|
+
button = helper.toolbar_button(
|
159
|
+
url: admin_users_path,
|
160
|
+
overlay: false
|
161
|
+
)
|
162
|
+
button.should match /<a.+href="#{admin_users_path}"/
|
163
|
+
button.should_not match /data-alchemy-overlay/
|
143
164
|
end
|
144
|
-
|
145
165
|
end
|
146
|
-
|
147
166
|
end
|
148
167
|
|
149
168
|
end
|
@@ -1,27 +1,35 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Alchemy::Admin::ContentsHelper do
|
4
|
+
let(:element) { FactoryGirl.create(:element, name: 'article', create_contents_after_create: true) }
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+
it "should render a dom id" do
|
7
|
+
helper.content_dom_id(element.content_by_type('EssenceText')).should match(/essence_text_\d{1,}/)
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
describe '#contents_form_field_ids_string' do
|
11
|
+
let(:content_1) { double('Alchemy::Content', form_field_id: 'contents_content_1_body') }
|
12
|
+
let(:content_2) { double('Alchemy::Content', form_field_id: 'contents_content_2_body') }
|
13
|
+
|
14
|
+
it "renders a jquery selector string of form field ids from given contents" do
|
15
|
+
expect(
|
16
|
+
helper.contents_form_field_ids_string([content_1, content_2])
|
17
|
+
).to eq('#contents_content_1_body, #contents_content_2_body')
|
18
|
+
end
|
11
19
|
end
|
12
20
|
|
13
21
|
it "should render the content name" do
|
14
|
-
helper.render_content_name(
|
22
|
+
helper.render_content_name(element.content_by_type('EssenceText')).should == "Intro"
|
15
23
|
end
|
16
24
|
|
17
25
|
it "should render a link to add new content to element" do
|
18
26
|
helper.stub!(:render_icon).and_return('')
|
19
|
-
helper.render_new_content_link(
|
27
|
+
helper.render_new_content_link(element).should match(/a.+href.*admin\/elements\/#{element.id}\/contents\/new/m)
|
20
28
|
end
|
21
29
|
|
22
30
|
it "should render a link to create a content in element" do
|
23
31
|
helper.stub!(:render_icon).and_return('')
|
24
|
-
helper.render_create_content_link(
|
32
|
+
helper.render_create_content_link(element, 'headline').should match(/a.+href.*admin\/contents.+class.+new_content_link.*data-method.+post/)
|
25
33
|
end
|
26
34
|
|
27
35
|
end
|
@@ -1,56 +1,101 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
module Alchemy
|
4
4
|
|
5
|
-
|
5
|
+
include BaseHelper
|
6
6
|
|
7
|
-
|
7
|
+
describe Admin::ElementsHelper do
|
8
8
|
|
9
|
-
|
10
|
-
@page = FactoryGirl.create(:public_page)
|
11
|
-
@element = FactoryGirl.create(:element, :page => @page, :create_contents_after_create => true)
|
12
|
-
end
|
9
|
+
context "partial rendering" do
|
13
10
|
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
before do
|
12
|
+
@page = FactoryGirl.create(:public_page)
|
13
|
+
@element = FactoryGirl.create(:element, :page => @page, :create_contents_after_create => true)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should render an element editor partial" do
|
17
|
+
helper.render_editor(@element).should match(/class="essence_text content_editor".+id="essence_text_\d{1,}"/)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should render a picture gallery editor partial" do
|
21
|
+
helper.render_picture_gallery_editor(@element).should match(/class=".+picture_gallery_editor"/)
|
22
|
+
end
|
17
23
|
|
18
|
-
it "should render a picture gallery editor partial" do
|
19
|
-
helper.render_picture_gallery_editor(@element).should match(/class=".+picture_gallery_editor"/)
|
20
24
|
end
|
21
25
|
|
22
|
-
|
26
|
+
describe "#grouped_elements_for_select" do
|
23
27
|
|
24
|
-
|
28
|
+
before do
|
29
|
+
@page = FactoryGirl.create(:public_page)
|
30
|
+
end
|
25
31
|
|
26
|
-
|
27
|
-
|
28
|
-
|
32
|
+
before(:each) do
|
33
|
+
@page.stub!(:layout_description).and_return({'name' => "foo", 'cells' => ["foo_cell"]})
|
34
|
+
cell_descriptions = [{'name' => "foo_cell", 'elements' => ["1", "2"]}]
|
35
|
+
@elements = [
|
36
|
+
mock_model('Element', name: '1', display_name: '1'),
|
37
|
+
mock_model('Element', name: '2', display_name: '2')
|
38
|
+
]
|
39
|
+
Alchemy::Cell.stub!(:definitions).and_return(cell_descriptions)
|
40
|
+
end
|
29
41
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
@elements = [{'name' => '1'}, {'name' => '2'}]
|
34
|
-
Alchemy::Cell.stub!(:definitions).and_return(cell_descriptions)
|
35
|
-
end
|
42
|
+
it "should return string of elements grouped by cell for select_tag helper" do
|
43
|
+
helper.grouped_elements_for_select(@elements).should == helper.grouped_options_for_select({"Foo cell" => [["1", "1#foo_cell"], ["2", "2#foo_cell"]]})
|
44
|
+
end
|
36
45
|
|
37
|
-
|
38
|
-
|
39
|
-
|
46
|
+
context "with empty elements array" do
|
47
|
+
it "should return an empty string" do
|
48
|
+
helper.grouped_elements_for_select([]).should == ""
|
49
|
+
end
|
50
|
+
end
|
40
51
|
|
41
|
-
|
42
|
-
|
43
|
-
|
52
|
+
context "with empty cell definitions" do
|
53
|
+
it "should return an empty string" do
|
54
|
+
@page.stub!(:layout_description).and_return({'name' => "foo"})
|
55
|
+
helper.grouped_elements_for_select(@elements).should == ""
|
56
|
+
end
|
44
57
|
end
|
58
|
+
|
45
59
|
end
|
46
60
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
61
|
+
describe "#elements_for_select" do
|
62
|
+
|
63
|
+
context "passing element instances" do
|
64
|
+
let(:element_objects) do
|
65
|
+
[
|
66
|
+
mock_model('Element', name: 'element_1', display_name: 'Element 1'),
|
67
|
+
mock_model('Element', name: 'element_2', display_name: 'Element 2')
|
68
|
+
]
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should return a String with html option tags" do
|
72
|
+
helper.should_receive(:options_for_select)
|
73
|
+
helper.elements_for_select(element_objects)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context "passing a hash with element descriptions" do
|
78
|
+
let(:element_descriptions) do
|
79
|
+
[{
|
80
|
+
'name' => 'headline',
|
81
|
+
'contents' => []
|
82
|
+
}]
|
83
|
+
end
|
84
|
+
|
85
|
+
subject { helper.elements_for_select(element_descriptions) }
|
86
|
+
|
87
|
+
it "should return a String with html option tags" do
|
88
|
+
helper.should_receive(:options_for_select)
|
89
|
+
subject
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should render the elements display name" do
|
93
|
+
Element.should_receive(:display_name_for).with('headline')
|
94
|
+
subject
|
95
|
+
end
|
51
96
|
end
|
97
|
+
|
52
98
|
end
|
53
99
|
|
54
100
|
end
|
55
|
-
|
56
101
|
end
|