diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-14 08:30:37 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-03-17 07:39:16 +0100 |
commit | a91101b19a44d98005dd21b06d8509abcd82ddfc (patch) | |
tree | 10c1a04d398441d6642db02f181abe166a512f81 | |
parent | 310b417b0f2336e5e7a9b44da2fabf5d4abb0cb4 (diff) | |
download | gitlab-ce-a91101b19a44d98005dd21b06d8509abcd82ddfc.tar.gz |
Make it possible to move issue if user is a reporter
Discussed it here:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2831#note_4190228
-rw-r--r-- | app/models/ability.rb | 1 | ||||
-rw-r--r-- | app/services/issues/move_service.rb | 4 | ||||
-rw-r--r-- | app/views/shared/issuable/_form.html.haml | 2 | ||||
-rw-r--r-- | spec/services/issues/move_service_spec.rb | 20 |
4 files changed, 13 insertions, 14 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index 5dff01a4e5d..ae1cf0c0f6b 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -223,7 +223,6 @@ class Ability :admin_project, :admin_commit_status, :admin_build, - :move_issue ] end diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb index d1bded5c99f..d9f4692d377 100644 --- a/app/services/issues/move_service.rb +++ b/app/services/issues/move_service.rb @@ -39,8 +39,8 @@ module Issues private def can_move? - can?(@current_user, :move_issue, @project_old) && - can?(@current_user, :move_issue, @project_new) + can?(@current_user, :admin_issue, @project_old) && + can?(@current_user, :admin_issue, @project_new) end def open_new_issue diff --git a/app/views/shared/issuable/_form.html.haml b/app/views/shared/issuable/_form.html.haml index bb0252ba3de..5b3c0ee2734 100644 --- a/app/views/shared/issuable/_form.html.haml +++ b/app/views/shared/issuable/_form.html.haml @@ -67,7 +67,7 @@ - if can? current_user, :admin_label, issuable.project = link_to 'Create new label', new_namespace_project_label_path(issuable.project.namespace, issuable.project), target: :blank -- if issuable.is_a?(Issue) && can?(current_user, :move_issue, issuable.project) +- if issuable.is_a?(Issue) && can?(current_user, :admin_issue, issuable.project) %hr .form-group = f.label :move_to_project_id, 'Move', class: 'control-label' diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb index 4fcfceaddd4..38fa5707cf7 100644 --- a/spec/services/issues/move_service_spec.rb +++ b/spec/services/issues/move_service_spec.rb @@ -24,8 +24,8 @@ describe Issues::MoveService, services: true do shared_context 'user can move issue' do before do - old_project.team << [user, :master] - new_project.team << [user, :master] + old_project.team << [user, :reporter] + new_project.team << [user, :reporter] end end @@ -186,25 +186,25 @@ describe Issues::MoveService, services: true do describe '#move?' do subject { move_service.move? } - context 'user is master in both projects' do + context 'user is reporter in both projects' do include_context 'user can move issue' it { is_expected.to be_truthy } end - context 'user is master only in new project' do - before { new_project.team << [user, :master] } + context 'user is reporter only in new project' do + before { new_project.team << [user, :reporter] } it { is_expected.to be_falsey } end - context 'user is master only in old project' do - before { old_project.team << [user, :master] } + context 'user is reporter only in old project' do + before { old_project.team << [user, :reporter] } it { is_expected.to be_falsey } end - context 'user is master in one project and developer in another' do + context 'user is reporter in one project and guest in another' do before do - new_project.team << [user, :developer] - old_project.team << [user, :master] + new_project.team << [user, :guest] + old_project.team << [user, :reporter] end it { is_expected.to be_falsey } |