Browse files

Ownership does not have to generate a token anymore

  • Loading branch information...
1 parent 92fa087 commit 12034a6e00ad647d0ecde01f3a314a6031501d9c @nickrivadeneira nickrivadeneira committed Jul 12, 2011
Showing with 0 additions and 16 deletions.
  1. +0 −6 app/models/ownership.rb
  2. +0 −10 test/unit/ownership_test.rb
View
6 app/models/ownership.rb
@@ -4,13 +4,8 @@ class Ownership < ActiveRecord::Base
validates :user_id, :uniqueness => {:scope => :rubygem_id}
- before_create :generate_token
before_destroy :keep_last_owner
- def generate_token
- self.token = ActiveSupport::SecureRandom.hex
- end
-
def keep_last_owner
if rubygem.owners.count == 1
errors[:base] << "Can't delete last owner of a gem."
@@ -19,5 +14,4 @@ def keep_last_owner
true
end
end
-
end
View
10 test/unit/ownership_test.rb
@@ -1,7 +1,6 @@
require 'test_helper'
class OwnershipTest < ActiveSupport::TestCase
-
should "be valid with factory" do
assert_valid Factory.build(:ownership)
end
@@ -20,14 +19,6 @@ class OwnershipTest < ActiveSupport::TestCase
subject { @ownership }
should validate_uniqueness_of(:user_id).scoped_to(:rubygem_id)
-
- should "create token" do
- assert_not_nil @ownership.token
- end
-
- should "have a 32 character hexadecimal api key" do
- assert @ownership.token =~ /[a-z0-9]{32}/
- end
end
context "with multiple ownerships on the same rubygem" do
@@ -49,5 +40,4 @@ class OwnershipTest < ActiveSupport::TestCase
assert_equal "Can't delete last owner of a gem.", @ownership_two.errors[:base].first
end
end
-
end

0 comments on commit 12034a6

Please sign in to comment.