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
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
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
9 additions
and
0 deletions
+9
-0
app/models/appearance.rb
app/models/appearance.rb
+1
-0
app/models/group.rb
app/models/group.rb
+1
-0
app/models/project.rb
app/models/project.rb
+1
-0
app/models/user.rb
app/models/user.rb
+1
-0
spec/models/appearance_spec.rb
spec/models/appearance_spec.rb
+2
-0
spec/models/group_spec.rb
spec/models/group_spec.rb
+1
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-0
spec/models/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
...
@@ -10,4 +10,5 @@ class Appearance < ActiveRecord::Base
mount_uploader
:logo
,
AttachmentUploader
mount_uploader
:logo
,
AttachmentUploader
mount_uploader
:header_logo
,
AttachmentUploader
mount_uploader
:header_logo
,
AttachmentUploader
has_many
:uploads
,
as: :model
,
dependent: :destroy
end
end
app/models/group.rb
View file @
23c2b8f6
...
@@ -28,6 +28,7 @@ class Group < Namespace
...
@@ -28,6 +28,7 @@ class Group < Namespace
validates
:avatar
,
file_size:
{
maximum:
200
.
kilobytes
.
to_i
}
validates
:avatar
,
file_size:
{
maximum:
200
.
kilobytes
.
to_i
}
mount_uploader
:avatar
,
AvatarUploader
mount_uploader
:avatar
,
AvatarUploader
has_many
:uploads
,
as: :model
,
dependent: :destroy
after_create
:post_create_hook
after_create
:post_create_hook
after_destroy
:post_destroy_hook
after_destroy
:post_destroy_hook
...
...
app/models/project.rb
View file @
23c2b8f6
...
@@ -212,6 +212,7 @@ class Project < ActiveRecord::Base
...
@@ -212,6 +212,7 @@ class Project < ActiveRecord::Base
before_save
:ensure_runners_token
before_save
:ensure_runners_token
mount_uploader
:avatar
,
AvatarUploader
mount_uploader
:avatar
,
AvatarUploader
has_many
:uploads
,
as: :model
,
dependent: :destroy
# Scopes
# Scopes
default_scope
{
where
(
pending_delete:
false
)
}
default_scope
{
where
(
pending_delete:
false
)
}
...
...
app/models/user.rb
View file @
23c2b8f6
...
@@ -191,6 +191,7 @@ class User < ActiveRecord::Base
...
@@ -191,6 +191,7 @@ class User < ActiveRecord::Base
end
end
mount_uploader
:avatar
,
AvatarUploader
mount_uploader
:avatar
,
AvatarUploader
has_many
:uploads
,
as: :model
,
dependent: :destroy
# Scopes
# Scopes
scope
:admins
,
->
{
where
(
admin:
true
)
}
scope
:admins
,
->
{
where
(
admin:
true
)
}
...
...
spec/models/appearance_spec.rb
View file @
23c2b8f6
...
@@ -7,4 +7,6 @@ RSpec.describe Appearance, type: :model do
...
@@ -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
(
:title
)
}
it
{
is_expected
.
to
validate_presence_of
(
:description
)
}
it
{
is_expected
.
to
validate_presence_of
(
:description
)
}
it
{
is_expected
.
to
have_many
(
:uploads
).
dependent
(
:destroy
)
}
end
end
spec/models/group_spec.rb
View file @
23c2b8f6
...
@@ -13,6 +13,7 @@ describe Group, models: true do
...
@@ -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
(
:shared_projects
).
through
(
:project_group_links
)
}
it
{
is_expected
.
to
have_many
(
:notification_settings
).
dependent
(
:destroy
)
}
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
(
:labels
).
class_name
(
'GroupLabel'
)
}
it
{
is_expected
.
to
have_many
(
:uploads
).
dependent
(
:destroy
)
}
describe
'#members & #requesters'
do
describe
'#members & #requesters'
do
let
(
:requester
)
{
create
(
:user
)
}
let
(
:requester
)
{
create
(
:user
)
}
...
...
spec/models/project_spec.rb
View file @
23c2b8f6
...
@@ -71,6 +71,7 @@ describe Project, models: true do
...
@@ -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
(
:project_group_links
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:notification_settings
).
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
(
:forks
).
through
(
:forked_project_links
)
}
it
{
is_expected
.
to
have_many
(
:uploads
).
dependent
(
:destroy
)
}
context
'after initialized'
do
context
'after initialized'
do
it
"has a project_feature"
do
it
"has a project_feature"
do
...
...
spec/models/user_spec.rb
View file @
23c2b8f6
...
@@ -36,6 +36,7 @@ describe User, models: true do
...
@@ -36,6 +36,7 @@ describe User, models: true do
it
{
is_expected
.
to
have_many
(
:builds
).
dependent
(
:nullify
)
}
it
{
is_expected
.
to
have_many
(
:builds
).
dependent
(
:nullify
)
}
it
{
is_expected
.
to
have_many
(
:pipelines
).
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
(
:chat_names
).
dependent
(
:destroy
)
}
it
{
is_expected
.
to
have_many
(
:uploads
).
dependent
(
:destroy
)
}
describe
'#group_members'
do
describe
'#group_members'
do
it
'does not include group memberships for which user is a requester'
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