-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15dc1ef
commit 28780a1
Showing
12 changed files
with
321 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
defaults: &defaults | ||
fog_provider: "Backblaze" | ||
b2_key_id: 'xxxx' | ||
b2_key_token: 'zzzz' | ||
b2_bucket_id: '1234' | ||
|
||
development: | ||
<<: *defaults | ||
fog_directory: "rails_app_development" | ||
existing_remote_files: keep | ||
|
||
test: | ||
<<: *defaults | ||
fog_directory: "rails_app_test" | ||
existing_remote_files: keep | ||
|
||
production: | ||
<<: *defaults | ||
fog_directory: "rails_app_production" | ||
existing_remote_files: delete |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
require File.dirname(__FILE__) + '/../spec_helper' | ||
require "fog/backblaze" | ||
|
||
def bucket(name) | ||
options = { | ||
:provider => 'Backblaze', | ||
:b2_key_id => ENV['B2_KEY_ID'], | ||
:b2_key_token => ENV['B2_KEY_TOKEN'], | ||
:b2_bucket_id => ENV['B2_BUCKET_ID'] | ||
} | ||
options.merge!({ :environment => ENV['FOG_REGION'] }) if ENV.has_key?('FOG_REGION') | ||
|
||
connection = Fog::Storage.new(options) | ||
connection.directories.get(ENV['FOG_DIRECTORY']) | ||
end | ||
|
||
def execute(command) | ||
app_path = File.expand_path("../../dummy_app", __FILE__) | ||
Dir.chdir app_path | ||
`#{command}` | ||
end | ||
|
||
describe "AssetSync" do | ||
|
||
before(:each) do | ||
@prefix = SecureRandom.hex(6) | ||
end | ||
|
||
let(:app_js_regex){ | ||
/#{@prefix}\/application-[a-zA-Z0-9]*.js$/ | ||
} | ||
|
||
let(:app_js_gz_regex){ | ||
/#{@prefix}\/application-[a-zA-Z0-9]*.js.gz$/ | ||
} | ||
|
||
let(:files){ bucket(@prefix).files } | ||
|
||
|
||
after(:each) do | ||
@directory = bucket(@prefix) | ||
@directory.files.each do |f| | ||
f.destroy | ||
end | ||
end | ||
|
||
it "sync" do | ||
execute "rake ASSET_SYNC_PREFIX=#{@prefix} assets:precompile" | ||
|
||
files = bucket(@prefix).files | ||
|
||
app_js = files.select{ |f| f.key =~ app_js_regex }.first | ||
expect(app_js.content_type).to eq("application/javascript") | ||
|
||
app_js_gz = files.select{ |f| f.key =~ app_js_gz_regex }.first | ||
expect(app_js_gz.content_type).to eq("application/javascript") | ||
expect(app_js_gz.content_encoding).to eq("gzip") | ||
end | ||
|
||
it "sync with enabled=false" do | ||
execute "rake ASSET_SYNC_PREFIX=#{@prefix} ASSET_SYNC_ENABLED=false assets:precompile" | ||
expect(bucket(@prefix).files.size).to eq(0) | ||
end | ||
|
||
it "sync with gzip_compression=true" do | ||
execute "rake ASSET_SYNC_PREFIX=#{@prefix} ASSET_SYNC_GZIP_COMPRESSION=true assets:precompile" | ||
# bucket(@prefix).files.size.should == 3 | ||
|
||
app_js_path = files.select{ |f| f.key =~ app_js_regex }.first | ||
app_js = files.get( app_js_path.key ) | ||
expect(app_js.content_type).to eq("application/javascript") | ||
end | ||
|
||
end |
Oops, something went wrong.