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
Léo-Paul Géneau
gitlab-ce
Commits
b3acd545
Commit
b3acd545
authored
Oct 05, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `alias_attribute` & `alias_method` to define parent-methods
parent
e013d398
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
8 deletions
+9
-8
app/models/project.rb
app/models/project.rb
+2
-8
spec/models/project_spec.rb
spec/models/project_spec.rb
+7
-0
No files found.
app/models/project.rb
View file @
b3acd545
...
...
@@ -82,6 +82,8 @@ class Project < ActiveRecord::Base
belongs_to
:creator
,
class_name:
'User'
belongs_to
:group
,
->
{
where
(
type:
'Group'
)
},
foreign_key:
'namespace_id'
belongs_to
:namespace
alias_method
:parent
,
:namespace
alias_attribute
:parent_id
,
:namespace_id
has_one
:last_event
,
->
{
order
'events.created_at DESC'
},
class_name:
'Event'
has_many
:boards
,
before_add: :validate_board_limit
...
...
@@ -1521,14 +1523,6 @@ class Project < ActiveRecord::Base
map
.
public_path_for_source_path
(
path
)
end
def
parent
namespace
end
def
parent_id
namespace_id
end
def
parent_changed?
namespace_id_changed?
end
...
...
spec/models/project_spec.rb
View file @
b3acd545
...
...
@@ -2095,6 +2095,13 @@ describe Project do
it
{
expect
(
project
.
parent
).
to
eq
(
project
.
namespace
)
}
end
describe
'#parent_id'
do
let
(
:project
)
{
create
(
:project
)
}
it
{
expect
(
project
.
parent_id
).
to
eq
(
project
.
namespace_id
)
}
end
describe
'#parent_changed?'
do
let
(
:project
)
{
create
(
:project
)
}
...
...
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