mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
DEV: improve usability of subfolder specs
Previously people were not consistent about mocking which left internals in a fragile state when running subfolder specs. This introduces a simple helper `set_subfolder` which you can use to set the subfolder for the spec. It takes care of proper configuration of subfolder and teardown. ``` # usage set_subfolder "/my_amazing_subfolder" ``` You should no longer stub base_uri or global_settings
This commit is contained in:
@ -31,19 +31,15 @@ describe ApplicationHelper do
|
||||
global_setting :s3_cdn_url, 'https://s3cdn.com'
|
||||
end
|
||||
|
||||
after do
|
||||
ActionController::Base.config.relative_url_root = nil
|
||||
end
|
||||
|
||||
it "deals correctly with subfolder" do
|
||||
ActionController::Base.config.relative_url_root = "/community"
|
||||
set_subfolder "/community"
|
||||
expect(helper.preload_script("application")).to include('https://s3cdn.com/assets/application.js')
|
||||
end
|
||||
|
||||
it "replaces cdn URLs with s3 cdn subfolder paths" do
|
||||
global_setting :s3_cdn_url, 'https://s3cdn.com/s3_subpath'
|
||||
set_cdn_url "https://awesome.com"
|
||||
ActionController::Base.config.relative_url_root = "/community"
|
||||
set_subfolder "/community"
|
||||
expect(helper.preload_script("application")).to include('https://s3cdn.com/s3_subpath/assets/application.js')
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user