locomotivecms_wagon 3.0.0 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/bin/wagon +64 -3
  4. data/bin/wagon_dev +11 -0
  5. data/generators/.DS_Store +0 -0
  6. data/generators/blank/Gemfile.tt +6 -2
  7. data/generators/blank/app/assets/stylesheets/app.scss +2 -0
  8. data/generators/blank/app/assets/stylesheets/sections/.empty_directory +1 -0
  9. data/generators/blank/app/views/pages/404.liquid +1 -1
  10. data/generators/blank/app/views/pages/index.liquid +1 -1
  11. data/generators/section/%type%.scss.tt +3 -0
  12. data/generators/section/template.liquid.tt +139 -80
  13. data/generators/webpack/app/assets/javascripts/.DS_Store +0 -0
  14. data/lib/locomotive/wagon.rb +15 -1
  15. data/lib/locomotive/wagon/cli.rb +11 -11
  16. data/lib/locomotive/wagon/commands/generate_command.rb +2 -7
  17. data/lib/locomotive/wagon/commands/push_command.rb +4 -8
  18. data/lib/locomotive/wagon/commands/serve_command.rb +5 -5
  19. data/lib/locomotive/wagon/generators/section.rb +121 -17
  20. data/lib/locomotive/wagon/generators/site/base.rb +0 -23
  21. data/lib/locomotive/wagon/version.rb +1 -1
  22. data/locomotivecms_wagon.gemspec +7 -4
  23. metadata +14 -233
  24. data/.gitignore +0 -36
  25. data/.rspec +0 -1
  26. data/.travis.yml +0 -11
  27. data/Gemfile +0 -30
  28. data/Rakefile +0 -32
  29. data/spec/fixtures/blog/app/content_types/comments.yml +0 -20
  30. data/spec/fixtures/blog/app/content_types/posts.yml +0 -19
  31. data/spec/fixtures/blog/app/views/pages/404.liquid +0 -11
  32. data/spec/fixtures/blog/app/views/pages/about-us.liquid.haml +0 -29
  33. data/spec/fixtures/blog/app/views/pages/index.liquid +0 -25
  34. data/spec/fixtures/blog/app/views/pages/posts.fr.liquid +0 -13
  35. data/spec/fixtures/blog/app/views/pages/posts.liquid +0 -13
  36. data/spec/fixtures/blog/app/views/pages/posts/content_type_template.fr.liquid +0 -14
  37. data/spec/fixtures/blog/app/views/pages/posts/content_type_template.liquid +0 -15
  38. data/spec/fixtures/blog/config/deploy.yml +0 -4
  39. data/spec/fixtures/blog/config/site.yml +0 -16
  40. data/spec/fixtures/blog/data/comments.yml +0 -16
  41. data/spec/fixtures/blog/data/posts.yml +0 -7
  42. data/spec/fixtures/cassettes/authenticate.yml +0 -236
  43. data/spec/fixtures/cassettes/delete.yml +0 -1255
  44. data/spec/fixtures/cassettes/push.yml +0 -9946
  45. data/spec/fixtures/cassettes/sync.yml +0 -11462
  46. data/spec/fixtures/default/README +0 -0
  47. data/spec/fixtures/default/app/content_types/bands.yml +0 -21
  48. data/spec/fixtures/default/app/content_types/events.yml +0 -25
  49. data/spec/fixtures/default/app/content_types/messages.yml +0 -17
  50. data/spec/fixtures/default/app/content_types/songs.yml +0 -25
  51. data/spec/fixtures/default/app/content_types/updates.yml +0 -33
  52. data/spec/fixtures/default/app/views/pages/404.liquid.haml +0 -10
  53. data/spec/fixtures/default/app/views/pages/about_us.fr.liquid.haml +0 -7
  54. data/spec/fixtures/default/app/views/pages/about_us.liquid.haml +0 -21
  55. data/spec/fixtures/default/app/views/pages/about_us.nb.liquid.haml +0 -4
  56. data/spec/fixtures/default/app/views/pages/about_us/jane_doe.liquid.haml +0 -4
  57. data/spec/fixtures/default/app/views/pages/about_us/john_doe.fr.liquid.haml +0 -5
  58. data/spec/fixtures/default/app/views/pages/about_us/john_doe.liquid.haml +0 -6
  59. data/spec/fixtures/default/app/views/pages/all.liquid.haml +0 -16
  60. data/spec/fixtures/default/app/views/pages/archives/news.liquid.haml +0 -10
  61. data/spec/fixtures/default/app/views/pages/contact.liquid.haml +0 -54
  62. data/spec/fixtures/default/app/views/pages/contest.liquid.haml +0 -18
  63. data/spec/fixtures/default/app/views/pages/events.liquid.haml +0 -64
  64. data/spec/fixtures/default/app/views/pages/filtered.liquid.haml +0 -20
  65. data/spec/fixtures/default/app/views/pages/grunge_bands.liquid.haml +0 -8
  66. data/spec/fixtures/default/app/views/pages/index.fr.liquid.haml +0 -3
  67. data/spec/fixtures/default/app/views/pages/index.liquid.haml +0 -101
  68. data/spec/fixtures/default/app/views/pages/layouts/simple.liquid.haml +0 -13
  69. data/spec/fixtures/default/app/views/pages/music.fr.liquid.haml +0 -4
  70. data/spec/fixtures/default/app/views/pages/music.liquid.haml +0 -42
  71. data/spec/fixtures/default/app/views/pages/songs/template.fr.liquid.haml +0 -16
  72. data/spec/fixtures/default/app/views/pages/songs/template.liquid.haml +0 -18
  73. data/spec/fixtures/default/app/views/pages/songs/template/band.liquid.haml +0 -16
  74. data/spec/fixtures/default/app/views/pages/store.fr.liquid.haml +0 -5
  75. data/spec/fixtures/default/app/views/pages/store.liquid +0 -5
  76. data/spec/fixtures/default/app/views/pages/tags/nav.liquid.haml +0 -6
  77. data/spec/fixtures/default/app/views/pages/tags/nav_in_deep.liquid.haml +0 -6
  78. data/spec/fixtures/default/app/views/pages/unlisted_pages.liquid.haml +0 -9
  79. data/spec/fixtures/default/app/views/snippets/A_Complicated-one.liquid.haml +0 -1
  80. data/spec/fixtures/default/app/views/snippets/footer.liquid.haml +0 -6
  81. data/spec/fixtures/default/app/views/snippets/header.liquid.haml +0 -1
  82. data/spec/fixtures/default/app/views/snippets/song.fr.liquid.haml +0 -8
  83. data/spec/fixtures/default/app/views/snippets/song.liquid +0 -12
  84. data/spec/fixtures/default/config/autoprefixer.yml +0 -2
  85. data/spec/fixtures/default/config/deploy.yml +0 -12
  86. data/spec/fixtures/default/config/deploy_example.yml +0 -12
  87. data/spec/fixtures/default/config/site.yml +0 -13
  88. data/spec/fixtures/default/config/translations.yml +0 -3
  89. data/spec/fixtures/default/data/bands.yml +0 -13
  90. data/spec/fixtures/default/data/events.yml +0 -54
  91. data/spec/fixtures/default/data/songs.yml +0 -46
  92. data/spec/fixtures/default/data/updates.yml +0 -48
  93. data/spec/fixtures/default/icon.png +0 -0
  94. data/spec/fixtures/default/public/fonts/chunkfive-webfont.eot +0 -0
  95. data/spec/fixtures/default/public/fonts/chunkfive-webfont.svg +0 -213
  96. data/spec/fixtures/default/public/fonts/chunkfive-webfont.ttf +0 -0
  97. data/spec/fixtures/default/public/fonts/chunkfive-webfont.woff +0 -0
  98. data/spec/fixtures/default/public/fonts/chunkfive.css +0 -8
  99. data/spec/fixtures/default/public/fonts/chunkfive.otf +0 -0
  100. data/spec/fixtures/default/public/images/nav_on.png +0 -0
  101. data/spec/fixtures/default/public/images/photo_frame.png +0 -0
  102. data/spec/fixtures/default/public/images/sep.png +0 -0
  103. data/spec/fixtures/default/public/images/top.jpg +0 -0
  104. data/spec/fixtures/default/public/javascripts/application.js.coffee +0 -2
  105. data/spec/fixtures/default/public/javascripts/common.js +0 -1
  106. data/spec/fixtures/default/public/samples/asset_collections/cover.jpg +0 -0
  107. data/spec/fixtures/default/public/samples/photo.jpg +0 -0
  108. data/spec/fixtures/default/public/samples/photo_2.jpg +0 -0
  109. data/spec/fixtures/default/public/stylesheets/application.css +0 -64
  110. data/spec/fixtures/default/public/stylesheets/other/extra.css.less +0 -8
  111. data/spec/fixtures/default/public/stylesheets/other/style.css.scss +0 -13
  112. data/spec/fixtures/default/public/stylesheets/reboot.css +0 -77
  113. data/spec/integration/cli_spec.rb +0 -17
  114. data/spec/integration/commands/authenticate_command_spec.rb +0 -60
  115. data/spec/integration/commands/delete_command_spec.rb +0 -147
  116. data/spec/integration/commands/push_command_spec.rb +0 -86
  117. data/spec/integration/commands/sync_command_spec.rb +0 -60
  118. data/spec/integration/generators/page_spec.rb +0 -87
  119. data/spec/integration/generators/relationship_spec.rb +0 -102
  120. data/spec/integration/integration_helper.rb +0 -15
  121. data/spec/spec_helper.rb +0 -19
  122. data/spec/support/api_settings.rb +0 -5
  123. data/spec/support/chronic.rb +0 -6
  124. data/spec/support/helpers.rb +0 -39
  125. data/spec/support/matchers.rb +0 -5
  126. data/spec/support/pry.rb +0 -4
  127. data/spec/support/thor.rb +0 -12
  128. data/spec/support/vcr.rb +0 -27
  129. data/spec/unit/commands/pull_sub_commands/concerns/assets_concern_spec.rb +0 -48
  130. data/spec/unit/commands/pull_sub_commands/pull_content_types_command_spec.rb +0 -41
  131. data/spec/unit/commands/push_sub_commands/push_pages_command_spec.rb +0 -125
  132. data/spec/unit/commands/push_sub_commands/push_theme_assets_command_spec.rb +0 -42
  133. data/spec/unit/decorators/content_entry_decorator_spec.rb +0 -104
  134. data/spec/unit/decorators/page_decorator_spec.rb +0 -35
  135. data/spec/unit/decorators/site_decorator_spec.rb +0 -62
  136. data/spec/unit/decorators/theme_asset_decorator_spec.rb +0 -89
  137. data/spec/unit/tools/glob_spec.rb +0 -26
  138. data/spec/unit/tools/yaml_ext_spec.rb +0 -46
@@ -1,60 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.dirname(__FILE__) + '/../integration_helper'
4
- require 'locomotive/steam'
5
- require 'locomotive/steam/adapters/filesystem'
6
- require 'locomotive/wagon/commands/push_command'
7
- require 'locomotive/wagon/commands/sync_command'
8
- require 'thor'
9
-
10
- describe Locomotive::Wagon::SyncCommand do
11
-
12
- before { Locomotive::Steam::Adapters::Filesystem::SimpleCacheStore.new.clear }
13
-
14
- before { VCR.insert_cassette 'sync', match_requests_on: [:uri, :method, :query, :body, :headers] }
15
- after { VCR.eject_cassette }
16
-
17
- let(:env) { 'hosting-sync' }
18
- let(:path) { default_site_path }
19
- let(:shell) { Thor::Shell::Color.new }
20
- let(:options) { { verbose: true } }
21
- let(:command) { described_class.new(env, path, options, shell) }
22
-
23
- describe '#sync' do
24
-
25
- before { create_site }
26
- after do
27
- restore_deploy_file(default_site_path)
28
- FileUtils.rm_rf(File.join(data_path))
29
- FileUtils.rm_rf(File.join(assets_path))
30
- end
31
-
32
- let(:data_path) { File.join(default_site_path, 'data', 'hosting-sync') }
33
- let(:assets_path) { File.join(default_site_path, 'public', 'samples', '_hosting-sync') }
34
-
35
- subject { command.sync }
36
-
37
- it 'exports the content of a site, content entries and pages' do
38
- is_expected.not_to eq nil
39
- expect(File.exists?(File.join(data_path, 'site.json'))).to eq true
40
- expect(File.exists?(File.join(data_path, 'content_entries', 'bands.yml'))).to eq true
41
- %w(fr nb en).each do |locale|
42
- expect(File.exists?(File.join(data_path, 'pages', locale, 'index.json'))).to eq true
43
- end
44
- end
45
-
46
- end
47
-
48
- def create_site
49
- _command = Locomotive::Wagon::PushCommand.new(env, path, { data: true, verbose: false }, shell)
50
- credentials = instance_double('Credentials', login: TEST_API_EMAIL, password: TEST_API_KEY)
51
- allow(Netrc).to receive(:read).and_return(TEST_PLATFORM_ALT_URL => credentials)
52
- allow(_command).to receive(:ask_for_performing).with('You are about to deploy a new site').and_return(true)
53
- allow(_command).to receive(:ask_for_performing).with("Warning! You're about to deploy data which will alter the content of your site.").and_return(true)
54
- expect(shell).to receive(:ask).with("What is the URL of your platform? (default: https://station.locomotive.works)").and_return(TEST_PLATFORM_URL)
55
- expect(shell).to receive(:ask).with('What is the handle of your site? (default: a random one)').and_return('wagon-test-sync')
56
- _command.push
57
- # Locomotive::Wagon::PushCommand.push(env, path, { data: true, verbose: false }, shell)
58
- end
59
-
60
- end
@@ -1,87 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.dirname(__FILE__) + '/../integration_helper'
4
-
5
- require 'locomotive/wagon'
6
- require 'locomotive/wagon/cli'
7
-
8
- describe 'Locomotive::Wagon::Generators::Page' do
9
-
10
- before { make_working_copy_of_site(:blog) }
11
- after { remove_working_copy_of_site(:blog) }
12
-
13
- let(:path) { working_copy_of_site(:blog) }
14
- let(:fullpath) { 'new-page' }
15
- let(:default_locales) { ['en', 'fr'] }
16
- let(:locales) { nil }
17
- let(:page_options) { { locales: locales, default_locales: default_locales } }
18
- let(:options) { { 'force_color' => true, 'path' => path, 'quiet' => true }.merge(page_options) }
19
-
20
- subject { Locomotive::Wagon.generate(:page, [fullpath, options.delete('path')], options) }
21
-
22
- describe 'wrong parameters' do
23
-
24
- describe 'empty locales' do
25
-
26
- let(:locales) { '' }
27
-
28
- it { expect { subject }.not_to raise_error }
29
-
30
- end
31
-
32
- end
33
-
34
- describe 'generating a page' do
35
-
36
- before { subject }
37
-
38
- it 'creates the page in the FS' do
39
- expect(File).to exist(page_path('new-page'))
40
- end
41
-
42
- it 'generates an header in YAML' do
43
- expect(read_page('new-page')).to include <<-EXPECTED
44
- ---
45
- title: New-page
46
- EXPECTED
47
- end
48
-
49
- describe 'other locales' do
50
-
51
- let(:locales) { 'en fr' }
52
-
53
- it 'creates the EN page in the FS' do
54
- expect(File).to exist(page_path('new-page'))
55
- end
56
-
57
- it 'creates the FR page in the FS' do
58
- expect(File).to exist(page_path('new-page.fr'))
59
- end
60
-
61
- describe 'separated by a comma' do
62
-
63
- let(:locales) { 'en,fr' }
64
-
65
- it 'creates the EN page in the FS' do
66
- expect(File).to exist(page_path('new-page'))
67
- end
68
-
69
- it 'creates the FR page in the FS' do
70
- expect(File).to exist(page_path('new-page.fr'))
71
- end
72
-
73
- end
74
-
75
- end
76
-
77
- end
78
-
79
- def page_path(slug)
80
- File.join(path, 'app', 'views', 'pages', "#{slug}.liquid")
81
- end
82
-
83
- def read_page(slug)
84
- File.read(page_path(slug))
85
- end
86
-
87
- end
@@ -1,102 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.dirname(__FILE__) + '/../integration_helper'
4
-
5
- require 'locomotive/wagon'
6
- require 'locomotive/wagon/cli'
7
-
8
- describe 'Locomotive::Wagon::Generators::Relationship' do
9
-
10
- before(:all) { make_working_copy_of_site(:blog) }
11
- after(:all) { remove_working_copy_of_site(:blog) }
12
-
13
- let(:path) { working_copy_of_site(:blog) }
14
- let(:source_slug) { 'comments' }
15
- let(:target_slug) { 'posts' }
16
- let(:type) { 'belongs_to' }
17
- let(:options) { { 'force_color' => true, 'path' => path, 'quiet' => true } }
18
-
19
- subject { Locomotive::Wagon.generate(:relationship, [source_slug, type, target_slug, options.delete('path')], options) }
20
-
21
- describe 'wrong parameters' do
22
-
23
- describe 'unknown slugs' do
24
-
25
- let(:source_slug) { 'authors' }
26
-
27
- it { expect { subject }.to raise_error 'The authors content type does not exist' }
28
-
29
- end
30
-
31
- describe 'unknown type' do
32
-
33
- let(:type) { 'has_one' }
34
-
35
- it { expect { subject }.to raise_error 'has_one is an unknown relationship type' }
36
-
37
- end
38
-
39
- end
40
-
41
- describe 'generating a belongs_to relationship' do
42
-
43
- before { subject }
44
-
45
- it 'adds code to the source content type' do
46
- expect(read_content_type(:comments)).to include <<-EXPECTED
47
- - post:
48
- label: Post
49
- hint: A description of the relationship for the editors
50
- type: belongs_to
51
- class_name: posts
52
- EXPECTED
53
- end
54
-
55
- it 'adds code the target content type' do
56
- expect(read_content_type(:posts)).to include <<-EXPECTED
57
- - comments:
58
- label: Comments
59
- hint: A description of the relationship for the editors
60
- type: has_many
61
- class_name: comments
62
- inverse_of: post
63
- EXPECTED
64
- end
65
-
66
- end
67
-
68
- describe 'generating a many_to_many relationship' do
69
-
70
- before { subject }
71
-
72
- let(:type) { 'many_to_many' }
73
-
74
- it 'adds code to the source content type' do
75
- expect(read_content_type(:comments)).to include <<-EXPECTED
76
- - posts:
77
- label: Posts
78
- hint: A description of the relationship for the editors
79
- type: many_to_many
80
- class_name: posts
81
- inverse_of: comments
82
- EXPECTED
83
- end
84
-
85
- it 'adds code the target content type' do
86
- expect(read_content_type(:posts)).to include <<-EXPECTED
87
- - comments:
88
- label: Comments
89
- hint: A description of the relationship for the editors
90
- type: many_to_many
91
- class_name: comments
92
- inverse_of: posts
93
- EXPECTED
94
- end
95
-
96
- end
97
-
98
- def read_content_type(name)
99
- File.read(File.join(path, 'app', 'content_types', "#{name}.yml"))
100
- end
101
-
102
- end
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.dirname(__FILE__) + '/../spec_helper'
4
-
5
- # require 'vcr'
6
- # require 'webmock/rspec'
7
-
8
- # VCR.configure do |c|
9
- # c.ignore_localhost = false
10
- # c.cassette_library_dir = File.dirname(__FILE__) + '/cassettes'
11
- # c.hook_into :webmock
12
- # c.default_cassette_options = { record: :new_episodes }
13
- # c.configure_rspec_metadata!
14
- # c.allow_http_connections_when_no_cassette = false
15
- # end
@@ -1,19 +0,0 @@
1
- require 'locomotive/wagon'
2
- require 'rspec'
3
- require 'simplecov'
4
- require 'coveralls'
5
-
6
- SimpleCov.start do
7
- add_filter 'spec/'
8
- end
9
-
10
- Dir["#{File.expand_path('../support', __FILE__)}/*.rb"].each do |file|
11
- require file
12
- end
13
-
14
- RSpec.configure do |c|
15
- c.include Spec::Helpers
16
- c.before(:all) { remove_logs }
17
- c.before { reset! }
18
- c.after { reset! }
19
- end
@@ -1,5 +0,0 @@
1
- TEST_PLATFORM_URL = 'http://localhost:3000'.freeze
2
- TEST_PLATFORM_ALT_URL = 'localhost:3000'.freeze
3
- TEST_API_EMAIL = 'admin@locomotivecms.com'.freeze
4
- TEST_API_PASSWORD = 'locomotive'.freeze
5
- TEST_API_KEY = 'd49cd50f6f0d2b163f48fc73cb249f0244c37074'.freeze
@@ -1,6 +0,0 @@
1
- require 'active_support'
2
- require 'active_support/core_ext'
3
- require 'chronic'
4
-
5
- Time.zone = 'Europe/Paris'
6
- Chronic.time_class = Time.zone
@@ -1,39 +0,0 @@
1
- module Spec
2
- module Helpers
3
-
4
- def default_site_path
5
- File.expand_path('../../fixtures/default', __FILE__)
6
- end
7
-
8
- def reset!
9
- FileUtils.rm_rf(File.expand_path('../../../site', __FILE__))
10
- end
11
-
12
- def remove_logs
13
- FileUtils.rm_rf(File.expand_path('../../fixtures/default/log', __FILE__))
14
- end
15
-
16
- def restore_deploy_file(path)
17
- FileUtils.cp(File.join(path, 'config', 'deploy_example.yml'), File.join(path, 'config', 'deploy.yml'))
18
- end
19
-
20
- def working_copy_of_site(name)
21
- tmp_path = File.expand_path('../../tmp', __FILE__)
22
- tmp_path = FileUtils.mkdir_p(tmp_path)
23
- File.join(tmp_path, name.to_s)
24
- end
25
-
26
- def make_working_copy_of_site(name)
27
- source = File.join(File.expand_path('../../fixtures', __FILE__), name.to_s)
28
- target = working_copy_of_site(name)
29
-
30
- FileUtils.cp_r(source, target)
31
- end
32
-
33
- def remove_working_copy_of_site(name)
34
- path = working_copy_of_site(name)
35
- FileUtils.rm_rf(path)
36
- end
37
-
38
- end
39
- end
@@ -1,5 +0,0 @@
1
- RSpec::Matchers.define :have_key_with_value do |key, expected|
2
- match do |actual|
3
- actual[key] == expected
4
- end
5
- end
@@ -1,4 +0,0 @@
1
- begin
2
- require 'pry'
3
- rescue LoadError
4
- end
@@ -1,12 +0,0 @@
1
- def capture(stream)
2
- begin
3
- stream = stream.to_s
4
- eval "$#{stream} = StringIO.new"
5
- yield
6
- result = eval("$#{stream}").string
7
- ensure
8
- eval("$#{stream} = #{stream.upcase}")
9
- end
10
-
11
- result.strip
12
- end
@@ -1,27 +0,0 @@
1
- require 'vcr'
2
- require 'faraday'
3
-
4
- # Custom VCR matchers
5
- custom_body_matcher = lambda do |request_1, request_2|
6
- if request_1.body.encoding.name == 'ASCII-8BIT'
7
- # when uploading a file, we noticed that VCR or Faraday added 2 extra characters
8
- # at the end of the body: \r\n.
9
- request_1.body == request_2.body ||
10
- request_1.body == request_2.body.gsub(/\r\n$/, '')
11
- else
12
- request_1.body == request_2.body
13
- end
14
- end
15
-
16
- # VCR config
17
- VCR.configure do |c|
18
- c.cassette_library_dir = 'spec/fixtures/cassettes'
19
- c.hook_into :faraday
20
- c.ignore_hosts 'codeclimate.com'
21
- c.configure_rspec_metadata!
22
- c.register_request_matcher :custom_body, &custom_body_matcher
23
- end
24
-
25
- # Without this, VCR is unable to match a POST request with uploaded files
26
- # https://github.com/lostisland/faraday/issues/772
27
- Faraday.default_connection_options.request.boundary = "------------------RubyMultiPartPost".freeze
@@ -1,48 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- require 'active_support'
6
- require 'active_support/core_ext'
7
- require 'locomotive/wagon/commands/pull_sub_commands/concerns/assets_concern'
8
-
9
- describe Locomotive::Wagon::AssetsConcern do
10
-
11
- let(:concern) { Class.new { include Locomotive::Wagon::AssetsConcern; def path; 'tmp'; end; def env; 'production'; end; } }
12
-
13
- describe "calling replace_asset_urls" do
14
-
15
- it "identifies the assets which should be downloaded when pulling" do
16
- input = <<-INPUT
17
- <td><img src="https://somedomain.com/sites/51277e8fc0864503db000007/assets/534d2a28e6439a92180009a6/UPPERCASE.CH.FILE.jpg"/></td>
18
- <td><img src="https://somedomain.com/sites/51277e8fc0864503db000007/assets/532a8eeacf7727c1bb00012e/lowercase.ch.file.jpg" /></td>
19
- <td><img src="https://somedomain.com/sites/51277e8fc0864503db000007/assets/532a8eeac086452e35000169/some_name.jpg" /></td>
20
- <td><img src="https://somedomain.com/sites/51277e8fc0864503db000007/assets/532a8eeac086452e35000169/some_name.JPG" /></td>
21
- <td><img src="https://somedomain.com/sites/51277e8fc0864503db000007/pages/532a8eeac086452e35000169/header.JPG?42" /></td>
22
- INPUT
23
-
24
- parsed_urls = []
25
- input.force_encoding('utf-8').gsub(concern::REGEX) do |url|
26
- parsed_urls.push url
27
- end
28
-
29
- expect(parsed_urls.count).to eq(5)
30
- end
31
- end
32
-
33
-
34
- describe '#replace_asset_urls' do
35
-
36
- let(:content) { %(<td><img src="https://somedomain.com/sites/51277e8fc0864503db000007/assets/532a8eeac086452e35000169/some_name.JPG?42" /></td>) }
37
- let(:instance) { concern.new }
38
-
39
- subject { instance.replace_asset_urls(content) }
40
-
41
- it 'removes the query string' do
42
- expect(instance).to receive(:write_asset).with("https://somedomain.com/sites/51277e8fc0864503db000007/assets/532a8eeac086452e35000169/some_name.JPG?42", "tmp/public/samples/_production/assets/some_name.JPG").and_return('some_name.JPG')
43
- is_expected.to eq %(<td><img src="/samples/_production/assets/some_name.JPG" /></td>)
44
- end
45
-
46
- end
47
-
48
- end