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
198fe1bf
Commit
198fe1bf
authored
Nov 14, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add toggle_subscription action to Groups::LabelsController
parent
0aac2e07
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
1 deletion
+33
-1
app/controllers/groups/labels_controller.rb
app/controllers/groups/labels_controller.rb
+7
-0
config/routes/group.rb
config/routes/group.rb
+4
-1
spec/controllers/groups/labels_controller_spec.rb
spec/controllers/groups/labels_controller_spec.rb
+22
-0
No files found.
app/controllers/groups/labels_controller.rb
View file @
198fe1bf
class
Groups::LabelsController
<
Groups
::
ApplicationController
class
Groups::LabelsController
<
Groups
::
ApplicationController
include
ToggleSubscriptionAction
before_action
:label
,
only:
[
:edit
,
:update
,
:destroy
]
before_action
:label
,
only:
[
:edit
,
:update
,
:destroy
]
before_action
:authorize_admin_labels!
,
only:
[
:new
,
:create
,
:edit
,
:update
,
:destroy
]
before_action
:authorize_admin_labels!
,
only:
[
:new
,
:create
,
:edit
,
:update
,
:destroy
]
before_action
:save_previous_label_path
,
only:
[
:edit
]
before_action
:save_previous_label_path
,
only:
[
:edit
]
...
@@ -69,6 +71,11 @@ class Groups::LabelsController < Groups::ApplicationController
...
@@ -69,6 +71,11 @@ class Groups::LabelsController < Groups::ApplicationController
def
label
def
label
@label
||=
@group
.
labels
.
find
(
params
[
:id
])
@label
||=
@group
.
labels
.
find
(
params
[
:id
])
end
end
alias_method
:subscribable_resource
,
:label
def
subscribable_project
nil
end
def
label_params
def
label_params
params
.
require
(
:label
).
permit
(
:title
,
:description
,
:color
)
params
.
require
(
:label
).
permit
(
:title
,
:description
,
:color
)
...
...
config/routes/group.rb
View file @
198fe1bf
...
@@ -30,7 +30,10 @@ scope(path: 'groups/:group_id', module: :groups, as: :group) do
...
@@ -30,7 +30,10 @@ scope(path: 'groups/:group_id', module: :groups, as: :group) do
resource
:avatar
,
only:
[
:destroy
]
resource
:avatar
,
only:
[
:destroy
]
resources
:milestones
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:index
,
:show
,
:update
,
:new
,
:create
]
resources
:milestones
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:index
,
:show
,
:update
,
:new
,
:create
]
resources
:labels
,
except:
[
:show
],
constraints:
{
id:
/\d+/
}
resources
:labels
,
except:
[
:show
],
constraints:
{
id:
/\d+/
}
do
post
:toggle_subscription
,
on: :member
end
end
end
# Must be last route in this file
# Must be last route in this file
...
...
spec/controllers/groups/labels_controller_spec.rb
0 → 100644
View file @
198fe1bf
require
'spec_helper'
describe
Groups
::
LabelsController
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
group
.
add_owner
(
user
)
sign_in
(
user
)
end
describe
'POST #toggle_subscription'
do
it
'allows user to toggle subscription on group labels'
do
label
=
create
(
:group_label
,
group:
group
)
post
:toggle_subscription
,
group_id:
group
.
to_param
,
id:
label
.
to_param
expect
(
response
).
to
have_http_status
(
200
)
end
end
end
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