From 4fb92c65fc166cf1276aa5fb783e8dc31322d27c Mon Sep 17 00:00:00 2001 From: Paul Hayes Date: Mon, 11 Sep 2017 17:07:32 +0100 Subject: [PATCH] Upload to different surge domains based on PR --- app.rb | 4 +--- lib/govuk_visual_regression/visual_diff/heroku_runner.rb | 3 ++- lib/govuk_visual_regression/visual_diff/runner.rb | 8 ++++---- spec/govuk_visual_regression/visual_diff/runner_spec.rb | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app.rb b/app.rb index 6aa4cb1..07e8467 100644 --- a/app.rb +++ b/app.rb @@ -13,8 +13,6 @@ end environment = payload['deployment']['environment'] - review_domain = "https://#{environment}.herokuapp.com" - paths = GovukVisualRegression::VisualDiff::DocumentTypes.new.type_paths('statistics') - GovukVisualRegression::VisualDiff::Runner.new(paths: paths, review_domain: review_domain).run + GovukVisualRegression::VisualDiff::HerokuRunner.new(paths: paths, environment: environment).run end diff --git a/lib/govuk_visual_regression/visual_diff/heroku_runner.rb b/lib/govuk_visual_regression/visual_diff/heroku_runner.rb index 964c429..b74308a 100644 --- a/lib/govuk_visual_regression/visual_diff/heroku_runner.rb +++ b/lib/govuk_visual_regression/visual_diff/heroku_runner.rb @@ -6,7 +6,8 @@ def install_surge end def upload_to_surge - @kernel.system "surge --project results/visual/ --domain govuk-vr.surge.sh" + surge_domain = @environment ? @environment : "govuk-vr" + @kernel.system "surge --project results/visual/ --domain #{surge_domain}.surge.sh" end def run diff --git a/lib/govuk_visual_regression/visual_diff/runner.rb b/lib/govuk_visual_regression/visual_diff/runner.rb index a7ed728..2929a5d 100644 --- a/lib/govuk_visual_regression/visual_diff/runner.rb +++ b/lib/govuk_visual_regression/visual_diff/runner.rb @@ -1,15 +1,15 @@ module GovukVisualRegression module VisualDiff class Runner - def initialize(paths:, review_domain: nil, live_domain: nil, kernel: Kernel) + def initialize(paths:, environment: nil, kernel: Kernel) @paths = paths @kernel = kernel - @live_domain = live_domain - @review_domain = review_domain + @environment = environment end def run - wraith_config = WraithConfig.new(paths: @paths, review_domain: @review_domain, live_domain: @live_domain) + review_domain = @environment ? "https://#{@environment}.herokuapp.com" : nil + wraith_config = WraithConfig.new(paths: @paths, review_domain: review_domain) wraith_config.write cmd = "wraith capture #{wraith_config.location}" diff --git a/spec/govuk_visual_regression/visual_diff/runner_spec.rb b/spec/govuk_visual_regression/visual_diff/runner_spec.rb index c80dd8a..601eb24 100644 --- a/spec/govuk_visual_regression/visual_diff/runner_spec.rb +++ b/spec/govuk_visual_regression/visual_diff/runner_spec.rb @@ -12,12 +12,12 @@ end it "executes wraith with the appropriate config" do - expect(config_handler_klass).to receive(:new).with(paths: ["/government/stats/foo", "/government/stats/bar"], review_domain: 'review', live_domain: nil) + expect(config_handler_klass).to receive(:new).with(paths: ["/government/stats/foo", "/government/stats/bar"], review_domain: nil) expect(config_handler).to receive(:write) expect(kernel).to receive(:system).with("wraith capture #{config_handler.location}") expect(config_handler).to receive(:delete) - expect { described_class.new(paths: input_paths, review_domain: 'review', kernel: kernel).run }.to output( + expect { described_class.new(paths: input_paths, kernel: kernel).run }.to output( "---> Creating Visual Diffs\n" + "running: wraith capture #{config_handler.location}\n" ).to_stdout