diff options
Diffstat (limited to 'app/controllers/concerns/membership_actions.rb')
-rw-r--r-- | app/controllers/concerns/membership_actions.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/app/controllers/concerns/membership_actions.rb b/app/controllers/concerns/membership_actions.rb index 7c6e449b509..773e4c15d6e 100644 --- a/app/controllers/concerns/membership_actions.rb +++ b/app/controllers/concerns/membership_actions.rb @@ -6,7 +6,7 @@ module MembershipActions def update update_params = params.require(root_params_key).permit(:access_level, :expires_at) - member = membershipable.members_and_requesters.find(params[:id]) + member = members_and_requesters.find(params[:id]) result = Members::UpdateService .new(current_user, update_params) .execute(member) @@ -30,7 +30,7 @@ module MembershipActions end def destroy - member = membershipable.members_and_requesters.find(params[:id]) + member = members_and_requesters.find(params[:id]) skip_subresources = !ActiveRecord::Type::Boolean.new.cast(params.delete(:remove_sub_memberships)) # !! is used in case unassign_issuables contains empty string which would result in nil unassign_issuables = !!ActiveRecord::Type::Boolean.new.cast(params.delete(:unassign_issuables)) @@ -71,7 +71,7 @@ module MembershipActions end def approve_access_request - access_requester = membershipable.requesters.find(params[:id]) + access_requester = requesters.find(params[:id]) Members::ApproveAccessRequestService .new(current_user, params) .execute(access_requester) @@ -81,7 +81,7 @@ module MembershipActions # rubocop: disable CodeReuse/ActiveRecord def leave - member = membershipable.members_and_requesters.find_by!(user_id: current_user.id) + member = members_and_requesters.find_by!(user_id: current_user.id) Members::DestroyService.new(current_user).execute(member) notice = @@ -140,6 +140,14 @@ module MembershipActions raise NotImplementedError end + def members_and_requesters + membershipable.members_and_requesters + end + + def requesters + membershipable.requesters + end + def requested_relations(inherited_permissions = :with_inherited_permissions) case params[inherited_permissions].presence when 'exclude' |