Module: Alchemy

Defined in:
app/models/alchemy/tag.rb,
app/models/alchemy.rb,
app/models/alchemy/cell.rb,
app/models/alchemy/page.rb,
app/models/alchemy/site.rb,
app/models/alchemy/content.rb,
app/models/alchemy/element.rb,
app/models/alchemy/message.rb,
app/models/alchemy/picture.rb,
app/models/alchemy/language.rb,
app/mailers/alchemy/messages.rb,
app/models/alchemy/tree_node.rb,
app/models/alchemy/attachment.rb,
app/helpers/alchemy/url_helper.rb,
app/models/alchemy/folded_page.rb,
app/models/alchemy/site/layout.rb,
app/helpers/alchemy/base_helper.rb,
app/models/alchemy/essence_date.rb,
app/models/alchemy/essence_file.rb,
app/models/alchemy/essence_html.rb,
app/models/alchemy/essence_link.rb,
app/models/alchemy/essence_text.rb,
app/models/alchemy/translations.rb,
app/helpers/alchemy/pages_helper.rb,
app/models/alchemy/essence_select.rb,
app/models/alchemy/content/factory.rb,
app/models/alchemy/element_to_page.rb,
app/models/alchemy/essence_boolean.rb,
app/models/alchemy/essence_picture.rb,
app/models/alchemy/page/page_cells.rb,
app/models/alchemy/page/page_users.rb,
app/helpers/alchemy/elements_helper.rb,
app/helpers/alchemy/essences_helper.rb,
app/models/alchemy/essence_richtext.rb,
app/models/alchemy/page/page_naming.rb,
app/models/alchemy/page/page_scopes.rb,
app/models/alchemy/picture/sweeping.rb,
app/models/alchemy/page/page_natures.rb,
app/helpers/alchemy/admin/base_helper.rb,
app/helpers/alchemy/admin/form_helper.rb,
app/helpers/alchemy/admin/tags_helper.rb,
app/models/alchemy/element/presenters.rb,
app/models/alchemy/page/page_elements.rb,
app/helpers/alchemy/admin/pages_helper.rb,
app/models/alchemy/element/definitions.rb,
app/controllers/alchemy/base_controller.rb,
app/serializers/alchemy/cell_serializer.rb,
app/serializers/alchemy/page_serializer.rb,
app/controllers/alchemy/pages_controller.rb,
app/helpers/alchemy/admin/contents_helper.rb,
app/helpers/alchemy/admin/elements_helper.rb,
app/helpers/alchemy/admin/essences_helper.rb,
app/helpers/alchemy/admin/pictures_helper.rb,
app/helpers/alchemy/elements_block_helper.rb,
app/models/alchemy/picture/transformations.rb,
app/serializers/alchemy/content_serializer.rb,
app/serializers/alchemy/element_serializer.rb,
app/serializers/alchemy/picture_serializer.rb,
app/controllers/alchemy/api/base_controller.rb,
app/controllers/alchemy/elements_controller.rb,
app/controllers/alchemy/messages_controller.rb,
app/controllers/alchemy/pictures_controller.rb,
app/helpers/alchemy/admin/navigation_helper.rb,
app/controllers/alchemy/api/pages_controller.rb,
app/helpers/alchemy/admin/attachments_helper.rb,
app/controllers/alchemy/admin/base_controller.rb,
app/controllers/alchemy/admin/tags_controller.rb,
app/serializers/alchemy/attachment_serializer.rb,
app/controllers/alchemy/admin/pages_controller.rb,
app/controllers/alchemy/admin/sites_controller.rb,
app/controllers/alchemy/admin/trash_controller.rb,
app/controllers/alchemy/attachments_controller.rb,
app/controllers/alchemy/api/contents_controller.rb,
app/controllers/alchemy/api/elements_controller.rb,
app/serializers/alchemy/essence_date_serializer.rb,
app/serializers/alchemy/essence_file_serializer.rb,
app/serializers/alchemy/essence_html_serializer.rb,
app/serializers/alchemy/essence_link_serializer.rb,
app/serializers/alchemy/essence_text_serializer.rb,
app/controllers/alchemy/admin/contents_controller.rb,
app/controllers/alchemy/admin/elements_controller.rb,
app/controllers/alchemy/admin/pictures_controller.rb,
app/serializers/alchemy/essence_select_serializer.rb,
app/serializers/alchemy/legacy_element_serializer.rb,
app/controllers/alchemy/admin/clipboard_controller.rb,
app/controllers/alchemy/admin/dashboard_controller.rb,
app/controllers/alchemy/admin/languages_controller.rb,
app/controllers/alchemy/admin/resources_controller.rb,
app/models/alchemy/translations/translation_pusher.rb,
app/serializers/alchemy/essence_boolean_serializer.rb,
app/serializers/alchemy/essence_picture_serializer.rb,
app/serializers/alchemy/essence_richtext_serializer.rb,
app/controllers/alchemy/admin/attachments_controller.rb,
app/controllers/alchemy/admin/layoutpages_controller.rb,
app/models/alchemy/translations/essence_body_updater.rb,
app/controllers/alchemy/admin/essence_files_controller.rb,
app/controllers/alchemy/admin/essence_pictures_controller.rb,
app/controllers/alchemy/admin/legacy_page_urls_controller.rb,
lib/alchemy_cms.rb,
lib/alchemy/i18n.rb,
lib/alchemy/hints.rb,
lib/alchemy/shell.rb,
lib/alchemy/config.rb,
lib/alchemy/engine.rb,
lib/alchemy/errors.rb,
lib/alchemy/locale.rb,
lib/alchemy/logger.rb,
lib/alchemy/seeder.rb,
lib/alchemy/essence.rb,
lib/alchemy/modules.rb,
lib/alchemy/tinymce.rb,
lib/alchemy/version.rb,
lib/alchemy/resource.rb,
lib/alchemy/touching.rb,
lib/alchemy/upgrader.rb,
lib/alchemy/filetypes.rb,
lib/alchemy/mount_point.rb,
lib/alchemy/page_layout.rb,
lib/alchemy/permissions.rb,
lib/alchemy/forms/builder.rb,
lib/alchemy/tasks/helpers.rb,
lib/alchemy/auth_accessors.rb,
lib/alchemy/on_page_layout.rb,
lib/alchemy/ssl_protection.rb,
lib/alchemy/name_conversions.rb,
lib/alchemy/resources_helper.rb,
lib/alchemy/controller_actions.rb,
lib/alchemy/picture_attributes.rb,
lib/alchemy/routing_constraints.rb,
lib/alchemy/configuration_methods.rb,
lib/rails/generators/alchemy/base.rb,
lib/alchemy/upgrader/three_point_one.rb,
lib/alchemy/upgrader/three_point_two.rb,
lib/alchemy/upgrader/three_point_zero.rb,
lib/alchemy/middleware/rescue_old_cookies.rb,
lib/alchemy/cache_digests/template_tracker.rb,
lib/alchemy/test_support/controller_requests.rb,
lib/alchemy/test_support/integration_helpers.rb,
lib/rails/generators/alchemy/views/views_generator.rb,
lib/rails/generators/alchemy/module/module_generator.rb,
lib/rails/generators/alchemy/essence/essence_generator.rb,
lib/rails/generators/alchemy/install/install_generator.rb,
lib/rails/generators/alchemy/elements/elements_generator.rb,
lib/rails/generators/alchemy/page_layouts/page_layouts_generator.rb,
lib/rails/generators/alchemy/site_layouts/site_layouts_generator.rb

