Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

63 lines (53 sloc) 1.901 kB
require 'test_helper'
class SubscriptionsControllerTest < ActionController::TestCase
context "When logged in" do
setup do
@user = create(:user)
sign_in_as(@user)
end
end
context "On POST to create for a gem that the user is not subscribed to" do
setup do
@rubygem = create(:rubygem)
create(:version, :rubygem => @rubygem)
post :create, :rubygem_id => @rubygem.to_param, :format => 'js'
end
should assign_to(:rubygem) { @rubygem }
should respond_with :success
should "toggle the subscribe link" do
assert_match /\("\.toggler"\)\.toggle\(\)/, @response.body
end
end
context "On POST to create for a gem that the user is subscribed to" do
setup do
@rubygem = create(:rubygem)
create(:version, :rubygem => @rubygem)
create(:subscription, :rubygem => @rubygem, :user => @user)
post :create, :rubygem_id => @rubygem.to_param, :format => 'js'
end
should assign_to(:rubygem) { @rubygem }
should respond_with :forbidden
end
context "On DELETE to destroy for a gem that the user is not subscribed to" do
setup do
@rubygem = create(:rubygem)
create(:version, :rubygem => @rubygem)
delete :destroy, :rubygem_id => @rubygem.to_param, :format => 'js'
end
should assign_to(:rubygem) { @rubygem }
should respond_with :forbidden
end
context "On DELETE to destroy for a gem that the user is subscribed to" do
setup do
@rubygem = create(:rubygem)
create(:version, :rubygem => @rubygem)
create(:subscription, :rubygem => @rubygem, :user => @user)
delete :destroy, :rubygem_id => @rubygem.to_param, :format => 'js'
end
should assign_to(:rubygem) { @rubygem }
should respond_with :success
should "toggle the subscribe link" do
assert_match /\("\.toggler"\)\.toggle\(\)/, @response.body
end
end
end
Jump to Line
Something went wrong with that request. Please try again.