Commit 9e2525cbd0da4204f93937e368e277be38d1a7b3
1 parent
5b35000f
Exists in
master
and in
4 other branches
Association form user to snippets added
Showing
2 changed files
with
2 additions
and
0 deletions
Show diff stats
app/models/user.rb
... | ... | @@ -75,6 +75,7 @@ class User < ActiveRecord::Base |
75 | 75 | has_many :team_projects, through: :user_team_project_relationships |
76 | 76 | |
77 | 77 | # Projects |
78 | + has_many :snippets, dependent: :destroy, foreign_key: :author_id, class_name: "Snippet" | |
78 | 79 | has_many :users_projects, dependent: :destroy |
79 | 80 | has_many :issues, dependent: :destroy, foreign_key: :author_id |
80 | 81 | has_many :notes, dependent: :destroy, foreign_key: :author_id | ... | ... |
spec/models/user_spec.rb
... | ... | @@ -40,6 +40,7 @@ require 'spec_helper' |
40 | 40 | describe User do |
41 | 41 | describe "Associations" do |
42 | 42 | it { should have_one(:namespace) } |
43 | + it { should have_many(:snippets).class_name('Snippet').dependent(:destroy) } | |
43 | 44 | it { should have_many(:users_projects).dependent(:destroy) } |
44 | 45 | it { should have_many(:groups) } |
45 | 46 | it { should have_many(:keys).dependent(:destroy) } | ... | ... |