版本库新增提交次数表,增加至项目动态

This commit is contained in:
huang 2016-07-21 16:09:07 +08:00
parent 3fb5322b03
commit 246923a335
4 changed files with 40 additions and 0 deletions

10
app/models/commit.rb Normal file
View File

@ -0,0 +1,10 @@
class Commit < ActiveRecord::Base
attr_accessible :comments, :committed_on, :committer, :project_id, :repository_id, :version
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
after_create :act_as_forge_activity
# 项目中提交动态
def act_as_forge_activity
self.forge_acts << ForgeActivity.new(:user_id => 2, :project_id => self.project_id)
end
end

View File

@ -0,0 +1,14 @@
class CreateCommits < ActiveRecord::Migration
def change
create_table :commits do |t|
t.integer :repository_id
t.string :version
t.string :committer
t.text :comments
t.date :committed_on
t.integer :project_id
t.timestamps
end
end
end

11
spec/factories/commits.rb Normal file
View File

@ -0,0 +1,11 @@
FactoryGirl.define do
factory :commit do
repository_id 1
version "MyString"
committer "MyString"
comments "MyText"
committed_on "2016-07-21"
project_id 1
end
end

View File

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