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,34 +17,39 @@
- if @show_merge_controls
.automerge_widget.can_be_merged.hide
.clearfix
= 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
= f.submit "Accept Merge Request", class: "btn btn-create accept_merge_request"
- if can_remove_branch?(@merge_request.source_project, @merge_request.source_branch) && !@merge_request.for_fork?
.accept-control.checkbox
= label_tag :should_remove_source_branch, class: "remove_source_checkbox" do
= check_box_tag :should_remove_source_branch
Remove source-branch
- if @merge_request.target_project.merge_requests_rebase_enabled && can_rebase?(@merge_request.target_project, @merge_request.target_branch)
.accept-control.remove_branch_holder
= label_tag :should_rebase, class: "checkbox" do
= check_box_tag :should_rebase, "1", @project.merge_requests_rebase_default
Rebase before merge
.accept-control
= link_to "#", class: "modify-merge-commit-link js-toggle-button", title: "Modify merge commit message" do
%i.fa.fa-edit
Modify commit message
.js-toggle-content.hide.prepend-top-20
= render 'shared/commit_message_container', params: params,
text: @merge_request.merge_commit_message,
rows: 14, hint: true
- 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
= f.submit "Accept Merge Request", class: "btn btn-create accept_merge_request"
- if can_remove_branch?(@merge_request.source_project, @merge_request.source_branch) && !@merge_request.for_fork?
.accept-control.checkbox
= label_tag :should_remove_source_branch, class: "remove_source_checkbox" do
= check_box_tag :should_remove_source_branch
Remove source-branch
- if @merge_request.target_project.merge_requests_rebase_enabled && can_rebase?(@merge_request.target_project, @merge_request.target_branch)
.accept-control.remove_branch_holder
= label_tag :should_rebase, class: "checkbox" do
= check_box_tag :should_rebase, "1", @project.merge_requests_rebase_default
Rebase before merge
.accept-control
= link_to "#", class: "modify-merge-commit-link js-toggle-button", title: "Modify merge commit message" do
%i.fa.fa-edit
Modify commit message
.js-toggle-content.hide.prepend-top-20
= render 'shared/commit_message_container', params: params,
text: @merge_request.merge_commit_message,
rows: 14, hint: true
%br
.light
If you want to merge this request manually, you can use the
%strong
= link_to "command line", "#modal_merge_info", class: "how_to_merge_link vlink", title: "How To Merge", "data-toggle" => "modal"
%br
.light
If you want to merge this request manually, you can use the
%strong
= link_to "command line", "#modal_merge_info", class: "how_to_merge_link vlink", title: "How To Merge", "data-toggle" => "modal"
.automerge_widget.no_satellite.hide
......
......@@ -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