Commit 15b17b3f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Implement approve button

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 73faf3c7
......@@ -4,7 +4,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
before_action :module_enabled
before_action :merge_request, only: [
:edit, :update, :show, :diffs, :commits, :automerge, :automerge_check,
:ci_status, :toggle_subscription
:ci_status, :toggle_subscription, :approve
]
before_action :closes_issues, only: [:edit, :update, :show, :diffs, :commits]
before_action :validates_merge_request, only: [:show, :diffs, :commits]
......@@ -195,6 +195,14 @@ class Projects::MergeRequestsController < Projects::ApplicationController
render nothing: true
end
def approve
@approval = @merge_request.approvals.new
@approval.user = current_user
@approval.save
redirect_to merge_request_path(@merge_request)
end
protected
def selected_target_project
......
......@@ -17,6 +17,11 @@
- if @show_merge_controls
.automerge_widget.can_be_merged.hide
.clearfix
- if @merge_request.requires_approve?
= form_for [:approve, @project.namespace.becomes(Namespace), @project, @merge_request], method: :post do |f|
%p This merge request must be approved by #{pluralize(@merge_request.approvals_left, 'user')} before it can be merged
= f.submit "Approve Merge Request", class: "btn btn-reopen"
- else
= form_for [:automerge, @project.namespace.becomes(Namespace), @project, @merge_request], remote: true, method: :post do |f|
.accept-merge-holder.clearfix.js-toggle-container
.accept-action
......
......@@ -491,6 +491,7 @@ Gitlab::Application.routes.draw do
get :automerge_check
get :ci_status
post :toggle_subscription
post :approve
end
collection do
......
......@@ -220,3 +220,9 @@ Feature: Project Merge Requests
When I click the "Target branch" dropdown
And I select a new target branch
Then I should see new target branch changes
Scenario: I approve merge request
Given merge request 'Bug NS-04' must be approved
Given I click link "Bug NS-04"
And I click link "Approve"
Then I should see approved merge request "Bug NS-04"
......@@ -329,6 +329,21 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
page.should have_content 'Target branch changed from master to feature'
end
step 'merge request \'Bug NS-04\' must be approved' do
merge_request = MergeRequest.find_by!(title: "Bug NS-04")
project = merge_request.target_project
project.approvals_before_merge = 1
project.save!
end
step 'I click link "Approve"' do
click_button 'Approve Merge Request'
end
step 'I should see approved merge request "Bug NS-04"' do
page.should have_button("Accept Merge Request")
end
def merge_request
@merge_request ||= MergeRequest.find_by!(title: "Bug NS-05")
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment