Skip to content

Commit

Permalink
feat: change version ordering to order by date by default
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Jun 14, 2018
1 parent 93f7d16 commit 9e6fca7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion container/etc/nginx/main.d/pactbroker-env.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
env NO_PROXY;
4 changes: 2 additions & 2 deletions pact_broker/config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions pact_broker/docker_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion spec/docker_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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" }
Expand Down

0 comments on commit 9e6fca7

Please sign in to comment.