locomotivecms 3.0.0.pre.beta.1 → 3.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -3
  3. data/app/api/locomotive/api.rb +1 -0
  4. data/app/api/locomotive/api/entities/page_entity.rb +1 -1
  5. data/app/api/locomotive/api/entities/site_entity.rb +9 -1
  6. data/app/api/locomotive/api/exception_rescuers.rb +3 -5
  7. data/app/api/locomotive/api/forms/page_form.rb +1 -1
  8. data/app/api/locomotive/api/forms/site_form.rb +1 -2
  9. data/app/api/locomotive/api/helpers/authentication_helper.rb +6 -1
  10. data/app/api/locomotive/api/helpers/locales_helper.rb +15 -0
  11. data/app/api/locomotive/api/helpers/params_helper.rb +13 -0
  12. data/app/api/locomotive/api/middlewares/locale_middleware.rb +6 -1
  13. data/app/api/locomotive/api/resources/content_entry_resource.rb +2 -0
  14. data/app/api/locomotive/api/resources/content_type_resource.rb +2 -2
  15. data/app/api/locomotive/api/resources/current_site_resource.rb +2 -1
  16. data/app/api/locomotive/api/resources/membership_resource.rb +0 -4
  17. data/app/api/locomotive/api/resources/page_resource.rb +6 -1
  18. data/app/api/locomotive/api/resources/site_resource.rb +4 -2
  19. data/app/assets/javascripts/locomotive.js +1 -0
  20. data/app/assets/javascripts/locomotive/utils/nprogress.js.coffee +3 -1
  21. data/app/assets/javascripts/locomotive/views/editable_elements/index_view.js.coffee +10 -3
  22. data/app/assets/javascripts/locomotive/views/inputs/markdown_view.js.coffee +82 -0
  23. data/app/assets/javascripts/locomotive/views/inputs/rte/file_view.js.coffee +1 -1
  24. data/app/assets/javascripts/locomotive/views/inputs/rte/link_view.js.coffee +1 -1
  25. data/app/assets/javascripts/locomotive/views/inputs/rte_view.js.coffee.erb +1 -1
  26. data/app/assets/javascripts/locomotive/views/inputs/text_view.js.coffee +4 -1
  27. data/app/assets/javascripts/locomotive/views/pages/list_view.js.coffee +3 -0
  28. data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +22 -1
  29. data/app/assets/javascripts/locomotive/views/shared/header_view.js.coffee +2 -2
  30. data/app/assets/stylesheets/locomotive/application.scss +2 -0
  31. data/app/assets/stylesheets/locomotive/base/_form.scss +2 -0
  32. data/app/assets/stylesheets/locomotive/base/form/_api_key.scss +0 -1
  33. data/app/assets/stylesheets/locomotive/base/form/_array_input.scss +2 -0
  34. data/app/assets/stylesheets/locomotive/base/form/_base.scss +13 -2
  35. data/app/assets/stylesheets/locomotive/base/form/_color_input.scss +12 -0
  36. data/app/assets/stylesheets/locomotive/base/form/_markdown.scss +292 -0
  37. data/app/assets/stylesheets/locomotive/base/form/_popover.scss +22 -0
  38. data/app/assets/stylesheets/locomotive/base/form/_rte.scss +2 -1
  39. data/app/assets/stylesheets/locomotive/components/_activity_feed.scss +1 -0
  40. data/app/assets/stylesheets/locomotive/components/_dashboard.scss +29 -0
  41. data/app/assets/stylesheets/locomotive/components/_live_editing.scss +13 -1
  42. data/app/assets/stylesheets/locomotive/components/_main.scss +1 -1
  43. data/app/assets/stylesheets/locomotive/components/_transitions.scss +24 -3
  44. data/app/assets/stylesheets/locomotive/components/sidebar/_base.scss +1 -0
  45. data/app/assets/stylesheets/locomotive/globals/_bootstrap.scss +2 -2
  46. data/app/assets/stylesheets/locomotive/globals/_variables.scss +4 -3
  47. data/app/assets/stylesheets/locomotive/layouts/_live_editing.scss +4 -0
  48. data/app/controllers/locomotive/concerns/locale_helpers_controller.rb +1 -0
  49. data/app/controllers/locomotive/content_entries_controller.rb +10 -2
  50. data/app/controllers/locomotive/pages_controller.rb +2 -1
  51. data/app/controllers/locomotive/passwords_controller.rb +17 -1
  52. data/app/helpers/locomotive/base_helper.rb +19 -0
  53. data/app/helpers/locomotive/content_types_helper.rb +2 -1
  54. data/app/helpers/locomotive/custom_fields_helper.rb +14 -1
  55. data/app/helpers/locomotive/dashboard_helper.rb +12 -0
  56. data/app/helpers/locomotive/editable_elements_helper.rb +9 -4
  57. data/app/helpers/locomotive/pages_helper.rb +1 -14
  58. data/app/helpers/locomotive/shared/pages_helper.rb +17 -0
  59. data/app/helpers/locomotive/translations_helper.rb +0 -14
  60. data/app/inputs/locomotive/color_input.rb +18 -0
  61. data/app/inputs/locomotive/markdown_input.rb +19 -0
  62. data/app/models/locomotive/account.rb +2 -1
  63. data/app/models/locomotive/concerns/content_entry/file_size.rb +27 -0
  64. data/app/models/locomotive/concerns/content_type/group_by.rb +3 -1
  65. data/app/models/locomotive/concerns/page/layout.rb +63 -19
  66. data/app/models/locomotive/concerns/shared/site_scope.rb +37 -0
  67. data/app/models/locomotive/concerns/site/cache.rb +32 -0
  68. data/app/models/locomotive/concerns/theme_asset/plain_text.rb +85 -0
  69. data/app/models/locomotive/content_entry.rb +7 -7
  70. data/app/models/locomotive/content_type.rb +12 -6
  71. data/app/models/locomotive/page.rb +12 -14
  72. data/app/models/locomotive/site.rb +9 -3
  73. data/app/models/locomotive/snippet.rb +6 -4
  74. data/app/models/locomotive/theme_asset.rb +8 -73
  75. data/app/models/locomotive/translation.rb +6 -5
  76. data/app/policies/locomotive/site_policy.rb +2 -2
  77. data/app/services/locomotive/content_entry_service.rb +7 -6
  78. data/app/services/locomotive/site_service.rb +1 -0
  79. data/app/views/locomotive/content_entries/_entry.html.slim +1 -0
  80. data/app/views/locomotive/content_entries/edit.html.slim +1 -1
  81. data/app/views/locomotive/content_entries/new.html.slim +1 -1
  82. data/app/views/locomotive/current_site/_membership.html.slim +1 -0
  83. data/app/views/locomotive/current_site/edit.html.slim +1 -1
  84. data/app/views/locomotive/current_site/form/_access_points.html.slim +1 -1
  85. data/app/views/locomotive/current_site/form/_advanced.html.slim +2 -0
  86. data/app/views/locomotive/dashboard/_activity.html.slim +26 -0
  87. data/app/views/locomotive/dashboard/_url.html.slim +9 -0
  88. data/app/views/locomotive/dashboard/show.html.slim +3 -21
  89. data/app/views/locomotive/devise_mailer/reset_password_instructions.html.slim +1 -1
  90. data/app/views/locomotive/editable_elements/_edit.html.slim +8 -1
  91. data/app/views/locomotive/editable_elements/_form.html.slim +1 -1
  92. data/app/views/locomotive/editable_elements/index_without_preview.html.slim +24 -17
  93. data/app/views/locomotive/layouts/application.html.slim +6 -4
  94. data/app/views/locomotive/layouts/live_editing.html.slim +9 -0
  95. data/app/views/locomotive/layouts/not_logged_in.html.slim +1 -1
  96. data/app/views/locomotive/layouts/without_site.html.slim +2 -0
  97. data/app/views/locomotive/memberships/edit.html.slim +1 -1
  98. data/app/views/locomotive/memberships/new.html.slim +1 -1
  99. data/app/views/locomotive/my_account/edit.html.slim +7 -5
  100. data/app/views/locomotive/pages/_header.html.slim +7 -0
  101. data/app/views/locomotive/pages/edit.html.slim +2 -4
  102. data/app/views/locomotive/pages/form/_main.html.slim +4 -1
  103. data/app/views/locomotive/pages/form/_tabs.html.slim +4 -3
  104. data/app/views/locomotive/public_submission_accounts/_account.html.slim +1 -1
  105. data/app/views/locomotive/public_submission_accounts/edit.html.slim +1 -1
  106. data/app/views/locomotive/shared/_header.html.slim +25 -22
  107. data/app/views/locomotive/shared/_locale_picker_link.html.slim +3 -0
  108. data/app/views/locomotive/shared/_main_app_header.html.slim +1 -1
  109. data/app/views/locomotive/shared/_sidebar.html.slim +15 -11
  110. data/app/views/locomotive/shared/rte/_markdown_toolbar.html.slim +42 -0
  111. data/config/locales/admin_ui.en.yml +9 -4
  112. data/config/locales/default.en.yml +4 -0
  113. data/config/locales/devise.en.yml +1 -0
  114. data/config/locales/simple_form.en.yml +6 -2
  115. data/lib/locomotive/action_controller/responder.rb +5 -0
  116. data/lib/locomotive/engine.rb +5 -0
  117. data/lib/locomotive/middlewares/site.rb +39 -21
  118. data/lib/locomotive/simple_form.rb +3 -31
  119. data/lib/locomotive/steam/middlewares/cache.rb +62 -0
  120. data/lib/locomotive/steam/middlewares/page_editing.rb +9 -3
  121. data/lib/locomotive/steam/services/api_entry_submission_service.rb +6 -3
  122. data/lib/locomotive/steam/services/liquid_parser_with_cache_service.rb +74 -0
  123. data/lib/locomotive/steam_adaptor.rb +7 -1
  124. data/lib/locomotive/version.rb +1 -1
  125. data/lib/tasks/development.rake +4 -0
  126. data/lib/tasks/locomotive.rake +14 -0
  127. data/spec/lib/locomotive/steam/services/api_entry_submission_service_spec.rb +10 -1
  128. data/spec/lib/locomotive/steam/services/liquid_parser_with_cache_service_spec.rb +53 -0
  129. data/spec/models/locomotive/concerns/content_entry/file_size_spec.rb +40 -0
  130. data/spec/models/locomotive/concerns/page/layout_spec.rb +122 -17
  131. data/spec/models/locomotive/concerns/site/cache_spec.rb +60 -0
  132. data/spec/models/locomotive/content_entry_spec.rb +7 -0
  133. data/spec/models/locomotive/content_type_spec.rb +18 -11
  134. data/spec/models/locomotive/page_spec.rb +32 -8
  135. data/spec/models/locomotive/snippet_spec.rb +13 -4
  136. data/spec/models/locomotive/theme_asset_spec.rb +10 -3
  137. data/spec/models/locomotive/translation_spec.rb +28 -0
  138. data/spec/requests/locomotive/steam/cache_spec.rb +83 -0
  139. data/spec/requests/site_spec.rb +24 -0
  140. data/spec/support/capybara.rb +5 -13
  141. data/spec/support/factories.rb +9 -0
  142. data/spec/support/features/session_helpers.rb +19 -3
  143. data/spec/support/features/site_helpers.rb +27 -0
  144. data/spec/support/shared_examples/site_scope_examples.rb +27 -0
  145. data/vendor/assets/images/locomotive/bootstrap-colorpicker/alpha-horizontal.png +0 -0
  146. data/vendor/assets/images/locomotive/bootstrap-colorpicker/alpha.png +0 -0
  147. data/vendor/assets/images/locomotive/bootstrap-colorpicker/hue-horizontal.png +0 -0
  148. data/vendor/assets/images/locomotive/bootstrap-colorpicker/hue.png +0 -0
  149. data/vendor/assets/images/locomotive/bootstrap-colorpicker/saturation.png +0 -0
  150. data/vendor/assets/javascripts/locomotive/bootstrap-colorpicker.js +1 -0
  151. data/vendor/assets/javascripts/locomotive/datepicker_i18n.js.erb +6 -6
  152. data/vendor/assets/javascripts/locomotive/kramed.min.js +11 -0
  153. data/vendor/assets/stylesheets/locomotive/bootstrap-colorpicker.scss +9 -0
  154. metadata +59 -44
  155. data/app/controllers/locomotive/api/accounts_controller.rb +0 -60
  156. data/app/controllers/locomotive/api/base_controller.rb +0 -35
  157. data/app/controllers/locomotive/api/content_assets_controller.rb +0 -51
  158. data/app/controllers/locomotive/api/content_entries_controller.rb +0 -71
  159. data/app/controllers/locomotive/api/content_types_controller.rb +0 -52
  160. data/app/controllers/locomotive/api/current_site_controller.rb +0 -34
  161. data/app/controllers/locomotive/api/memberships_controller.rb +0 -52
  162. data/app/controllers/locomotive/api/my_account_controller.rb +0 -46
  163. data/app/controllers/locomotive/api/pages_controller.rb +0 -53
  164. data/app/controllers/locomotive/api/sites_controller.rb +0 -58
  165. data/app/controllers/locomotive/api/snippets_controller.rb +0 -52
  166. data/app/controllers/locomotive/api/theme_assets_controller.rb +0 -51
  167. data/app/controllers/locomotive/api/tokens_controller.rb +0 -36
  168. data/app/controllers/locomotive/api/translations_controller.rb +0 -51
  169. data/app/controllers/locomotive/api/version_controller.rb +0 -11
  170. data/spec/models/locomotive/editable_control_spec.rb +0 -79
  171. data/spec/models/locomotive/editable_file_spec.rb +0 -94
  172. data/spec/models/locomotive/editable_text_spec.rb +0 -219
  173. data/vendor/assets/images/select2-spinner.gif +0 -0
  174. data/vendor/assets/images/select2.png +0 -0
  175. data/vendor/assets/images/select2x2.png +0 -0
@@ -1,58 +0,0 @@
1
- # module Locomotive
2
- # module Api
3
- # class SitesController < Api::BaseController
4
-
5
- # account_required
6
-
7
- # before_filter :load_site, only: [:show, :update, :destroy]
8
- # before_filter :load_sites, only: [:index]
9
-
10
- # def index
11
- # authorize Locomotive::Site
12
- # respond_with @sites
13
- # end
14
-
15
- # def show
16
- # authorize @site
17
- # respond_with @site
18
- # end
19
-
20
- # def create
21
- # authorize Locomotive::Site
22
- # @site = Site.from_presenter(params[:site])
23
- # @site.memberships.build account: self.current_locomotive_account, role: 'admin'
24
- # @site.save
25
- # respond_with @site, location: -> { main_app.locomotive_api_site_url(@site) }
26
- # end
27
-
28
- # def update
29
- # authorize @site
30
- # @site.from_presenter(params[:site]).save
31
- # respond_with @site, location: main_app.locomotive_api_site_url(@site)
32
- # end
33
-
34
- # def destroy
35
- # authorize @site
36
- # @site.destroy
37
- # respond_with @site, location: main_app.locomotive_api_sites_url
38
- # end
39
-
40
- # private
41
-
42
- # def load_site
43
- # @site = policy_scope(Locomotive::Site).find(params[:id])
44
- # end
45
-
46
- # def load_sites
47
- # @sites = policy_scope(Locomotive::Site)
48
- # end
49
-
50
- # def current_membership
51
- # membership = @site ? @site.membership_for(current_locomotive_account) : nil
52
- # membership || Locomotive::Membership.new(account: current_locomotive_account)
53
- # end
54
-
55
- # end
56
-
57
- # end
58
- # end
@@ -1,52 +0,0 @@
1
- # module Locomotive
2
- # module Api
3
- # class SnippetsController < Api::BaseController
4
-
5
- # account_required & within_site
6
-
7
- # before_filter :load_snippet, only: [:show, :update, :destroy]
8
- # before_filter :load_snippets, only: [:index]
9
-
10
- # def index
11
- # authorize Locomotive::Snippet
12
- # @snippets = @snippets.order_by(:name.asc)
13
- # respond_with @snippets
14
- # end
15
-
16
- # def show
17
- # authorize @snippet
18
- # respond_with @snippet
19
- # end
20
-
21
- # def create
22
- # authorize Locomotive::Snippet
23
- # @snippet = current_site.snippets.build
24
- # @snippet.from_presenter(params[:snippet]).save
25
- # respond_with @snippet, location: -> { main_app.locomotive_api_snippet_url(@snippet) }
26
- # end
27
-
28
- # def update
29
- # authorize @snippet
30
- # @snippet.from_presenter(params[:snippet]).save
31
- # respond_with @snippet, location: main_app.locomotive_api_snippet_url(@snippet)
32
- # end
33
-
34
- # def destroy
35
- # authorize Locomotive::Snippet
36
- # @snippet.destroy
37
- # respond_with @snippet, location: main_app.locomotive_api_snippets_url
38
- # end
39
-
40
- # private
41
-
42
- # def load_snippet
43
- # @snippet = current_site.snippets.find(params[:id])
44
- # end
45
-
46
- # def load_snippets
47
- # @snippets = current_site.snippets
48
- # end
49
-
50
- # end
51
- # end
52
- # end
@@ -1,51 +0,0 @@
1
- # module Locomotive
2
- # module Api
3
- # class ThemeAssetsController < Api::BaseController
4
-
5
- # account_required & within_site
6
-
7
- # before_filter :load_theme_asset, only: [:show, :update, :destroy]
8
- # before_filter :load_theme_assets, only: [:index]
9
-
10
- # def index
11
- # authorize Locomotive::ThemeAsset
12
- # respond_with @theme_assets.sort_by(&:local_path)
13
- # end
14
-
15
- # def show
16
- # authorize @theme_asset
17
- # respond_with @theme_asset
18
- # end
19
-
20
- # def create
21
- # authorize Locomotive::ThemeAsset
22
- # @theme_asset = current_site.theme_assets.build
23
- # @theme_asset.from_presenter(params[:theme_asset]).save
24
- # respond_with @theme_asset, location: -> { main_app.locomotive_api_theme_asset_url(@theme_asset) }
25
- # end
26
-
27
- # def update
28
- # authorize @theme_asset
29
- # @theme_asset.from_presenter(params[:theme_asset]).save
30
- # respond_with @theme_asset, location: main_app.locomotive_api_theme_asset_url(@theme_asset)
31
- # end
32
-
33
- # def destroy
34
- # authorize @theme_asset
35
- # @theme_asset.destroy
36
- # respond_with @theme_asset, location: main_app.locomotive_api_theme_assets_url
37
- # end
38
-
39
- # private
40
-
41
- # def load_theme_asset
42
- # @theme_asset = current_site.theme_assets.find(params[:id])
43
- # end
44
-
45
- # def load_theme_assets
46
- # @theme_assets = current_site.theme_assets
47
- # end
48
-
49
- # end
50
- # end
51
- # end
@@ -1,36 +0,0 @@
1
- # module Locomotive
2
- # module Api
3
- # class TokensController < Api::BaseController
4
-
5
- # def create
6
- # begin
7
- # token = Account.create_api_token(params[:email], params[:password], params[:api_key])
8
- # respond_with({ token: token }, location: location_after_request)
9
- # rescue Exception => e
10
- # logger.error "Unable to create a token, reason: #{e.message}"
11
- # respond_with({ message: e.message }, status: 401, location: location_after_request)
12
- # end
13
- # end
14
-
15
- # def destroy
16
- # begin
17
- # token = Account.invalidate_api_token(params[:id])
18
- # respond_with({ token: token }, location: location_after_request)
19
- # rescue Exception => e
20
- # respond_with({ message: e.message }, status: 404, location: location_after_request)
21
- # end
22
- # end
23
-
24
- # private
25
-
26
- # def set_locale
27
- # I18n.locale = Locomotive.config.locales.first
28
- # end
29
-
30
- # def location_after_request
31
- # main_app.locomotive_api_my_account_url(format: :json)
32
- # end
33
-
34
- # end
35
- # end
36
- # end
@@ -1,51 +0,0 @@
1
- # module Locomotive
2
- # module Api
3
- # class TranslationsController < Api::BaseController
4
-
5
- # account_required & within_site
6
-
7
- # before_filter :load_translation, only: [:show, :update, :destroy]
8
- # before_filter :load_translations, only: [:index]
9
-
10
- # def index
11
- # authorize Translation
12
- # respond_with @translations
13
- # end
14
-
15
- # def show
16
- # authorize @translation
17
- # respond_with @translation
18
- # end
19
-
20
- # def create
21
- # authorize Translation
22
- # @translation = self.current_site.translations.build
23
- # @translation.from_presenter(params[:translation]).save
24
- # respond_with @translation, location: -> { main_app.locomotive_api_translation_url(@translation) }
25
- # end
26
-
27
- # def update
28
- # authorize @translation
29
- # @translation.from_presenter(params[:translation]).save
30
- # respond_with @translation, location: main_app.locomotive_api_translation_url(@translation)
31
- # end
32
-
33
- # def destroy
34
- # authorize @translation
35
- # @translation.destroy
36
- # respond_with @translation, location: main_app.locomotive_api_translations_url
37
- # end
38
-
39
- # private
40
-
41
- # def load_translation
42
- # @translation = self.current_site.translations.find params[:id]
43
- # end
44
-
45
- # def load_translations
46
- # @translations = self.current_site.translations
47
- # end
48
-
49
- # end
50
- # end
51
- # end
@@ -1,11 +0,0 @@
1
- # module Locomotive
2
- # module Api
3
- # class VersionController < Api::BaseController
4
-
5
- # def show
6
- # respond_with({ engine: Locomotive::VERSION })
7
- # end
8
-
9
- # end
10
- # end
11
- # end
@@ -1,79 +0,0 @@
1
- # require 'spec_helper'
2
-
3
- # describe Locomotive::EditableControl do
4
-
5
- # before(:each) do
6
- # @site = FactoryGirl.create(:site)
7
- # @home = @site.pages.root.first
8
- # end
9
-
10
- # describe '#simple' do
11
-
12
- # before(:each) do
13
- # @home.update_attributes raw_template: %({% block body %}{% editable_control 'menu', options: "true=Yes,false=No" %}false{% endeditable_control %}{% endblock %}%)
14
-
15
- # @sub_page_1 = FactoryGirl.create(:page, slug: 'sub_page_1', parent: @home, raw_template: "{% extends 'parent' %}")
16
- # end
17
-
18
- # it 'exists' do
19
- # expect(@sub_page_1.editable_elements.size).to eq(1)
20
- # end
21
-
22
- # it 'has a non-nil slug' do
23
- # expect(@sub_page_1.editable_elements.first.slug).to eq('menu')
24
- # end
25
-
26
- # it 'has a default value' do
27
- # expect(@sub_page_1.editable_elements.first.content).to eq('false')
28
- # end
29
-
30
- # it 'has a list of options' do
31
- # expect(@sub_page_1.editable_elements.first.options).to eq([{ 'value' => 'true', 'text' => 'Yes' }, { 'value' => 'false', 'text' => 'No' }])
32
- # end
33
-
34
- # it 'removes leading and trailling characters' do
35
- # @home.update_attributes raw_template: %({% block body %}
36
- # {% editable_control 'menu', options: 'true=Yes,false=No' %}
37
- # true
38
- # {% endeditable_control %}
39
- # {% endblock %})
40
- # expect(@home.editable_elements.first.content).to eq('true')
41
- # end
42
-
43
- # end
44
-
45
- # describe '"sticky" elements' do
46
-
47
- # before(:each) do
48
- # @home.update_attributes raw_template: "{% block body %}{% editable_control 'menu', options: 'true=Yes,false=No', fixed: true %}false{% endeditable_control %}{% endblock %}"
49
- # @home_el = @home.editable_elements.first
50
-
51
- # @sub_page_1 = FactoryGirl.create(:page, slug: 'sub_page_1', parent: @home, raw_template: "{% extends 'parent' %}")
52
- # @sub_page_2 = FactoryGirl.create(:page, slug: 'sub_page_2', parent: @home, raw_template: "{% extends 'parent' %}")
53
-
54
- # @sub_page_1_el = @sub_page_1.editable_elements.first
55
- # @sub_page_2_el = @sub_page_2.editable_elements.first
56
- # end
57
-
58
- # it 'exists in sub pages' do
59
- # expect(@sub_page_1.editable_elements.size).to eq(1)
60
- # expect(@sub_page_2.editable_elements.size).to eq(1)
61
- # end
62
-
63
- # it 'is marked as fixed' do
64
- # expect(@sub_page_1_el.fixed?).to eq(true)
65
- # expect(@sub_page_2_el.fixed?).to eq(true)
66
- # end
67
-
68
- # it 'gets also updated when updating the very first element' do
69
- # @home_el.content = 'true'
70
- # @home.save
71
- # @sub_page_1.reload; @sub_page_1_el = @sub_page_1.editable_elements.first
72
- # @sub_page_2.reload; @sub_page_2_el = @sub_page_2.editable_elements.first
73
- # expect(@sub_page_1_el.content).to eq('true')
74
- # expect(@sub_page_2_el.content).to eq('true')
75
- # end
76
-
77
- # end
78
-
79
- # end
@@ -1,94 +0,0 @@
1
- # require 'spec_helper'
2
-
3
- # describe Locomotive::EditableFile do
4
-
5
- # before(:each) do
6
- # @site = FactoryGirl.create(:site)
7
- # @home = @site.pages.root.first
8
-
9
- # @home.update_attributes raw_template: "{% block body %}{% editable_file 'image' %}Lorem ipsum{% endeditable_file %}{% endblock %}"
10
-
11
- # @home = @site.pages.root.first
12
- # end
13
-
14
- # it 'has one editable file element' do
15
- # expect(@home.editable_elements.size).to eq(1)
16
- # expect(@home.editable_elements.first.slug).to eq('image')
17
- # end
18
-
19
- # it 'disables the default content flag if the remove_source method is called' do
20
- # @home.editable_elements.first.remove_source = true
21
- # @home.save; @home.reload
22
- # expect(@home.editable_elements.first.default_content?).to be(false)
23
- # end
24
-
25
- # it 'disables the default content when a new file is uploaded' do
26
- # @home.editable_elements.first.source = FixturedAsset.open('5k.png')
27
- # @home.save
28
- # expect(@home.editable_elements.first.default_content?).to be(false)
29
- # end
30
-
31
- # it 'does not have 2 image fields' do
32
- # editable_file = @home.editable_elements.first
33
- # fields = editable_file.class.fields.keys
34
- # expect(fields.include?('source') && fields.include?(:source)).to be(false)
35
- # end
36
-
37
- # describe 'with an attached file' do
38
-
39
- # before(:each) do
40
- # @editable_file = @home.editable_elements.first
41
- # @editable_file.source = FixturedAsset.open('5k.png')
42
- # @home.save
43
- # @home.reload
44
- # end
45
-
46
- # it 'has a valid source' do
47
- # expect(@editable_file.source?).to be(true)
48
- # end
49
-
50
- # it 'returns the right path even if the page has been retrieved with the minimum_attributes scope' do
51
- # @home = @site.pages.root.first
52
- # expect(@home.editable_elements.first.source?).to be(true)
53
- # end
54
-
55
- # end
56
-
57
- # describe '"sticky" files' do
58
-
59
- # before(:each) do
60
- # @home.update_attributes raw_template: "{% block body %}{% editable_file 'image', fixed: true %}/foo.png{% endeditable_file %}{% endblock %}"
61
-
62
- # @sub_page_1 = FactoryGirl.create(:page, slug: 'sub_page_1', parent: @home, raw_template: "{% extends 'index' %}")
63
- # @sub_page_2 = FactoryGirl.create(:page, slug: 'sub_page_2', parent: @home, raw_template: "{% extends 'index' %}")
64
-
65
- # @sub_page_1_el = @sub_page_1.editable_elements.first
66
- # @sub_page_2_el = @sub_page_2.editable_elements.first
67
- # end
68
-
69
- # it 'exists in sub pages' do
70
- # expect(@sub_page_1.editable_elements.size).to eq(1)
71
- # expect(@sub_page_2.editable_elements.size).to eq(1)
72
- # end
73
-
74
- # it 'is marked as fixed' do
75
- # expect(@sub_page_1_el.fixed?).to be(true)
76
- # expect(@sub_page_2_el.fixed?).to be(true)
77
- # end
78
-
79
- # it 'enables the default content when it just got created' do
80
- # expect(@sub_page_1_el.source?).to be(false)
81
- # expect(@sub_page_1_el.default_source_url).to eq('/foo.png')
82
- # expect(@sub_page_1_el.default_content?).to be(true)
83
- # end
84
-
85
- # it 'gets also updated when updating the very first element' do
86
- # @home.editable_elements.first.source = FixturedAsset.open('5k.png')
87
- # @home.save; @sub_page_1.reload; @sub_page_2.reload
88
- # expect(@sub_page_1.editable_elements.first.default_source_url).to match(/files\/5k.png$/)
89
- # expect(@sub_page_2.editable_elements.first.default_source_url).to match(/files\/5k.png$/)
90
- # end
91
-
92
- # end
93
-
94
- # end
@@ -1,219 +0,0 @@
1
- # require 'spec_helper'
2
-
3
- # describe Locomotive::EditableText do
4
-
5
- # describe 'a simple case' do
6
-
7
- # before(:each) do
8
- # @site = FactoryGirl.create(:site)
9
- # @home = @site.pages.root.first
10
-
11
- # @home.update_attributes raw_template: "{% block body %}{% editable_text 'body' %}Lorem ipsum{% endeditable_text %}{% endblock %}"
12
-
13
- # @sub_page_1 = FactoryGirl.create(:page, title: '1', slug: 'sub_page_1', parent: @home, raw_template: "{% extends 'parent' %}")
14
- # @sub_page_2 = FactoryGirl.create(:page, title: '2', slug: 'sub_page_2', parent: @home, raw_template: "{% extends 'parent' %}")
15
-
16
- # @sub_page_1_el = @sub_page_1.editable_elements.first
17
-
18
- # @sub_page_1_1 = FactoryGirl.create(:page, title: '1_1', slug: 'sub_page_1_1', parent: @sub_page_1, raw_template: "{% extends 'parent' %}")
19
- # end
20
-
21
- # describe 'properties' do
22
-
23
- # it 'exists' do
24
- # expect(@sub_page_1.editable_elements.size).to eq(1)
25
- # end
26
-
27
- # it 'has a non-nil slug' do
28
- # expect(@sub_page_1.editable_elements.first.slug).to eq('body')
29
- # end
30
-
31
- # it 'has a default content at first' do
32
- # expect(@sub_page_1.editable_elements.first.default_content).to eq(true)
33
- # expect(@sub_page_1.editable_elements.first.content).to eq('Lorem ipsum')
34
- # end
35
-
36
- # it 'is still default when it gets modified by the exact same value' do
37
- # @sub_page_1.editable_elements.first.content = 'Lorem ipsum'
38
- # expect(@sub_page_1.editable_elements.first.default_content).to eq(true)
39
- # end
40
-
41
- # it 'strips the content' do
42
- # @sub_page_1.editable_elements.first.update_attribute :content, " Lorem ipsum\n\n "
43
- # expect(@sub_page_1.editable_elements.first.content).to eq('Lorem ipsum')
44
- # end
45
-
46
- # end
47
-
48
- # describe 'locales' do
49
-
50
- # it 'assigns the default locale' do
51
- # expect(@sub_page_1_el.locales).to eq(['en'])
52
- # end
53
-
54
- # it 'adds new locale' do
55
- # ::Mongoid::Fields::I18n.with_locale 'fr' do
56
- # page = Locomotive::Page.find(@home._id)
57
- # page.editable_elements.first.content = 'Lorem ipsum (FR)'
58
- # page.save
59
- # expect(page.editable_elements.first.locales).to eq(%w(en fr))
60
- # end
61
- # end
62
-
63
- # it 'adds new locale within sub page elements' do
64
- # ::Mongoid::Fields::I18n.with_locale 'fr' do
65
- # @home.update_attributes title: 'Accueil', raw_template: "{% block body %}{% editable_text 'body' %}Lorem ipsum{% endeditable_text %}{% endblock %}"
66
- # page = Locomotive::Page.find(@sub_page_1._id)
67
- # page.editable_elements.first.content = 'Lorem ipsum (FR)'
68
- # page.save
69
- # expect(page.editable_elements.first.locales).to eq(%w(en fr))
70
- # end
71
- # end
72
-
73
- # end
74
-
75
- # describe 'when modifying the raw template' do
76
-
77
- # it 'can update its content from the raw template if the user has not modified it' do
78
- # @home.update_attributes raw_template: "{% block body %}{% editable_text 'body' %}Lorem ipsum v2{% endeditable_text %}{% endblock %}"
79
- # expect(@home.editable_elements.first.default_content).to eq(true)
80
- # expect(@home.editable_elements.first.content).to eq('Lorem ipsum v2')
81
- # end
82
-
83
- # it 'does not touch the content if the user has modified it before' do
84
- # @home.editable_elements.first.content = 'Hello world'
85
- # @home.raw_template = "{% block body %}{% editable_text 'body' %}Lorem ipsum v2{% endeditable_text %}{% endblock %}"
86
- # @home.save
87
- # expect(@home.editable_elements.first.default_content).to eq(false)
88
- # expect(@home.editable_elements.first.content).to eq('Hello world')
89
- # end
90
-
91
- # end
92
-
93
- # describe '.editable?' do
94
-
95
- # it 'is editable' do
96
- # expect(@sub_page_1_el.editable?).to eq(true)
97
- # end
98
-
99
- # it 'is not editable if the element is disabled' do
100
- # @sub_page_1_el.disabled = true
101
- # expect(@sub_page_1_el.editable?).to eq(false)
102
- # end
103
-
104
- # it 'is not editable if it is a fixed one' do
105
- # @sub_page_1_el.fixed = true
106
- # expect(@sub_page_1_el.editable?).to eq(false)
107
- # end
108
-
109
- # it 'is not editable if it does exist for the current locale' do
110
- # ::Mongoid::Fields::I18n.with_locale 'fr' do
111
- # expect(@sub_page_1_el.editable?).to eq(false)
112
- # end
113
- # end
114
-
115
- # it 'is among the editable elements of the page' do
116
- # expect(@sub_page_1.enabled_editable_elements.map(&:slug)).to eq(%w(body))
117
- # end
118
-
119
- # it 'is not among the editable elements of the page if disabled' do
120
- # @sub_page_1_el.disabled = true
121
- # expect(@sub_page_1.enabled_editable_elements.map(&:slug)).to eq([])
122
- # end
123
-
124
- # end
125
-
126
- # describe 'in sub pages level #1' do
127
-
128
- # before(:each) do
129
- # @sub_page_1.reload
130
- # @sub_page_2.reload
131
- # end
132
-
133
- # it 'exists' do
134
- # expect(@sub_page_1.editable_elements.size).to eq(1)
135
- # expect(@sub_page_2.editable_elements.size).to eq(1)
136
- # end
137
-
138
- # it 'has a non-nil slug' do
139
- # expect(@sub_page_1.editable_elements.first.slug).to eq('body')
140
- # end
141
-
142
- # it 'does not have a content at first' do
143
- # expect(@sub_page_1_el.default_content).to eq(true)
144
- # expect(@sub_page_1_el.content).to eq('Lorem ipsum')
145
- # end
146
-
147
- # end
148
-
149
- # describe 'in sub pages level #2' do
150
-
151
- # before(:each) do
152
- # @sub_page_1_1.reload
153
- # end
154
-
155
- # it 'exists' do
156
- # expect(@sub_page_1_1.editable_elements.size).to eq(1)
157
- # end
158
-
159
- # it 'has a non-nil slug' do
160
- # expect(@sub_page_1_1.editable_elements.first.slug).to eq('body')
161
- # end
162
-
163
- # it 'removes editable elements' do
164
- # @sub_page_1_1.editable_elements.destroy_all
165
- # @sub_page_1_1.reload
166
- # expect(@sub_page_1_1.editable_elements.size).to eq(0)
167
- # end
168
-
169
- # end
170
-
171
- # end
172
-
173
- # describe '"sticky" elements' do
174
-
175
- # before(:each) do
176
- # @site = FactoryGirl.create(:site)
177
- # @home = @site.pages.root.first
178
-
179
- # @home.update_attributes raw_template: "{% block body %}{% editable_text 'body', fixed: true %}Lorem ipsum{% endeditable_text %}{% endblock %}"
180
- # @home_el = @home.editable_elements.first
181
-
182
- # @sub_page_1 = FactoryGirl.create(:page, slug: 'sub_page_1', parent: @home, raw_template: "{% extends 'parent' %}")
183
- # @sub_page_2 = FactoryGirl.create(:page, slug: 'sub_page_2', parent: @home, raw_template: "{% extends 'parent' %}")
184
-
185
- # @sub_page_1_el = @sub_page_1.editable_elements.first
186
- # @sub_page_2_el = @sub_page_2.editable_elements.first
187
- # end
188
-
189
- # it 'exists in sub pages' do
190
- # expect(@sub_page_1.editable_elements.size).to eq(1)
191
- # expect(@sub_page_2.editable_elements.size).to eq(1)
192
- # end
193
-
194
- # it 'is marked as fixed' do
195
- # expect(@sub_page_1_el.fixed?).to eq(true)
196
- # expect(@sub_page_2_el.fixed?).to eq(true)
197
- # end
198
-
199
- # it 'enables the default content when it just got created' do
200
- # expect(@sub_page_1_el.default_content?).to eq(true)
201
- # end
202
-
203
- # it 'disables the default content if the content changed' do
204
- # @sub_page_1_el.content = 'Bla bla'
205
- # expect(@sub_page_1_el.default_content?).to eq(false)
206
- # end
207
-
208
- # it 'gets also updated when updating the very first element' do
209
- # @home_el.content = 'Hello world'
210
- # @home.save
211
- # @sub_page_1.reload; @sub_page_1_el = @sub_page_1.editable_elements.first
212
- # @sub_page_2.reload; @sub_page_2_el = @sub_page_2.editable_elements.first
213
- # expect(@sub_page_1_el.content).to eq('Hello world')
214
- # expect(@sub_page_2_el.content).to eq('Hello world')
215
- # end
216
-
217
- # end
218
-
219
- # end