2010-02-03 02:03:43 +01:00
|
|
|
Feature: Alternate between multiple asset hosts
|
2013-04-20 21:59:14 +02:00
|
|
|
|
|
|
|
Scenario: Set single host with inline-option
|
|
|
|
Given a fixture app "asset-host-app"
|
|
|
|
And a file named "config.rb" with:
|
|
|
|
"""
|
2014-05-27 02:58:35 +02:00
|
|
|
activate :asset_host, host: "http://assets1.example.com"
|
2013-04-20 21:59:14 +02:00
|
|
|
"""
|
|
|
|
And the Server is running
|
|
|
|
When I go to "/asset_host.html"
|
2016-01-14 23:29:45 +01:00
|
|
|
Then I should see "'.google-analytics.com/ga.js'"
|
2015-04-22 18:41:03 +02:00
|
|
|
Then I should see 'src="https://code.jquery.com/jquery-2.1.3.min.js"'
|
2014-04-07 21:43:16 +02:00
|
|
|
Then I should see content matching %r{http://assets1.example.com/}
|
|
|
|
Then I should not see content matching %r{http://assets1.example.com//}
|
2015-10-26 07:58:34 +01:00
|
|
|
Then I should see content matching %r{<a href="https://github.com/angular/angular.js">Angular.js</a>}
|
2015-10-26 07:35:40 +01:00
|
|
|
Then I should see content matching %r{'//www.example.com/script.js'}
|
2013-04-20 21:59:14 +02:00
|
|
|
When I go to "/stylesheets/asset_host.css"
|
2014-04-07 21:43:16 +02:00
|
|
|
Then I should see content matching %r{http://assets1.example.com/}
|
|
|
|
Then I should not see content matching %r{http://assets1.example.com//}
|
2016-01-26 22:47:27 +01:00
|
|
|
When I go to "/javascripts/asset_host.js"
|
|
|
|
Then I should not see content matching %r{http://assets1.example.com/}
|
2013-04-20 21:59:14 +02:00
|
|
|
|
|
|
|
Scenario: Set proc host with inline-option
|
|
|
|
Given a fixture app "asset-host-app"
|
|
|
|
And a file named "config.rb" with:
|
|
|
|
"""
|
2014-05-27 02:58:35 +02:00
|
|
|
activate :asset_host, host: Proc.new { |asset|
|
2016-09-13 10:25:17 +02:00
|
|
|
hash = Digest::MD5.digest(asset).bytes.map!(&:ord).reduce(&:+)
|
|
|
|
"http://assets%d.example.com" % (hash % 4)
|
2013-04-20 21:59:14 +02:00
|
|
|
}
|
|
|
|
"""
|
|
|
|
And the Server is running
|
|
|
|
When I go to "/asset_host.html"
|
2015-04-22 18:41:03 +02:00
|
|
|
Then I should see 'src="https://code.jquery.com/jquery-2.1.3.min.js"'
|
2014-04-07 21:43:16 +02:00
|
|
|
Then I should see content matching %r{http://assets1.example.com/}
|
|
|
|
Then I should not see content matching %r{http://assets1.example.com//}
|
2015-10-26 07:58:34 +01:00
|
|
|
Then I should see content matching %r{<a href="https://github.com/angular/angular.js">Angular.js</a>}
|
2015-10-26 07:35:40 +01:00
|
|
|
Then I should see content matching %r{'//www.example.com/script.js'}
|
2013-04-20 21:59:14 +02:00
|
|
|
When I go to "/stylesheets/asset_host.css"
|
2014-04-07 21:43:16 +02:00
|
|
|
Then I should see content matching %r{http://assets1.example.com/}
|
2015-10-26 07:35:40 +01:00
|
|
|
Then I should not see content matching %r{http://assets1.example.com//}
|
2016-01-09 16:06:47 +01:00
|
|
|
|
|
|
|
Scenario: Hosts are not rewritten for rewrite ignored paths
|
|
|
|
Given a fixture app "asset-host-app"
|
|
|
|
And a file named "config.rb" with:
|
|
|
|
"""
|
|
|
|
activate :asset_host, host: "http://assets1.example.com", rewrite_ignore: [
|
|
|
|
'/stylesheets/asset_host.css',
|
|
|
|
]
|
|
|
|
"""
|
|
|
|
And the Server is running
|
|
|
|
When I go to "/asset_host.html"
|
|
|
|
Then I should see content matching %r{http://assets1.example.com/}
|
|
|
|
When I go to "/stylesheets/asset_host.css"
|
|
|
|
Then I should not see content matching %r{http://assets1.example.com/}
|