Skip to content
Merged
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
38 changes: 4 additions & 34 deletions app/controllers/rubygems_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
class RubygemsController < ApplicationController
include LatestVersion
before_action :redirect_to_root, only: %i[edit update], unless: :signed_in?
before_action :set_blacklisted_gem, only: %i[show], if: :blacklisted?
before_action :find_rubygem, only: %i[edit update show], unless: :blacklisted?
before_action :latest_version, only: %i[show], unless: :blacklisted?
before_action :find_versioned_links, only: %i[show], unless: :blacklisted?
before_action :load_gem, only: %i[edit update]
before_action :set_blacklisted_gem, only: :show, if: :blacklisted?
before_action :find_rubygem, only: :show, unless: :blacklisted?
before_action :latest_version, only: :show, unless: :blacklisted?
before_action :find_versioned_links, only: :show, unless: :blacklisted?
before_action :set_page, only: :index

def index
Expand Down Expand Up @@ -34,30 +32,6 @@ def show
end
end

def edit
flash[:warning] = t('.deprecation_message').html_safe # rubocop:disable Rails/OutputSafety
end

def update
if @linkset.update(params_linkset)
redirect_to rubygem_path(@rubygem)
flash[:success] = "Gem links updated."
else
render :edit
end
end

protected

def load_gem
unless @rubygem.owned_by?(current_user)
flash[:warning] = "You do not have permission to edit this gem."
redirect_to root_path
end

@linkset = @rubygem.linkset
end

private

def blacklisted?
Expand All @@ -67,8 +41,4 @@ def blacklisted?
def set_blacklisted_gem
@blacklisted_gem = params[:id].downcase
end

def params_linkset
params.require(:linkset).permit(:code, :docs, :wiki, :mail, :bugs)
end
end
2 changes: 0 additions & 2 deletions app/views/rubygems/_aside.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@

<h3 class="t-list__heading"><%= t '.links.header' %>:</h3>
<div class="t-list__items">
<%= link_to t('edit'), edit_rubygem_path(@rubygem), :class => "gem__link t-list__item", :id => "edit" if @rubygem.owned_by?(current_user) %>

<%- @versioned_links.each do |name, link| %>
<%= link_to_page name, link %>
<%- end %>
Expand Down
31 changes: 0 additions & 31 deletions app/views/rubygems/edit.html.erb

This file was deleted.

5 changes: 0 additions & 5 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ de:
blacklisted_namespace:
dependencies:
header: "%{title} Abhängigkeiten"
edit:
other_fields_notice: Alle anderen Felder können nur durch eine gepushte, aktualisierte Version deines Gems bearbeitet werden.
subtitle: für %{gem}
title: Bearbeite Links
deprecation_message:
gem_members:
authors_header: Autoren
owners_header: Besitzer
Expand Down
5 changes: 0 additions & 5 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ en:
blacklisted_namespace: This namespace is reserved by rubygems.org.
dependencies:
header: "%{title} Dependencies"
edit:
other_fields_notice: All other fields can only be edited by pushing an updated version of your gem.
subtitle: for %{gem}
title: Edit links
deprecation_message: This page has been deprecated. Please use Gem::Specification#metadata to configure these links. (<a href='https://guides.rubygems.org/specification-reference/#metadata' target='_blank'>read more</a>)
gem_members:
authors_header: Authors
owners_header: Owners
Expand Down
5 changes: 0 additions & 5 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ es:
blacklisted_namespace:
dependencies:
header: dependencias de %{title}
edit:
other_fields_notice: Los otros campos solo pueden ser editados al envíar una versión nueva de tu gema.
subtitle: para %{gem}
title: Editar ligas
deprecation_message:
gem_members:
authors_header: Autores
owners_header: Administradores
Expand Down
5 changes: 0 additions & 5 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ fr:
blacklisted_namespace: Ce nom est réservé par rubygems.org.
dependencies:
header: Dépendances de %{title}
edit:
other_fields_notice: Tous les autres champs ne sont modifiables qu'en soumettant une nouvelle version de votre gem.
subtitle: pour %{gem}
title: Modifier les liens
deprecation_message: Cette page est obsolète. Veuillez utiliser Gem::Specification#metadata pour configurer ces liens. (<a href='https://guides.rubygems.org/specification-reference/#metadata' target='_blank'>read more</a>)
gem_members:
authors_header: Auteurs
owners_header: Propriétaires
Expand Down
5 changes: 0 additions & 5 deletions config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ nl:
blacklisted_namespace:
dependencies:
header: "%{title} afhankelijkheden"
edit:
other_fields_notice: Alle andere velden kunnen alleen gewijzigd worden door een nieuwe versie van de gem te publiceren.
subtitle: voor %{gem}
title: Wijzig gem links
deprecation_message:
gem_members:
authors_header:
owners_header: Eigenaren
Expand Down
5 changes: 0 additions & 5 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ pt-BR:
blacklisted_namespace: This namespace is reserved by rubygems.org.
dependencies:
header:
edit:
other_fields_notice: Os outros campos só podem ser editados quando você submeter uma versão atualizada da sua gem.
subtitle: "%{gem}"
title: Editar links
deprecation_message:
gem_members:
authors_header: Autores
owners_header: Donos
Expand Down
5 changes: 0 additions & 5 deletions config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ zh-CN:
blacklisted_namespace:
dependencies:
header: "%{title} 依赖关系"
edit:
other_fields_notice: 其他字段的信息你只能通过发布一个新版本的 Gem 来修改。
subtitle: "%{gem}"
title: 编辑链接
deprecation_message:
gem_members:
authors_header: 作者
owners_header: 所有者
Expand Down
5 changes: 0 additions & 5 deletions config/locales/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ zh-TW:
blacklisted_namespace:
dependencies:
header: "%{title} 相依性套件"
edit:
other_fields_notice: 其他設定欄位只能透過發佈一個新版本的 Gem 來修改
subtitle: "%{gem}"
title: 編輯連結
deprecation_message:
gem_members:
authors_header: 作者
owners_header: 擁有者
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
end

