Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Harmonize controller code and remove obsolete check for exisiting array (as it always exists)

Henriette Dargecea1b385e99a
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb
index 545b041a4ab..4815c737a61 100644
--- a/app/controllers/members_controller.rb
+++ b/app/controllers/members_controller.rb
@@ -45,11 +45,7 @@ class MembersController < ApplicationController
.new(user: current_user)
.call(member_params)
- if overall_result
- overall_result.push(service_call)
- else
- overall_result = [service_call]
- end
+ overall_result.push(service_call)
end
if overall_result.empty?
diff --git a/app/controllers/work_packages/shares_controller.rb b/app/controllers/work_packages/shares_controller.rb
index d69ee61830a..e7b3770aca0 100644
--- a/app/controllers/work_packages/shares_controller.rb
+++ b/app/controllers/work_packages/shares_controller.rb
@@ -40,7 +40,7 @@ class WorkPackages::SharesController < ApplicationController
end
def create
- overall_result = nil
+ overall_result = []
find_or_create_users(send_notification: false) do |member_params|
service_call = WorkPackageMembers::CreateOrUpdateService
@@ -51,16 +51,12 @@ class WorkPackages::SharesController < ApplicationController
@share = service_call.result
- if overall_result
- overall_result.push(service_call)
- else
- overall_result = [service_call]
- end
+ overall_result.push(service_call)
end
@shares = overall_result.map(&:result).reverse
- unless overall_result.nil?
+ if overall_result.present?
# In case the number of newly added shares is equal to the whole number of shares,
# we have to render the whole modal again to get rid of the blankslate
if current_visible_member_count > 1 && @shares.size < current_visible_member_count