diff --git a/app/assets/javascripts/locomotive/application.js.coffee b/app/assets/javascripts/locomotive/application.js.coffee index ea35ecea..6590be79 100644 --- a/app/assets/javascripts/locomotive/application.js.coffee +++ b/app/assets/javascripts/locomotive/application.js.coffee @@ -4,9 +4,9 @@ #= require_tree ./views window.Locomotive = - mounted_on: '/locomotive' # default path + mounted_on: window.Locomotive.mounted_on Models: {} Collections: {} Views: {} -window.Locomotive.Views.Memberships = {} \ No newline at end of file +window.Locomotive.Views.Memberships = {} diff --git a/app/views/locomotive/shared/_head.html.haml b/app/views/locomotive/shared/_head.html.haml index 89f25515..fb89e923 100644 --- a/app/views/locomotive/shared/_head.html.haml +++ b/app/views/locomotive/shared/_head.html.haml @@ -7,6 +7,10 @@ %meta{ :name => 'key-param', :content => Rails.application.config.session_options[:key] } %meta{ :name => 'key-token', :content => cookies[key] } +%script{ :type => 'text/javascript' } + :plain + window.Locomotive = { mounted_on: '#{Locomotive.mounted_on}' }; + = stylesheet_link_tag 'locomotive', :media => 'screen' = javascript_include_tag 'locomotive' @@ -15,7 +19,6 @@ window.locale = '#{I18n.locale}'; window.content_locale = '#{::Mongoid::Fields::I18n.locale}'; - Locomotive.mounted_on = '#{Locomotive.mounted_on}'; Locomotive.current_site = new Locomotive.Models.Site(#{current_site.to_json}); Locomotive.current_account = new Locomotive.Models.Account(#{current_locomotive_account.to_json}); @@ -32,4 +35,4 @@ = yield :head -= render 'locomotive/shared/main_app_head' \ No newline at end of file += render 'locomotive/shared/main_app_head' diff --git a/features/backoffice/mounting.feature b/features/backoffice/mounting.feature new file mode 100644 index 00000000..0f6af821 --- /dev/null +++ b/features/backoffice/mounting.feature @@ -0,0 +1,13 @@ +Feature: Mounting Locomotive CMS + As an administrator + In order to gain some flexibility when mounting locomotive CMS + I want to be able to mount locomotove on any given path + + Background: + Given I have a site set up + + @javascript + Scenario: Accessing the backend when mounted on a custom path + Given the engine is mounted on a non standard path + And I am an authenticated "admin" + Then I should be able to access the backend diff --git a/features/step_definitions/backoffice/mounting_steps.rb b/features/step_definitions/backoffice/mounting_steps.rb new file mode 100644 index 00000000..b142a72c --- /dev/null +++ b/features/step_definitions/backoffice/mounting_steps.rb @@ -0,0 +1,19 @@ +Given /^the engine is mounted on a non standard path$/ do + Rails.application.routes.draw do + mount Locomotive::Engine => '/my-custom-path', :as => 'locomotive' + end +end + +Then /^I should be able to access the backend$/ do + # Ensure we can access the backend + visit '/my-custom-path' + page.should have_content 'LocomotiveCMS' + + # Ensure we can update the homepage content + click_link 'Home page' + click_button 'Save' + page.should have_content 'Page was successfully updated' + + # Reset the routes back to normal once we are done + Rails.application.reload_routes! +end