Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f81d0fb9
Commit
f81d0fb9
authored
Jul 11, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ProjectGroupLink model with migration and specs
parent
5c4c10e8
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
1 deletion
+68
-1
app/models/project.rb
app/models/project.rb
+3
-0
app/models/project_group_link.rb
app/models/project_group_link.rb
+20
-0
db/migrate/20130711063759_create_project_group_links.rb
db/migrate/20130711063759_create_project_group_links.rb
+10
-0
db/schema.rb
db/schema.rb
+8
-1
spec/factories/project_group_links.rb
spec/factories/project_group_links.rb
+6
-0
spec/models/project_group_link_spec.rb
spec/models/project_group_link_spec.rb
+21
-0
No files found.
app/models/project.rb
View file @
f81d0fb9
...
...
@@ -67,6 +67,9 @@ class Project < ActiveRecord::Base
has_many
:deploy_keys_projects
,
dependent: :destroy
has_many
:deploy_keys
,
through: :deploy_keys_projects
has_many
:project_group_links_path
,
dependent: :destroy
has_many
:invited_groups
,
through: :project_group_links
,
source:
'group'
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
delegate
:members
,
to: :team
,
prefix:
true
...
...
app/models/project_group_link.rb
0 → 100644
View file @
f81d0fb9
#-------------------------------------------------------------------
#
# The GitLab Enterprise Edition (EE) license
#
# Copyright (c) 2013 GitLab.com
#
# All Rights Reserved. No part of this software may be reproduced without
# prior permission of GitLab.com. By using this software you agree to be
# bound by the GitLab Enterprise Support Subscription Terms.
#
#-------------------------------------------------------------------
class
ProjectGroupLink
<
ActiveRecord
::
Base
belongs_to
:project
belongs_to
:group
validates
:project_id
,
presence:
true
validates
:group_id
,
presence:
true
validates
:group_id
,
uniqueness:
{
scope:
[
:project_id
],
message:
"already shared with this group"
}
end
db/migrate/20130711063759_create_project_group_links.rb
0 → 100644
View file @
f81d0fb9
class
CreateProjectGroupLinks
<
ActiveRecord
::
Migration
def
change
create_table
:project_group_links
do
|
t
|
t
.
integer
:project_id
,
null:
false
t
.
integer
:group_id
,
null:
false
t
.
timestamps
end
end
end
db/schema.rb
View file @
f81d0fb9
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
20130
624162710
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
20130
711063759
)
do
create_table
"deploy_keys_projects"
,
:force
=>
true
do
|
t
|
t
.
integer
"deploy_key_id"
,
:null
=>
false
...
...
@@ -157,6 +157,13 @@ ActiveRecord::Schema.define(:version => 20130624162710) do
add_index
"notes"
,
[
"project_id"
,
"noteable_type"
],
:name
=>
"index_notes_on_project_id_and_noteable_type"
add_index
"notes"
,
[
"project_id"
],
:name
=>
"index_notes_on_project_id"
create_table
"project_group_links"
,
:force
=>
true
do
|
t
|
t
.
integer
"project_id"
,
:null
=>
false
t
.
integer
"group_id"
,
:null
=>
false
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
end
create_table
"projects"
,
:force
=>
true
do
|
t
|
t
.
string
"name"
t
.
string
"path"
...
...
spec/factories/project_group_links.rb
0 → 100644
View file @
f81d0fb9
FactoryGirl
.
define
do
factory
:project_group_link
do
project
group
end
end
spec/models/project_group_link_spec.rb
0 → 100644
View file @
f81d0fb9
require
'spec_helper'
describe
ProjectGroupLink
do
describe
"Associations"
do
it
{
should
belong_to
(
:group
)
}
it
{
should
belong_to
(
:project
)
}
end
describe
"Mass assignment"
do
it
{
should_not
allow_mass_assignment_of
(
:group_id
)
}
it
{
should_not
allow_mass_assignment_of
(
:project_id
)
}
end
describe
"Validation"
do
let!
(
:project_group_link
)
{
create
(
:project_group_link
)
}
it
{
should
validate_presence_of
(
:project_id
)
}
it
{
should
validate_uniqueness_of
(
:group_id
).
scoped_to
(
:project_id
).
with_message
(
/already shared/
)
}
it
{
should
validate_presence_of
(
:group_id
)
}
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment