diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-03-30 20:49:34 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-03-30 20:49:34 +0300 |
commit | 90748cf724d4b019c954d316621b04cefd69dbaf (patch) | |
tree | 6e6ac8345aec69abd1e38b259a1735ba7d28aa9d /app | |
parent | 464cd59dff0e543cc367c0d468a70ca590334e42 (diff) | |
download | gitlab-ce-90748cf724d4b019c954d316621b04cefd69dbaf.tar.gz |
Merge Button v1 complete
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/merge_requests_controller.rb | 1 | ||||
-rw-r--r-- | app/models/ability.rb | 1 | ||||
-rw-r--r-- | app/models/merge_request.rb | 4 | ||||
-rw-r--r-- | app/views/merge_requests/show.html.haml | 3 |
4 files changed, 6 insertions, 3 deletions
diff --git a/app/controllers/merge_requests_controller.rb b/app/controllers/merge_requests_controller.rb index f4b97de93a6..b3776c0af27 100644 --- a/app/controllers/merge_requests_controller.rb +++ b/app/controllers/merge_requests_controller.rb @@ -102,6 +102,7 @@ class MergeRequestsController < ApplicationController def automerge render_404 unless @merge_request.open? && @merge_request.can_be_merged? + return access_denied! unless can?(current_user, :accept_mr, @project) @merge_request.automerge!(current_user) end diff --git a/app/models/ability.rb b/app/models/ability.rb index e97b662b8ce..8ff45b6d17e 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -46,6 +46,7 @@ class Ability :admin_team_member, :admin_merge_request, :admin_note, + :accept_mr, :admin_wiki ] if project.master_access_for?(user) || project.owner == user diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 85492e802e3..d7863c2edb0 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -73,7 +73,7 @@ class MergeRequest < ActiveRecord::Base end def check_if_can_be_merged - self.state = if GitlabMerge.new(self).can_be_merged? + self.state = if GitlabMerge.new(self, self.author).can_be_merged? CAN_BE_MERGED else CANNOT_BE_MERGED @@ -175,7 +175,7 @@ class MergeRequest < ActiveRecord::Base end def automerge!(current_user) - if GitlabMerge.new(self).merge + if GitlabMerge.new(self, current_user).merge self.merge!(current_user.id) true end diff --git a/app/views/merge_requests/show.html.haml b/app/views/merge_requests/show.html.haml index 7e14a61c661..68c165605ea 100644 --- a/app/views/merge_requests/show.html.haml +++ b/app/views/merge_requests/show.html.haml @@ -52,7 +52,8 @@ Closed by #{@merge_request.closed_event.author_name} %small #{time_ago_in_words(@merge_request.closed_event.created_at)} ago. -- if @merge_request.open? && @commits.any? + +- if @merge_request.open? && @commits.any? && can?(current_user, :accept_mr, @project) - if @merge_request.can_be_merged? .ui-box.padded %p |