镜像管理的model创建

This commit is contained in:
cxt 2017-08-22 14:38:56 +08:00
parent c5703e742e
commit b853f4bf16
16 changed files with 137 additions and 0 deletions

View File

@ -0,0 +1,5 @@
class MirrorRepository < ActiveRecord::Base
has_many :mirror_update_records
has_many :mirror_repository_types
attr_accessible :description, :mirrorID, :name, :status, :tag, :main_type
end

View File

@ -0,0 +1,5 @@
class MirrorRepositoryType < ActiveRecord::Base
belongs_to :mirror_type
belongs_to :mirror_repository
# attr_accessible :title, :body
end

View File

@ -0,0 +1,5 @@
class MirrorType < ActiveRecord::Base
belongs_to :user
has_many :mirror_repository_types
attr_accessible :name, :user_id
end

View File

@ -0,0 +1,5 @@
class MirrorUpdateRecord < ActiveRecord::Base
belongs_to :user
belongs_to :mirror_repository
attr_accessible :newDescription, :newName, :newStatus, :newTag, :newType, :oldDescription, :oldName, :oldStatus, :oldTag, :oldType, :user_id, :mirror_repository_id
end

View File

@ -0,0 +1,10 @@
class CreateMirrorTypes < ActiveRecord::Migration
def change
create_table :mirror_types do |t|
t.string :name
t.references :user
t.timestamps
end
end
end

View File

@ -0,0 +1,14 @@
class CreateMirrorRepositories < ActiveRecord::Migration
def change
create_table :mirror_repositories do |t|
t.string :mirrorID
t.string :name
t.string :main_type
t.string :tag
t.text :description
t.integer :status
t.timestamps
end
end
end

View File

@ -0,0 +1,12 @@
class CreateMirrorRepositoryTypes < ActiveRecord::Migration
def change
create_table :mirror_repository_types do |t|
t.references :mirror_type
t.references :mirror_repository
t.timestamps
end
add_index :mirror_repository_types, :mirror_type_id
add_index :mirror_repository_types, :mirror_repository_id
end
end

View File

@ -0,0 +1,22 @@
class CreateMirrorUpdateRecords < ActiveRecord::Migration
def change
create_table :mirror_update_records do |t|
t.references :user
t.references :mirror_repository
t.string :oldName
t.string :newName
t.string :oldType
t.string :newType
t.text :oldTag
t.text :newTag
t.text :oldDescription
t.text :newDescription
t.integer :oldStatus
t.integer :newStatus
t.timestamps
end
add_index :mirror_update_records, :user_id
add_index :mirror_update_records, :mirror_repository_id
end
end

View File

@ -0,0 +1,10 @@
FactoryGirl.define do
factory :mirror_repository do
mirrorID "MyString"
name "MyString"
tag "MyText"
description "MyText"
status 1
end
end

View File

@ -0,0 +1,7 @@
FactoryGirl.define do
factory :mirror_repository_type do
mirror_type nil
mirror_repository nil
end
end

View File

@ -0,0 +1,6 @@
FactoryGirl.define do
factory :mirror_type do
name "MyString"
end
end

View File

@ -0,0 +1,16 @@
FactoryGirl.define do
factory :mirror_update_record do
user nil
oldName "MyString"
newName "MyString"
oldType "MyString"
newType "MyString"
oldTag "MyText"
newTag "MyText"
oldDescription "MyText"
newDescription "MyText"
oldStatus 1
newStatus 1
end
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe MirrorRepository, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe MirrorRepositoryType, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe MirrorType, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe MirrorUpdateRecord, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end