建立forge_messages表

建立user、project关联
This commit is contained in:
huang 2015-08-11 16:52:04 +08:00
parent 6e5f6069bd
commit 998fe24e49
4 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,20 @@
class ForgeMessage < ActiveRecord::Base
# 公共表中活动类型,命名规则:TYPE_OF_{类名}_ACT
TYPE_OF_ISSUE_ACT = "Issue"
TYPE_OF_MESSAGE_ACT = "Message"
TYPE_OF_ATTACHMENT_ACT = "Attachment"
TYPE_OF_DOCUMENT_ACT = "Document"
TYPE_OF_JOURNAL_ACT = "Journal"
TYPE_OF_WIKI_ACT = "Wiki"
TYPE_OF_NEWS_ACT = "News"
attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed
belongs_to :forge_message ,:polymorphic => true
belongs_to :project
belongs_to :user
validates :user_id,presence: true
validates :project_id,presence: true
validates :forge_message_id,presence: true
validates :forge_message_type, presence: true
end

View File

@ -0,0 +1,13 @@
class CreateForgeMessages < ActiveRecord::Migration
def change
create_table :forge_messages do |t|
t.integer :user_id
t.integer :project_id
t.integer :forge_message_id
t.string :forge_message_type
t.integer :viewed
t.timestamps
end
end
end

View File

@ -0,0 +1,10 @@
FactoryGirl.define do
factory :forge_message do
user_id 1
project_id 1
forge_message_id 1
forge_message_type "MyString"
viewed 1
end
end

View File

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