locomotivecms_steam 1.0.0.pre.alpha → 1.0.0.pre.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +49 -34
  4. data/bin/steam.rb +1 -1
  5. data/lib/locomotive/steam.rb +8 -6
  6. data/lib/locomotive/steam/adapters/filesystem/simple_cache_store.rb +4 -0
  7. data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/content_type.rb +1 -1
  8. data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/page.rb +32 -10
  9. data/lib/locomotive/steam/adapters/filesystem/yaml_loaders/theme_asset.rb +31 -1
  10. data/lib/locomotive/steam/decorators/i18n_decorator.rb +1 -1
  11. data/lib/locomotive/steam/decorators/template_decorator.rb +1 -0
  12. data/lib/locomotive/steam/entities/content_entry.rb +9 -1
  13. data/lib/locomotive/steam/entities/content_type_field.rb +4 -0
  14. data/lib/locomotive/steam/entities/theme_asset.rb +8 -0
  15. data/lib/locomotive/steam/initializers/sprockets.rb +49 -0
  16. data/lib/locomotive/steam/liquid/filters/base.rb +5 -6
  17. data/lib/locomotive/steam/liquid/tags/editable/base.rb +4 -5
  18. data/lib/locomotive/steam/liquid/tags/extends.rb +1 -36
  19. data/lib/locomotive/steam/liquid/tags/inherited_block.rb +10 -4
  20. data/lib/locomotive/steam/liquid/tags/snippet.rb +8 -9
  21. data/lib/locomotive/steam/middlewares/dynamic_assets.rb +6 -36
  22. data/lib/locomotive/steam/middlewares/helpers.rb +9 -2
  23. data/lib/locomotive/steam/middlewares/site.rb +10 -2
  24. data/lib/locomotive/steam/models/associations/embedded.rb +1 -1
  25. data/lib/locomotive/steam/models/mapper.rb +2 -1
  26. data/lib/locomotive/steam/repositories.rb +1 -1
  27. data/lib/locomotive/steam/repositories/content_type_field_repository.rb +8 -0
  28. data/lib/locomotive/steam/repositories/theme_asset_repository.rb +1 -1
  29. data/lib/locomotive/steam/server.rb +0 -1
  30. data/lib/locomotive/steam/services.rb +7 -3
  31. data/lib/locomotive/steam/services/asset_host_service.rb +1 -3
  32. data/lib/locomotive/steam/services/image_resizer_service.rb +1 -3
  33. data/lib/locomotive/steam/services/liquid_parser_service.rb +1 -2
  34. data/lib/locomotive/steam/services/url_builder_service.rb +18 -1
  35. data/lib/locomotive/steam/version.rb +1 -1
  36. data/locomotivecms_steam.gemspec +9 -11
  37. data/spec/integration/repositories/theme_asset_repository_spec.rb +10 -0
  38. data/spec/support/helpers.rb +1 -0
  39. data/spec/support/liquid.rb +5 -0
  40. data/spec/unit/adapters/filesystem/simple_cache_store_spec.rb +27 -0
  41. data/spec/unit/adapters/filesystem/yaml_loaders/page_spec.rb +2 -0
  42. data/spec/unit/decorators/i18n_decorator_spec.rb +10 -0
  43. data/spec/unit/entities/content_entry_spec.rb +2 -2
  44. data/spec/unit/entities/content_type_field_spec.rb +15 -5
  45. data/spec/unit/entities/snippet_spec.rb +17 -0
  46. data/spec/unit/initializers/sprockets_spec.rb +25 -0
  47. data/spec/unit/liquid/drops/content_entry_collection_spec.rb +2 -0
  48. data/spec/unit/liquid/filters/html_spec.rb +28 -37
  49. data/spec/unit/liquid/tags/editable/control_spec.rb +4 -3
  50. data/spec/unit/liquid/tags/editable/file_spec.rb +7 -4
  51. data/spec/unit/liquid/tags/editable/text_spec.rb +4 -6
  52. data/spec/unit/liquid/tags/extends_spec.rb +3 -3
  53. data/spec/unit/liquid/tags/inherited_block_spec.rb +2 -2
  54. data/spec/unit/liquid/tags/nav_spec.rb +2 -2
  55. data/spec/unit/liquid/tags/snippet_spec.rb +3 -3
  56. data/spec/unit/middlewares/dynamic_assets_spec.rb +18 -9
  57. data/spec/unit/repositories/content_type_field_repository_spec.rb +51 -0
  58. data/spec/unit/services/url_builder_service_spec.rb +20 -3
  59. metadata +39 -56
  60. data/lib/locomotive/steam/core_ext.rb +0 -6
  61. data/lib/locomotive/steam/core_ext/array.rb +0 -3
  62. data/lib/locomotive/steam/core_ext/boolean/false.rb +0 -3
  63. data/lib/locomotive/steam/core_ext/boolean/true.rb +0 -3
  64. data/lib/locomotive/steam/core_ext/hash.rb +0 -39
  65. data/lib/locomotive/steam/core_ext/kernel.rb +0 -14
  66. data/lib/locomotive/steam/core_ext/string.rb +0 -37
  67. data/spec/fixtures/default/app/views/pages/songs.liquid +0 -6
  68. data/spec/unit/core_ext/string_spec.rb +0 -44
@@ -3,8 +3,6 @@ module Locomotive
3
3
 
4
4
  class AssetHostService
5
5
 
6
- IsHTTP = /^https?:\/\//o
7
-
8
6
  attr_reader :request, :site, :host
9
7
 
10
8
  def initialize(request, site, host)
@@ -16,7 +14,7 @@ module Locomotive
16
14
  def compute(source, timestamp = nil)
17
15
  return source if source.nil?
18
16
 
19
- return add_timestamp_suffix(source, timestamp) if source =~ IsHTTP
17
+ return add_timestamp_suffix(source, timestamp) if source =~ Steam::IsHTTP
20
18
 
21
19
  url = self.host ? URI.join(host, source).to_s : source
22
20
 
@@ -3,8 +3,6 @@ module Locomotive
3
3
 
4
4
  class ImageResizerService < Struct.new(:resizer, :asset_path)
5
5
 
6
- IsHTTP = /^https?:\/\//o
7
-
8
6
  def resize(source, geometry)
9
7
  return nil if disabled? || geometry.blank?
10
8
 
@@ -25,7 +23,7 @@ module Locomotive
25
23
  def fetch_file(source)
26
24
  url_or_path = get_url_or_path(source)
27
25
 
28
- if url_or_path =~ IsHTTP
26
+ if url_or_path =~ Steam::IsHTTP
29
27
  resizer.fetch_url(url_or_path)
30
28
  else
31
29
  path = url_or_path.sub(/(\?.*)$/, '')
@@ -3,10 +3,9 @@ module Locomotive
3
3
 
4
4
  class LiquidParserService < Struct.new(:parent_finder, :snippet_finder)
5
5
 
6
- def parse(page, events_listener = nil)
6
+ def parse(page)
7
7
  _parse(page,
8
8
  page: page,
9
- events_listener: events_listener,
10
9
  parent_finder: parent_finder,
11
10
  snippet_finder: snippet_finder,
12
11
  parser: self)
@@ -1,9 +1,13 @@
1
1
  module Locomotive
2
2
  module Steam
3
3
 
4
- class UrlBuilderService < Struct.new(:site, :current_locale)
4
+ class UrlBuilderService < Struct.new(:site, :current_locale, :request)
5
5
 
6
6
  def url_for(page, locale = nil)
7
+ prefix(_url_for(page, locale))
8
+ end
9
+
10
+ def _url_for(page, locale = nil)
7
11
  [''].tap do |segments|
8
12
  locale ||= current_locale
9
13
  same_locale = locale.to_sym == site.default_locale.to_sym
@@ -17,11 +21,24 @@ module Locomotive
17
21
  end
18
22
 
19
23
  def public_submission_url_for(content_type)
24
+ prefix(_public_submission_url_for(content_type))
25
+ end
26
+
27
+ def _public_submission_url_for(content_type)
20
28
  "/entry_submissions/#{content_type.slug}"
21
29
  end
22
30
 
23
31
  private
24
32
 
33
+ def prefix(url)
34
+ mounted_on ? "#{mounted_on}#{url}" : url
35
+ end
36
+
37
+ def mounted_on
38
+ return if request.nil?
39
+ request.env['steam.mounted_on']
40
+ end
41
+
25
42
  def sanitized_fullpath(page, same_locale)
26
43
  path = page.fullpath
27
44
 
@@ -3,6 +3,6 @@
3
3
  # 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0
4
4
  module Locomotive
5
5
  module Steam
6
- VERSION = '1.0.0-alpha'
6
+ VERSION = '1.0.0-alpha.1'
7
7
  end
8
8
  end
@@ -5,9 +5,8 @@ Gem::Specification.new do |spec|
5
5
  spec.version = Locomotive::Steam::VERSION
6
6
  spec.authors = ['Didier Lafforgue', 'Rodrigo Alvarez', 'Arnaud Sellenet', 'Joel Azemar']
7
7
  spec.email = ['did@locomotivecms.com', 'papipo@gmail.com', 'arnaud@sellenet.fr', 'joel.azemar@gmail.com']
8
- spec.description = %q{The LocomotiveCMS steam is a front end server LocomotiveCMS libraries}
9
- spec.summary = %q{The LocomotiveCMS steam is a technical piece for compiled and steam front end stuff for LocomotiveCMS libraries}
10
- spec.homepage = 'http://www.locomotivecms.com'
8
+ spec.description = %q{The LocomotiveCMS Steam is the rendering stack used by both Wagon and Engine}
9
+ spec.summary = %q{The LocomotiveCMS Steam is the rendering stack used by both Wagon and Engine}
11
10
  spec.homepage = 'https://github.com/locomotivecms/steam'
12
11
  spec.license = 'MIT'
13
12
 
@@ -22,32 +21,31 @@ Gem::Specification.new do |spec|
22
21
  spec.add_development_dependency 'moped', '~> 2.0.4'
23
22
  spec.add_development_dependency 'origin', '~> 2.1.1'
24
23
 
25
- spec.add_dependency 'activesupport', '~> 4.2.1'
26
- spec.add_dependency 'stringex', '~> 2.5.2'
27
- spec.add_dependency 'sanitize', '~> 3.1.2'
24
+ spec.add_dependency 'sanitize', '~> 4.0.0'
28
25
  spec.add_dependency 'morphine', '~> 0.1.1'
29
26
  spec.add_dependency 'httparty', '~> 0.13.3'
30
27
  spec.add_dependency 'chronic', '~> 0.10.2'
31
28
 
32
29
  spec.add_dependency 'rack-rewrite', '~> 1.5.1'
33
30
  spec.add_dependency 'rack-cache', '~> 1.2'
34
- spec.add_dependency 'dragonfly', '~> 1.0.7'
31
+ spec.add_dependency 'dragonfly', '~> 1.0.9'
35
32
  spec.add_dependency 'moneta', '~> 0.8.0'
36
33
  spec.add_dependency 'rack_csrf', '~> 2.5.0'
37
34
 
38
35
  spec.add_dependency 'sprockets', '~> 2.12.3'
39
36
  spec.add_dependency 'sprockets-sass', '~> 1.3.1'
40
- spec.add_dependency 'coffee-script', '~> 2.3.0'
37
+ spec.add_dependency 'sprockets-less', '~> 0.6.1'
38
+ spec.add_dependency 'coffee-script', '~> 2.4.1'
41
39
  spec.add_dependency 'compass', '~> 1.0.3'
42
40
 
43
- spec.add_dependency 'kramdown', '~> 1.6.0'
41
+ spec.add_dependency 'kramdown', '~> 1.7.0'
44
42
  spec.add_dependency 'RedCloth', '~> 4.2.9'
45
43
  spec.add_dependency 'haml', '~> 4.0.6'
46
44
  spec.add_dependency 'mimetype-fu', '~> 0.1.2'
47
- spec.add_dependency 'mime-types', '~> 2.4.3'
45
+ spec.add_dependency 'mime-types', '~> 2.5.0'
48
46
 
49
47
  spec.add_dependency 'locomotivecms-solid', '~> 4.0.0.alpha2'
50
- spec.add_dependency 'locomotivecms_common', '~> 0.0.2'
48
+ spec.add_dependency 'locomotivecms_common', '~> 0.0.4'
51
49
 
52
50
  spec.required_ruby_version = '>= 2.0'
53
51
  end
@@ -13,6 +13,11 @@ describe Locomotive::Steam::ThemeAssetRepository do
13
13
  let(:site_id) { BSON::ObjectId.from_string('54eb49c12475804b2b000002') }
14
14
  let(:adapter) { Locomotive::Steam::MongoDBAdapter.new(database: 'steam_test', hosts: ['127.0.0.1:27017']) }
15
15
 
16
+ describe '#all' do
17
+ subject { repository.all }
18
+ it { expect(subject.size).to eq 16 }
19
+ end
20
+
16
21
  describe '#url_for' do
17
22
  subject { repository.url_for('stylesheets/application.css') }
18
23
  it { is_expected.to eq '/sites/54eb49c12475804b2b000002/theme/stylesheets/application.css' }
@@ -31,6 +36,11 @@ describe Locomotive::Steam::ThemeAssetRepository do
31
36
  let(:site_id) { 1 }
32
37
  let(:adapter) { Locomotive::Steam::FilesystemAdapter.new(default_fixture_site_path) }
33
38
 
39
+ describe '#all' do
40
+ subject { repository.all }
41
+ it { expect(subject.size).to eq 16 }
42
+ end
43
+
34
44
  describe '#url_for' do
35
45
  subject { repository.url_for('stylesheets/application.css') }
36
46
  it { is_expected.to eq '/stylesheets/application.css' }
@@ -42,5 +42,6 @@ module Spec
42
42
  def env_for(url, opts={})
43
43
  Rack::MockRequest.env_for(url, opts)
44
44
  end
45
+
45
46
  end
46
47
  end
@@ -10,6 +10,11 @@ end
10
10
 
11
11
  module Liquid
12
12
  class SimpleEventsListener
13
+ def initialize
14
+ ActiveSupport::Notifications.subscribe(/^steam\.parse\./) do |name, start, finish, id, payload|
15
+ emit(name, payload)
16
+ end
17
+ end
13
18
  def emit(name, options = {})
14
19
  (@stack ||= []) << [name, options]
15
20
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ require_relative '../../../../lib/locomotive/steam/adapters/filesystem/simple_cache_store.rb'
4
+
5
+ describe Locomotive::Steam::Adapters::Filesystem::SimpleCacheStore do
6
+
7
+ let(:store) { described_class.new }
8
+
9
+ describe '#fetch' do
10
+
11
+ subject { store.read(:title) }
12
+ before { store.fetch(:title) { 'Hello world' } }
13
+
14
+ it { is_expected.to eq 'Hello world' }
15
+
16
+ end
17
+
18
+ describe '#delete' do
19
+
20
+ subject { store.fetch(:title) }
21
+ before { store.fetch(:title) { 'Hello world' }; store.delete(:title) }
22
+
23
+ it { is_expected.to eq nil }
24
+
25
+ end
26
+
27
+ end
@@ -18,6 +18,8 @@ describe Locomotive::Steam::Adapters::Filesystem::YAMLLoaders::Page do
18
18
  expect(subject.size).to eq 24
19
19
  expect(subject.first[:title]).to eq(en: 'Page not found')
20
20
  expect(subject[14][:slug]).to eq(en: 'music', fr: 'notre-musique')
21
+ expect(subject[15][:_fullpath]).to eq 'songs'
22
+ expect(subject[15][:template_path]).to eq(en: false)
21
23
  end
22
24
 
23
25
  end
@@ -26,6 +26,16 @@ describe Locomotive::Steam::Decorators::I18nDecorator do
26
26
  expect(decorated.title).to eq 'Bonjour le monde'
27
27
  end
28
28
 
29
+ describe 'the field is nil' do
30
+
31
+ let(:field) { nil }
32
+
33
+ it 'returns nil if the attribute was originally nil' do
34
+ expect(decorated.title).to eq nil
35
+ end
36
+
37
+ end
38
+
29
39
  describe 'using a different locale' do
30
40
 
31
41
  before { decorated.__locale__ = 'en' }
@@ -133,10 +133,10 @@ describe Locomotive::Steam::ContentEntry do
133
133
 
134
134
  context 'a file' do
135
135
  let(:field_type) { :file }
136
- let(:value) { 'foo.png' }
136
+ let(:value) { '/foo.png' }
137
137
  it { expect(subject.url).to eq('/foo.png') }
138
138
  context 'localized' do
139
- let(:value) { build_i18n_field(en: 'foo-en.png', fr: 'foo-fr.png') }
139
+ let(:value) { build_i18n_field(en: '/foo-en.png', fr: '/foo-fr.png') }
140
140
  it { expect(subject.translations[:en].url).to eq('/foo-en.png') }
141
141
  it { expect(subject.translations[:fr].url).to eq('/foo-fr.png') }
142
142
  end
@@ -3,18 +3,18 @@ require 'spec_helper'
3
3
  describe Locomotive::Steam::ContentTypeField do
4
4
 
5
5
  let(:attributes) { { name: 'title', type: 'string' } }
6
- let(:content_type) { described_class.new(attributes) }
6
+ let(:field) { described_class.new(attributes) }
7
7
 
8
8
  describe '#type' do
9
9
 
10
- subject { content_type.type }
10
+ subject { field.type }
11
11
  it { is_expected.to eq :string }
12
12
 
13
13
  end
14
14
 
15
15
  describe '#order_by' do
16
16
 
17
- subject { content_type.order_by }
17
+ subject { field.order_by }
18
18
  it { is_expected.to eq nil }
19
19
 
20
20
  context 'has_many field' do
@@ -35,7 +35,7 @@ describe Locomotive::Steam::ContentTypeField do
35
35
 
36
36
  describe '#target_id' do
37
37
 
38
- subject { content_type.target_id }
38
+ subject { field.target_id }
39
39
  it { is_expected.to eq nil }
40
40
 
41
41
  context 'slug' do
@@ -58,10 +58,20 @@ describe Locomotive::Steam::ContentTypeField do
58
58
 
59
59
  let(:attributes) { { name: 'articles', class_name: 'articles', type: 'has_many', inverse_of: 'author' } }
60
60
 
61
- subject { content_type.association_options }
61
+ subject { field.association_options }
62
62
 
63
63
  it { is_expected.to eq(target_id: 'articles', inverse_of: 'author', order_by: { position_in_author: 'asc' }) }
64
64
 
65
65
  end
66
66
 
67
+ describe '#is_relationship?' do
68
+
69
+ let(:attributes) { { name: 'articles', class_name: 'articles', type: 'has_many', inverse_of: 'author' } }
70
+
71
+ subject { field.is_relationship? }
72
+
73
+ it { is_expected.to eq true }
74
+
75
+ end
76
+
67
77
  end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Locomotive::Steam::Snippet do
4
+
5
+ let(:attributes) { {} }
6
+ let(:snippet) { described_class.new(attributes) }
7
+
8
+ describe '#source' do
9
+
10
+ let(:attributes) { { template: 'Hello world' } }
11
+
12
+ subject { snippet.source }
13
+ it { is_expected.to eq 'Hello world' }
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ require_relative '../../../lib/locomotive/steam/initializers/sprockets'
4
+
5
+ describe Locomotive::Steam::SprocketsEnvironment do
6
+
7
+ let(:root) { '.' }
8
+ let(:options) { { minify: true } }
9
+ let(:env) { described_class.new(root, options) }
10
+
11
+ describe '#install_yui_compressor' do
12
+
13
+ context 'java not installed' do
14
+
15
+ before { allow(env).to receive(:is_java_installed?).and_return(false) }
16
+
17
+ subject { env.send(:install_yui_compressor, options) }
18
+
19
+ it { is_expected.to eq(false) }
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -8,6 +8,8 @@ describe Locomotive::Steam::Liquid::Drops::ContentEntryCollection do
8
8
  let(:context) { ::Liquid::Context.new(assigns, {}, { services: services }) }
9
9
  let(:drop) { described_class.new(content_type).tap { |d| d.context = context } }
10
10
 
11
+ before { allow(services).to receive(:current_site).and_return(nil) }
12
+
11
13
  describe '#public_submission_url' do
12
14
  it { expect(drop.public_submission_url).to eq '/entry_submissions/articles' }
13
15
  end
@@ -6,7 +6,7 @@ describe Locomotive::Steam::Liquid::Filters::Html do
6
6
  include Locomotive::Steam::Liquid::Filters::Html
7
7
 
8
8
  let(:site) { instance_double('Site', _id: 42)}
9
- let(:services) { Locomotive::Steam::Services.build_instance.tap { |s| s.repositories.current_site = site } }
9
+ let(:services) { Locomotive::Steam::Services.build_instance }
10
10
  let(:context) { instance_double('Context', registers: { services: services }) }
11
11
 
12
12
  let(:theme_asset_url) { services.theme_asset_url }
@@ -14,6 +14,8 @@ describe Locomotive::Steam::Liquid::Filters::Html do
14
14
 
15
15
  before { services.repositories.theme_asset = EngineThemeAsset.new(nil, site) }
16
16
 
17
+ before { allow(services).to receive(:current_site).and_return(site) }
18
+
17
19
  before { @context = context }
18
20
 
19
21
  it 'writes the tag to display a rss/atom feed' do
@@ -63,20 +65,17 @@ describe Locomotive::Steam::Liquid::Filters::Html do
63
65
  end
64
66
 
65
67
  it 'returns an url for a stylesheet file without touching the url that starts with "http:"' do
66
- result = "http://cdn.example.com/trash/main.css"
67
- expect(stylesheet_url('http://cdn.example.com/trash/main.css')).to eq(result)
68
- expect(stylesheet_url('http://cdn.example.com/trash/main')).to eq(result)
68
+ expect(stylesheet_url('http://cdn.example.com/trash/main.css')).to eq "http://cdn.example.com/trash/main.css"
69
69
  end
70
70
 
71
71
  it 'returns an url for a stylesheet file without touching the url that starts with "https:"' do
72
- result = "https://cdn.example.com/trash/main.css"
73
- expect(stylesheet_url('https://cdn.example.com/trash/main.css')).to eq(result)
74
- expect(stylesheet_url('https://cdn.example.com/trash/main')).to eq(result)
72
+ expect(stylesheet_url('https://cdn.example.com/trash/main.css')).to eq "https://cdn.example.com/trash/main.css"
75
73
  end
76
74
 
77
75
  it 'returns an url for a stylesheet file with respect to URL-parameters' do
78
76
  result = "/sites/42/theme/stylesheets/main.css?v=42"
79
77
  expect(stylesheet_url('main.css?v=42')).to eq(result)
78
+ expect(stylesheet_url('main?v=42')).to eq(result)
80
79
  end
81
80
 
82
81
  it 'returns a link tag for a stylesheet file' do
@@ -92,21 +91,16 @@ describe Locomotive::Steam::Liquid::Filters::Html do
92
91
  end
93
92
 
94
93
  it 'returns a link tag for a stylesheet file without touching the url that starts with "/"' do
95
- result = "<link href=\"/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
96
- expect(stylesheet_tag('/trash/main.css')).to eq(result)
97
- expect(stylesheet_tag('/trash/main')).to eq(result)
94
+ expect(stylesheet_tag('/trash/main.css')).to eq "<link href=\"/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
95
+ expect(stylesheet_tag('/trash/main')).to eq "<link href=\"/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
98
96
  end
99
97
 
100
98
  it 'returns a link tag for a stylesheet file without touching the url that starts with "http:"' do
101
- result = "<link href=\"http://cdn.example.com/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
102
- expect(stylesheet_tag('http://cdn.example.com/trash/main.css')).to eq(result)
103
- expect(stylesheet_tag('http://cdn.example.com/trash/main')).to eq(result)
99
+ expect(stylesheet_tag('http://cdn.example.com/trash/main.css')).to eq "<link href=\"http://cdn.example.com/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
104
100
  end
105
101
 
106
102
  it 'returns a link tag for a stylesheet file without touching the url that starts with "https:"' do
107
- result = "<link href=\"https://cdn.example.com/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
108
- expect(stylesheet_tag('https://cdn.example.com/trash/main.css')).to eq(result)
109
- expect(stylesheet_tag('https://cdn.example.com/trash/main')).to eq(result)
103
+ expect(stylesheet_tag('https://cdn.example.com/trash/main.css')).to eq "<link href=\"https://cdn.example.com/trash/main.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />"
110
104
  end
111
105
 
112
106
  it 'returns a link tag for a stylesheet stored in Amazon S3' do
@@ -135,15 +129,13 @@ describe Locomotive::Steam::Liquid::Filters::Html do
135
129
  end
136
130
 
137
131
  it 'returns a link tag for a stylesheet file without touching the url that starts with "http:" and media attribute set to print' do
138
- result = "<link href=\"http://cdn.example.com/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
139
- expect(stylesheet_tag('http://cdn.example.com/trash/main.css','print')).to eq(result)
140
- expect(stylesheet_tag('http://cdn.example.com/trash/main','print')).to eq(result)
132
+ expect(stylesheet_tag('http://cdn.example.com/trash/main.css', 'print')).to eq "<link href=\"http://cdn.example.com/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
133
+ expect(stylesheet_tag('http://cdn.example.com/trash/main', 'print')).to eq "<link href=\"http://cdn.example.com/trash/main\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
141
134
  end
142
135
 
143
136
  it 'returns a link tag for a stylesheet file without touching the url that starts with "https:" and media attribute set to print' do
144
- result = "<link href=\"https://cdn.example.com/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
145
- expect(stylesheet_tag('https://cdn.example.com/trash/main.css','print')).to eq(result)
146
- expect(stylesheet_tag('https://cdn.example.com/trash/main','print')).to eq(result)
137
+ expect(stylesheet_tag('https://cdn.example.com/trash/main.css', 'print')).to eq "<link href=\"https://cdn.example.com/trash/main.css\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
138
+ expect(stylesheet_tag('https://cdn.example.com/trash/main', 'print')).to eq "<link href=\"https://cdn.example.com/trash/main\" media=\"print\" rel=\"stylesheet\" type=\"text/css\" />"
147
139
  end
148
140
 
149
141
  it 'returns an url for a javascript file' do
@@ -166,20 +158,17 @@ describe Locomotive::Steam::Liquid::Filters::Html do
166
158
  end
167
159
 
168
160
  it 'returns an url for a javascript file without touching the url that starts with "http:"' do
169
- result = "http://cdn.example.com/trash/main.js"
170
- expect(javascript_url('http://cdn.example.com/trash/main.js')).to eq(result)
171
- expect(javascript_url('http://cdn.example.com/trash/main')).to eq(result)
161
+ expect(javascript_url('http://cdn.example.com/trash/main.js')).to eq "http://cdn.example.com/trash/main.js"
162
+ expect(javascript_url('http://cdn.example.com/trash/main')).to eq "http://cdn.example.com/trash/main"
172
163
  end
173
164
 
174
165
  it 'returns an url for a javascript file without touching the url that starts with "https:"' do
175
- result = "https://cdn.example.com/trash/main.js"
176
- expect(javascript_url('https://cdn.example.com/trash/main.js')).to eq(result)
177
- expect(javascript_url('https://cdn.example.com/trash/main')).to eq(result)
166
+ expect(javascript_url('https://cdn.example.com/trash/main.js')).to eq "https://cdn.example.com/trash/main.js"
167
+ expect(javascript_url('https://cdn.example.com/trash/main')).to eq "https://cdn.example.com/trash/main"
178
168
  end
179
169
 
180
170
  it 'returns an url for a javascript file with respect to URL-parameters' do
181
- result = "/sites/42/theme/javascripts/main.js?v=42"
182
- expect(javascript_url('main.js?v=42')).to eq(result)
171
+ expect(javascript_url('main.js?v=42')).to eq "/sites/42/theme/javascripts/main.js?v=42"
183
172
  end
184
173
 
185
174
  it 'returns a script tag for a javascript file' do
@@ -202,15 +191,13 @@ describe Locomotive::Steam::Liquid::Filters::Html do
202
191
  end
203
192
 
204
193
  it 'returns a script tag for a javascript file without touching the url that starts with "http:"' do
205
- result = %{<script src="http://cdn.example.com/trash/main.js" type="text/javascript" ></script>}
206
- expect(javascript_tag('http://cdn.example.com/trash/main.js')).to eq(result)
207
- expect(javascript_tag('http://cdn.example.com/trash/main')).to eq(result)
194
+ expect(javascript_tag('http://cdn.example.com/trash/main.js')).to eq %{<script src="http://cdn.example.com/trash/main.js" type="text/javascript" ></script>}
195
+ expect(javascript_tag('http://cdn.example.com/trash/main')).to eq %{<script src="http://cdn.example.com/trash/main" type="text/javascript" ></script>}
208
196
  end
209
197
 
210
198
  it 'returns a script tag for a javascript file without touching the url that starts with "https:"' do
211
- result = %{<script src="https://cdn.example.com/trash/main.js" type="text/javascript" ></script>}
212
- expect(javascript_tag('https://cdn.example.com/trash/main.js')).to eq(result)
213
- expect(javascript_tag('https://cdn.example.com/trash/main')).to eq(result)
199
+ expect(javascript_tag('https://cdn.example.com/trash/main.js')).to eq %{<script src="https://cdn.example.com/trash/main.js" type="text/javascript" ></script>}
200
+ expect(javascript_tag('https://cdn.example.com/trash/main')).to eq %{<script src="https://cdn.example.com/trash/main" type="text/javascript" ></script>}
214
201
  end
215
202
 
216
203
  it 'returns a script tag for a javascript file with "defer" option' do
@@ -219,7 +206,7 @@ describe Locomotive::Steam::Liquid::Filters::Html do
219
206
  end
220
207
 
221
208
  it 'returns an image tag for a given theme file without parameters' do
222
- expect(theme_image_tag('foo.jpg')).to eq("<img src=\"/sites/42/theme/images/foo.jpg\" >")
209
+ expect(theme_image_tag('foo.jpg')).to eq "<img src=\"/sites/42/theme/images/foo.jpg\" >"
223
210
  end
224
211
 
225
212
  it 'returns an image tag for a given theme file with size' do
@@ -230,6 +217,10 @@ describe Locomotive::Steam::Liquid::Filters::Html do
230
217
  expect(image_tag('foo.jpg')).to eq("<img src=\"foo.jpg\" >")
231
218
  end
232
219
 
220
+ it 'returns an image tag for a file with a leading slash' do
221
+ expect(image_tag('/foo.jpg')).to eq "<img src=\"/foo.jpg\" >"
222
+ end
223
+
233
224
  it 'returns an image tag with size' do
234
225
  expect(image_tag('foo.jpg', 'width:100', 'height:50')).to eq("<img src=\"foo.jpg\" height=\"50\" width=\"100\" >")
235
226
  end