Commit 7ba4e05f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Create Approve model for merge request

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent d7d3a288
class Approve < ActiveRecord::Base
belongs_to :user
belongs_to :merge_request
end
......@@ -35,6 +35,7 @@ class MergeRequest < ActiveRecord::Base
belongs_to :source_project, foreign_key: :source_project_id, class_name: "Project"
has_one :merge_request_diff, dependent: :destroy
has_many :approves, dependent: :destroy
after_create :create_merge_request_diff
after_update :update_merge_request_diff
......
......@@ -130,6 +130,7 @@ class User < ActiveRecord::Base
has_many :assigned_issues, dependent: :destroy, foreign_key: :assignee_id, class_name: "Issue"
has_many :assigned_merge_requests, dependent: :destroy, foreign_key: :assignee_id, class_name: "MergeRequest"
has_many :oauth_applications, class_name: 'Doorkeeper::Application', as: :owner, dependent: :destroy
has_many :approves, dependent: :destroy
#
......
class CreateApproves < ActiveRecord::Migration
def change
create_table :approves do |t|
t.integer :merge_request_id, null: false
t.integer :user_id, null: false
t.timestamps
end
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150529150354) do
ActiveRecord::Schema.define(version: 20150609113337) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -49,6 +49,13 @@ ActiveRecord::Schema.define(version: 20150529150354) do
t.string "after_sign_out_path"
end
create_table "approves", force: true do |t|
t.integer "merge_request_id", null: false
t.integer "user_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "audit_events", force: true do |t|
t.integer "author_id", null: false
t.string "type", null: false
......
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :approve, class: 'Approve' do
merge_request
user
end
end
require 'spec_helper'
describe Approve do
subject { create(:approve) }
it { should be_valid }
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment