BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
23c2b8f6
Commit
23c2b8f6
authored
Mar 02, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `has_many` associations for models that can have Upload records
parent
5c41338f
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
9 additions
and
0 deletions
+9
-0
appearance.rb
app/models/appearance.rb
+1
-0
group.rb
app/models/group.rb
+1
-0
project.rb
app/models/project.rb
+1
-0
user.rb
app/models/user.rb
+1
-0
appearance_spec.rb
spec/models/appearance_spec.rb
+2
-0
group_spec.rb
spec/models/group_spec.rb
+1
-0
project_spec.rb
spec/models/project_spec.rb
+1
-0
user_spec.rb
spec/models/user_spec.rb
+1
-0
No files found.
app/models/appearance.rb
View file @
23c2b8f6
...
...
@@ -10,4 +10,5 @@ class Appearance < ActiveRecord::Base
mount_uploader
:logo
,
AttachmentUploader
mount_uploader
:header_logo
,
AttachmentUploader
has_many
:uploads
,
as: :model
,
dependent: :destroy
end
app/models/group.rb
View file @
23c2b8f6
...
...
@@ -28,6 +28,7 @@ class Group < Namespace
validates
:avatar
,
file_size:
{
maximum:
200
.
kilobytes
.
to_i
}
mount_uploader
:avatar
,
AvatarUploader
has_many
:uploads
,
as: :model
,
dependent: :destroy
after_create
:post_create_hook
after_destroy
:post_destroy_hook
...
...
app/models/project.rb
View file @
23c2b8f6
...
...
@@ -212,6 +212,7 @@ class Project < ActiveRecord::Base
before_save
:ensure_runners_token
mount_uploader
:avatar
,
AvatarUploader
has_many
:uploads
,
as: :model
,
dependent: :destroy
# Scopes
default_scope
{
where
(
pending_delete:
false
)
}
...
...
app/models/user.rb
View file @
23c2b8f6
...
...
@@ -191,6 +191,7 @@ class User < ActiveRecord::Base
end
mount_uploader
:avatar
,
AvatarUploader
has_many
:uploads
,
as: :model
,
dependent: :destroy
# Scopes
scope
:admins
,
->
{
where
(
admin:
true
)
}
...
...
spec/models/appearance_spec.rb
View file @
23c2b8f6
...
...
@@ -7,4 +7,6 @@ RSpec.describe Appearance, type: :model do
it
{
is_expected
.
to
validate_presence_of
(
:title
)
}
it
{
is_expected
.
to
validate_presence_of
(
:description
)
}
it
{
is_expected
.
to
have_many
(
:uploads
).
dependent
(
:destroy
)
}
end
spec/models/group_spec.rb
View file @
23c2b8f6
...
...
@@ -13,6 +13,7 @@ describe Group, models: true do
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'
)
}
it
{
is_expected
.
to
have_many
(
:uploads
).
dependent
(
:destroy
)
}
describe
'#members & #requesters'
do
let
(
:requester
)
{
create
(
:user
)
}
...
...
spec/models/project_spec.rb
View file @
23c2b8f6
...
...
@@ -71,6 +71,7 @@ describe Project, models: true do
it
{
is_expected
.
to
have_many
(
:project_group_links
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:notification_settings
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:forks
).
through
(
:forked_project_links
)
}
it
{
is_expected
.
to
have_many
(
:uploads
).
dependent
(
:destroy
)
}
context
'after initialized'
do
it
"has a project_feature"
do
...
...
spec/models/user_spec.rb
View file @
23c2b8f6
...
...
@@ -36,6 +36,7 @@ describe User, models: true do
it
{
is_expected
.
to
have_many
(
:builds
).
dependent
(
:nullify
)
}
it
{
is_expected
.
to
have_many
(
:pipelines
).
dependent
(
:nullify
)
}
it
{
is_expected
.
to
have_many
(
:chat_names
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:uploads
).
dependent
(
:destroy
)
}
describe
'#group_members'
do
it
'does not include group memberships for which user is a requester'
do
...
...
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