Overview

Use this module to easily test Alchemy actions within Alchemy components or inside your application to test routes for the mounted Alchemy engine.

Inside your spec_helper.rb, include this module inside the RSpec.configure block by doing this:

require 'alchemy/test_support/controller_requests'
RSpec.configure do |c|
  c.include Alchemy::TestSupport::ControllerRequests, type: :controller
end

Then, in your controller tests, you can access alchemy routes like this:

require 'spec_helper'

describe Alchemy::Admin::PagesController do
  it "can see all the pages" do
    alchemy_get :index
  end
end

Use alchemy_get, alchemy_post, alchemy_put or alchemy_delete to make requests to the Alchemy engine, and use regular get, post, put or delete to make requests to your application.

Note: Based on Spree::TestingSupport::ControllerRequests. Thanks <3

Defined Under Namespace

Modules: Admin, BaseHelper, CacheDigests, ConfigurationMethods, ControllerActions, ElementsBlockHelper, ElementsHelper, Essence, EssencesHelper, Filetypes, Forms, Generators, Hints, I18n, Locale, Logger, Middleware, Modules, NameConversions, OnPageLayout, PagesHelper, ResourcesHelper, SSLProtection, Shell, Tasks, TestSupport, Tinymce, Touching, Translations, UrlHelper Classes: Attachment, AttachmentSerializer, AttachmentsController, BaseController, Cell, CellDefinitionError, CellSerializer, Config, Content, ContentDefinitionError, ContentSerializer, DefaultLanguageNotDeletable, DefaultLanguageNotFoundError, Element, ElementDefinitionError, ElementSerializer, ElementToPage, ElementsController, Engine, EssenceBoolean, EssenceBooleanSerializer, EssenceDate, EssenceDateSerializer, EssenceFile, EssenceFileSerializer, EssenceHtml, EssenceHtmlSerializer, EssenceLink, EssenceLinkSerializer, EssenceMissingError, EssencePicture, EssencePictureSerializer, EssenceRichtext, EssenceRichtextSerializer, EssenceSelect, EssenceSelectSerializer, EssenceText, EssenceTextSerializer, FoldedPage, Language, LegacyElementSerializer, LegacyPageUrl, Message, Messages, MessagesController, MissingActiveRecordAssociation, MissingImageFileError, MountPoint, NoCurrentUserFoundError, NotMountedError, Page, PageLayout, PageSerializer, PagesController, Permissions, Picture, PictureAttributes, PictureInUseError, PictureSerializer, PicturesController, Resource, RoutingConstraints, Seeder, Site, Tag, TinymceError, TreeNode, UpdateServiceUnavailable, Upgrader

