From a627eb42d9078b93c3e8a818def96a26ff000687 Mon Sep 17 00:00:00 2001 From: Mostafa Ahangarha Date: Sat, 18 Nov 2023 23:24:49 +0330 Subject: [PATCH] Remove any references to relative_url_root Despite being added in webpacker, it never got used. There is no functionality tied to this configuration and this commit, removes its references in the code and tests. --- CHANGELOG.md | 2 +- lib/install/config/shakapacker.yml | 2 - lib/shakapacker/compiler.rb | 1 - lib/shakapacker/configuration.rb | 7 ---- .../compiler_spec.rb | 3 -- spec/shakapacker/compiler_spec.rb | 3 -- spec/shakapacker/configuration_spec.rb | 42 ------------------- 7 files changed, 1 insertion(+), 59 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 740b1add..f3b09656 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ _Please add entries here for your pull requests that are not yet released._ ### Added - Experimental support for other JS package managers using `package_json` gem [PR 349](https://github.com/shakacode/shakapacker/pull/349) by [G-Rath](https://github.com/g-rath). -- Use `config/shakapacker.yml` as the secondary source for `asset_host` and `relative_url_root` configurations [PR 376](https://github.com/shakacode/shakapacker/pull/376) by [ahangarha](https://github.com/ahangarha). +- Use `config/shakapacker.yml` as the secondary source for `asset_host` configuration [PR 376](https://github.com/shakacode/shakapacker/pull/376) by [ahangarha](https://github.com/ahangarha). ### Fixed - Recommend `server` option instead of deprecated `https` option when `--https` is provided [PR 380](https://github.com/shakacode/shakapacker/pull/380) by [G-Rath](https://github.com/g-rath) diff --git a/lib/install/config/shakapacker.yml b/lib/install/config/shakapacker.yml index 3e080bef..7b91f233 100644 --- a/lib/install/config/shakapacker.yml +++ b/lib/install/config/shakapacker.yml @@ -55,8 +55,6 @@ default: &default # SHAKAPACKER_ASSET_HOST will override both configurations. # asset_host: custom-path - # relative_url_root: custom-path - development: <<: *default compile: true diff --git a/lib/shakapacker/compiler.rb b/lib/shakapacker/compiler.rb index 4c0dcb09..ff54fe1a 100644 --- a/lib/shakapacker/compiler.rb +++ b/lib/shakapacker/compiler.rb @@ -108,7 +108,6 @@ def webpack_env env.merge( "SHAKAPACKER_ASSET_HOST" => instance.config.asset_host, - "SHAKAPACKER_RELATIVE_URL_ROOT" => instance.config.relative_url_root, "SHAKAPACKER_CONFIG" => instance.config_path.to_s ) end diff --git a/lib/shakapacker/configuration.rb b/lib/shakapacker/configuration.rb index 101aa845..e1824229 100644 --- a/lib/shakapacker/configuration.rb +++ b/lib/shakapacker/configuration.rb @@ -123,13 +123,6 @@ def asset_host ).to_s end - def relative_url_root - ENV.fetch( - "SHAKAPACKER_RELATIVE_URL_ROOT", - fetch(:relative_url_root) || ActionController::Base.relative_url_root - ).to_s - end - private def data @data ||= load diff --git a/spec/backward_compatibility_specs/compiler_spec.rb b/spec/backward_compatibility_specs/compiler_spec.rb index 7d80d17d..e5ec75a5 100644 --- a/spec/backward_compatibility_specs/compiler_spec.rb +++ b/spec/backward_compatibility_specs/compiler_spec.rb @@ -48,12 +48,9 @@ it "accepts external env variables" do expect(Webpacker.compiler.send(:webpack_env)["SHAKAPACKER_ASSET_HOST"]).to eq "" - expect(Webpacker.compiler.send(:webpack_env)["SHAKAPACKER_RELATIVE_URL_ROOT"]).to eq "" ENV["WEBPACKER_ASSET_HOST"] = "foo.bar" - ENV["WEBPACKER_RELATIVE_URL_ROOT"] = "/baz" expect(Webpacker.compiler.send(:webpack_env)["SHAKAPACKER_ASSET_HOST"]).to eq "foo.bar" - expect(Webpacker.compiler.send(:webpack_env)["SHAKAPACKER_RELATIVE_URL_ROOT"]).to eq "/baz" end end diff --git a/spec/shakapacker/compiler_spec.rb b/spec/shakapacker/compiler_spec.rb index 1fbd3b4a..7fb7a406 100644 --- a/spec/shakapacker/compiler_spec.rb +++ b/spec/shakapacker/compiler_spec.rb @@ -48,12 +48,9 @@ it "accepts external env variables" do expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_ASSET_HOST"]).to eq "" - expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_RELATIVE_URL_ROOT"]).to eq "" allow(ENV).to receive(:fetch).with("SHAKAPACKER_ASSET_HOST", nil).and_return("foo.bar") - allow(ENV).to receive(:fetch).with("SHAKAPACKER_RELATIVE_URL_ROOT", nil).and_return("/baz") expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_ASSET_HOST"]).to eq "foo.bar" - expect(Shakapacker.compiler.send(:webpack_env)["SHAKAPACKER_RELATIVE_URL_ROOT"]).to eq "/baz" end end diff --git a/spec/shakapacker/configuration_spec.rb b/spec/shakapacker/configuration_spec.rb index 0b454871..a2746383 100644 --- a/spec/shakapacker/configuration_spec.rb +++ b/spec/shakapacker/configuration_spec.rb @@ -373,46 +373,4 @@ end end end - - describe "#relative_url_root" do - let(:config) do - Shakapacker::Configuration.new( - root_path: ROOT_PATH, - config_path: Pathname.new(File.expand_path("./test_app/config/shakapacker.yml", __dir__)), - env: "production" - ) - end - - it "returns the value of SHAKAPACKER_RELATIVE_URL_ROOT if set" do - expect(ENV).to receive(:fetch).with("SHAKAPACKER_RELATIVE_URL_ROOT", nil).and_return("custom_value") - - expect(config.relative_url_root).to eq "custom_value" - end - - context "without SHAKAPACKER_RELATIVE_URL_ROOT set" do - it "returns relative_url_root in shakapacker.yml if set" do - expect(config).to receive(:fetch).with(:relative_url_root).and_return("value-in-config-file") - expect(ENV).to receive(:fetch).with("SHAKAPACKER_RELATIVE_URL_ROOT", "value-in-config-file").and_return("value-in-config-file") - - expect(config.relative_url_root).to eq "value-in-config-file" - end - - context "without relative_url_root set in the shakapacker.yml" do - it "returns ActionController::Base.relative_url_root if SHAKAPACKER_RELATIVE_URL_ROOT is not set" do - expect(ActionController::Base).to receive(:relative_url_root).and_return("abcd") - expect(ENV).to receive(:fetch).with("SHAKAPACKER_RELATIVE_URL_ROOT", "abcd").and_return("abcd") - - expect(config.relative_url_root).to eq "abcd" - end - - context "without ActionController::Base.relative_url_root returing any value" do - it "returns an empty string" do - expect(ENV).to receive(:fetch).with("SHAKAPACKER_RELATIVE_URL_ROOT", nil).and_return(nil) - - expect(config.relative_url_root).to eq "" - end - end - end - end - end end