asset_sync 2.4.0 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yaml +64 -0
- data/.travis.yml +25 -26
- data/Appraisals +6 -10
- data/CHANGELOG.md +158 -2
- data/README.md +120 -9
- data/asset_sync.gemspec +4 -3
- data/gemfiles/{rails_4_1.gemfile → rails_5_2.gemfile} +1 -1
- data/gemfiles/{rails_4_2.gemfile → rails_6_0.gemfile} +1 -1
- data/gemfiles/{rails_5_0.gemfile → rails_6_1.gemfile} +1 -1
- data/lib/asset_sync/config.rb +150 -12
- data/lib/asset_sync/engine.rb +8 -0
- data/lib/asset_sync/multi_mime.rb +7 -2
- data/lib/asset_sync/storage.rb +81 -20
- data/lib/asset_sync/version.rb +1 -1
- data/lib/generators/asset_sync/install_generator.rb +21 -1
- data/lib/generators/asset_sync/templates/asset_sync.rb +21 -0
- data/lib/generators/asset_sync/templates/asset_sync.yml +20 -1
- data/lib/tasks/asset_sync.rake +3 -1
- data/spec/fixtures/backblaze_with_yml/config/asset_sync.yml +20 -0
- data/spec/fixtures/google_with_service_account_yml/config/asset_sync.yml +19 -0
- data/spec/integration/backblaze_intergration_spec.rb +74 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/unit/asset_sync_spec.rb +35 -3
- data/spec/unit/backblaze_spec.rb +150 -0
- data/spec/unit/google_spec.rb +124 -29
- data/spec/unit/multi_mime_spec.rb +47 -0
- data/spec/unit/railsless_spec.rb +4 -3
- data/spec/unit/storage_spec.rb +150 -7
- metadata +49 -14
- data/gemfiles/rails_5_1.gemfile +0 -10
data/lib/asset_sync/version.rb
CHANGED
@@ -5,7 +5,7 @@ module AssetSync
|
|
5
5
|
|
6
6
|
# Commandline options can be defined here using Thor-like options:
|
7
7
|
class_option :use_yml, :type => :boolean, :default => false, :desc => "Use YML file instead of Rails Initializer"
|
8
|
-
class_option :provider, :type => :string, :default => "AWS", :desc => "Generate with support for 'AWS', 'Rackspace', 'Google', or '
|
8
|
+
class_option :provider, :type => :string, :default => "AWS", :desc => "Generate with support for 'AWS', 'Rackspace', 'Google', 'AzureRM', or 'Backblaze'"
|
9
9
|
|
10
10
|
def self.source_root
|
11
11
|
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
@@ -27,6 +27,10 @@ module AssetSync
|
|
27
27
|
options[:provider] == 'AzureRM'
|
28
28
|
end
|
29
29
|
|
30
|
+
def backblaze?
|
31
|
+
options[:provider] == 'Backblaze'
|
32
|
+
end
|
33
|
+
|
30
34
|
def aws_access_key_id
|
31
35
|
"<%= ENV['AWS_ACCESS_KEY_ID'] %>"
|
32
36
|
end
|
@@ -35,6 +39,10 @@ module AssetSync
|
|
35
39
|
"<%= ENV['AWS_SECRET_ACCESS_KEY'] %>"
|
36
40
|
end
|
37
41
|
|
42
|
+
def aws_session_token
|
43
|
+
"<%= ENV['AWS_SESSION_TOKEN'] %>"
|
44
|
+
end
|
45
|
+
|
38
46
|
def google_storage_access_key_id
|
39
47
|
"<%= ENV['GOOGLE_STORAGE_ACCESS_KEY_ID'] %>"
|
40
48
|
end
|
@@ -59,6 +67,18 @@ module AssetSync
|
|
59
67
|
"<%= ENV['AZURE_STORAGE_ACCESS_KEY'] %>"
|
60
68
|
end
|
61
69
|
|
70
|
+
def b2_key_id
|
71
|
+
"<%= ENV['B2_KEY_ID'] %>"
|
72
|
+
end
|
73
|
+
|
74
|
+
def b2_key_token
|
75
|
+
"<%= ENV['B2_KEY_TOKEN'] %>"
|
76
|
+
end
|
77
|
+
|
78
|
+
def b2_bucket_id
|
79
|
+
"<%= ENV['B2_BUCKET_ID'] %>"
|
80
|
+
end
|
81
|
+
|
62
82
|
def app_name
|
63
83
|
@app_name ||= Rails.application.is_a?(Rails::Application) && Rails.application.class.name.sub(/::Application$/, "").downcase
|
64
84
|
end
|
@@ -4,6 +4,7 @@ if defined?(AssetSync)
|
|
4
4
|
config.fog_provider = 'AWS'
|
5
5
|
config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
|
6
6
|
config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
|
7
|
+
config.aws_session_token = ENV['AWS_SESSION_TOKEN'] if ENV.key?('AWS_SESSION_TOKEN')
|
7
8
|
# To use AWS reduced redundancy storage.
|
8
9
|
# config.aws_reduced_redundancy = true
|
9
10
|
#
|
@@ -13,6 +14,9 @@ if defined?(AssetSync)
|
|
13
14
|
# Change host option in fog (only if you need to)
|
14
15
|
# config.fog_host = "s3.amazonaws.com"
|
15
16
|
#
|
17
|
+
# Change port option in fog (only if you need to)
|
18
|
+
# config.fog_port = "9000"
|
19
|
+
#
|
16
20
|
# Use http instead of https. Default should be "https" (at least for fog-aws)
|
17
21
|
# config.fog_scheme = "http"
|
18
22
|
<%- elsif google? -%>
|
@@ -31,6 +35,12 @@ if defined?(AssetSync)
|
|
31
35
|
config.azure_storage_account_name = ENV['AZURE_STORAGE_ACCOUNT_NAME']
|
32
36
|
config.azure_storage_access_key = ENV['AZURE_STORAGE_ACCESS_KEY']
|
33
37
|
|
38
|
+
<%- elsif backblaze? -%>
|
39
|
+
config.fog_provider = 'Backblaze'
|
40
|
+
config.b2_key_id = ENV['B2_KEY_ID']
|
41
|
+
config.b2_key_token = ENV['B2_KEY_TOKEN']
|
42
|
+
config.b2_bucket_id = ENV['B2_BUCKET_ID']
|
43
|
+
|
34
44
|
# config.fog_directory specifies container name of Azure Blob storage
|
35
45
|
<%- end -%>
|
36
46
|
config.fog_directory = ENV['FOG_DIRECTORY']
|
@@ -42,6 +52,11 @@ if defined?(AssetSync)
|
|
42
52
|
# Increase upload performance by configuring your region
|
43
53
|
# config.fog_region = 'eu-west-1'
|
44
54
|
#
|
55
|
+
# Set `public` option when uploading file depending on value,
|
56
|
+
# Setting to "default" makes asset sync skip setting the option
|
57
|
+
# Possible values: true, false, "default" (default: true)
|
58
|
+
# config.fog_public = true
|
59
|
+
#
|
45
60
|
# Don't delete files from the store
|
46
61
|
# config.existing_remote_files = "keep"
|
47
62
|
#
|
@@ -55,6 +70,12 @@ if defined?(AssetSync)
|
|
55
70
|
# Upload the manifest file also.
|
56
71
|
# config.include_manifest = false
|
57
72
|
#
|
73
|
+
# Upload files concurrently
|
74
|
+
# config.concurrent_uploads = false
|
75
|
+
#
|
76
|
+
# Path to cache file to skip scanning remote
|
77
|
+
# config.remote_file_list_cache_file_path = './.asset_sync_remote_file_list_cache.json'
|
78
|
+
#
|
58
79
|
# Fail silently. Useful for environments such as Heroku
|
59
80
|
# config.fail_silently = true
|
60
81
|
#
|
@@ -3,6 +3,7 @@ defaults: &defaults
|
|
3
3
|
fog_provider: 'AWS'
|
4
4
|
aws_access_key_id: "<%= aws_access_key_id %>"
|
5
5
|
aws_secret_access_key: "<%= aws_secret_access_key %>"
|
6
|
+
|
6
7
|
# To use AWS reduced redundancy storage.
|
7
8
|
# aws_reduced_redundancy: true
|
8
9
|
#
|
@@ -12,6 +13,9 @@ defaults: &defaults
|
|
12
13
|
# Change host option in fog (only if you need to)
|
13
14
|
# fog_host: "s3.amazonaws.com"
|
14
15
|
#
|
16
|
+
# Change port option in fog (only if you need to)
|
17
|
+
# config.fog_port = "9000"
|
18
|
+
#
|
15
19
|
# Use http instead of https. Default should be "https" (at least for fog-aws)
|
16
20
|
# fog_scheme: "http"
|
17
21
|
<%- elsif google? -%>
|
@@ -28,19 +32,34 @@ defaults: &defaults
|
|
28
32
|
fog_provider: 'AzureRM'
|
29
33
|
azure_storage_account_name: "<%= azure_storage_account_name %>"
|
30
34
|
azure_storage_access_key: "<%= azure_storage_access_key %>"
|
31
|
-
|
32
35
|
# fog_directory specifies container name of Azure Blob storage
|
36
|
+
<%- elsif backblaze? -%>
|
37
|
+
fog_provider: Backblaze
|
38
|
+
b2_key_id: "<%= b2_key_id %>"
|
39
|
+
b2_key_token: "<%= b2_key_token %>"
|
40
|
+
b2_bucket_id: "<%= b2_bucket_id %>"
|
41
|
+
# fog_directory specifies container name of Backblaze B2 Bucket
|
33
42
|
<%- end -%>
|
34
43
|
fog_directory: "<%= app_name %>-assets"
|
44
|
+
|
35
45
|
# You may need to specify what region your storage bucket is in
|
36
46
|
# fog_region: "eu-west-1"
|
47
|
+
|
48
|
+
# Set `public` option when uploading file depending on value,
|
49
|
+
# Setting to "default" makes asset sync skip setting the option
|
50
|
+
# Possible values: true, false, "default" (default: true)
|
51
|
+
# config.fog_public = true
|
52
|
+
|
37
53
|
existing_remote_files: keep
|
38
54
|
# To delete existing remote files.
|
39
55
|
# existing_remote_files: delete
|
56
|
+
|
40
57
|
# Automatically replace files with their equivalent gzip compressed version
|
41
58
|
# gzip_compression: true
|
59
|
+
|
42
60
|
# Fail silently. Useful for environments such as Heroku
|
43
61
|
# fail_silently: true
|
62
|
+
|
44
63
|
# Allow custom assets to be cacheable. Note: The base filename will be matched
|
45
64
|
# cache_asset_regexps: ['cache_me.js', !ruby/regexp '/cache_some\.\d{8}\.css/']
|
46
65
|
|
data/lib/tasks/asset_sync.rake
CHANGED
@@ -19,7 +19,7 @@ if Rake::Task.task_defined?("assets:precompile:nondigest")
|
|
19
19
|
# will get executed before yaml or Rails initializers.
|
20
20
|
Rake::Task["assets:sync"].invoke if defined?(AssetSync) && AssetSync.config.run_on_precompile
|
21
21
|
end
|
22
|
-
|
22
|
+
elsif Rake::Task.task_defined?("assets:precompile")
|
23
23
|
Rake::Task["assets:precompile"].enhance do
|
24
24
|
# rails 3.1.1 will clear out Rails.application.config if the env vars
|
25
25
|
# RAILS_GROUP and RAILS_ENV are not defined. We need to reload the
|
@@ -27,4 +27,6 @@ else
|
|
27
27
|
# Rake::Task["assets:environment"].invoke if Rake::Task.task_defined?("assets:environment")
|
28
28
|
Rake::Task["assets:sync"].invoke if defined?(AssetSync) && AssetSync.config.run_on_precompile
|
29
29
|
end
|
30
|
+
else
|
31
|
+
# Nothing to be enhanced
|
30
32
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
fog_provider: "Backblaze"
|
3
|
+
b2_key_id: 'xxxx'
|
4
|
+
b2_key_token: 'zzzz'
|
5
|
+
b2_bucket_id: '1234'
|
6
|
+
|
7
|
+
development:
|
8
|
+
<<: *defaults
|
9
|
+
fog_directory: "rails_app_development"
|
10
|
+
existing_remote_files: keep
|
11
|
+
|
12
|
+
test:
|
13
|
+
<<: *defaults
|
14
|
+
fog_directory: "rails_app_test"
|
15
|
+
existing_remote_files: keep
|
16
|
+
|
17
|
+
production:
|
18
|
+
<<: *defaults
|
19
|
+
fog_directory: "rails_app_production"
|
20
|
+
existing_remote_files: delete
|
@@ -0,0 +1,19 @@
|
|
1
|
+
defaults: &defaults
|
2
|
+
fog_provider: "Google"
|
3
|
+
google_json_key_location: 'gcs.json'
|
4
|
+
google_project: 'some-project'
|
5
|
+
|
6
|
+
development:
|
7
|
+
<<: *defaults
|
8
|
+
fog_directory: "rails_app_development"
|
9
|
+
existing_remote_files: keep
|
10
|
+
|
11
|
+
test:
|
12
|
+
<<: *defaults
|
13
|
+
fog_directory: "rails_app_test"
|
14
|
+
existing_remote_files: keep
|
15
|
+
|
16
|
+
production:
|
17
|
+
<<: *defaults
|
18
|
+
fog_directory: "rails_app_production"
|
19
|
+
existing_remote_files: delete
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require "fog/backblaze"
|
3
|
+
|
4
|
+
def bucket(name)
|
5
|
+
options = {
|
6
|
+
:provider => 'Backblaze',
|
7
|
+
:b2_key_id => ENV['B2_KEY_ID'],
|
8
|
+
:b2_key_token => ENV['B2_KEY_TOKEN'],
|
9
|
+
:b2_bucket_id => ENV['B2_BUCKET_ID']
|
10
|
+
}
|
11
|
+
options.merge!({ :environment => ENV['FOG_REGION'] }) if ENV.has_key?('FOG_REGION')
|
12
|
+
|
13
|
+
connection = Fog::Storage.new(options)
|
14
|
+
connection.directories.get(ENV['FOG_DIRECTORY'])
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute(command)
|
18
|
+
app_path = File.expand_path("../../dummy_app", __FILE__)
|
19
|
+
Dir.chdir app_path
|
20
|
+
`#{command}`
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "AssetSync" do
|
24
|
+
|
25
|
+
before(:each) do
|
26
|
+
@prefix = SecureRandom.hex(6)
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:app_js_regex){
|
30
|
+
/#{@prefix}\/application-[a-zA-Z0-9]*.js$/
|
31
|
+
}
|
32
|
+
|
33
|
+
let(:app_js_gz_regex){
|
34
|
+
/#{@prefix}\/application-[a-zA-Z0-9]*.js.gz$/
|
35
|
+
}
|
36
|
+
|
37
|
+
let(:files){ bucket(@prefix).files }
|
38
|
+
|
39
|
+
|
40
|
+
after(:each) do
|
41
|
+
@directory = bucket(@prefix)
|
42
|
+
@directory.files.each do |f|
|
43
|
+
f.destroy
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it "sync" do
|
48
|
+
execute "rake ASSET_SYNC_PREFIX=#{@prefix} assets:precompile"
|
49
|
+
|
50
|
+
files = bucket(@prefix).files
|
51
|
+
|
52
|
+
app_js = files.select{ |f| f.key =~ app_js_regex }.first
|
53
|
+
expect(app_js.content_type).to eq("application/javascript")
|
54
|
+
|
55
|
+
app_js_gz = files.select{ |f| f.key =~ app_js_gz_regex }.first
|
56
|
+
expect(app_js_gz.content_type).to eq("application/javascript")
|
57
|
+
expect(app_js_gz.content_encoding).to eq("gzip")
|
58
|
+
end
|
59
|
+
|
60
|
+
it "sync with enabled=false" do
|
61
|
+
execute "rake ASSET_SYNC_PREFIX=#{@prefix} ASSET_SYNC_ENABLED=false assets:precompile"
|
62
|
+
expect(bucket(@prefix).files.size).to eq(0)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "sync with gzip_compression=true" do
|
66
|
+
execute "rake ASSET_SYNC_PREFIX=#{@prefix} ASSET_SYNC_GZIP_COMPRESSION=true assets:precompile"
|
67
|
+
# bucket(@prefix).files.size.should == 3
|
68
|
+
|
69
|
+
app_js_path = files.select{ |f| f.key =~ app_js_regex }.first
|
70
|
+
app_js = files.get( app_js_path.key )
|
71
|
+
expect(app_js.content_type).to eq("application/javascript")
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -145,7 +145,7 @@ describe AssetSync do
|
|
145
145
|
|
146
146
|
it "should default asset_regexps to match regexps" do
|
147
147
|
expect(AssetSync.config.cache_asset_regexps).to eq(['cache_me.js', /cache_some\.\d{8}\.css/])
|
148
|
-
end
|
148
|
+
end
|
149
149
|
end
|
150
150
|
|
151
151
|
describe 'from yml, exporting to a mobile hybrid development directory' do
|
@@ -255,12 +255,12 @@ describe AssetSync do
|
|
255
255
|
expect(AssetSync.config.manifest_path).to match(/public\/custom_assets\/manifest.yml/)
|
256
256
|
end
|
257
257
|
end
|
258
|
-
|
258
|
+
|
259
259
|
describe 'with cache_asset_regexps' do
|
260
260
|
before(:each) do
|
261
261
|
AssetSync.config = AssetSync::Config.new
|
262
262
|
end
|
263
|
-
|
263
|
+
|
264
264
|
it "config.cache_asset_regexp should set cache_asset_regexps" do
|
265
265
|
AssetSync.config.cache_asset_regexp = /\.[a-f0-9]{8}/i
|
266
266
|
expect(AssetSync.config.cache_asset_regexps.size).to eq(1)
|
@@ -283,4 +283,36 @@ describe AssetSync do
|
|
283
283
|
expect{ AssetSync::Config.new }.to raise_error(Psych::SyntaxError)
|
284
284
|
end
|
285
285
|
end
|
286
|
+
|
287
|
+
describe 'FogPublicValue' do
|
288
|
+
describe "#to_bool" do
|
289
|
+
it "true should be converted to true" do
|
290
|
+
expect(AssetSync::Config::FogPublicValue.new(true).to_bool).to be_truthy
|
291
|
+
end
|
292
|
+
it "false should be converted to false" do
|
293
|
+
expect(AssetSync::Config::FogPublicValue.new(false).to_bool).to be_falsey
|
294
|
+
end
|
295
|
+
it "nil should be converted to false" do
|
296
|
+
expect(AssetSync::Config::FogPublicValue.new(nil).to_bool).to be_falsey
|
297
|
+
end
|
298
|
+
it "'default' should be converted to false" do
|
299
|
+
expect(AssetSync::Config::FogPublicValue.new("default").to_bool).to be_truthy
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
describe "#use_explicit_value?" do
|
304
|
+
it "true should be converted to true" do
|
305
|
+
expect(AssetSync::Config::FogPublicValue.new(true).use_explicit_value?).to be_truthy
|
306
|
+
end
|
307
|
+
it "false should be converted to true" do
|
308
|
+
expect(AssetSync::Config::FogPublicValue.new(false).use_explicit_value?).to be_truthy
|
309
|
+
end
|
310
|
+
it "nil should be converted to true" do
|
311
|
+
expect(AssetSync::Config::FogPublicValue.new(nil).use_explicit_value?).to be_truthy
|
312
|
+
end
|
313
|
+
it "'default' should be converted to false" do
|
314
|
+
expect(AssetSync::Config::FogPublicValue.new("default").use_explicit_value?).to be_falsey
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
286
318
|
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe AssetSync do
|
4
|
+
include_context "mock Rails without_yml"
|
5
|
+
|
6
|
+
describe 'with initializer' do
|
7
|
+
before(:each) do
|
8
|
+
AssetSync.config = AssetSync::Config.new
|
9
|
+
AssetSync.configure do |config|
|
10
|
+
config.fog_provider = 'Backblaze'
|
11
|
+
config.b2_key_id = 'aaaa'
|
12
|
+
config.b2_key_token = 'bbbb'
|
13
|
+
config.b2_bucket_id = '4567'
|
14
|
+
config.fog_directory = 'mybucket'
|
15
|
+
config.existing_remote_files = "keep"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should configure provider as Backblaze" do
|
20
|
+
expect(AssetSync.config.fog_provider).to eq('Backblaze')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should should keep existing remote files" do
|
24
|
+
expect(AssetSync.config.existing_remote_files?).to eq(true)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should configure b2_key_id" do
|
28
|
+
expect(AssetSync.config.b2_key_id).to eq("aaaa")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should configure b2_key_token" do
|
32
|
+
expect(AssetSync.config.b2_key_token).to eq("bbbb")
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should configure b2_bucket_id" do
|
36
|
+
expect(AssetSync.config.b2_bucket_id).to eq("4567")
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should configure fog_directory" do
|
40
|
+
expect(AssetSync.config.fog_directory).to eq("mybucket")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should configure existing_remote_files" do
|
44
|
+
expect(AssetSync.config.existing_remote_files).to eq("keep")
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should default gzip_compression to false" do
|
48
|
+
expect(AssetSync.config.gzip_compression).to be_falsey
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should default manifest to false" do
|
52
|
+
expect(AssetSync.config.manifest).to be_falsey
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'from yml' do
|
57
|
+
before(:each) do
|
58
|
+
set_rails_root('backblaze_with_yml')
|
59
|
+
AssetSync.config = AssetSync::Config.new
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should configure b2_key_id" do
|
63
|
+
expect(AssetSync.config.b2_key_id).to eq("xxxx")
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should configure b2_key_token" do
|
67
|
+
expect(AssetSync.config.b2_key_token).to eq("zzzz")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should configure b2_bucket_id" do
|
71
|
+
expect(AssetSync.config.b2_bucket_id).to eq("1234")
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should configure fog_directory" do
|
75
|
+
expect(AssetSync.config.fog_directory).to eq("rails_app_test")
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should configure existing_remote_files" do
|
79
|
+
expect(AssetSync.config.existing_remote_files).to eq("keep")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should default gzip_compression to false" do
|
83
|
+
expect(AssetSync.config.gzip_compression).to be_falsey
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should default manifest to false" do
|
87
|
+
expect(AssetSync.config.manifest).to be_falsey
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'with no configuration' do
|
92
|
+
before(:each) do
|
93
|
+
AssetSync.config = AssetSync::Config.new
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should be invalid" do
|
97
|
+
expect{ AssetSync.sync }.to raise_error(::AssetSync::Config::Invalid)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe 'with fail_silent configuration' do
|
102
|
+
before(:each) do
|
103
|
+
allow(AssetSync).to receive(:stderr).and_return(StringIO.new)
|
104
|
+
AssetSync.config = AssetSync::Config.new
|
105
|
+
AssetSync.configure do |config|
|
106
|
+
config.fail_silently = true
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should not raise an invalid exception" do
|
111
|
+
expect{ AssetSync.sync }.not_to raise_error
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe 'with gzip_compression enabled' do
|
116
|
+
before(:each) do
|
117
|
+
AssetSync.config = AssetSync::Config.new
|
118
|
+
AssetSync.config.gzip_compression = true
|
119
|
+
end
|
120
|
+
|
121
|
+
it "config.gzip? should be true" do
|
122
|
+
expect(AssetSync.config.gzip?).to be_truthy
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
describe 'with manifest enabled' do
|
127
|
+
before(:each) do
|
128
|
+
AssetSync.config = AssetSync::Config.new
|
129
|
+
AssetSync.config.manifest = true
|
130
|
+
end
|
131
|
+
|
132
|
+
it "config.manifest should be true" do
|
133
|
+
expect(AssetSync.config.manifest).to be_truthy
|
134
|
+
end
|
135
|
+
|
136
|
+
it "config.manifest_path should default to public/assets.." do
|
137
|
+
expect(AssetSync.config.manifest_path).to match(/public\/assets\/manifest.yml/)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "config.manifest_path should default to public/assets.." do
|
141
|
+
Rails.application.config.assets.manifest = "/var/assets"
|
142
|
+
expect(AssetSync.config.manifest_path).to eq("/var/assets/manifest.yml")
|
143
|
+
end
|
144
|
+
|
145
|
+
it "config.manifest_path should default to public/custom_assets.." do
|
146
|
+
Rails.application.config.assets.prefix = 'custom_assets'
|
147
|
+
expect(AssetSync.config.manifest_path).to match(/public\/custom_assets\/manifest.yml/)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|