Skip to content

Commit 09958f3

Browse files
committed
Add test for config.relative_url_root
1 parent 8fa5652 commit 09958f3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

spec/shakapacker/configuration_spec.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,30 @@
356356
expect(config.asset_host).to eq "domain.abc"
357357
end
358358
end
359+
360+
describe "#relative_url_root" do
361+
let(:config) do
362+
Shakapacker::Configuration.new(
363+
root_path: ROOT_PATH,
364+
config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker.yml", __dir__)),
365+
env: "production"
366+
)
367+
end
368+
369+
it "returns the value of SHAKAPACKER_RELATIVE_URL_ROOT if set" do
370+
original_env_value = ENV["SHAKAPACKER_RELATIVE_URL_ROOT"]
371+
ENV["SHAKAPACKER_RELATIVE_URL_ROOT"] = "custom_value"
372+
373+
expect(config.relative_url_root).to eq "custom_value"
374+
375+
ensure
376+
ENV["SHAKAPACKER_RELATIVE_URL_ROOT"] = original_env_value
377+
end
378+
379+
it "returns ActionController::Base.helpers.compute_asset_host if SHAKAPACKER_RELATIVE_URL_ROOT is not set" do
380+
allow(ActionController::Base).to receive(:relative_url_root).and_return("abcd")
381+
382+
expect(config.relative_url_root).to eq "abcd"
383+
end
384+
end
359385
end

0 commit comments

Comments
 (0)