From 002dc417b56d18e52b7625257567fcff2bdf06ee Mon Sep 17 00:00:00 2001 From: Alexey Nayden Date: Wed, 16 Mar 2011 00:52:27 +0300 Subject: [PATCH] Container/Arch/Rpm --- app/controllers/containers_controller.rb | 2 ++ app/helpers/containers_helper.rb | 2 ++ app/models/arch.rb | 3 +++ app/models/container.rb | 8 ++++++++ app/models/rpm.rb | 8 ++++++++ db/migrate/20110312133121_create_containers.rb | 15 +++++++++++++++ db/migrate/20110312133559_create_arches.rb | 15 +++++++++++++++ db/migrate/20110312133948_create_rpms.rb | 18 ++++++++++++++++++ spec/controllers/containers_controller_spec.rb | 5 +++++ spec/helpers/containers_helper_spec.rb | 15 +++++++++++++++ spec/models/arch_spec.rb | 5 +++++ spec/models/containter_spec.rb | 5 +++++ spec/models/rpm_spec.rb | 5 +++++ 13 files changed, 106 insertions(+) create mode 100644 app/controllers/containers_controller.rb create mode 100644 app/helpers/containers_helper.rb create mode 100644 app/models/arch.rb create mode 100644 app/models/container.rb create mode 100644 app/models/rpm.rb create mode 100644 db/migrate/20110312133121_create_containers.rb create mode 100644 db/migrate/20110312133559_create_arches.rb create mode 100644 db/migrate/20110312133948_create_rpms.rb create mode 100644 spec/controllers/containers_controller_spec.rb create mode 100644 spec/helpers/containers_helper_spec.rb create mode 100644 spec/models/arch_spec.rb create mode 100644 spec/models/containter_spec.rb create mode 100644 spec/models/rpm_spec.rb diff --git a/app/controllers/containers_controller.rb b/app/controllers/containers_controller.rb new file mode 100644 index 000000000..57c27003c --- /dev/null +++ b/app/controllers/containers_controller.rb @@ -0,0 +1,2 @@ +class ContainersController < ApplicationController +end diff --git a/app/helpers/containers_helper.rb b/app/helpers/containers_helper.rb new file mode 100644 index 000000000..aa138f451 --- /dev/null +++ b/app/helpers/containers_helper.rb @@ -0,0 +1,2 @@ +module ContainersHelper +end diff --git a/app/models/arch.rb b/app/models/arch.rb new file mode 100644 index 000000000..5fcd026ae --- /dev/null +++ b/app/models/arch.rb @@ -0,0 +1,3 @@ +class Arch < ActiveRecord::Base + validate :name, :presence => true, :uniqueness => true +end diff --git a/app/models/container.rb b/app/models/container.rb new file mode 100644 index 000000000..c5caf14f1 --- /dev/null +++ b/app/models/container.rb @@ -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 diff --git a/app/models/rpm.rb b/app/models/rpm.rb new file mode 100644 index 000000000..a66609da1 --- /dev/null +++ b/app/models/rpm.rb @@ -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 diff --git a/db/migrate/20110312133121_create_containers.rb b/db/migrate/20110312133121_create_containers.rb new file mode 100644 index 000000000..e5a2fbf87 --- /dev/null +++ b/db/migrate/20110312133121_create_containers.rb @@ -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 diff --git a/db/migrate/20110312133559_create_arches.rb b/db/migrate/20110312133559_create_arches.rb new file mode 100644 index 000000000..98a064628 --- /dev/null +++ b/db/migrate/20110312133559_create_arches.rb @@ -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 diff --git a/db/migrate/20110312133948_create_rpms.rb b/db/migrate/20110312133948_create_rpms.rb new file mode 100644 index 000000000..8feaa5221 --- /dev/null +++ b/db/migrate/20110312133948_create_rpms.rb @@ -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 diff --git a/spec/controllers/containers_controller_spec.rb b/spec/controllers/containers_controller_spec.rb new file mode 100644 index 000000000..5d79cb997 --- /dev/null +++ b/spec/controllers/containers_controller_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe ContainersController do + +end diff --git a/spec/helpers/containers_helper_spec.rb b/spec/helpers/containers_helper_spec.rb new file mode 100644 index 000000000..15bff5d33 --- /dev/null +++ b/spec/helpers/containers_helper_spec.rb @@ -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 diff --git a/spec/models/arch_spec.rb b/spec/models/arch_spec.rb new file mode 100644 index 000000000..3493766cd --- /dev/null +++ b/spec/models/arch_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Arch do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/containter_spec.rb b/spec/models/containter_spec.rb new file mode 100644 index 000000000..d43ba585e --- /dev/null +++ b/spec/models/containter_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Containter do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/rpm_spec.rb b/spec/models/rpm_spec.rb new file mode 100644 index 000000000..078804244 --- /dev/null +++ b/spec/models/rpm_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe Rpm do + pending "add some examples to (or delete) #{__FILE__}" +end