diff --git a/app/helpers/rubygems_helper.rb b/app/helpers/rubygems_helper.rb index 7898a9e9475..16db99c1aa9 100644 --- a/app/helpers/rubygems_helper.rb +++ b/app/helpers/rubygems_helper.rb @@ -12,9 +12,15 @@ def formatted_licenses(license_names) end def link_to_page(id, url, verified: false) + return if url.blank? + classes = %w[gem__link t-list__item] - classes << "gem__link__verified" if verified - link_to(t("rubygems.aside.links.#{id}"), url, rel: "nofollow", class: classes, id: id) if url.present? + if verified + classes << "gem__link__verified" + title = t("rubygems.aside.link_verified") + end + + link_to(t("rubygems.aside.links.#{id}"), url, rel: "nofollow", class: classes, id:, title:) end def link_to_directory diff --git a/config/locales/de.yml b/config/locales/de.yml index a9e7347b5f6..65d054a18fb 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -612,6 +612,7 @@ de: required_rubygems_version: requires_mfa: released_with_mfa: + link_verified: links: badge: Abzeichen bugs: Bug Tracker diff --git a/config/locales/en.yml b/config/locales/en.yml index 139d55d933c..8d1e8b5f4f0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -596,6 +596,7 @@ en: required_rubygems_version: Required Rubygems Version requires_mfa: New versions require MFA released_with_mfa: Version published with MFA + link_verified: ✓ indicates a verified backlink links: badge: Badge bugs: Bug Tracker diff --git a/config/locales/es.yml b/config/locales/es.yml index b6b4ad88ac6..5bca381805b 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -703,6 +703,7 @@ es: required_rubygems_version: Versión de Rubygems requerida requires_mfa: Nuevas versiones requieren AMF released_with_mfa: Versión publicada con AMF + link_verified: links: badge: Badge bugs: Seguimiento de Bugs diff --git a/config/locales/fr.yml b/config/locales/fr.yml index e127bef4999..b0016bb82bd 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -631,6 +631,7 @@ fr: required_rubygems_version: requires_mfa: released_with_mfa: + link_verified: links: badge: Badge bugs: Suivi de bugs diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 3fb56292342..37cabb60209 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -597,6 +597,7 @@ ja: required_rubygems_version: 必要なRubyGemsのバージョン requires_mfa: 新しいバージョンはMFAを必要とします released_with_mfa: MFAで投稿されたバージョン + link_verified: links: badge: バッジ bugs: バグトラッカー diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 2ac2633b314..767ab79b9b7 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -598,6 +598,7 @@ nl: required_rubygems_version: Required Rubygems Version requires_mfa: released_with_mfa: + link_verified: links: badge: Badge bugs: Bug-tracker diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 40ef7fe51e6..fe5ee68ffda 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -609,6 +609,7 @@ pt-BR: required_rubygems_version: Versão Requerida do RubyGems requires_mfa: released_with_mfa: + link_verified: links: badge: Badge bugs: diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 476bf9bdc3a..47351c84abf 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -605,6 +605,7 @@ zh-CN: required_rubygems_version: 需要的 RubyGems 版本 requires_mfa: 新的版本需要开启多因素验证 released_with_mfa: 使用多因素验证发布的版本 + link_verified: links: badge: 徽章 bugs: Bug 追踪 diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 3edf3b68b57..0d62240e00e 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -581,6 +581,7 @@ zh-TW: required_rubygems_version: RubyGems 版本需求 requires_mfa: released_with_mfa: + link_verified: links: badge: 徽章 bugs: Bug 追蹤 diff --git a/test/integration/gems_test.rb b/test/integration/gems_test.rb index 4a16312365f..14c7435d03c 100644 --- a/test/integration/gems_test.rb +++ b/test/integration/gems_test.rb @@ -168,6 +168,16 @@ class GemsSystemTest < SystemTest assert page.has_selector?(".github-btn") end + test "shows verified link when hompage_uri is set and verified" do + github_link = "http://github.com/user/project" + version = create(:version, number: "3.0.1", rubygem: @rubygem, metadata: { "homepage_uri" => github_link }) + version.rubygem.link_verifications.create!(uri: github_link, last_verified_at: 1.day.ago) + + visit rubygem_path(@rubygem.slug) + + assert page.has_selector?(".gem__link__verified") + end + test "shows github link when homepage_uri is set" do github_link = "http://github.com/user/project" create(:version, number: "3.0.1", rubygem: @rubygem, metadata: { "homepage_uri" => github_link })