Commit 15a66339 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Revert authors ability to assign anyone

parent 829830ae
......@@ -15,7 +15,7 @@ class AutocompleteController < ApplicationController
@users = [*@users, current_user]
end
unless params[:author_id] == "false"
if params[:author_id] && params[:author_id] != "false"
@users = [User.find(params[:author_id]), *@users]
end
......
......@@ -116,11 +116,6 @@ module Issuable
assignee_id_changed?
end
def can_assign_user?(current_user)
author == current_user ||
Ability.abilities.allowed?(current_user, :"admin_#{to_ability_name}", project)
end
def open?
opened? || reopened?
end
......
......@@ -33,7 +33,7 @@ class IssuableBaseService < BaseService
end
end
def filter_params(issuable_ability_name, issuable)
def filter_params(issuable_ability_name = :issue)
params[:assignee_id] = "" if params[:assignee_id] == IssuableFinder::NONE
params[:milestone_id] = "" if params[:milestone_id] == IssuableFinder::NONE
......@@ -42,18 +42,13 @@ class IssuableBaseService < BaseService
unless can?(current_user, ability, project)
params.delete(:milestone_id)
params.delete(:label_ids)
# The author of an issue can be assigned, to signal the ball being in his/her
# court. This allow him/her to reassign the issue back to the reviewer.
if issuable && !(issuable.author == current_user)
params.delete(:assignee_id)
end
end
end
def update(issuable)
change_state(issuable)
filter_params(issuable)
filter_params
old_labels = issuable.labels.to_a
if params.present? && issuable.update_attributes(params.merge(updated_by: current_user))
......
......@@ -10,8 +10,8 @@ module Issues
private
def filter_params(issuable = nil)
super(:issue, issuable)
def filter_params
super(:issue)
end
def execute_hooks(issue, action = 'open')
......
......@@ -23,8 +23,8 @@ module MergeRequests
private
def filter_params(issuable = nil)
super(:merge_request, issuable)
def filter_params
super(:merge_request)
end
end
end
......@@ -30,7 +30,7 @@
.title
%label
Assignee
- if issuable.can_assign_user?(current_user)
- if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
.pull-right
= link_to 'Edit', '#', class: 'edit-link'
.value
......
......@@ -12,13 +12,13 @@ describe AutocompleteController do
project.team << [user, :master]
end
let(:body) { JSON.parse(response.body) }
describe 'GET #users with project ID' do
before do
get(:users, project_id: project.id)
end
let(:body) { JSON.parse(response.body) }
it { expect(body).to be_kind_of(Array) }
it { expect(body.size).to eq 1 }
it { expect(body.first["username"]).to eq user.username }
......
......@@ -111,20 +111,6 @@ describe Issue, "Issuable" do
end
end
describe "#can_assign_user?" do
let(:author) { build(:user) }
let(:issue) { build(:issue, author: author)}
it "Allows the author to change the assignee" do
expect(issue.can_assign_user?(author)).to be_truthy
end
it "Doesn't allow others, non-team members" do
other_user = build(:user)
expect(issue.can_assign_user?(other_user)).to be_falsey
end
end
describe "votes" do
before do
author = create :user
......
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