sinicum 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +7 -0
  2. data/.cane +19 -0
  3. data/.gitignore +14 -0
  4. data/.rubocop.yml +30 -0
  5. data/.travis.yml +14 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +24 -0
  8. data/README.md +327 -0
  9. data/Rakefile +37 -0
  10. data/app/assets/javascripts/sinicum/magnolia_client.js.coffee +233 -0
  11. data/app/controllers/sinicum/controller_base.rb +173 -0
  12. data/app/controllers/sinicum/controllers/cache_aware.rb +16 -0
  13. data/app/controllers/sinicum/controllers/global_state_cache.rb +83 -0
  14. data/app/helpers/sinicum/helper_utils.rb +152 -0
  15. data/app/helpers/sinicum/mgnl_helper.rb +145 -0
  16. data/app/helpers/sinicum/mgnl_helper5.rb +7 -0
  17. data/app/helpers/sinicum/mgnl_image_helper.rb +26 -0
  18. data/app/helpers/sinicum/taglib_helper5.rb +166 -0
  19. data/gemfiles/Gemfile-3.2 +6 -0
  20. data/gemfiles/Gemfile-4.0 +6 -0
  21. data/lib/generators/sinicum/install_generator.rb +162 -0
  22. data/lib/generators/sinicum/templates/VersionHandler.java +18 -0
  23. data/lib/generators/sinicum/templates/config/default/log4j-development.xml +203 -0
  24. data/lib/generators/sinicum/templates/config/default/log4j.xml +200 -0
  25. data/lib/generators/sinicum/templates/config/default/magnolia-author.properties +63 -0
  26. data/lib/generators/sinicum/templates/config/default/magnolia-public01.properties +63 -0
  27. data/lib/generators/sinicum/templates/config/default/magnolia.properties +63 -0
  28. data/lib/generators/sinicum/templates/config/repo-conf/jackrabbit-bundle-postgres-search-author.xml +73 -0
  29. data/lib/generators/sinicum/templates/config/repo-conf/jackrabbit-bundle-postgres-search-public01.xml +73 -0
  30. data/lib/generators/sinicum/templates/config/repo-conf/jackrabbit-bundle-postgres-search.xml +70 -0
  31. data/lib/generators/sinicum/templates/magnolia/config.modules.myproject.dialogs.xml +1625 -0
  32. data/lib/generators/sinicum/templates/magnolia/config.modules.myproject.templates.xml +247 -0
  33. data/lib/generators/sinicum/templates/module-config.xml +13 -0
  34. data/lib/generators/sinicum/templates/module-pom.xml +67 -0
  35. data/lib/generators/sinicum/templates/project-pom.xml +104 -0
  36. data/lib/generators/sinicum/templates/rails/_article.html.haml +15 -0
  37. data/lib/generators/sinicum/templates/rails/_content.html.haml +2 -0
  38. data/lib/generators/sinicum/templates/rails/_meta.html.haml +9 -0
  39. data/lib/generators/sinicum/templates/rails/application.html.haml +11 -0
  40. data/lib/generators/sinicum/templates/rails/content_controller.rb +5 -0
  41. data/lib/generators/sinicum/templates/rails/imaging.yml +8 -0
  42. data/lib/generators/sinicum/templates/rails/sinicum_server.yml +15 -0
  43. data/lib/sinicum.rb +53 -0
  44. data/lib/sinicum/content/aggregator.rb +173 -0
  45. data/lib/sinicum/content/website_content_resolver.rb +10 -0
  46. data/lib/sinicum/engine.rb +23 -0
  47. data/lib/sinicum/imaging.rb +29 -0
  48. data/lib/sinicum/imaging/config.rb +133 -0
  49. data/lib/sinicum/imaging/converter.rb +81 -0
  50. data/lib/sinicum/imaging/default_converter.rb +20 -0
  51. data/lib/sinicum/imaging/image_size_converter.rb +52 -0
  52. data/lib/sinicum/imaging/imaging.rb +171 -0
  53. data/lib/sinicum/imaging/imaging_file.rb +115 -0
  54. data/lib/sinicum/imaging/imaging_middleware.rb +56 -0
  55. data/lib/sinicum/imaging/max_size_converter.rb +39 -0
  56. data/lib/sinicum/imaging/resize_crop_converter.rb +35 -0
  57. data/lib/sinicum/jcr/api_client.rb +50 -0
  58. data/lib/sinicum/jcr/api_queries.rb +37 -0
  59. data/lib/sinicum/jcr/cache/global_cache.rb +26 -0
  60. data/lib/sinicum/jcr/dam/document.rb +57 -0
  61. data/lib/sinicum/jcr/dam/image.rb +40 -0
  62. data/lib/sinicum/jcr/jcr_configuration.rb +67 -0
  63. data/lib/sinicum/jcr/mgnl4_compatibility.rb +11 -0
  64. data/lib/sinicum/jcr/node.rb +268 -0
  65. data/lib/sinicum/jcr/node_initializer.rb +16 -0
  66. data/lib/sinicum/jcr/node_queries.rb +101 -0
  67. data/lib/sinicum/jcr/query_sanitizer.rb +24 -0
  68. data/lib/sinicum/jcr/type_translator.rb +38 -0
  69. data/lib/sinicum/jcr/type_translators/component_translator.rb +28 -0
  70. data/lib/sinicum/jcr/type_translators/dam_translator.rb +33 -0
  71. data/lib/sinicum/jcr/type_translators/data_translator.rb +31 -0
  72. data/lib/sinicum/jcr/type_translators/default_translator.rb +13 -0
  73. data/lib/sinicum/jcr/type_translators/translator_base.rb +40 -0
  74. data/lib/sinicum/logger.rb +28 -0
  75. data/lib/sinicum/navigation/default_navigation_element.rb +30 -0
  76. data/lib/sinicum/navigation/navigation_element.rb +39 -0
  77. data/lib/sinicum/navigation/navigation_element_list.rb +33 -0
  78. data/lib/sinicum/navigation/navigation_handler.rb +95 -0
  79. data/lib/sinicum/navigation/navigation_status.rb +27 -0
  80. data/lib/sinicum/templating/area_handler.rb +33 -0
  81. data/lib/sinicum/templating/dialog_resolver.rb +26 -0
  82. data/lib/sinicum/templating/templating_utils.rb +24 -0
  83. data/lib/sinicum/util.rb +12 -0
  84. data/lib/sinicum/version.rb +3 -0
  85. data/script/cibuild +31 -0
  86. data/sinicum.gemspec +29 -0
  87. data/spec/controllers/sinicum/controller_base_spec.rb +53 -0
  88. data/spec/controllers/sinicum/controllers/global_state_cache_spec.rb +35 -0
  89. data/spec/dummy/REVISION +1 -0
  90. data/spec/dummy/Rakefile +7 -0
  91. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  92. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  93. data/spec/dummy/app/views/application/index.html.erb +1 -0
  94. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  95. data/spec/dummy/app/views/layouts/layout_name.html.erb +0 -0
  96. data/spec/dummy/app/views/layouts/my-module/test.html.erb +0 -0
  97. data/spec/dummy/app/views/layouts/my_module/test.html.erb +0 -0
  98. data/spec/dummy/config.ru +4 -0
  99. data/spec/dummy/config/application.rb +45 -0
  100. data/spec/dummy/config/boot.rb +10 -0
  101. data/spec/dummy/config/database.yml +22 -0
  102. data/spec/dummy/config/environment.rb +5 -0
  103. data/spec/dummy/config/environments/development.rb +24 -0
  104. data/spec/dummy/config/environments/production.rb +51 -0
  105. data/spec/dummy/config/environments/test.rb +34 -0
  106. data/spec/dummy/config/imaging.yml +7 -0
  107. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  108. data/spec/dummy/config/initializers/inflections.rb +10 -0
  109. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  110. data/spec/dummy/config/initializers/secret_token.rb +11 -0
  111. data/spec/dummy/config/initializers/session_store.rb +8 -0
  112. data/spec/dummy/config/locales/en.yml +5 -0
  113. data/spec/dummy/config/routes.rb +59 -0
  114. data/spec/dummy/config/sinicum_server.yml +13 -0
  115. data/spec/dummy/public/404.html +26 -0
  116. data/spec/dummy/public/422.html +26 -0
  117. data/spec/dummy/public/500.html +26 -0
  118. data/spec/dummy/public/favicon.ico +0 -0
  119. data/spec/dummy/public/javascripts/application.js +2 -0
  120. data/spec/dummy/public/javascripts/controls.js +965 -0
  121. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  122. data/spec/dummy/public/javascripts/effects.js +1123 -0
  123. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  124. data/spec/dummy/public/javascripts/rails.js +191 -0
  125. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  126. data/spec/dummy/script/rails +6 -0
  127. data/spec/fixtures/api/cache_global.json +3 -0
  128. data/spec/fixtures/api/content_mgnl5.json +22 -0
  129. data/spec/fixtures/api/default_json.json.erb +47 -0
  130. data/spec/fixtures/api/default_json_mgnl5.json.erb +27 -0
  131. data/spec/fixtures/api/file.json +73 -0
  132. data/spec/fixtures/api/file_mgnl5.json +51 -0
  133. data/spec/fixtures/api/homepage.json +1497 -0
  134. data/spec/fixtures/api/homepage_parent.json +483 -0
  135. data/spec/fixtures/api/image.json +73 -0
  136. data/spec/fixtures/api/image_mgnl5.json +50 -0
  137. data/spec/fixtures/api/navigation_children.json +3107 -0
  138. data/spec/fixtures/api/navigation_parents.json +25 -0
  139. data/spec/fixtures/api/product.json +2084 -0
  140. data/spec/fixtures/api/query_result.json +61 -0
  141. data/spec/fixtures/mock_content.rb +6 -0
  142. data/spec/fixtures/mock_image.gif +0 -0
  143. data/spec/helpers/sinicum/helper_utils_spec.rb +55 -0
  144. data/spec/helpers/sinicum/mgnl_helper_spec.rb +315 -0
  145. data/spec/helpers/sinicum/mgnl_image_helper_spec.rb +103 -0
  146. data/spec/sinicum/content/aggregator_spec.rb +91 -0
  147. data/spec/sinicum/content/website_content_resolver_spec.rb +14 -0
  148. data/spec/sinicum/imaging/config_spec.rb +50 -0
  149. data/spec/sinicum/imaging/converter_spec.rb +41 -0
  150. data/spec/sinicum/imaging/image_size_converter_spec.rb +27 -0
  151. data/spec/sinicum/imaging/imaging.yml +15 -0
  152. data/spec/sinicum/imaging/imaging_file_spec.rb +125 -0
  153. data/spec/sinicum/imaging/imaging_middleware_spec.rb +79 -0
  154. data/spec/sinicum/imaging/max_size_converter_spec.rb +52 -0
  155. data/spec/sinicum/imaging/resize_crop_converter_spec.rb +18 -0
  156. data/spec/sinicum/imaging_spec.rb +13 -0
  157. data/spec/sinicum/jcr/api_client_spec.rb +69 -0
  158. data/spec/sinicum/jcr/cache/global_cache_spec.rb +29 -0
  159. data/spec/sinicum/jcr/dam/document_spec.rb +81 -0
  160. data/spec/sinicum/jcr/dam/image_spec.rb +46 -0
  161. data/spec/sinicum/jcr/jcr_configuration_spec.rb +57 -0
  162. data/spec/sinicum/jcr/mgnl4_compatibility_spec.rb +10 -0
  163. data/spec/sinicum/jcr/node_queries_spec.rb +113 -0
  164. data/spec/sinicum/jcr/node_spec.rb +261 -0
  165. data/spec/sinicum/jcr/query_sanitizer_spec.rb +26 -0
  166. data/spec/sinicum/jcr/type_translator_spec.rb +42 -0
  167. data/spec/sinicum/jcr/type_translators/component_translator_spec.rb +71 -0
  168. data/spec/sinicum/jcr/type_translators/data_translator_spec.rb +38 -0
  169. data/spec/sinicum/jcr/type_translators/default_translator_spec.rb +19 -0
  170. data/spec/sinicum/navigation/default_navigation_element_spec.rb +45 -0
  171. data/spec/sinicum/navigation/navigation_handler_spec.rb +71 -0
  172. data/spec/sinicum/templating/dialog_resolver_spec.rb +13 -0
  173. data/spec/sinicum/util_spec.rb +34 -0
  174. data/spec/spec_helper.rb +42 -0
  175. data/spec/support/default_node_reader.rb +40 -0
  176. metadata +434 -0
