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
8379fbcd
Commit
8379fbcd
authored
Oct 17, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add subject to group and projects labels which return group/project
parent
d3b76e83
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
8 deletions
+22
-8
app/helpers/labels_helper.rb
app/helpers/labels_helper.rb
+2
-8
app/models/group_label.rb
app/models/group_label.rb
+2
-0
app/models/project_label.rb
app/models/project_label.rb
+2
-0
spec/models/group_label_spec.rb
spec/models/group_label_spec.rb
+8
-0
spec/models/project_label_spec.rb
spec/models/project_label_spec.rb
+8
-0
No files found.
app/helpers/labels_helper.rb
View file @
8379fbcd
...
@@ -14,7 +14,7 @@ module LabelsHelper
...
@@ -14,7 +14,7 @@ module LabelsHelper
#
#
# Examples:
# Examples:
#
#
# # Allow the generated link to use the label's own
pro
ject
# # Allow the generated link to use the label's own
sub
ject
# link_to_label(label)
# link_to_label(label)
#
#
# # Force the generated link to use a provided group
# # Force the generated link to use a provided group
...
@@ -31,13 +31,7 @@ module LabelsHelper
...
@@ -31,13 +31,7 @@ module LabelsHelper
#
#
# Returns a String
# Returns a String
def
link_to_label
(
label
,
subject:
nil
,
type: :issue
,
tooltip:
true
,
css_class:
nil
,
&
block
)
def
link_to_label
(
label
,
subject:
nil
,
type: :issue
,
tooltip:
true
,
css_class:
nil
,
&
block
)
subject
||=
link
=
label_filter_path
(
subject
||
label
.
subject
,
label
,
type:
type
)
case
label
when
GroupLabel
then
label
.
group
when
ProjectLabel
then
label
.
project
end
link
=
label_filter_path
(
subject
,
label
,
type:
type
)
if
block_given?
if
block_given?
link_to
link
,
class:
css_class
,
&
block
link_to
link
,
class:
css_class
,
&
block
...
...
app/models/group_label.rb
View file @
8379fbcd
...
@@ -3,6 +3,8 @@ class GroupLabel < Label
...
@@ -3,6 +3,8 @@ class GroupLabel < Label
validates
:group
,
presence:
true
validates
:group
,
presence:
true
alias_attribute
:subject
,
:group
def
to_reference
(
source_project
=
nil
,
target_project
=
nil
,
format: :id
)
def
to_reference
(
source_project
=
nil
,
target_project
=
nil
,
format: :id
)
super
(
source_project
,
target_project
,
format:
format
)
super
(
source_project
,
target_project
,
format:
format
)
end
end
...
...
app/models/project_label.rb
View file @
8379fbcd
...
@@ -10,6 +10,8 @@ class ProjectLabel < Label
...
@@ -10,6 +10,8 @@ class ProjectLabel < Label
delegate
:group
,
to: :project
,
allow_nil:
true
delegate
:group
,
to: :project
,
allow_nil:
true
alias_attribute
:subject
,
:project
def
to_reference
(
target_project
=
nil
,
format: :id
)
def
to_reference
(
target_project
=
nil
,
format: :id
)
super
(
project
,
target_project
,
format:
format
)
super
(
project
,
target_project
,
format:
format
)
end
end
...
...
spec/models/group_label_spec.rb
View file @
8379fbcd
...
@@ -9,6 +9,14 @@ describe GroupLabel, models: true do
...
@@ -9,6 +9,14 @@ describe GroupLabel, models: true do
it
{
is_expected
.
to
validate_presence_of
(
:group
)
}
it
{
is_expected
.
to
validate_presence_of
(
:group
)
}
end
end
describe
'#subject'
do
it
'aliases group to subject'
do
subject
=
described_class
.
new
(
group:
build
(
:group
))
expect
(
subject
.
subject
).
to
be
(
subject
.
group
)
end
end
describe
'#to_reference'
do
describe
'#to_reference'
do
let
(
:label
)
{
create
(
:group_label
)
}
let
(
:label
)
{
create
(
:group_label
)
}
...
...
spec/models/project_label_spec.rb
View file @
8379fbcd
...
@@ -64,6 +64,14 @@ describe ProjectLabel, models: true do
...
@@ -64,6 +64,14 @@ describe ProjectLabel, models: true do
end
end
end
end
describe
'#subject'
do
it
'aliases project to subject'
do
subject
=
described_class
.
new
(
project:
build
(
:empty_project
))
expect
(
subject
.
subject
).
to
be
(
subject
.
project
)
end
end
describe
'#to_reference'
do
describe
'#to_reference'
do
let
(
:label
)
{
create
(
:label
)
}
let
(
:label
)
{
create
(
:label
)
}
...
...
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