diff --git a/app/models/platform.rb b/app/models/platform.rb new file mode 100644 index 000000000..77ae72a0e --- /dev/null +++ b/app/models/platform.rb @@ -0,0 +1,19 @@ +class Platform < ActiveRecord::Base + validate :name, :presence => true, :uniqueness => true + validate :unixname, :presence => true, :uniqueness => true + before_validation :generate_unixname + validate :validate_unixname + + has_many :projects + has_one :parent, :class_name => 'Platform', :foreign_key => 'parent_platform_id' + + protected + + def generate_unixname + #TODO: Implement unixname generation + end + + def validate_unixname + #TODO: Implement unixname validation + end +end diff --git a/app/models/project.rb b/app/models/project.rb new file mode 100644 index 000000000..e01184770 --- /dev/null +++ b/app/models/project.rb @@ -0,0 +1,19 @@ +class Project < ActiveRecord::Base + validate :name, :uniqueness => true, :presence => true + validate :unixname, :uniqueness => true, :presence => true + before_validation :generate_unixname + validate :validate_unixname + + belongs_to :platform + + protected + + def generate_unixname + #TODO: Implement unixname generation + end + + def validate_unixname + #TODO: Implement unixname validation + end + +end diff --git a/db/migrate/20110309173339_create_platforms.rb b/db/migrate/20110309173339_create_platforms.rb new file mode 100644 index 000000000..787f4a9ed --- /dev/null +++ b/db/migrate/20110309173339_create_platforms.rb @@ -0,0 +1,15 @@ +class CreatePlatforms < ActiveRecord::Migration + def self.up + create_table :platforms do |t| + t.string :name + t.string :unixname + t.integer :parent_platform_id + + t.timestamps + end + end + + def self.down + drop_table :platforms + end +end diff --git a/db/migrate/20110309173421_create_projects.rb b/db/migrate/20110309173421_create_projects.rb new file mode 100644 index 000000000..06eb3a62d --- /dev/null +++ b/db/migrate/20110309173421_create_projects.rb @@ -0,0 +1,15 @@ +class CreateProjects < ActiveRecord::Migration + def self.up + create_table :projects do |t| + t.string :name + t.string :unixname + t.integer :platform_id + + t.timestamps + end + end + + def self.down + drop_table :projects + end +end diff --git a/spec/models/platform_spec.rb b/spec/models/platform_spec.rb new file mode 100644 index 000000000..52468b7ae --- /dev/null +++ b/spec/models/platform_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Platform do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb new file mode 100644 index 000000000..9bda4d927 --- /dev/null +++ b/spec/models/project_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Project do + pending "add some examples to (or delete) #{__FILE__}" +end