[ARVADOS] updated: 1.3.0-390-g0dbe95af0

Git user git at public.curoverse.com
Tue Feb 26 15:18:50 EST 2019


Summary of changes:
 .../config/initializers/validate_wb2_url_config.rb | 17 ++-----------
 apps/workbench/lib/config_validators.rb            | 28 ++++++++++++++++++++++
 .../test/integration/application_layout_test.rb    |  2 ++
 3 files changed, 32 insertions(+), 15 deletions(-)
 create mode 100644 apps/workbench/lib/config_validators.rb

       via  0dbe95af08f5e63086ee14a287350a36d3405812 (commit)
      from  ebf4385eee0408a357641254aac688ecc713be6f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 0dbe95af08f5e63086ee14a287350a36d3405812
Author: Lucas Di Pentima <ldipentima at veritasgenetics.com>
Date:   Tue Feb 26 17:18:19 2019 -0300

    14794: Moved config validator to lib/ so that it can be testable.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima at veritasgenetics.com>

diff --git a/apps/workbench/config/initializers/validate_wb2_url_config.rb b/apps/workbench/config/initializers/validate_wb2_url_config.rb
index 9725e7d97..f9096486c 100644
--- a/apps/workbench/config/initializers/validate_wb2_url_config.rb
+++ b/apps/workbench/config/initializers/validate_wb2_url_config.rb
@@ -2,19 +2,6 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
-require 'uri'
+include ConfigValidators
 
-if Rails.configuration.workbench2_url
-    begin
-        if !URI.parse(Rails.configuration.workbench2_url).is_a?(URI::HTTP)
-            Rails.logger.warn("workbench2_url config is not an HTTP URL: #{Rails.configuration.workbench2_url}")
-            Rails.configuration.workbench2_url = false
-        elsif /.*[\/]{2,}$/.match(Rails.configuration.workbench2_url)
-            Rails.logger.warn("workbench2_url config shouldn't have multiple trailing slashes: #{Rails.configuration.workbench2_url}")
-            Rails.configuration.workbench2_url = false
-        end
-    rescue URI::InvalidURIError
-        Rails.logger.warn("workbench2_url config invalid URL: #{Rails.configuration.workbench2_url}")
-        Rails.configuration.workbench2_url = false
-    end
-end
+ConfigValidators::validate_wb2_url_config()
\ No newline at end of file
diff --git a/apps/workbench/lib/config_validators.rb b/apps/workbench/lib/config_validators.rb
new file mode 100644
index 000000000..ec769168c
--- /dev/null
+++ b/apps/workbench/lib/config_validators.rb
@@ -0,0 +1,28 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
+require 'uri'
+
+module ConfigValidators
+    def validate_wb2_url_config
+        if Rails.configuration.workbench2_url
+            begin
+                if !URI.parse(Rails.configuration.workbench2_url).is_a?(URI::HTTP)
+                    Rails.logger.warn("workbench2_url config is not an HTTP URL: #{Rails.configuration.workbench2_url}")
+                    Rails.configuration.workbench2_url = false
+                elsif /.*[\/]{2,}$/.match(Rails.configuration.workbench2_url)
+                    Rails.logger.warn("workbench2_url config shouldn't have multiple trailing slashes: #{Rails.configuration.workbench2_url}")
+                    Rails.configuration.workbench2_url = false
+                else
+                    return true
+                end
+            rescue URI::InvalidURIError
+                Rails.logger.warn("workbench2_url config invalid URL: #{Rails.configuration.workbench2_url}")
+                Rails.configuration.workbench2_url = false
+            end
+        end
+        return false
+    end
+end
+
diff --git a/apps/workbench/test/integration/application_layout_test.rb b/apps/workbench/test/integration/application_layout_test.rb
index 77b08368c..b3f704cdd 100644
--- a/apps/workbench/test/integration/application_layout_test.rb
+++ b/apps/workbench/test/integration/application_layout_test.rb
@@ -152,6 +152,8 @@ class ApplicationLayoutTest < ActionDispatch::IntegrationTest
   ].each do |wb2_url_config, wb2_menu_appear|
     test "workbench2_url=#{wb2_url_config} should#{wb2_menu_appear ? '' : ' not'} show WB2 menu" do
       Rails.configuration.workbench2_url = wb2_url_config
+      assert_equal wb2_menu_appear, ConfigValidators::validate_wb2_url_config()
+
       visit page_with_token('active')
       within('.navbar-fixed-top') do
         page.find("#notifications-menu").click

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list