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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
d820c090
Commit
d820c090
authored
Sep 19, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GroupLabel model
parent
d9273364
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
44 additions
and
0 deletions
+44
-0
app/models/group.rb
app/models/group.rb
+1
-0
app/models/group_label.rb
app/models/group_label.rb
+5
-0
db/migrate/20160919144305_add_type_to_labels.rb
db/migrate/20160919144305_add_type_to_labels.rb
+9
-0
db/migrate/20160919145149_add_group_id_to_labels.rb
db/migrate/20160919145149_add_group_id_to_labels.rb
+13
-0
db/schema.rb
db/schema.rb
+4
-0
spec/models/group_label_spec.rb
spec/models/group_label_spec.rb
+11
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+1
-0
No files found.
app/models/group.rb
View file @
d820c090
...
...
@@ -19,6 +19,7 @@ class Group < Namespace
has_many
:project_group_links
,
dependent: :destroy
has_many
:shared_projects
,
through: :project_group_links
,
source: :project
has_many
:notification_settings
,
dependent: :destroy
,
as: :source
has_many
:labels
,
class_name:
'GroupLabel'
validate
:avatar_type
,
if:
->
(
user
)
{
user
.
avatar
.
present?
&&
user
.
avatar_changed?
}
validate
:visibility_level_allowed_by_projects
...
...
app/models/group_label.rb
0 → 100644
View file @
d820c090
class
GroupLabel
<
Label
belongs_to
:group
validates
:group
,
presence:
true
end
db/migrate/20160919144305_add_type_to_labels.rb
0 → 100644
View file @
d820c090
class
AddTypeToLabels
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
def
change
add_column
:labels
,
:type
,
:string
end
end
db/migrate/20160919145149_add_group_id_to_labels.rb
0 → 100644
View file @
d820c090
class
AddGroupIdToLabels
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
change
add_column
:labels
,
:group_id
,
:integer
add_foreign_key
:labels
,
:namespaces
,
column: :group_id
,
on_delete: :cascade
add_concurrent_index
:labels
,
:group_id
end
end
db/schema.rb
View file @
d820c090
...
...
@@ -529,8 +529,11 @@ ActiveRecord::Schema.define(version: 20161017095000) do
t
.
string
"description"
t
.
integer
"priority"
t
.
text
"description_html"
t
.
string
"type"
t
.
integer
"group_id"
end
add_index
"labels"
,
[
"group_id"
],
name:
"index_labels_on_group_id"
,
using: :btree
add_index
"labels"
,
[
"priority"
],
name:
"index_labels_on_priority"
,
using: :btree
add_index
"labels"
,
[
"project_id"
],
name:
"index_labels_on_project_id"
,
using: :btree
add_index
"labels"
,
[
"title"
],
name:
"index_labels_on_title"
,
using: :btree
...
...
@@ -1213,6 +1216,7 @@ ActiveRecord::Schema.define(version: 20161017095000) do
add_foreign_key
"boards"
,
"projects"
add_foreign_key
"issue_metrics"
,
"issues"
,
on_delete: :cascade
add_foreign_key
"labels"
,
"namespaces"
,
column:
"group_id"
,
on_delete: :cascade
add_foreign_key
"lists"
,
"boards"
add_foreign_key
"lists"
,
"labels"
add_foreign_key
"merge_request_metrics"
,
"merge_requests"
,
on_delete: :cascade
...
...
spec/models/group_label_spec.rb
0 → 100644
View file @
d820c090
require
'spec_helper'
describe
GroupLabel
,
models:
true
do
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:group
)
}
end
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:group
)
}
end
end
spec/models/group_spec.rb
View file @
d820c090
...
...
@@ -12,6 +12,7 @@ describe Group, models: true do
it
{
is_expected
.
to
have_many
(
:project_group_links
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:shared_projects
).
through
(
:project_group_links
)
}
it
{
is_expected
.
to
have_many
(
:notification_settings
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:labels
).
class_name
(
'GroupLabel'
)
}
describe
'#members & #requesters'
do
let
(
:requester
)
{
create
(
:user
)
}
...
...
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