diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a6cf02c..d24f9ee3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - For Rails applications, `suppress_required_validations` is automatically set to `true` if `SECRET_KEY_BASE_DUMMY` is defined. - Fix handling relative vs. absolute paths in `autoload_static_configs_path=`. ([@palkan][]) +- Fix support for array values in `except` option for required attributes. ([@dominikb][]) ## 2.6.4 (2024-04-30) diff --git a/lib/anyway/settings.rb b/lib/anyway/settings.rb index 4fc3a240..2f4b6c33 100644 --- a/lib/anyway/settings.rb +++ b/lib/anyway/settings.rb @@ -89,7 +89,7 @@ def matching_env?(env) if env.is_a?(::Hash) envs = env[:except] - excluded_envs = [envs].flat_map(&:to_s) + excluded_envs = [*envs].flat_map(&:to_s) excluded_envs.none?(current_environment) elsif env.is_a?(::Array) env.flat_map(&:to_s).include?(current_environment) diff --git a/spec/config_spec.rb b/spec/config_spec.rb index fbe65269..fc456574 100644 --- a/spec/config_spec.rb +++ b/spec/config_spec.rb @@ -896,6 +896,16 @@ def self.name end end + context "when current env matches one of env options under except array" do + before { allow(Anyway::Settings).to receive(:current_environment).and_return("local") } + + let(:missed_keys) { [:sentry_api_key] } + + it "not raises ValidationError" do + expect { demo_config.new }.to_not raise_error + end + end + context "when env value under except key mismatched" do before { allow(Anyway::Settings).to receive(:current_environment).and_return("demo") }