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
c98089b2
Commit
c98089b2
authored
Mar 15, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the #toggle_subscription controller method to a concern
parent
54ec7e95
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
28 deletions
+15
-28
app/controllers/projects/issues_controller.rb
app/controllers/projects/issues_controller.rb
+4
-9
app/controllers/projects/labels_controller.rb
app/controllers/projects/labels_controller.rb
+8
-10
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+3
-9
No files found.
app/controllers/projects/issues_controller.rb
View file @
c98089b2
class
Projects::IssuesController
<
Projects
::
ApplicationController
include
ToggleSubscriptionAction
before_action
:module_enabled
before_action
:issue
,
only:
[
:edit
,
:update
,
:show
,
:toggle_subscription
]
before_action
:issue
,
only:
[
:edit
,
:update
,
:show
]
# Allow read any issue
before_action
:authorize_read_issue!
...
...
@@ -110,14 +112,6 @@ class Projects::IssuesController < Projects::ApplicationController
redirect_back_or_default
(
default:
{
action:
'index'
},
options:
{
notice:
"
#{
result
[
:count
]
}
issues updated"
})
end
def
toggle_subscription
return
unless
current_user
@issue
.
toggle_subscription
(
current_user
)
render
nothing:
true
end
def
closed_by_merge_requests
@closed_by_merge_requests
||=
@issue
.
closed_by_merge_requests
(
current_user
)
end
...
...
@@ -131,6 +125,7 @@ class Projects::IssuesController < Projects::ApplicationController
redirect_old
end
end
alias_method
:subscribable_resource
,
:issue
def
authorize_update_issue!
return
render_404
unless
can?
(
current_user
,
:update_issue
,
@issue
)
...
...
app/controllers/projects/labels_controller.rb
View file @
c98089b2
class
Projects::LabelsController
<
Projects
::
ApplicationController
include
ToggleSubscriptionAction
before_action
:module_enabled
before_action
:label
,
only:
[
:edit
,
:update
,
:destroy
,
:toggle_subscription
]
before_action
:label
,
only:
[
:edit
,
:update
,
:destroy
]
before_action
:authorize_read_label!
before_action
:authorize_admin_labels!
,
except:
[
:index
,
:toggle_subscription
]
before_action
:authorize_admin_labels!
,
only:
[
:new
,
:create
,
:edit
,
:update
,
:generate
,
:destroy
]
respond_to
:js
,
:html
...
...
@@ -60,13 +64,6 @@ class Projects::LabelsController < Projects::ApplicationController
end
end
def
toggle_subscription
return
unless
current_user
@label
.
toggle_subscription
(
current_user
)
render
nothing:
true
end
protected
def
module_enabled
...
...
@@ -80,8 +77,9 @@ class Projects::LabelsController < Projects::ApplicationController
end
def
label
@label
=
@project
.
labels
.
find
(
params
[
:id
])
@label
||
=
@project
.
labels
.
find
(
params
[
:id
])
end
alias_method
:subscribable_resource
,
:label
def
authorize_admin_labels!
return
render_404
unless
can?
(
current_user
,
:admin_label
,
@project
)
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
c98089b2
class
Projects::MergeRequestsController
<
Projects
::
ApplicationController
include
ToggleSubscriptionAction
include
DiffHelper
before_action
:module_enabled
before_action
:merge_request
,
only:
[
:edit
,
:update
,
:show
,
:diffs
,
:commits
,
:builds
,
:merge
,
:merge_check
,
:ci_status
,
:
toggle_subscription
,
:
cancel_merge_when_build_succeeds
:ci_status
,
:cancel_merge_when_build_succeeds
]
before_action
:closes_issues
,
only:
[
:edit
,
:update
,
:show
,
:diffs
,
:commits
,
:builds
]
before_action
:validates_merge_request
,
only:
[
:show
,
:diffs
,
:commits
,
:builds
]
...
...
@@ -233,14 +234,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
render
json:
response
end
def
toggle_subscription
return
unless
current_user
@merge_request
.
toggle_subscription
(
current_user
)
render
nothing:
true
end
protected
def
selected_target_project
...
...
@@ -254,6 +247,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def
merge_request
@merge_request
||=
@project
.
merge_requests
.
find_by!
(
iid:
params
[
:id
])
end
alias_method
:subscribable_resource
,
:merge_request
def
closes_issues
@closes_issues
||=
@merge_request
.
closes_issues
...
...
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