Permalink
Browse files

Adding linksets

  • Loading branch information...
1 parent 97ccc2b commit 94e4bc10dc951aa2855b70a359e98ac47a20d5b1 @qrush qrush committed Jun 1, 2009
View
@@ -0,0 +1,3 @@
+class Linkset < ActiveRecord::Base
+ belongs_to :rubygem
+end
View
@@ -4,6 +4,7 @@ class Rubygem < ActiveRecord::Base
belongs_to :user
has_many :versions, :dependent => :destroy
+ has_one :linkset, :dependent => :destroy
validates_presence_of :name
validates_uniqueness_of :name
@@ -58,6 +59,8 @@ def build
:name => dependency.name,
:requirement => dependency.requirements_list.to_s)
end
+
+ self.build_linkset(:home => self.spec.homepage)
end
def store
@@ -0,0 +1,19 @@
+class CreateLinksets < ActiveRecord::Migration
+ def self.up
+ create_table :linksets do |table|
+ table.integer :rubygem_id
+ table.string :home
+ table.string :wiki
+ table.string :docs
+ table.string :mail
+ table.string :code
+ table.string :bugs
+ table.timestamps
+ end
+
+ end
+
+ def self.down
+ drop_table :linksets
+ end
+end
View
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20090601003056) do
+ActiveRecord::Schema.define(:version => 20090601115133) do
create_table "dependencies", :force => true do |t|
t.string "name"
@@ -19,6 +19,18 @@
t.integer "version_id"
end
+ create_table "linksets", :force => true do |t|
+ t.integer "rubygem_id"
+ t.string "home"
+ t.string "wiki"
+ t.string "docs"
+ t.string "mail"
+ t.string "code"
+ t.string "bugs"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
create_table "rubygems", :force => true do |t|
t.string "name"
t.string "token"
@@ -0,0 +1,8 @@
+Factory.define :linkset do |linkset|
+ linkset.home { 'string' }
+ linkset.wiki { 'string' }
+ linkset.docs { 'string' }
+ linkset.mail { 'string' }
+ linkset.code { 'string' }
+ linkset.bugs { 'string' }
+end
@@ -0,0 +1,9 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class LinksetTest < ActiveSupport::TestCase
+ should_belong_to :rubygem
+
+ should "be valid with factory" do
+ assert_valid Factory.build(:linkset)
+ end
+end
View
@@ -8,6 +8,7 @@ class RubygemTest < ActiveSupport::TestCase
should_belong_to :user
should_have_many :versions, :dependent => :destroy
+ should_have_one :linkset, :dependent => :destroy
should_validate_uniqueness_of :name
should "return name for #to_s" do
@@ -52,6 +53,26 @@ class RubygemTest < ActiveSupport::TestCase
assert_not_nil version
assert_equal "0.0.0-mswin", version.number
end
+
+ should "create linkset with valid homepage" do
+ spec = Rubygem.pull_spec(gem_file.path)
+ spec.homepage = "http://something.com"
+ @rubygem.spec = spec
+ @rubygem.build
+
+ assert_not_nil @rubygem.linkset
+ assert_equal spec.homepage, @rubygem.linkset.home
+ end
+
+ should "create linkset without homepage" do
+ spec = Rubygem.pull_spec(gem_file.path)
+ spec.homepage = nil
+ @rubygem.spec = spec
+ @rubygem.build
+
+ assert_not_nil @rubygem.linkset
+ assert_nil @rubygem.linkset.home
+ end
end
should "pull spec out of the given gem" do

0 comments on commit 94e4bc1

Please sign in to comment.