Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/assets/stylesheets/modules/gem.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
.gem__ghbtn {
margin-bottom: 15px; }

.gem__owners {
.gem__gravatars {
margin-top: 16px; }
.gem__owners img {
.gem__gravatars img {
margin-right: 12px;
margin-bottom: 12px;
height: 32px;
width: 32px;
border-radius: 16px; }
.gem__owners a:hover:before {
.gem__gravatars a:hover:before {
content: "";
height: 32px;
width: 32px;
Expand Down
34 changes: 6 additions & 28 deletions app/helpers/rubygems_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,6 @@ def simple_markup(text)
end
end

def subscribe_link(rubygem)
if signed_in?
style = if rubygem.subscribers.find_by_id(current_user.id)
'display:none'
else
'display:inline-block'
end
link_to t('.links.subscribe'), rubygem_subscription_path(rubygem),
class: ['toggler', 'gem__link', 't-list__item'], id: 'subscribe',
method: :post, remote: true, style: style
else
link_to t('.links.subscribe'), sign_in_path,
class: [:toggler, 'gem__link', 't-list__item'], id: :subscribe
end
end

def unsubscribe_link(rubygem)
return unless signed_in?
style = if rubygem.subscribers.find_by_id(current_user.id)
'display:inline-block'
else
'display:none'
end
link_to t('.links.unsubscribe'), rubygem_subscription_path(rubygem),
class: [:toggler, 'gem__link', 't-list__item'], id: 'unsubscribe',
method: :delete, remote: true, style: style
end

def atom_link(rubygem)
link_to t(".links.rss"), rubygem_versions_path(rubygem, format: 'atom'),
class: 'gem__link t-list__item', id: :rss
Expand All @@ -93,6 +65,12 @@ def report_abuse_link(rubygem)
link_to t(".links.report_abuse"), report_abuse_url.html_safe, class: 'gem__link t-list__item'
end

def link_to_pusher(handle)
user = User.find_by_slug!(handle)
link_to gravatar(48, "gravatar-#{user.id}", user), profile_path(user.display_id),
alt: handle, title: handle
end

def links_to_owners(rubygem)
rubygem.owners.sort_by(&:id).map do |owner|
link_to gravatar(48, "gravatar-#{owner.id}", owner), profile_path(owner.display_id),
Expand Down
29 changes: 29 additions & 0 deletions app/helpers/rubygems_subscription_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module RubygemsSubscriptionHelper
def subscribe_link(rubygem)
if signed_in?
style = if rubygem.subscribers.find_by_id(current_user.id)
'display:none'
else
'display:inline-block'
end
link_to t('.links.subscribe'), rubygem_subscription_path(rubygem),
class: ['toggler', 'gem__link', 't-list__item'], id: 'subscribe',
method: :post, remote: true, style: style
else
link_to t('.links.subscribe'), sign_in_path,
class: [:toggler, 'gem__link', 't-list__item'], id: :subscribe
end
end

def unsubscribe_link(rubygem)
return unless signed_in?
style = if rubygem.subscribers.find_by_id(current_user.id)
'display:inline-block'
else
'display:none'
end
link_to t('.links.unsubscribe'), rubygem_subscription_path(rubygem),
class: [:toggler, 'gem__link', 't-list__item'], id: 'unsubscribe',
method: :delete, remote: true, style: style
end
end
3 changes: 2 additions & 1 deletion app/models/pusher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def find
@version = @rubygem.versions.new number: spec.version.to_s,
platform: spec.original_platform.to_s,
size: size,
sha256: sha256
sha256: sha256,
pushed_by: user.handle

true
end
Expand Down
1 change: 1 addition & 0 deletions app/models/rubygem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def payload(version = versions.most_recent, protocol = Gemcutter::PROTOCOL, host
'version_downloads' => version.downloads_count,
'platform' => version.platform,
'authors' => version.authors,
'pushed_by' => version.pushed_by,
'info' => version.info,
'licenses' => version.licenses,
'metadata' => version.metadata,
Expand Down
9 changes: 8 additions & 1 deletion app/views/rubygems/_gem_members.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<div class="gem__members">
<% if latest_version.pushed_by.present? %>
<h3 class="t-list__heading"><%= t '.publish_header' %>:</h3>
<div class="gem__gravatars">
<%= link_to_pusher(latest_version.pushed_by) %>
</div>
<% end %>

<% if latest_version.authors.present? %>
<h3 class="t-list__heading"><%= t '.authors_header' %>:</h3>
<ul class="t-list__items">
Expand All @@ -10,7 +17,7 @@

<% if rubygem.owners.present? %>
<h3 class="t-list__heading"><%= t '.owners_header' %>:</h3>
<div class="gem__owners">
<div class="gem__gravatars">
<%= links_to_owners(rubygem) %>
</div>
<% end %>
Expand Down
1 change: 0 additions & 1 deletion app/views/versions/_version.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<% if version.platformed? %>
<span class="gem__version__date platform"><%= version.platform %></span>
<% end %>

<span class="gem__version__date">(<%= number_to_human_size(version.size) %>)</span>
<% if version.yanked? -%>
<span class="gem__version__date"><%= t '.yanked' %></span>
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ en:
title: 'Gems'
downloads: Downloads
gem_members:
publish_header: Published by
authors_header: Authors
owners_header: Owners
sha_256_checksum: SHA 256 checksum
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20161222090545_add_pushed_by_to_versions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPushedByToVersions < ActiveRecord::Migration
def change
add_column :versions, :pushed_by, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160929104437) do
ActiveRecord::Schema.define(version: 20161222090545) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -177,6 +177,7 @@
t.string "required_rubygems_version"
t.string "info_checksum"
t.string "yanked_info_checksum"
t.string "pushed_by"
end

add_index "versions", ["built_at"], name: "index_versions_on_built_at", using: :btree
Expand Down
18 changes: 10 additions & 8 deletions test/functional/rubygems_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,11 @@ class RubygemsControllerTest < ActionController::TestCase
context "On GET to show with a gem that has multiple versions" do
setup do
@rubygem = create(:rubygem)
@owner = create(:user)
@rubygem.owners << @owner
@versions = [
create(:version, number: "2.0.0rc1", rubygem: @rubygem, created_at: 1.day.ago),
create(:version, number: "1.9.9", rubygem: @rubygem, created_at: 1.minute.ago),
create(:version, number: "1.9.9", rubygem: @rubygem, created_at: 1.minute.ago, pushed_by: @owner.handle),
create(:version, number: "1.9.9.rc4", rubygem: @rubygem, created_at: 2.days.ago)
]
get :show, id: @rubygem.to_param
Expand All @@ -319,14 +321,14 @@ class RubygemsControllerTest < ActionController::TestCase
should render_template :show
should "render info about the gem" do
assert page.has_content?(@rubygem.name)
assert page.has_content?(@versions[0].number)
css = "small:contains('#{@versions[0].built_at.to_date.to_formatted_s(:long)}')"
assert page.has_css?(css)

assert page.has_content?("Versions")
assert page.has_content?(@versions[2].number)
css = "small:contains('#{@versions[2].built_at.to_date.to_formatted_s(:long)}')"
assert page.has_css?(css)

@versions.each do |version|
assert page.has_content?(version.number)
css = "small:contains('#{version.built_at.to_date.to_formatted_s(:long)}')"
assert page.has_css?(css)
assert page.has_selector?("a[href='#{profile_path(version.pushed_by)}']") if version.pushed_by.present?
end
end

should "render versions in correct order" do
Expand Down