Constant Summary collapse

VERSION =
"3.2.0"
@@user_class_name =

Defaults

'User'
@@current_user_method =
'current_user'
@@signup_path =
'/signup'
@@login_path =
'/login'
@@logout_path =
'/logout'
@@admin_path =
'/admin'
@@admin_constraints =
{}

Class Method Summary collapse

Class Method Details

.register_ability(klass) ⇒ Object

Register a CanCan Ability class



94
95
96
97
# File 'lib/alchemy/auth_accessors.rb', line 94

def self.register_ability(klass)
  @abilities ||= []
  @abilities << klass
end

.registered_abilitiesObject

All CanCan Ability classes registered to Alchemy



101
102
103
# File 'lib/alchemy/auth_accessors.rb', line 101

def self.registered_abilities
  @abilities ||= []
end

.table_name_prefixObject



3
4
5
# File 'app/models/alchemy.rb', line 3

def self.table_name_prefix
  'alchemy_'
end

.user_classObject

Returns the user class

Set your App’s user class to Alchemy.user_class_name in an initializer.

Defaults to User

Example

# config/initializers/alchemy.rb
Alchemy.user_class_name = 'Admin'


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/alchemy/auth_accessors.rb', line 68

def self.user_class
  @@user_class ||= begin
    if @@user_class_name.is_a?(String)
      @@user_class_name.constantize
    else
      raise TypeError, 'Alchemy.user_class_name must be a String, not a Class.'
    end
  end
rescue NameError => e
  if e.message.match(/#{Regexp.escape(@@user_class_name)}/)
    abort <<-MSG

AlchemyCMS cannot find any user class!

Please add a user class and tell Alchemy about it or, if you don't want
to create your own class, add the `alchemy-devise` gem to your Gemfile.

gem 'alchemy-devise', '~> 2.1.0'
MSG
  else
    raise e
  end
end

.versionObject



4
5
6
# File 'lib/alchemy/version.rb', line 4

def self.version
  VERSION
end