@ -117,8 +117,13 @@ class MembersController < ApplicationController
def destroy
if @member.deletable?
@member.destroy
flash.notice = l(:notice_member_removed)
if @member.disposable?
@member.user.destroy
flash.notice = I18n.t(:notice_member_removed)
else
end
redirect_to project_members_path(project_id: @project)
@ -130,6 +130,13 @@ class Member < ActiveRecord::Base
@membership
##
# Returns true if this user can be deleted as they have no other memberships
# and haven't been activated yet.
def disposable?
user.invited? && user.memberships.none? { |m| m.project_id != project_id }
protected
def destroy_if_no_roles_left!