Skip to content

Commit

Permalink
Merge pull request rubygems#412 from philnash/master
Browse files Browse the repository at this point in the history
Allow users to unsubscribe from yanked gems.
  • Loading branch information
sferik committed Mar 24, 2012
2 parents d220780 + 305224c commit dcfb3fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
8 changes: 3 additions & 5 deletions app/views/rubygems/show.html.erb
Expand Up @@ -25,11 +25,9 @@
<%= link_to t('edit'), edit_rubygem_path(@rubygem), :id => "edit" if @rubygem.owned_by?(current_user) %>
<%= download_link(@latest_version) %>
<%= documentation_link(@latest_version, @rubygem.linkset) %>
<% if @latest_version.indexed %>
<%= subscribe_link(@rubygem) %>
<%= unsubscribe_link(@rubygem) %>
<%= link_to t('.stats_header'), rubygem_stats_path(@rubygem), :id => "stats" %>
<% end %>
<%= subscribe_link(@rubygem) if @latest_version.indexed %>
<%= unsubscribe_link(@rubygem) %>
<%= link_to t('.stats_header'), rubygem_stats_path(@rubygem), :id => "stats" if @latest_version.indexed %>
</div>

<% if @latest_version.indexed %>
Expand Down
27 changes: 20 additions & 7 deletions test/functional/rubygems_controller_test.rb
Expand Up @@ -316,14 +316,27 @@ class RubygemsControllerTest < ActionController::TestCase
version = Factory(:version, :created_at => 1.minute.ago)
@rubygem = version.rubygem
@rubygem.yank!(version)
get :show, :id => @rubygem.to_param
end
should respond_with :success
should render_template :show
should assign_to :rubygem
should "render info about the gem" do
assert page.has_content?("This gem has been yanked")
assert page.has_no_content?('Versions')
context 'when signed out' do
setup { get :show, :id => @rubygem.to_param }
should respond_with :success
should render_template :show
should assign_to :rubygem
should "render info about the gem" do
assert page.has_content?("This gem has been yanked")
assert page.has_no_content?('Versions')
end
end
context 'with a signed in user subscribed to the gem' do
setup do
@user = Factory(:user)
sign_in_as @user
Factory(:subscription, :user => @user, :rubygem => @rubygem)
get :show, :id => @rubygem.to_param
end
should "have a visible unsubscribe link" do
assert page.has_selector?("a[style='display:inline-block']", :content => 'Unsubscribe')
end
end
end

Expand Down

0 comments on commit dcfb3fd

Please sign in to comment.