Container/Arch/Rpm

This commit is contained in:
Alexey Nayden 2011-03-16 00:52:27 +03:00
parent c1ff6dcc05
commit 002dc417b5
13 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,2 @@
class ContainersController < ApplicationController
end

View File

@ -0,0 +1,2 @@
module ContainersHelper
end

3
app/models/arch.rb Normal file
View File

@ -0,0 +1,3 @@
class Arch < ActiveRecord::Base
validate :name, :presence => true, :uniqueness => true
end

8
app/models/container.rb Normal file
View File

@ -0,0 +1,8 @@
class Container < ActiveRecord::Base
validate :name, :presence => true
validate :project_id, :presence => true
validate :onwer_id, :presence => true
belongs_to :project
belongs_to :owner, :class_name => 'User', :foreign_key => 'owner_id'
end

8
app/models/rpm.rb Normal file
View File

@ -0,0 +1,8 @@
class Rpm < ActiveRecord::Base
validate :name, :presence => true
validate :arch_id, :presence => true
validate :project_id, :presence => true
belongs_to :arch
belongs_to :project
end

View File

@ -0,0 +1,15 @@
class CreateContainers < ActiveRecord::Migration
def self.up
create_table :containers do |t|
t.string :name, :null => false
t.integer :project_id, :null => false
t.integer :owner_id, :null => false
t.timestamps
end
end
def self.down
drop_table :containers
end
end

View File

@ -0,0 +1,15 @@
class CreateArches < ActiveRecord::Migration
def self.up
create_table :arches do |t|
t.string :name, :null => false
t.timestamps
end
add_index :arches, :name, :unique => true
end
def self.down
drop_table :arches
end
end

View File

@ -0,0 +1,18 @@
class CreateRpms < ActiveRecord::Migration
def self.up
create_table :rpms do |t|
t.string :name, :null => false
t.integer :arch_id, :null => false
t.integer :project_id, :null => false
t.timestamps
end
add_index :rpms, :project_id
add_index :rpms, [:project_id, :arch_id]
end
def self.down
drop_table :rpms
end
end

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe ContainersController do
end

View File

@ -0,0 +1,15 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the ContainersHelper. For example:
#
# describe ContainersHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe ContainersHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

5
spec/models/arch_spec.rb Normal file
View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe Arch do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe Containter do
pending "add some examples to (or delete) #{__FILE__}"
end

5
spec/models/rpm_spec.rb Normal file
View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe Rpm do
pending "add some examples to (or delete) #{__FILE__}"
end