resources :rubygems,
only: %i[index show edit update],
only: %i[index show update],
path: 'gems',
constraints: { id: Patterns::ROUTE_PATTERN, format: /html|atom/ } do
resource :subscription,
Expand Down
122 changes: 0 additions & 122 deletions test/functional/rubygems_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,6 @@ class RubygemsControllerTest < ActionController::TestCase
end
end

context "On GET to show for another user's gem" do
setup do
@rubygem = create(:rubygem, number: "1.0.0")
get :show, params: { id: @rubygem.to_param }
end

should respond_with :success
should "not render edit link" do
refute page.has_selector?("a[href='#{edit_rubygem_path(@rubygem)}']")
end
end

context "On GET to show for this user's gem" do
setup do
@rubygem = create(:rubygem, owners: [@user], number: "1.0.0")
get :show, params: { id: @rubygem.to_param }
end

should respond_with :success
should "render edit link" do
assert page.has_selector?("a[href='#{edit_rubygem_path(@rubygem)}']")
end
end

context "On GET to show for a gem that the user is subscribed to" do
setup do
@rubygem = create(:rubygem)
Expand Down Expand Up @@ -88,86 +64,6 @@ class RubygemsControllerTest < ActionController::TestCase
refute page.has_content? 'Unsubscribe'
end
end

context "On GET to edit for this user's gem" do
setup do
@rubygem = create(:rubygem, owners: [@user], number: "1.0.0")
get :edit, params: { id: @rubygem.to_param }
end

should respond_with :success
should "render form" do
assert page.has_selector?("form")
assert page.has_selector?("input#linkset_code")
assert page.has_selector?("input#linkset_docs")
assert page.has_selector?("input#linkset_wiki")
assert page.has_selector?("input#linkset_mail")
assert page.has_selector?("input#linkset_bugs")
assert page.has_selector?("input[type='submit']")
end
end

context "On GET to edit for another user's gem" do
setup do
@other_user = create(:user)
@rubygem = create(:rubygem, owners: [@other_user], number: "1.0.0")
get :edit, params: { id: @rubygem.to_param }
end
should respond_with :redirect
should redirect_to('the homepage') { root_path }
should set_flash.to("You do not have permission to edit this gem.")
end

context "On PUT to update for this user's gem that is successful" do
setup do
@url = "https://github.com/qrush/gemcutter"
@rubygem = create(:rubygem, owners: [@user], number: "1.0.0")
put :update,
params: {
id: @rubygem.to_param,
linkset: {
code: @url,
docs: 'http://docs.com',
wiki: 'http://wiki.com',
mail: 'http://mail.com',
bugs: 'http://bugs.com'
}
}
end
should respond_with :redirect
should redirect_to('the gem') { rubygem_path(@rubygem) }
should set_flash.to("Gem links updated.")
should "update source code url" do
assert_equal @url, Rubygem.last.linkset.code
end
should "update documentation rul" do
assert_equal 'http://docs.com', Rubygem.last.linkset.docs
end
should "update wiki url" do
assert_equal 'http://wiki.com', Rubygem.last.linkset.wiki
end
should "update mailing list url" do
assert_equal 'http://mail.com', Rubygem.last.linkset.mail
end
should "update bugtracker url" do
assert_equal 'http://bugs.com', Rubygem.last.linkset.bugs
end
end

context "On PUT to update for this user's gem that fails" do
setup do
@rubygem = create(:rubygem, owners: [@user], number: "1.0.0")
@url = "totally not a url"
put :update, params: { id: @rubygem.to_param, linkset: { code: @url } }
end
should respond_with :success
should "not update linkset" do
assert_not_equal @url, Rubygem.last.linkset.code
end
should "render error messages" do
assert page.has_content?("error prohibited")
end
end
end

context "On GET to index with no parameters" do
Expand Down Expand Up @@ -494,23 +390,5 @@ class RubygemsControllerTest < ActionController::TestCase
refute page.has_selector?("a#unsubscribe")
end
end

context "On GET to edit" do
setup do
@rubygem = create(:rubygem)
get :edit, params: { id: @rubygem.to_param }
end
should respond_with :redirect
should redirect_to('the homepage') { root_path }
end

context "On PUT to update" do
setup do
@rubygem = create(:rubygem)
put :update, params: { id: @rubygem.to_param, linkset: {} }
end
should respond_with :redirect
should redirect_to('the homepage') { root_path }
end
end
end