Skip to content
Snippets Groups Projects
Commit b2cc24ba authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Imrpove participants model and add some basic specs

parent ae8d5600
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2,6 +2,7 @@ class Participant < ActiveRecord::Base
belongs_to :user
belongs_to :target, polymorphic: true
 
validates :target, presence: true
validates :user_id,
uniqueness: { scope: [:target_id, :target_type] },
presence: true
Loading
Loading
Loading
Loading
@@ -132,6 +132,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 :participants, dependent: :destroy
 
 
#
Loading
Loading
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :participant do
target factory: issue
user
end
end
require 'spec_helper'
describe Participant do
describe 'associations' do
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:target) }
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment