Commit 56311d2b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Refactor code for bulk update merge requests feature

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 7891aec0
...@@ -409,7 +409,7 @@ ...@@ -409,7 +409,7 @@
li { li {
.issue-check { .issue-check {
float: left; float: left;
padding-right: 16px; padding-right: $gl-padding;
margin-bottom: 10px; margin-bottom: 10px;
min-width: 15px; min-width: 15px;
......
...@@ -24,13 +24,13 @@ module IssuableActions ...@@ -24,13 +24,13 @@ module IssuableActions
private private
def authorize_destroy_issuable! def authorize_destroy_issuable!
unless current_user.can?(:"destroy_#{issuable.to_ability_name}", issuable) unless can?(current_user, :"destroy_#{issuable.to_ability_name}", issuable)
return access_denied! return access_denied!
end end
end end
def authorize_admin_issuable! def authorize_admin_issuable!
unless current_user.can?(:"admin_#{resource_name}", @project) unless can?(current_user, :"admin_#{resource_name}", @project)
return access_denied! return access_denied!
end end
end end
......
...@@ -111,12 +111,4 @@ module IssuablesHelper ...@@ -111,12 +111,4 @@ module IssuablesHelper
issuable.open? ? :opened : :closed issuable.open? ? :opened : :closed
end end
end end
def issuable_bulk_update_path(type)
if type == :merge_requests
bulk_update_namespace_project_merge_requests_path(@project.namespace, @project)
else
bulk_update_namespace_project_issues_path(@project.namespace, @project)
end
end
end end
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
- if @bulk_edit - if @bulk_edit
.issues_bulk_update.hide .issues_bulk_update.hide
= form_tag issuable_bulk_update_path(type), method: :post, class: 'bulk-update' do = form_tag [:bulk_update, @project.namespace.becomes(Namespace), @project, type], method: :post, class: 'bulk-update' do
.filter-item.inline .filter-item.inline
= dropdown_tag("Status", options: { toggle_class: "js-issue-status", title: "Change status", dropdown_class: "dropdown-menu-status dropdown-menu-selectable", data: { field_name: "update[state_event]" } } ) do = dropdown_tag("Status", options: { toggle_class: "js-issue-status", title: "Change status", dropdown_class: "dropdown-menu-status dropdown-menu-selectable", data: { field_name: "update[state_event]" } } ) do
%ul %ul
......
...@@ -13,29 +13,39 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t ...@@ -13,29 +13,39 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t
end end
context 'status', js: true do context 'status', js: true do
it 'sets to closed' do describe 'close merge request' do
visit namespace_project_merge_requests_path(project.namespace, project) before do
visit namespace_project_merge_requests_path(project.namespace, project)
end
change_status('Closed') it 'closes merge request' do
expect(page).to have_selector('.merge-request', count: 0) change_status('Closed')
expect(page).to have_selector('.merge-request', count: 0)
end
end end
it 'sets to open' do describe 'reopen merge request' do
merge_request.close before do
visit namespace_project_merge_requests_path(project.namespace, project, state: 'closed') merge_request.close
visit namespace_project_merge_requests_path(project.namespace, project, state: 'closed')
end
it 'reopens merge request' do
change_status('Open')
change_status('Open') expect(page).to have_selector('.merge-request', count: 0)
expect(page).to have_selector('.merge-request', count: 0) end
end end
end end
context 'assignee', js: true do context 'assignee', js: true do
context 'set assignee' do describe 'set assignee' do
before do before do
visit namespace_project_merge_requests_path(project.namespace, project) visit namespace_project_merge_requests_path(project.namespace, project)
end end
it "should update merge request with assignee" do it "updates merge request with assignee" do
change_assignee(user.name) change_assignee(user.name)
page.within('.merge-request .controls') do page.within('.merge-request .controls') do
...@@ -44,15 +54,16 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t ...@@ -44,15 +54,16 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t
end end
end end
context 'remove assignee' do describe 'remove assignee' do
before do before do
merge_request.assignee = user merge_request.assignee = user
merge_request.save merge_request.save
visit namespace_project_merge_requests_path(project.namespace, project) visit namespace_project_merge_requests_path(project.namespace, project)
end end
it "should remove assignee from the merge request" do it "removes assignee from the merge request" do
change_assignee('Unassigned') change_assignee('Unassigned')
expect(find('.merge-request .controls')).not_to have_css('.author_link') expect(find('.merge-request .controls')).not_to have_css('.author_link')
end end
end end
...@@ -61,26 +72,28 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t ...@@ -61,26 +72,28 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t
context 'milestone', js: true do context 'milestone', js: true do
let(:milestone) { create(:milestone, project: project) } let(:milestone) { create(:milestone, project: project) }
context 'set milestone' do describe 'set milestone' do
before do before do
visit namespace_project_merge_requests_path(project.namespace, project) visit namespace_project_merge_requests_path(project.namespace, project)
end end
it "should update merge request with milestone" do it "updates merge request with milestone" do
change_milestone(milestone.title) change_milestone(milestone.title)
expect(find('.merge-request')).to have_content milestone.title expect(find('.merge-request')).to have_content milestone.title
end end
end end
context 'unset milestone' do describe 'unset milestone' do
before do before do
merge_request.milestone = milestone merge_request.milestone = milestone
merge_request.save merge_request.save
visit namespace_project_merge_requests_path(project.namespace, project) visit namespace_project_merge_requests_path(project.namespace, project)
end end
it "should remove milestone from the merge request" do it "removes milestone from the merge request" do
change_milestone("No Milestone") change_milestone("No Milestone")
expect(find('.merge-request')).not_to have_content milestone.title expect(find('.merge-request')).not_to have_content milestone.title
end end
end 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