@@ -0,0 +1,95 @@
1
+ module Sinicum
2
+ module Navigation
3
+ # Public: Handles the API communication and initializes the
4
+ # NavigationElement instances.
5
+ class NavigationHandler
6
+ include Jcr::ApiClient
7
+
8
+ def initialize(axis, base_node_or_path, navigation_element_class, options = {})
9
+ @navigation_element_class = navigation_element_class
10
+ if axis == :children
11
+ @elements = fetch_children(base_node_or_path, options[:depth])
12
+ elsif axis == :parents
13
+ @elements = fetch_parents(base_node_or_path)
14
+ end
15
+ end
16
+
17
+ def elements
18
+ NavigationElementList.new(@elements)
19
+ end
20
+
21
+ def self.children(base_node_or_path, depth,
22
+ navigation_element_class = DefaultNavigationElement)
23
+ new(:children, base_node_or_path, navigation_element_class, depth: depth)
24
+ end
25
+
26
+ def self.parents(base_node_or_path, navigation_element_class = DefaultNavigationElement)
27
+ new(:parents, base_node_or_path, navigation_element_class)
28
+ end
29
+
30
+ private
31
+
32
+ def fetch_children(base_node, depth)
33
+ url = "/_navigation/children#{base_node_url_part(base_node)}"
34
+ result = api_get(
35
+ url,
36
+ "depth" => depth,
37
+ "properties" => @navigation_element_class.navigation_properties.join(";"))
38
+ if result.ok?
39
+ json = MultiJson.load(result.body)
40
+ initialize_from_json(json)
41
+ end
42
+ end
43
+
44
+ def fetch_parents(base_node)
45
+ url = "/_navigation/parents#{base_node_url_part(base_node)}"
46
+ result = api_get(
47
+ url, "properties" => @navigation_element_class.navigation_properties.join(";"))
48
+ if result.ok?
49
+ json = MultiJson.load(result.body)
50
+ initialize_from_json(json)
51
+ end
52
+ end
53
+
54
+ def initialize_from_json(json)
55
+ result = []
56
+ json.each do |el|
57
+ element = initialize_element(el)
58
+ result << element if element
59
+ end
60
+ @elements = result
61
+ end
62
+
63
+ def initialize_element(el)
64
+ result = nil
65
+ unless @navigation_element_class.filter_node(el)
66
+ children = resolve_children(el)
67
+ element = @navigation_element_class.new(
68
+ el["uuid"], el["path"], el["depth"], el["properties"], children)
69
+ result = element
70
+ end
71
+ result
72
+ end
73
+
74
+ def resolve_children(el)
75
+ children = []
76
+ if el["children"]
77
+ el["children"].each do |child_el|
78
+ child = initialize_element(child_el)
79
+ children << child if child
80
+ end
81
+ end
82
+ children.size > 0 ? children : nil
83
+ end
84
+
85
+ def base_node_url_part(base_node)
86
+ if base_node.respond_to?(:uuid)
87
+ url_part = "/" + base_node.uuid
88
+ else
89
+ url_part = base_node
90
+ end
91
+ url_part
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,27 @@
1
+ module Sinicum
2
+ module Navigation
3
+ # Public: Provides meta-information about the status of a NavigationElement
4
+ # in the iteration.
5
+ class NavigationStatus
6
+ attr_reader :size, :count
7
+
8
+ def initialize(size, count)
9
+ @size = size
10
+ @count = count
11
+ end
12
+
13
+ def first?
14
+ count == 0
15
+ end
16
+
17
+ def last?
18
+ count == size - 1
19
+ end
20
+
21
+ def to_s
22
+ self.class.to_s + ": " +
23
+ { size: @size, count: @count, :first? => first?, :last? => last? }.inspect
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,33 @@
1
+ module Sinicum
2
+ module Templating
3
+ # Private: Handles the lookup and creation of Areas on the server.
4
+ #
5
+ # Returns an Array of Strings with the available components or nil if no
6
+ # area could be identified.
7
+ class AreaHandler
8
+ include Jcr::ApiClient
9
+
10
+ def lookup_or_create_area(base_node, area_name)
11
+ result = nil
12
+ if base_node && area_name.present?
13
+ path = "/_templating/areas/initialize"
14
+ response = api_post(
15
+ path, body: {
16
+ workspace: base_node.jcr_workspace,
17
+ baseNodeUuid: base_node.uuid,
18
+ areaName: area_name })
19
+ if response.ok?
20
+ begin
21
+ json = MultiJson.load(response.body)
22
+ result = json["availableComponents"]
23
+ rescue => e
24
+ Rails.logger.error("Could not lookup area: " + e.to_s)
25
+ nil
26
+ end
27
+ end
28
+ end
29
+ result
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,26 @@
1
+ module Sinicum
2
+ module Templating
3
+ # Private: Provides information about Magnolia dialogs.
4
+ class DialogResolver
5
+ include TemplatingUtils
6
+ include Jcr::ApiClient
7
+
8
+ def dialog_for_node(node)
9
+ result = nil
10
+ template = split_template_path(node.mgnl_template)
11
+ path = "/_templating/dialogs/#{template[:type]}" \
12
+ "/#{template[:module]}/#{template[:name]}"
13
+ response = api_get(path)
14
+ if response.ok?
15
+ begin
16
+ json = MultiJson.load(response.body)
17
+ result = json["dialog"]
18
+ rescue
19
+ # nothing
20
+ end
21
+ end
22
+ result
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,24 @@
1
+ module Sinicum
2
+ module Templating
3
+ module TemplatingUtils
4
+ private
5
+
6
+ def split_template_path(path)
7
+ result = {}
8
+ parts = path.split(":")
9
+ result[:module] = parts[0]
10
+ result[:type] = result_type(parts)
11
+ result[:name] = parts[1][parts[1].index("/") + 1, parts[1].length]
12
+ result
13
+ end
14
+
15
+ def result_type(parts)
16
+ if parts[1].index("pages/") == 0
17
+ :page
18
+ elsif parts[1].index("components/") == 0
19
+ :component
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,12 @@
1
+ module Sinicum
2
+ # Public: Collection of various utility methods.
3
+ class Util
4
+ UUID_REGEXP = /^[abcdef0-9]{8}-[abcdef0-9]{4}-[abcdef0-9]{4}-[abcdef0-9]{4}-[abcdef0-9]{12}$/i
5
+
6
+ def self.is_a_uuid?(value)
7
+ return false if value.nil? || !value.respond_to?('match')
8
+ result = value.match(UUID_REGEXP)
9
+ !!result
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module Sinicum
2
+ VERSION = "0.5.0"
3
+ end
@@ -0,0 +1,31 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ eval "$(rbenv init -)"
6
+
7
+ run_tests () {
8
+ if [ $BUNDLE_GEMFILE ]; then
9
+ rm -f "${BUNDLE_GEMFILE}.lock"
10
+ echo "Testing with Gemfile ${BUNDLE_GEMFILE}"
11
+ else
12
+ rm -f "Gemfile.lock"
13
+ echo "Testing with default Gemfile"
14
+ fi
15
+ bundle install --path vendor/bundle
16
+ bundle exec rake
17
+ }
18
+
19
+ # run tests
20
+ for rbenv_version in "1.9.3-p545" "2.0.0-p247" "2.1.1"; do
21
+ rbenv shell $rbenv_version
22
+ echo "Using Ruby ${rbenv_version}"
23
+
24
+ # Run with Rails 3.2
25
+ export BUNDLE_GEMFILE=gemfiles/Gemfile-3.2
26
+ run_tests
27
+
28
+ # Run with Rails 4
29
+ unset BUNDLE_GEMFILE
30
+ run_tests
31
+ done
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "sinicum/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "sinicum"
7
+ s.version = Sinicum::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Dievision GmbH"]
10
+ s.email = ["info@dievision.de"]
11
+ s.homepage = "http://github.com/dievision/sinicum"
12
+ s.summary = %q{Use Magnolia as a CMS backend in a Rails application}
13
+ s.description = %q{Provides the necessary functionality to work with Magnolia-managed content in a Rails application.}
14
+
15
+ s.add_dependency('rails', '>= 3.2')
16
+ s.add_dependency('httpclient', '~> 2.3')
17
+ s.add_dependency('multi_json', '~> 1.3')
18
+ s.add_development_dependency('rspec-rails', '~> 2.14')
19
+ s.add_development_dependency('yard')
20
+ s.add_development_dependency('webmock', '~> 1.8')
21
+ s.add_development_dependency('rubocop', '~> 0.20')
22
+ s.add_development_dependency('cane', '~> 2.5.2')
23
+ s.add_development_dependency('codeclimate-test-reporter')
24
+
25
+ s.files = `git ls-files`.split("\n")
26
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
28
+ s.require_paths = ["lib"]
29
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ module Sinicum
4
+ describe ApplicationController do
5
+ let(:node) { Jcr::Node.new }
6
+
7
+ before(:each) do
8
+ Content::Aggregator.stub(:original_content).and_return(node)
9
+ Content::WebsiteContentResolver.stub(:find_for_path).and_return(node)
10
+ node.stub(:mgnl_template).and_return("something")
11
+ end
12
+
13
+ it "should remove the html_ending" do
14
+ get :index, format: "html"
15
+ response.should redirect_to("/home")
16
+ end
17
+
18
+ it "should ignore and conserve query strings" do
19
+ get :index, format: "html", key: "value"
20
+ response.should redirect_to("/home?key=value")
21
+ end
22
+
23
+ it "should ignore post requests" do
24
+ post :index, format: "html"
25
+ response.status.should eq(200)
26
+ end
27
+
28
+ describe "layout" do
29
+ it "should render with the application layout if no matching file is found" do
30
+ get :index
31
+ response.should render_template("application")
32
+ end
33
+
34
+ it "should render with the application layout if no matching file is found" do
35
+ node.stub(:mgnl_template).and_return("layout_name")
36
+ get :index
37
+ response.should render_template("layout_name")
38
+ end
39
+
40
+ it "should handle Magnolia 4.5-style layouts" do
41
+ node.stub(:mgnl_template).and_return("my_module:pages/test")
42
+ get :index
43
+ response.should render_template("my_module/test")
44
+ end
45
+
46
+ it "should handle Magnolia 4.5-style layouts with dashes" do
47
+ node.stub(:mgnl_template).and_return("my-module:pages/test")
48
+ get :index
49
+ response.should render_template("my-module/test")
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ module Sinicum
4
+ module Controllers
5
+ describe GlobalStateCache do
6
+ let(:controller) do
7
+ controller = double(:controller)
8
+ request = double(:request)
9
+ controller.stub(:request).and_return(request)
10
+ request.stub(:base_url).and_return("base")
11
+ request.stub(:fullpath).and_return("fullpath")
12
+ controller
13
+ end
14
+
15
+ before(:each) do
16
+ Sinicum::Jcr::Cache::GlobalCache.any_instance
17
+ .stub(:current_key).and_return("a11cd0d31248427cbadfd8a7bc51e04e96e4de98")
18
+ end
19
+
20
+ it "should return Rails' deployment revision" do
21
+ GlobalStateCache.send(:deploy_revision)
22
+ .should eq("d18187f9016c71e82993c867a90ff9a0554519c9")
23
+ end
24
+
25
+ it "should return the cache key" do
26
+ cache = GlobalStateCache.new(controller)
27
+ cache.send(:cache_key).should eq(%w(
28
+ basefullpath
29
+ a11cd0d31248427cbadfd8a7bc51e04e96e4de98
30
+ d18187f9016c71e82993c867a90ff9a0554519c9
31
+ ))
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1 @@
1
+ d18187f9016c71e82993c867a90ff9a0554519c9
@@ -0,0 +1,7 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+ require 'rake'
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ include Sinicum::ControllerBase
4
+
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1 @@
1
+ <h1>Sinicum</h1>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag :all %>
6
+ <%= javascript_include_tag :defaults %>
7
+ <%= csrf_meta_tag %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require "active_model/railtie"
4
+ # require "active_record/railtie"
5
+ require "action_controller/railtie"
6
+ require "action_view/railtie"
7
+ require "action_mailer/railtie"
8
+
9
+ Bundler.require
10
+ require "sinicum"
11
+
12
+ module Dummy
13
+ class Application < Rails::Application
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+
18
+ # Custom directories with classes and modules you want to be autoloadable.
19
+ # config.autoload_paths += %W(#{config.root}/extras)
20
+
21
+ # Only load the plugins named here, in the order given (default is alphabetical).
22
+ # :all can be used as a placeholder for all plugins not explicitly named.
23
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
24
+
25
+ # Activate observers that should always be running.
26
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
27
+
28
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
29
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
30
+ # config.time_zone = 'Central Time (US & Canada)'
31
+
32
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
33
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
+ # config.i18n.default_locale = :de
35
+
36
+ # JavaScript files you want as :defaults (application.js is always included).
37
+ # config.action_view.javascript_expansions[:defaults] = %w(jquery rails)
38
+
39
+ # Configure the default encoding used in templates for Ruby 1.9.
40
+ config.encoding = "utf-8"
41
+
42
+ # Configure sensitive parameters which will be filtered from the log file.
43
+ config.filter_parameters += [:password]
44
+ end
45
+ end