Skip to content

Commit

Permalink
Merge pull request #3193 from nvasilevski/add-superscript-start-for-t…
Browse files Browse the repository at this point in the history
…ooltiped-version-numbers

Use superscript star for a rubygem version date with a tooltip
  • Loading branch information
sonalkr132 authored Aug 25, 2022
2 parents 9277173 + 07fd8a2 commit dee7118
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions app/helpers/versions_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ module VersionsHelper
def version_date_tag(version)
data = {}
klass = ["gem__version__date"]
text = version_authored_date(version)
date = version_authored_date(version)
if version.rely_on_built_at?
klass << "tooltip__text"
data.merge!(tooltip: t("versions.index.imported_gem_version_notice", import_date: nice_date_for(Version::RUBYGEMS_IMPORT_DATE)))
text << " [?]"
end

content_tag(:small, text, class: klass, data: data)
content_tag(:small, class: klass, data: data) do
concat date
concat content_tag(:sup, "*") if version.rely_on_built_at?
end
end

def version_authored_date(version)
Expand Down
8 changes: 5 additions & 3 deletions test/functional/versions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,24 @@ class VersionsControllerTest < ActionController::TestCase
setup do
@built_at = Date.parse("2000-01-01")
rubygem = create(:rubygem)
create(:version, rubygem: rubygem, created_at: Version::RUBYGEMS_IMPORT_DATE, built_at: @built_at)
create(:version, number: "1.1.2", rubygem: rubygem, created_at: Version::RUBYGEMS_IMPORT_DATE, built_at: @built_at)
get :index, params: { rubygem_id: rubygem.name }
end

should respond_with :success

should "show imported versions authored_at dates with an asterisk" do
should "show imported version number with an superscript asterisk and a tooltip" do
tooltip_text = <<~NOTICE.squish
This gem version was imported to RubyGems.org on July 25, 2009.
The date displayed was specified by the author in the gemspec.
NOTICE

assert_select ".gem__version__date", text: "- January 01, 2000 [?]", count: 1 do |elements|
assert_select ".gem__version__date", text: "- January 01, 2000*", count: 1 do |elements|
version = elements.first
assert_equal(tooltip_text, version["data-tooltip"])
end

assert_select ".gem__version__date sup", text: "*", count: 1
end
end

Expand Down

0 comments on commit dee7118

Please sign in to comment.