From 3f904a5ede4a8ed57dc93b20bc61427af21c8b36 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Fri, 5 Dec 2014 01:49:26 -0500 Subject: [PATCH] 4465: Link to arvados.org revision history instead of github.com code view. Also, remove spurious helper inclusions, and fix 'locally modified' detection (it was broken because "" is truthy). refs #4465 --- .../app/helpers/application_helper.rb | 2 -- apps/workbench/app/helpers/version_helper.rb | 29 ++++++++++--------- .../application/_report_issue_popup.html.erb | 4 +-- apps/workbench/config/application.default.yml | 2 +- .../test/integration/report_issue_test.rb | 10 ++++--- services/api/config/application.default.yml | 2 +- 6 files changed, 25 insertions(+), 24 deletions(-) diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb index e003b2cb0a..f1502afee1 100644 --- a/apps/workbench/app/helpers/application_helper.rb +++ b/apps/workbench/app/helpers/application_helper.rb @@ -1,6 +1,4 @@ module ApplicationHelper - include VersionHelper - def current_user controller.current_user end diff --git a/apps/workbench/app/helpers/version_helper.rb b/apps/workbench/app/helpers/version_helper.rb index 54470ae395..6cae78f53e 100644 --- a/apps/workbench/app/helpers/version_helper.rb +++ b/apps/workbench/app/helpers/version_helper.rb @@ -1,29 +1,30 @@ module VersionHelper - include ArvadosApiClientHelper + # api_version returns the git commit hash for the API server's + # current version. It is extracted from api_version_text, which + # returns the source_version provided by the discovery document and + # may have the word "-modified" appended to it (if the API server is + # running from a locally modified repository). - # api_version returns the git commit hash for the API server's current version. - # It is extracted from api_version_text, which returns the source_version provided - # by the discovery document and may have the word "-modified" appended to it (if - # the API server is running from a locally modified repository). - - def api_version() - api_version_text().sub(/[^[:xdigit:]].*/, '') + def api_version + api_version_text.sub(/[^[:xdigit:]].*/, '') end - def api_version_text() + def api_version_text arvados_api_client.discovery[:source_version] end # wb_version and wb_version_text provide the same strings for the # code version that this Workbench is currently running. - def wb_version() + def wb_version Rails.configuration.source_version end - def wb_version_text() - wbv = wb_version - wbv += Rails.configuration.local_modified if Rails.configuration.local_modified - wbv + def wb_version_text + wb_version + (Rails.configuration.local_modified or '') + end + + def version_link_target version + "https://arvados.org/projects/arvados/repository/changes?rev=#{version}" end end diff --git a/apps/workbench/app/views/application/_report_issue_popup.html.erb b/apps/workbench/app/views/application/_report_issue_popup.html.erb index 705ddffe11..315116bbc8 100644 --- a/apps/workbench/app/views/application/_report_issue_popup.html.erb +++ b/apps/workbench/app/views/application/_report_issue_popup.html.erb @@ -3,8 +3,8 @@ arvados_base = Rails.configuration.arvados_v1_base support_email = Rails.configuration.support_email_address - api_version_link = link_to api_version_text, "https://github.com/curoverse/arvados/tree/#{api_version}/services/api" - wb_version_link = link_to wb_version_text, "https://github.com/curoverse/arvados/tree/#{wb_version}/apps/workbench" + api_version_link = link_to api_version_text, version_link_target(api_version) + wb_version_link = link_to wb_version_text, version_link_target(wb_version) additional_info = {} additional_info['Current location'] = params[:current_location] diff --git a/apps/workbench/config/application.default.yml b/apps/workbench/config/application.default.yml index 7e95bb359e..b485276c09 100644 --- a/apps/workbench/config/application.default.yml +++ b/apps/workbench/config/application.default.yml @@ -38,7 +38,7 @@ development: assets.debug: true profiling_enabled: true site_name: Arvados Workbench (dev) - local_modified: <%= '-modified' if `git status -s` %> + local_modified: "<%= '-modified' if `git status -s` != '' %>" # API server configuration arvados_login_base: ~ diff --git a/apps/workbench/test/integration/report_issue_test.rb b/apps/workbench/test/integration/report_issue_test.rb index 3af7f922a3..ac9e596f8c 100644 --- a/apps/workbench/test/integration/report_issue_test.rb +++ b/apps/workbench/test/integration/report_issue_test.rb @@ -37,10 +37,12 @@ class ReportIssueTest < ActionDispatch::IntegrationTest assert page.has_no_text?('Describe the problem?'), 'Found text - Describe the problem' assert page.has_button?('Close'), 'No button - Close' assert page.has_no_button?('Send problem report'), 'Found button - Send problem report' - api_version_rgx = %r!^https://github.com/curoverse/arvados/tree/[0-9a-f]+/services/api/?$! - wb_version_rgx = %r!^https://github.com/curoverse/arvados/tree/[0-9a-f]+/apps/workbench/?$! - assert_not_empty(all("a").select { |a| a[:href] =~ wb_version_rgx }) - assert_not_empty(all("a").select { |a| a[:href] =~ api_version_rgx }) + history_links = all('a').select do |a| + a[:href] =~ %r!^https://arvados.org/projects/arvados/repository/changes\?rev=[0-9a-f]+$! + end + assert_operator(2, :<=, history_links.count, + "Should have found two links to revision history " + + "in #{history_links.inspect}") click_button 'Close' end diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml index 253f12a3ef..fb94402f99 100644 --- a/services/api/config/application.default.yml +++ b/services/api/config/application.default.yml @@ -15,7 +15,7 @@ development: active_record.auto_explain_threshold_in_seconds: 0.5 assets.compress: false assets.debug: true - local_modified: <%= '-modified' if `git status -s` %> + local_modified: "<%= '-modified' if `git status -s` != '' %>" production: force_ssl: true -- 2.39.5