sinicum 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.cane +19 -0
- data/.gitignore +14 -0
- data/.rubocop.yml +30 -0
- data/.travis.yml +14 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +327 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/sinicum/magnolia_client.js.coffee +233 -0
- data/app/controllers/sinicum/controller_base.rb +173 -0
- data/app/controllers/sinicum/controllers/cache_aware.rb +16 -0
- data/app/controllers/sinicum/controllers/global_state_cache.rb +83 -0
- data/app/helpers/sinicum/helper_utils.rb +152 -0
- data/app/helpers/sinicum/mgnl_helper.rb +145 -0
- data/app/helpers/sinicum/mgnl_helper5.rb +7 -0
- data/app/helpers/sinicum/mgnl_image_helper.rb +26 -0
- data/app/helpers/sinicum/taglib_helper5.rb +166 -0
- data/gemfiles/Gemfile-3.2 +6 -0
- data/gemfiles/Gemfile-4.0 +6 -0
- data/lib/generators/sinicum/install_generator.rb +162 -0
- data/lib/generators/sinicum/templates/VersionHandler.java +18 -0
- data/lib/generators/sinicum/templates/config/default/log4j-development.xml +203 -0
- data/lib/generators/sinicum/templates/config/default/log4j.xml +200 -0
- data/lib/generators/sinicum/templates/config/default/magnolia-author.properties +63 -0
- data/lib/generators/sinicum/templates/config/default/magnolia-public01.properties +63 -0
- data/lib/generators/sinicum/templates/config/default/magnolia.properties +63 -0
- data/lib/generators/sinicum/templates/config/repo-conf/jackrabbit-bundle-postgres-search-author.xml +73 -0
- data/lib/generators/sinicum/templates/config/repo-conf/jackrabbit-bundle-postgres-search-public01.xml +73 -0
- data/lib/generators/sinicum/templates/config/repo-conf/jackrabbit-bundle-postgres-search.xml +70 -0
- data/lib/generators/sinicum/templates/magnolia/config.modules.myproject.dialogs.xml +1625 -0
- data/lib/generators/sinicum/templates/magnolia/config.modules.myproject.templates.xml +247 -0
- data/lib/generators/sinicum/templates/module-config.xml +13 -0
- data/lib/generators/sinicum/templates/module-pom.xml +67 -0
- data/lib/generators/sinicum/templates/project-pom.xml +104 -0
- data/lib/generators/sinicum/templates/rails/_article.html.haml +15 -0
- data/lib/generators/sinicum/templates/rails/_content.html.haml +2 -0
- data/lib/generators/sinicum/templates/rails/_meta.html.haml +9 -0
- data/lib/generators/sinicum/templates/rails/application.html.haml +11 -0
- data/lib/generators/sinicum/templates/rails/content_controller.rb +5 -0
- data/lib/generators/sinicum/templates/rails/imaging.yml +8 -0
- data/lib/generators/sinicum/templates/rails/sinicum_server.yml +15 -0
- data/lib/sinicum.rb +53 -0
- data/lib/sinicum/content/aggregator.rb +173 -0
- data/lib/sinicum/content/website_content_resolver.rb +10 -0
- data/lib/sinicum/engine.rb +23 -0
- data/lib/sinicum/imaging.rb +29 -0
- data/lib/sinicum/imaging/config.rb +133 -0
- data/lib/sinicum/imaging/converter.rb +81 -0
- data/lib/sinicum/imaging/default_converter.rb +20 -0
- data/lib/sinicum/imaging/image_size_converter.rb +52 -0
- data/lib/sinicum/imaging/imaging.rb +171 -0
- data/lib/sinicum/imaging/imaging_file.rb +115 -0
- data/lib/sinicum/imaging/imaging_middleware.rb +56 -0
- data/lib/sinicum/imaging/max_size_converter.rb +39 -0
- data/lib/sinicum/imaging/resize_crop_converter.rb +35 -0
- data/lib/sinicum/jcr/api_client.rb +50 -0
- data/lib/sinicum/jcr/api_queries.rb +37 -0
- data/lib/sinicum/jcr/cache/global_cache.rb +26 -0
- data/lib/sinicum/jcr/dam/document.rb +57 -0
- data/lib/sinicum/jcr/dam/image.rb +40 -0
- data/lib/sinicum/jcr/jcr_configuration.rb +67 -0
- data/lib/sinicum/jcr/mgnl4_compatibility.rb +11 -0
- data/lib/sinicum/jcr/node.rb +268 -0
- data/lib/sinicum/jcr/node_initializer.rb +16 -0
- data/lib/sinicum/jcr/node_queries.rb +101 -0
- data/lib/sinicum/jcr/query_sanitizer.rb +24 -0
- data/lib/sinicum/jcr/type_translator.rb +38 -0
- data/lib/sinicum/jcr/type_translators/component_translator.rb +28 -0
- data/lib/sinicum/jcr/type_translators/dam_translator.rb +33 -0
- data/lib/sinicum/jcr/type_translators/data_translator.rb +31 -0
- data/lib/sinicum/jcr/type_translators/default_translator.rb +13 -0
- data/lib/sinicum/jcr/type_translators/translator_base.rb +40 -0
- data/lib/sinicum/logger.rb +28 -0
- data/lib/sinicum/navigation/default_navigation_element.rb +30 -0
- data/lib/sinicum/navigation/navigation_element.rb +39 -0
- data/lib/sinicum/navigation/navigation_element_list.rb +33 -0
- data/lib/sinicum/navigation/navigation_handler.rb +95 -0
- data/lib/sinicum/navigation/navigation_status.rb +27 -0
- data/lib/sinicum/templating/area_handler.rb +33 -0
- data/lib/sinicum/templating/dialog_resolver.rb +26 -0
- data/lib/sinicum/templating/templating_utils.rb +24 -0
- data/lib/sinicum/util.rb +12 -0
- data/lib/sinicum/version.rb +3 -0
- data/script/cibuild +31 -0
- data/sinicum.gemspec +29 -0
- data/spec/controllers/sinicum/controller_base_spec.rb +53 -0
- data/spec/controllers/sinicum/controllers/global_state_cache_spec.rb +35 -0
- data/spec/dummy/REVISION +1 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/application/index.html.erb +1 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/layout_name.html.erb +0 -0
- data/spec/dummy/app/views/layouts/my-module/test.html.erb +0 -0
- data/spec/dummy/app/views/layouts/my_module/test.html.erb +0 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +24 -0
- data/spec/dummy/config/environments/production.rb +51 -0
- data/spec/dummy/config/environments/test.rb +34 -0
- data/spec/dummy/config/imaging.yml +7 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +11 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +59 -0
- data/spec/dummy/config/sinicum_server.yml +13 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +191 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/fixtures/api/cache_global.json +3 -0
- data/spec/fixtures/api/content_mgnl5.json +22 -0
- data/spec/fixtures/api/default_json.json.erb +47 -0
- data/spec/fixtures/api/default_json_mgnl5.json.erb +27 -0
- data/spec/fixtures/api/file.json +73 -0
- data/spec/fixtures/api/file_mgnl5.json +51 -0
- data/spec/fixtures/api/homepage.json +1497 -0
- data/spec/fixtures/api/homepage_parent.json +483 -0
- data/spec/fixtures/api/image.json +73 -0
- data/spec/fixtures/api/image_mgnl5.json +50 -0
- data/spec/fixtures/api/navigation_children.json +3107 -0
- data/spec/fixtures/api/navigation_parents.json +25 -0
- data/spec/fixtures/api/product.json +2084 -0
- data/spec/fixtures/api/query_result.json +61 -0
- data/spec/fixtures/mock_content.rb +6 -0
- data/spec/fixtures/mock_image.gif +0 -0
- data/spec/helpers/sinicum/helper_utils_spec.rb +55 -0
- data/spec/helpers/sinicum/mgnl_helper_spec.rb +315 -0
- data/spec/helpers/sinicum/mgnl_image_helper_spec.rb +103 -0
- data/spec/sinicum/content/aggregator_spec.rb +91 -0
- data/spec/sinicum/content/website_content_resolver_spec.rb +14 -0
- data/spec/sinicum/imaging/config_spec.rb +50 -0
- data/spec/sinicum/imaging/converter_spec.rb +41 -0
- data/spec/sinicum/imaging/image_size_converter_spec.rb +27 -0
- data/spec/sinicum/imaging/imaging.yml +15 -0
- data/spec/sinicum/imaging/imaging_file_spec.rb +125 -0
- data/spec/sinicum/imaging/imaging_middleware_spec.rb +79 -0
- data/spec/sinicum/imaging/max_size_converter_spec.rb +52 -0
- data/spec/sinicum/imaging/resize_crop_converter_spec.rb +18 -0
- data/spec/sinicum/imaging_spec.rb +13 -0
- data/spec/sinicum/jcr/api_client_spec.rb +69 -0
- data/spec/sinicum/jcr/cache/global_cache_spec.rb +29 -0
- data/spec/sinicum/jcr/dam/document_spec.rb +81 -0
- data/spec/sinicum/jcr/dam/image_spec.rb +46 -0
- data/spec/sinicum/jcr/jcr_configuration_spec.rb +57 -0
- data/spec/sinicum/jcr/mgnl4_compatibility_spec.rb +10 -0
- data/spec/sinicum/jcr/node_queries_spec.rb +113 -0
- data/spec/sinicum/jcr/node_spec.rb +261 -0
- data/spec/sinicum/jcr/query_sanitizer_spec.rb +26 -0
- data/spec/sinicum/jcr/type_translator_spec.rb +42 -0
- data/spec/sinicum/jcr/type_translators/component_translator_spec.rb +71 -0
- data/spec/sinicum/jcr/type_translators/data_translator_spec.rb +38 -0
- data/spec/sinicum/jcr/type_translators/default_translator_spec.rb +19 -0
- data/spec/sinicum/navigation/default_navigation_element_spec.rb +45 -0
- data/spec/sinicum/navigation/navigation_handler_spec.rb +71 -0
- data/spec/sinicum/templating/dialog_resolver_spec.rb +13 -0
- data/spec/sinicum/util_spec.rb +34 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/support/default_node_reader.rb +40 -0
- metadata +434 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module Sinicum
|
4
|
+
module Imaging
|
5
|
+
describe MaxSizeConverter do
|
6
|
+
describe "#converted_size" do
|
7
|
+
def image(x, y)
|
8
|
+
image = double("image")
|
9
|
+
image.stub(:width).and_return(x)
|
10
|
+
image.stub(:height).and_return(y)
|
11
|
+
image
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should rescale a landscape image correctly to a landscape format" do
|
15
|
+
converter = MaxSizeConverter.new("x" => 57, "y" => 42)
|
16
|
+
converter.document = image(192, 110)
|
17
|
+
converter.converted_size.should == [57, 33]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should rescale a portrait image correctly to a landscape format" do
|
21
|
+
converter = MaxSizeConverter.new("x" => 57, "y" => 42)
|
22
|
+
converter.document = image(110, 192)
|
23
|
+
converter.converted_size.should == [24, 42]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should rescale a portrait image correctly to a portrait format" do
|
27
|
+
converter = MaxSizeConverter.new("x" => 42, "y" => 57)
|
28
|
+
converter.document = image(110, 192)
|
29
|
+
converter.converted_size.should == [33, 57]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should rescale a landscape image correctly to a portrait format" do
|
33
|
+
converter = MaxSizeConverter.new("x" => 42, "y" => 57)
|
34
|
+
converter.document = image(192, 110)
|
35
|
+
converter.converted_size.should == [42, 24]
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should rescale to the same format" do
|
39
|
+
converter = MaxSizeConverter.new("x" => 308, "y" => 800)
|
40
|
+
converter.document = image(308, 125)
|
41
|
+
converter.converted_size.should == [308, 125]
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should rescale an image even if the configuration has no 'y' information" do
|
45
|
+
converter = MaxSizeConverter.new("x" => 57)
|
46
|
+
converter.document = image(192, 110)
|
47
|
+
converter.converted_size.should == [57, 33]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
module Sinicum
|
3
|
+
module Imaging
|
4
|
+
describe ResizeCropConverter do
|
5
|
+
|
6
|
+
it "should require the arguments format, x, y" do
|
7
|
+
config = { "format" => "jpeg", "x" => "200", "y" => "300" }
|
8
|
+
conv = ResizeCropConverter.new(config)
|
9
|
+
config = { "format" => "jpeg", "x" => "200" }
|
10
|
+
expect { conv = ResizeCropConverter.new(config) }.to raise_error(ArgumentError)
|
11
|
+
config = { "format" => "jpeg", "y" => "300" }
|
12
|
+
expect { conv = ResizeCropConverter.new(config) }.to raise_error(ArgumentError)
|
13
|
+
config = { "x" => "200", "y" => "300" }
|
14
|
+
expect { conv = ResizeCropConverter.new(config) }.to raise_error(ArgumentError)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Sinicum
|
4
|
+
describe Imaging do
|
5
|
+
it "should return the default converter name" do
|
6
|
+
Imaging.default_converter_name.should eq("default")
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return the imaging path" do
|
10
|
+
Imaging.path_prefix.should eq("/damfiles")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Sinicum
|
4
|
+
module Jcr
|
5
|
+
describe ApiClient do
|
6
|
+
mock_api_client_class = Class.new do
|
7
|
+
include ApiClient
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:subject) { mock_api_client_class.new }
|
11
|
+
let(:http_client) { double :http_client }
|
12
|
+
let(:response) { double :response }
|
13
|
+
|
14
|
+
let(:host) { "content.dievision.de" }
|
15
|
+
let(:client_base_url) { "http://content.dievision.de/sinicum-rest" }
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
ApiQueries.configure_jcr = { host: host }
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "GET" do
|
22
|
+
it "should delegate to the ApiQueries get method" do
|
23
|
+
path = "/path/to/url"
|
24
|
+
|
25
|
+
ApiQueries.should_receive(:http_client).and_return(http_client)
|
26
|
+
http_client.should_receive(:get).with(
|
27
|
+
client_base_url + path).and_return(response)
|
28
|
+
|
29
|
+
subject.api_get(path)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should delegate to the ApiQueries post method with query parameters" do
|
33
|
+
path = "/path/to/url"
|
34
|
+
query = { query: { param: "value" } }
|
35
|
+
|
36
|
+
ApiQueries.should_receive(:http_client).and_return(http_client)
|
37
|
+
http_client.should_receive(:get).with(
|
38
|
+
client_base_url + path, query).and_return(response)
|
39
|
+
|
40
|
+
subject.api_get(path, query)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "POST" do
|
45
|
+
|
46
|
+
it "should delegate to the ApiQueries post method" do
|
47
|
+
path = "/path/to/url"
|
48
|
+
|
49
|
+
ApiQueries.should_receive(:http_client).and_return(http_client)
|
50
|
+
http_client.should_receive(:post).with(
|
51
|
+
client_base_url + path).and_return(response)
|
52
|
+
|
53
|
+
subject.api_post(path)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should delegate to the ApiQueries post method with query parameters" do
|
57
|
+
path = "/path/to/url"
|
58
|
+
query = { query: { param: "value" } }
|
59
|
+
|
60
|
+
ApiQueries.should_receive(:http_client).and_return(http_client)
|
61
|
+
http_client.should_receive(:post).with(
|
62
|
+
client_base_url + path, query).and_return(response)
|
63
|
+
|
64
|
+
subject.api_post(path, query)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Sinicum
|
4
|
+
module Jcr
|
5
|
+
module Cache
|
6
|
+
describe GlobalCache do
|
7
|
+
let(:prefix) { "http://content.dievision.de:80/sinicum-rest" }
|
8
|
+
let(:api_response) do
|
9
|
+
File.read(File.dirname(__FILE__) + "/../../../fixtures/api/cache_global.json")
|
10
|
+
end
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
::Sinicum::Jcr::ApiQueries.configure_jcr = { host: "content.dievision.de" }
|
14
|
+
end
|
15
|
+
|
16
|
+
before(:each) do
|
17
|
+
stub_request(:get, "#{prefix}/_cache/global").to_return(
|
18
|
+
body: api_response,
|
19
|
+
headers: { "Content-Type" => "application/json" }
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return the current key" do
|
24
|
+
GlobalCache.new.current_key.should eq("a11cd0d31248427cbadfd8a7bc51e04e96e4de98")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Sinicum
|
4
|
+
module Jcr
|
5
|
+
module Dam
|
6
|
+
describe Document do
|
7
|
+
let(:api_response) do
|
8
|
+
File.read(File.dirname(__FILE__) + "/../../../fixtures/api/file_mgnl5.json")
|
9
|
+
end
|
10
|
+
let(:json) { MultiJson.load(api_response).first }
|
11
|
+
|
12
|
+
subject do
|
13
|
+
::Sinicum::Jcr::NodeInitializer.initialize_node_from_json(json)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "when created from JSON" do
|
17
|
+
it { should be_kind_of Document }
|
18
|
+
its(:name) { should eq("Tecnotes_18_Sommer_10") }
|
19
|
+
its(:subject) { should eq("TecNotes Ausgabe 18, Sommer 2010") }
|
20
|
+
its(:description) { should eq("Some Description") }
|
21
|
+
its(:file_size) { should eq(562_116_5) }
|
22
|
+
its(:file_name) { should eq("Tecnotes_18_Sommer_10.pdf") }
|
23
|
+
its(:mime_type) { should eq("application/pdf") }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "date" do
|
27
|
+
it "should have the correct date when 'date1' is given" do
|
28
|
+
subject.date.should eq(Date.new(2013, 06, 05))
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have the correct date when 'date1' is not defined" do
|
32
|
+
subject.stub(:[]).with(:date1).and_return(nil)
|
33
|
+
unless defined?(JRUBY_VERSION)
|
34
|
+
subject.date.should eq(DateTime.new(2010, 7, 27, 14, 41, 4.105, "+0200"))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should return a web-compatible path" do
|
40
|
+
subject.path.should eq(
|
41
|
+
"/damfiles/default/shure/support_downloads/education/tecnotes/Tecnotes_18_Sommer_10" \
|
42
|
+
"-79209c1a63d7435f3f2179e31c104ef8.pdf")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should accept a 'converter_name' argument to specify the converter" do
|
46
|
+
subject.path(converter: "some_converter").should eq(
|
47
|
+
"/damfiles/some_converter/shure/support_downloads/education/tecnotes/" \
|
48
|
+
"Tecnotes_18_Sommer_10-79209c1a63d7435f3f2179e31c104ef8.pdf")
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "fingerprint" do
|
52
|
+
let(:default_fingerprint) { "79209c1a63d7435f3f2179e31c104ef8" }
|
53
|
+
|
54
|
+
its(:fingerprint) { should eq(default_fingerprint) }
|
55
|
+
|
56
|
+
it "should depend on the path" do
|
57
|
+
subject.stub(:jcr_path).and_return("different")
|
58
|
+
subject.send(:fingerprint).should_not eq(default_fingerprint)
|
59
|
+
subject.send(:fingerprint).should =~ /^[a-f0-9]{32}$/
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should depend on the id" do
|
63
|
+
subject.stub(:id).and_return("different")
|
64
|
+
subject.send(:fingerprint).should_not eq(default_fingerprint)
|
65
|
+
subject.send(:fingerprint).should =~ /^[a-f0-9]{32}$/
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should depend on the various other attributes" do
|
69
|
+
doc = double("document")
|
70
|
+
doc.stub(:[]).with(:"jcr:lastModified").and_return("different")
|
71
|
+
doc.stub(:[]).with(:"jcr:lastModifiedBy").and_return("different")
|
72
|
+
doc.stub(:[]).with(:size).and_return("different")
|
73
|
+
subject.stub(:[]).with(:'jcr:content').and_return(doc)
|
74
|
+
subject.send(:fingerprint).should_not eq(default_fingerprint)
|
75
|
+
subject.send(:fingerprint).should =~ /^[a-f0-9]{32}$/
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Sinicum
|
4
|
+
module Jcr
|
5
|
+
module Dam
|
6
|
+
describe Document do
|
7
|
+
let(:api_response) do
|
8
|
+
File.read(File.dirname(__FILE__) + "/../../../fixtures/api/image_mgnl5.json")
|
9
|
+
end
|
10
|
+
let(:json) { MultiJson.load(api_response).first }
|
11
|
+
|
12
|
+
subject do
|
13
|
+
::Sinicum::Jcr::NodeInitializer.initialize_node_from_json(json)
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "when created from JSON" do
|
17
|
+
it { should be_kind_of Image }
|
18
|
+
it { should be_kind_of Document }
|
19
|
+
its(:width) { should eq(300) }
|
20
|
+
its(:height) { should eq(110) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "alt tag" do
|
24
|
+
it "should take the alt attribute from the subject" do
|
25
|
+
subject.alt.should eq("A subject")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should return an empty string if no subject is given" do
|
29
|
+
subject.stub(:[]).with(:subject).and_return(nil)
|
30
|
+
subject.alt.should eq("")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "height and width" do
|
35
|
+
it "should consider a converter for the width" do
|
36
|
+
subject.width("teaser").should eq(960)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should consider a converter for the height" do
|
40
|
+
subject.height("teaser").should eq(444)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Sinicum; end
|
2
|
+
require_relative '../../../lib/sinicum/jcr/jcr_configuration'
|
3
|
+
|
4
|
+
module Sinicum
|
5
|
+
module Jcr
|
6
|
+
describe JcrConfiguration do
|
7
|
+
it "should respect the configuration parameters" do
|
8
|
+
config = JcrConfiguration.new(
|
9
|
+
host: "some.host", port: "8080", protocol: "https",
|
10
|
+
path_prefix: "/some_prefix", username: "user", password: "pass"
|
11
|
+
)
|
12
|
+
config.host.should eq("some.host")
|
13
|
+
config.port.should eq("8080")
|
14
|
+
config.protocol.should eq("https")
|
15
|
+
config.path_prefix.should eq("/some_prefix")
|
16
|
+
config.username.should eq("user")
|
17
|
+
config.password.should eq("pass")
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should add a / to the path prefix if not automatically given" do
|
21
|
+
subject.path_prefix = "some_prefix"
|
22
|
+
subject.path_prefix.should eq("/some_prefix")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should not add a / to the path prefix if it does not exist in the configuration" do
|
26
|
+
subject.path_prefix = "/some_prefix"
|
27
|
+
subject.path_prefix.should eq("/some_prefix")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should construct a right base url only with the mininum parameters" do
|
31
|
+
config = JcrConfiguration.new
|
32
|
+
config.base_url.should eq("http://localhost/sinicum-rest")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should construct a right base_proto_host_port only with the mininum parameters" do
|
36
|
+
config = JcrConfiguration.new
|
37
|
+
config.base_proto_host_port.should eq("http://localhost")
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should respect the various configuration parameters" do
|
41
|
+
config = JcrConfiguration.new(
|
42
|
+
host: "some.host", port: "8443", protocol: "https",
|
43
|
+
path_prefix: "some_prefix", username: "user", password: "pass"
|
44
|
+
)
|
45
|
+
config.base_url.should eq("https://some.host:8443/some_prefix")
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should respect the varios configuration parameters for the host part" do
|
49
|
+
config = JcrConfiguration.new(
|
50
|
+
host: "some.host", port: "8443", protocol: "https",
|
51
|
+
path_prefix: "some_prefix", username: "user", password: "pass"
|
52
|
+
)
|
53
|
+
config.base_proto_host_port.should eq("https://some.host:8443")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'digest/md5'
|
3
|
+
|
4
|
+
module Sinicum
|
5
|
+
module Jcr
|
6
|
+
describe NodeQueries do
|
7
|
+
let(:api_response) { File.read(File.dirname(__FILE__) + "/../../fixtures/api/homepage.json") }
|
8
|
+
let(:json_response) { MultiJson.load(api_response) }
|
9
|
+
let(:prefix) { "http://content.dievision.de:80/sinicum-rest" }
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
ApiQueries.configure_jcr = { host: "content.dievision.de" }
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "web access" do
|
16
|
+
before(:each) do
|
17
|
+
stub_request(:get, "#{prefix}/website/home")
|
18
|
+
.to_return(body: api_response, headers: { "Content-Type" => "application/json" })
|
19
|
+
stub_request(:get, "#{prefix}/website/_uuid/21cbc762-bdcd-4520-9eff-1928986fb419")
|
20
|
+
.to_return(body: api_response, headers: { "Content-Type" => "application/json" })
|
21
|
+
end
|
22
|
+
|
23
|
+
xit "should query for a node by path" do
|
24
|
+
Node.should_receive(:new).with(json_response: json_response.first)
|
25
|
+
result = Node.find_by_path("website", "home")
|
26
|
+
result.should be_a(Sinicum::Jcr::Node)
|
27
|
+
end
|
28
|
+
|
29
|
+
xit "should query for a node by uuid" do
|
30
|
+
Node.should_receive(:new).with(json_response: json_response.first)
|
31
|
+
result = Node.find_by_uuid("website", "21cbc762-bdcd-4520-9eff-1928986fb419")
|
32
|
+
result.should be_a(Sinicum::Jcr::Node)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "authentication" do
|
37
|
+
it "should use no authentication if no user and password is configured" do
|
38
|
+
stub_request(:get, "#{prefix}/website/home")
|
39
|
+
.to_return(body: api_response, headers: { "Content-Type" => "application/json" })
|
40
|
+
Node.should_receive(:new).with(json_response: json_response.first)
|
41
|
+
|
42
|
+
Node.find_by_path("website", "home")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should use no authentication if no user and password is configured" do
|
46
|
+
stub_request(:get, "user:pass@content.dievision.de/sinicum-rest/website/home")
|
47
|
+
.to_return(body: api_response, headers: { "Content-Type" => "application/json" })
|
48
|
+
ApiQueries.configure_jcr = {
|
49
|
+
host: "content.dievision.de",
|
50
|
+
username: "user",
|
51
|
+
password: "pass"
|
52
|
+
}
|
53
|
+
Node.should_receive(:new).with(json_response: json_response.first)
|
54
|
+
|
55
|
+
Node.find_by_path("website", "home")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "streaming" do
|
60
|
+
it "should construct the right url for streaming an attribute and stream the content" do
|
61
|
+
pending "The actual test seems wrong"
|
62
|
+
begin
|
63
|
+
image_file = File.join(File.dirname(__FILE__), "..", "..", "fixtures", "mock_image.gif")
|
64
|
+
tmp_file = File.join(File.dirname(__FILE__), "..", "..", "fixtures", "tmp.gif")
|
65
|
+
stub_request(:get, "http://content.dievision.de/sinicum-rest/dam/_binary/some/path")
|
66
|
+
.with(query: { "property" => "jcr:data" }).to_return(body: File.new(image_file))
|
67
|
+
|
68
|
+
target = File.open(tmp_file, "wb")
|
69
|
+
Node.stream_attribute(
|
70
|
+
"dam", "/some/path", "jcr:data", File.open(tmp_file, "wb")
|
71
|
+
)
|
72
|
+
WebMock.should have_requested(
|
73
|
+
:get,
|
74
|
+
"http://content.dievision.de/sinicum-rest/dam/_binary/some/path"
|
75
|
+
).with(query: { "property" => "jcr:data" })
|
76
|
+
target.close
|
77
|
+
|
78
|
+
Digest::MD5.hexdigest(File.read(tmp_file)).should eq(
|
79
|
+
Digest::MD5.hexdigest(File.read(tmp_file)))
|
80
|
+
ensure
|
81
|
+
File.delete(tmp_file) if File.exist?(tmp_file)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "queries" do
|
87
|
+
let(:api_response) do
|
88
|
+
File.read(File.dirname(__FILE__) + "/../../fixtures/api/query_result.json")
|
89
|
+
end
|
90
|
+
let(:json_response) { MultiJson.load(api_response) }
|
91
|
+
|
92
|
+
before(:each) do
|
93
|
+
stub_request(
|
94
|
+
:get,
|
95
|
+
"http://content.dievision.de/sinicum-rest/website/_query?" \
|
96
|
+
"query=/jcr:root/path//element(*, mgnl:page)&language=xpath"
|
97
|
+
).to_return(
|
98
|
+
status: 200,
|
99
|
+
body: api_response,
|
100
|
+
headers: { "Content-Type" => "application/json" }
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should return results based on a query" do
|
105
|
+
Node.should_receive(:new).with(json_response: json_response.first)
|
106
|
+
Node.should_receive(:new).with(json_response: json_response.last)
|
107
|
+
result = Node.query("website", :xpath, "/jcr:root/path//element(*, mgnl:page)")
|
108
|
+
result.should be_kind_of(Array)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|