diff --git a/README.md b/README.md index 8f341c0..b525186 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ Set the environment variable `PACT_BROKER_LOG_LEVEL` to one of `DEBUG`, `INFO`, ## Other environment variables * PACT_BROKER_BASE_EQUALITY_ONLY_ON_CONTENT_THAT_AFFECTS_VERIFICATION_RESULTS - `true` by default, may be set to `false`. +* `PACT_BROKER_ORDER_VERSIONS_BY_DATE` - `true` by default, may be set to `false`. ## General Pact Broker configuration and usage diff --git a/container/etc/nginx/main.d/pactbroker-env.conf b/container/etc/nginx/main.d/pactbroker-env.conf index eed9a0c..ac1ecf1 100644 --- a/container/etc/nginx/main.d/pactbroker-env.conf +++ b/container/etc/nginx/main.d/pactbroker-env.conf @@ -12,9 +12,10 @@ env PACT_BROKER_WEBHOOK_HTTP_METHOD_WHITELIST; env PACT_BROKER_WEBHOOK_SCHEME_WHITELIST; env PACT_BROKER_WEBHOOK_HOST_WHITELIST; env PACT_BROKER_BASE_EQUALITY_ONLY_ON_CONTENT_THAT_AFFECTS_VERIFICATION_RESULTS; +env PACT_BROKER_ORDER_VERSIONS_BY_DATE; env http_proxy; env https_proxy; env no_proxy; env HTTP_PROXY; env HTTPS_PROXY; -env NO_PROXY; \ No newline at end of file +env NO_PROXY; diff --git a/pact_broker/config.ru b/pact_broker/config.ru index 21d1428..b52f44f 100644 --- a/pact_broker/config.ru +++ b/pact_broker/config.ru @@ -17,10 +17,10 @@ app = PactBroker::App.new do | config | config.webhook_http_method_whitelist = dc.webhook_http_method_whitelist config.webhook_scheme_whitelist = dc.webhook_scheme_whitelist config.base_equality_only_on_content_that_affects_verification_results = dc.base_equality_only_on_content_that_affects_verification_results + config.order_versions_by_date = dc.order_versions_by_date + config.load_from_database! end -PactBroker.configuration.load_from_database! - PactBroker::Configuration::SAVABLE_SETTING_NAMES.each do | setting | $logger.info "PactBroker.configuration.#{setting}=#{PactBroker.configuration.send(setting).inspect}" end diff --git a/pact_broker/docker_configuration.rb b/pact_broker/docker_configuration.rb index 20716e2..d3c7b23 100644 --- a/pact_broker/docker_configuration.rb +++ b/pact_broker/docker_configuration.rb @@ -35,6 +35,14 @@ def base_equality_only_on_content_that_affects_verification_results end end + def order_versions_by_date + if env_populated?(:order_versions_by_date) + env(:order_versions_by_date) == 'true' + else + true + end + end + def env name @env["PACT_BROKER_#{name.to_s.upcase}"] end diff --git a/spec/docker_configuration_spec.rb b/spec/docker_configuration_spec.rb index f5c0a91..120e068 100644 --- a/spec/docker_configuration_spec.rb +++ b/spec/docker_configuration_spec.rb @@ -8,10 +8,13 @@ let(:env) do { - "PACT_BROKER_WEBHOOK_HOST_WHITELIST" => host_whitelist + "PACT_BROKER_WEBHOOK_HOST_WHITELIST" => host_whitelist, + "PACT_BROKER_ORDER_VERSIONS_BY_DATE" => "false" } end + let(:host_whitelist) { "" } + let(:default_configuration) do instance_double('default configuration', webhook_host_whitelist: 'default' @@ -37,6 +40,17 @@ its(:pact_broker_environment_variables) { is_expected.to eq expected_environment_variables } end + describe "order_versions_by_date" do + context "when PACT_BROKER_ORDER_VERSIONS_BY_DATE is set to false" do + its(:order_versions_by_date) { is_expected.to be false } + end + + context "when PACT_BROKER_ORDER_VERSIONS_BY_DATE is not set" do + let(:env) { {} } + its(:order_versions_by_date) { is_expected.to be true } + end + end + describe "webhook_host_whitelist" do context "when PACT_BROKER_WEBHOOK_HOST_WHITELIST is 'foo bar'" do let(:host_whitelist) { "foo bar" }