diff --git a/.rubocop.yml b/.rubocop.yml index 0a5a84c6e..62b242e67 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,7 +9,7 @@ AllCops: - "spec/**/*" NewCops: enable UseCache: false - TargetRubyVersion: 2.6 + TargetRubyVersion: 3.2 ##################### Style #################################### @@ -100,6 +100,7 @@ Style/GuardClause: Style/HashSyntax: EnforcedStyle: ruby19 + EnforcedShorthandSyntax: never Style/IfUnlessModifier: Enabled: true diff --git a/Dockerfile.production b/Dockerfile.production index 438d729e9..61595ea27 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -15,7 +15,7 @@ RUN \ ENV APP_HOME /usr/src/app ENV RAILS_ENV=production -ENV GEM_HOME=$APP_HOME/vendor/bundle/ruby/2.7.0 +ENV GEM_HOME=$APP_HOME/vendor/bundle/ruby/3.2.0 ENV PATH=$GEM_HOME/bin:$PATH ENV BUNDLE_APP_CONFIG=.bundle ENV BUNDLE_BUILD__SASSC=--disable-march-tune-native @@ -29,7 +29,7 @@ RUN \ bundle config set path '/usr/src/app/tmp/bundle' && \ bundle install --jobs `nproc` && \ cp -r tmp/bundle/ vendor && \ - rm -rf vendor/bundle/ruby/2.7.0/cache && \ + rm -rf vendor/bundle/ruby/3.2.0/cache && \ find vendor/bundle/ruby -type d -name '.git' -exec rm -rf {} + && \ bundle config --local path vendor/bundle @@ -65,14 +65,17 @@ RUN \ RUN \ --mount=type=cache,target=/var/cache/apt,sharing=locked \ --mount=type=cache,target=/var/lib/apt,sharing=locked \ + DEBIAN_FRONTEND=noninteractive \ apt-get update -qq && \ apt-get install -y --no-install-recommends \ + default-jre-headless \ + ca-certificates-java && \ + apt-get install -y --no-install-recommends \ libjemalloc2 \ groff-base \ postgresql-client \ - netcat-openbsd \ npm \ - default-jre-headless \ + netcat-openbsd \ poppler-utils \ librsvg2-2 \ libvips42 \ @@ -95,7 +98,7 @@ RUN \ ENV APP_HOME /usr/src/app ENV RAILS_ENV=production -ENV GEM_HOME=$APP_HOME/vendor/bundle/ruby/2.7.0 +ENV GEM_HOME=$APP_HOME/vendor/bundle/ruby/3.2.0 ENV PATH=$GEM_HOME/bin:$PATH ENV BUNDLE_APP_CONFIG=.bundle diff --git a/app/controllers/active_storage/blobs/redirect_controller.rb b/app/controllers/active_storage/blobs/redirect_controller.rb index d70480d92..31742a9fc 100644 --- a/app/controllers/active_storage/blobs/redirect_controller.rb +++ b/app/controllers/active_storage/blobs/redirect_controller.rb @@ -8,7 +8,7 @@ module ActiveStorage def show expires_in ActiveStorage.service_urls_expire_in - redirect_to @blob.url(disposition: params[:disposition]) + redirect_to @blob.url(disposition: params[:disposition]), allow_other_host: true end end end diff --git a/app/controllers/active_storage/representations/redirect_controller.rb b/app/controllers/active_storage/representations/redirect_controller.rb index 38b2f5d9e..edebc540e 100644 --- a/app/controllers/active_storage/representations/redirect_controller.rb +++ b/app/controllers/active_storage/representations/redirect_controller.rb @@ -12,7 +12,8 @@ module ActiveStorage end expires_in ActiveStorage.service_urls_expire_in - redirect_to @blob.representation(params[:variation_key]).processed.url(disposition: params[:disposition]) + redirect_to @blob.representation(params[:variation_key]).processed.url(disposition: params[:disposition]), + allow_other_host: true end private diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index f1690e56e..594dfb76d 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -6,7 +6,7 @@ class ActivitiesController < ApplicationController render json: { more_url: local_vars.fetch(:more_activities_url), html: render_to_string( - partial: 'list', locals: @vars + partial: 'list', locals: @vars, formats: :html ) } end diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb index 161268c32..ec17ef0a7 100644 --- a/app/controllers/assets_controller.rb +++ b/app/controllers/assets_controller.rb @@ -28,7 +28,8 @@ class AssetsController < ApplicationController can_edit: can_manage_asset?(@asset), gallery: params[:gallery], preview: params[:preview] - } + }, + formats: :html ) } end @@ -60,7 +61,8 @@ class AssetsController < ApplicationController locals: { asset: @asset, gallery_view_id: gallery_view_id - }) } + }, + formats: :html) } end def file_url diff --git a/app/controllers/at_who_controller.rb b/app/controllers/at_who_controller.rb index 09c188f45..c4c5ae9ef 100644 --- a/app/controllers/at_who_controller.rb +++ b/app/controllers/at_who_controller.rb @@ -7,7 +7,7 @@ class AtWhoController < ApplicationController def users users = @team.search_users(@query).limit(Constants::ATWHO_SEARCH_LIMIT + 1) render json: { - users: [render_to_string(partial: 'shared/smart_annotation/users', locals: { users: users })] + users: [render_to_string(partial: 'shared/smart_annotation/users', locals: { users: users }, formats: :html)] } end @@ -44,7 +44,8 @@ class AtWhoController < ApplicationController render json: { res: [ render_to_string(partial: 'shared/smart_annotation/repository_items', - locals: { repository_rows: items, repository: repository }) + locals: { repository_rows: items, repository: repository }, + formats: :html) ], repository: repository_id, team: current_team.id @@ -53,15 +54,19 @@ class AtWhoController < ApplicationController def menu repositories = Repository.active.accessible_by_teams(@team) - render json: { html: render_to_string({ partial: "shared/smart_annotation/menu.html.erb", - locals: { repositories: repositories } }) } + render json: { + html: render_to_string(partial: 'shared/smart_annotation/menu', + locals: { repositories: repositories }, + formats: :html) + } end def projects res = SmartAnnotation.new(current_user, current_team, @query) render json: { res: [render_to_string(partial: 'shared/smart_annotation/project_items', - locals: { projects: res.projects })], + locals: { projects: res.projects }, + formats: :html)], team: current_team.id } end @@ -70,7 +75,8 @@ class AtWhoController < ApplicationController res = SmartAnnotation.new(current_user, current_team, @query) render json: { res: [render_to_string(partial: 'shared/smart_annotation/experiment_items', - locals: { experiments: res.experiments })], + locals: { experiments: res.experiments }, + formats: :html)], team: current_team.id } end @@ -79,7 +85,8 @@ class AtWhoController < ApplicationController res = SmartAnnotation.new(current_user, current_team, @query) render json: { res: [render_to_string(partial: 'shared/smart_annotation/my_module_items', - locals: { my_modules: res.my_modules })], + locals: { my_modules: res.my_modules }, + formats: :html)], team: current_team.id } end diff --git a/app/controllers/bio_eddie_assets_controller.rb b/app/controllers/bio_eddie_assets_controller.rb index 5b4232312..473271522 100644 --- a/app/controllers/bio_eddie_assets_controller.rb +++ b/app/controllers/bio_eddie_assets_controller.rb @@ -18,10 +18,9 @@ class BioEddieAssetsController < ApplicationController if asset && bio_eddie_params[:object_type] == 'Step' create_register_bio_eddie_activity(asset, current_user) if bio_eddie_params[:schedule_for_registration] == 'true' render json: { - html: render_to_string(partial: 'assets/asset', locals: { - asset: asset, - gallery_view_id: bio_eddie_params[:object_id] - }) + html: render_to_string(partial: 'assets/asset', + locals: { asset: asset, gallery_view_id: bio_eddie_params[:object_id] }, + formats: :html) } elsif asset && bio_eddie_params[:object_type] == 'Result' create_register_bio_eddie_activity(asset, current_user) if bio_eddie_params[:schedule_for_registration] == 'true' diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index d82f50561..6341043e4 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -28,7 +28,8 @@ class CommentsController < ApplicationController object_url: object_url, comment_addable: comment_addable?(@commentable), comments: render_to_string(partial: 'shared/comments/comments_list', - locals: { comments: comments }) + locals: { comments: comments }, + formats: :html) } end diff --git a/app/controllers/dashboard/calendars_controller.rb b/app/controllers/dashboard/calendars_controller.rb index 5fe3defe5..93217a54c 100644 --- a/app/controllers/dashboard/calendars_controller.rb +++ b/app/controllers/dashboard/calendars_controller.rb @@ -30,9 +30,9 @@ module Dashboard .where('my_modules.due_date > ? AND my_modules.due_date < ?', start_date, end_date) .where(projects: { team_id: current_team.id }) render json: { - html: render_to_string(partial: 'shared/my_modules_list_partial', locals: { - my_modules: my_modules - }) + html: render_to_string(partial: 'shared/my_modules_list_partial', + locals: { my_modules: my_modules }, + formats: :html) } end end diff --git a/app/controllers/dashboard/current_tasks_controller.rb b/app/controllers/dashboard/current_tasks_controller.rb index a57f8e85c..703935006 100644 --- a/app/controllers/dashboard/current_tasks_controller.rb +++ b/app/controllers/dashboard/current_tasks_controller.rb @@ -14,7 +14,7 @@ module Dashboard tasks = load_tasks.page(page).per(Constants::INFINITE_SCROLL_LIMIT).without_count tasks_list = tasks.map do |task| - render_to_string(partial: 'dashboards/current_tasks/task', locals: { task: task }) + render_to_string(partial: 'dashboards/current_tasks/task', locals: { task: task }, formats: :html) end render json: { data: tasks_list, next_page: tasks.next_page } diff --git a/app/controllers/experiments_controller.rb b/app/controllers/experiments_controller.rb index 0c69e8aa7..57f68a834 100644 --- a/app/controllers/experiments_controller.rb +++ b/app/controllers/experiments_controller.rb @@ -31,8 +31,7 @@ class ExperimentsController < ApplicationController @experiment = Experiment.new render json: { html: render_to_string( - partial: 'new_modal', - formats: :html + partial: 'new_modal', formats: :html ) } end @@ -63,7 +62,7 @@ class ExperimentsController < ApplicationController def show render json: { - html: render_to_string(partial: 'experiments/details_modal') + html: render_to_string(partial: 'experiments/details_modal', formats: :html) } end @@ -143,9 +142,7 @@ class ExperimentsController < ApplicationController def edit render json: { - html: render_to_string( - partial: 'edit_modal' - ) + html: render_to_string(partial: 'edit_modal', formats: :html) } end @@ -256,7 +253,8 @@ class ExperimentsController < ApplicationController render json: { html: render_to_string( partial: 'clone_modal', - locals: { view_mode: params[:view_mode] } + locals: { view_mode: params[:view_mode] }, + formats: :html ) } end @@ -285,9 +283,7 @@ class ExperimentsController < ApplicationController def move_modal @projects = @experiment.movable_projects(current_user) render json: { - html: render_to_string( - partial: 'move_modal' - ) + html: render_to_string(partial: 'move_modal', formats: :html) } end @@ -331,9 +327,7 @@ class ExperimentsController < ApplicationController @experiments = @experiment.project.experiments.active.where.not(id: @experiment) .managable_by_user(current_user).order(name: :asc) render json: { - html: render_to_string( - partial: 'move_modules_modal' - ) + html: render_to_string(partial: 'move_modules_modal', formats: :html) } end @@ -394,7 +388,8 @@ class ExperimentsController < ApplicationController render json: { workflowimg: render_to_string( partial: 'projects/show/workflow_img', - locals: { experiment: @experiment } + locals: { experiment: @experiment }, + formats: :html ) } end diff --git a/app/controllers/global_activities_controller.rb b/app/controllers/global_activities_controller.rb index 20bfad3ef..1ea1038c9 100644 --- a/app/controllers/global_activities_controller.rb +++ b/app/controllers/global_activities_controller.rb @@ -55,11 +55,17 @@ class GlobalActivitiesController < ApplicationController @next_page = activities.next_page @starting_timestamp = activities.first&.created_at.to_i - render json: { - activities_html: render_to_string(partial: 'activity_list'), - next_page: @next_page, - starting_timestamp: @starting_timestamp - } + respond_to do |format| + format.json do + render json: { + activities_html: render_to_string(partial: 'activity_list'), + next_page: @next_page, + starting_timestamp: @starting_timestamp + } + end + format.html do + end + end end def team_filter diff --git a/app/controllers/my_modules_controller.rb b/app/controllers/my_modules_controller.rb index efe6c49c2..5722ccb57 100644 --- a/app/controllers/my_modules_controller.rb +++ b/app/controllers/my_modules_controller.rb @@ -143,15 +143,15 @@ class MyModulesController < ApplicationController @activities = @my_module.last_activities(1, @per_page) render json: { - html: render_to_string(partial: 'activities') + html: render_to_string(partial: 'activities', formats: :html) } end # Due date modal window in full-zoom canvas def due_date render json: { - html: render_to_string(partial: 'due_date'), - title: t('my_modules.due_date.title', module: escape_input(@my_module.name)) + html: render_to_string(partial: 'due_date', formats: :html), + title: t('.due_date.title', module: escape_input(@my_module.name)) } end diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index ad0aec197..1d29cb737 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -852,28 +852,15 @@ class ProtocolsController < ApplicationController end def load_from_repository_modal - @protocol = Protocol.find_by_id(params[:id]) - respond_to do |format| - format.json do - render json: { - html: render_to_string({ - partial: "my_modules/protocols/load_from_repository_modal_body.html.erb" - }) - } - end - end + render json: { + html: render_to_string(partial: 'my_modules/protocols/load_from_repository_modal_body', formats: :html) + } end def protocol_status_bar - respond_to do |format| - format.json do - render json: { - html: render_to_string({ - partial: "my_modules/protocols/protocol_status_bar.html.erb" - }) - } - end - end + render json: { + html: render_to_string(partial: 'my_modules/protocols/protocol_status_bar', formats: :html) + } end def version_comment diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 92d1a7f90..ff51239a7 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -84,23 +84,13 @@ class RepositoriesController < ApplicationController def create_modal @repository = Repository.new - respond_to do |format| - format.json do - render json: { - html: render_to_string( - partial: 'create_repository_modal' - ) - } - end - end + render json: { + html: render_to_string(partial: 'create_repository_modal', formats: :html) + } end def share_modal - respond_to do |format| - format.json do - render json: { html: render_to_string(partial: 'share_repository_modal') } - end - end + render json: { html: render_to_string(partial: 'share_repository_modal', formats: :html) } end def hide_reminders diff --git a/app/controllers/result_texts_controller.rb b/app/controllers/result_texts_controller.rb index 11822a192..8fa75ea34 100644 --- a/app/controllers/result_texts_controller.rb +++ b/app/controllers/result_texts_controller.rb @@ -101,20 +101,19 @@ class ResultTextsController < ApplicationController respond_to do |format| if saved - format.html { + format.html do flash[:success] = success_flash redirect_to results_my_module_path(@my_module) - } - format.json { + end + format.json do render json: { - html: render_to_string({ - partial: "my_modules/result.html.erb", - locals: { - result: @result - } - }) - }, status: :ok - } + html: render_to_string( + partial: 'my_modules/result.html.erb', + locals: { result: @result }, + formats: :html + ) + } + end else format.json { render json: @result.errors, status: :bad_request diff --git a/app/controllers/steps_controller.rb b/app/controllers/steps_controller.rb index b3ab0399d..7cc3d400c 100644 --- a/app/controllers/steps_controller.rb +++ b/app/controllers/steps_controller.rb @@ -102,7 +102,8 @@ class StepsController < ApplicationController render json: { html: render_to_string( partial: 'steps/step', - locals: { step: @step } + locals: { step: @step }, + formats: :html ) } end diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index 7a5f15523..f0bf65cff 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -15,7 +15,8 @@ class TeamsController < ApplicationController render json: { html: render_to_string( partial: 'shared/sidebar/projects', - locals: { team: current_team, sort: params[:sort] } + locals: { team: current_team, sort: params[:sort] }, + formats: :html ) } end @@ -50,7 +51,8 @@ class TeamsController < ApplicationController partial: 'projects/export/modal', locals: { num_projects: @exp_projects.size, limit: TeamZipExport.exports_limit, - num_of_requests_left: current_user.exports_left - 1 } + num_of_requests_left: current_user.exports_left - 1 }, + formats: :html ), title: t('projects.export_projects.modal_title') } @@ -58,7 +60,8 @@ class TeamsController < ApplicationController render json: { html: render_to_string( partial: 'projects/export/error', - locals: { limit: TeamZipExport.exports_limit } + locals: { limit: TeamZipExport.exports_limit }, + formats: :html ), title: t('projects.export_projects.error_title'), status: 'error' diff --git a/app/controllers/user_my_modules_controller.rb b/app/controllers/user_my_modules_controller.rb index 2a8766630..1e2302ad8 100644 --- a/app/controllers/user_my_modules_controller.rb +++ b/app/controllers/user_my_modules_controller.rb @@ -11,9 +11,7 @@ class UserMyModulesController < ApplicationController @user_my_modules = @my_module.user_my_modules render json: { - html: render_to_string( - partial: 'designated_users' - ), + html: render_to_string(partial: 'designated_users', formats: :html), my_module_id: @my_module.id, counter: @my_module.designated_users.count # Used for counter badge } @@ -21,7 +19,7 @@ class UserMyModulesController < ApplicationController def index render json: { - html: render_to_string(partial: 'index') + html: render_to_string(partial: 'index', formats: :html) } end @@ -33,7 +31,7 @@ class UserMyModulesController < ApplicationController render json: { my_module: @my_module, html: render_to_string( - partial: 'index_edit' + partial: 'index_edit', formats: :html ) } end @@ -48,7 +46,8 @@ class UserMyModulesController < ApplicationController if params[:table] render json: { html: render_to_string(partial: 'experiments/assigned_users', - locals: { my_module: @my_module, user: current_user, skip_unassigned: false }), + locals: { my_module: @my_module, user: current_user, skip_unassigned: false }, + formats: :html), unassign_url: my_module_user_my_module_path(@my_module, @um) } else @@ -75,7 +74,8 @@ class UserMyModulesController < ApplicationController if params[:table] render json: { html: render_to_string(partial: 'experiments/assigned_users', - locals: { my_module: @my_module, user: current_user, skip_unassigned: false }) + locals: { my_module: @my_module, user: current_user, skip_unassigned: false }, + formats: :html) } else render json: {} diff --git a/app/controllers/users/invitations_controller.rb b/app/controllers/users/invitations_controller.rb index b5321b2f3..232869234 100644 --- a/app/controllers/users/invitations_controller.rb +++ b/app/controllers/users/invitations_controller.rb @@ -137,7 +137,7 @@ module Users end render json: { - html: render_to_string(partial: 'shared/invite_users_modal_results') + html: render_to_string(partial: 'shared/invite_users_modal_results', formats: :html) } end diff --git a/app/controllers/users/settings/teams_controller.rb b/app/controllers/users/settings/teams_controller.rb index ea85b6232..c798d8cf2 100644 --- a/app/controllers/users/settings/teams_controller.rb +++ b/app/controllers/users/settings/teams_controller.rb @@ -77,7 +77,8 @@ module Users render json: { html: render_to_string( partial: 'users/settings/teams/name_modal_body', - locals: { team: @team } + locals: { team: @team }, + formats: :html ) } end @@ -86,7 +87,8 @@ module Users render json: { html: render_to_string( partial: 'users/settings/teams/description_modal_body', - locals: { team: @team } + locals: { team: @team }, + formats: :html ) } end diff --git a/app/controllers/users/settings/user_teams_controller.rb b/app/controllers/users/settings/user_teams_controller.rb index de13e6efd..171602c11 100644 --- a/app/controllers/users/settings/user_teams_controller.rb +++ b/app/controllers/users/settings/user_teams_controller.rb @@ -40,7 +40,8 @@ module Users render json: { html: render_to_string( partial: 'users/settings/user_teams/leave_user_team_modal_body', - locals: { user_assignment: @user_assignment } + locals: { user_assignment: @user_assignment }, + formats: :html ), heading: I18n.t( 'users.settings.user_teams.leave_uo_heading', @@ -54,7 +55,8 @@ module Users html: render_to_string( partial: 'users/settings/user_teams/' \ 'destroy_user_team_modal_body', - locals: { user_assignment: @user_assignment } + locals: { user_assignment: @user_assignment }, + formats: :html ), heading: I18n.t( 'users.settings.user_teams.destroy_uo_heading', diff --git a/app/datatables/protocol_linked_children_datatable.rb b/app/datatables/protocol_linked_children_datatable.rb index d1b980717..4459eda06 100644 --- a/app/datatables/protocol_linked_children_datatable.rb +++ b/app/datatables/protocol_linked_children_datatable.rb @@ -60,19 +60,22 @@ class ProtocolLinkedChildrenDatatable < CustomDatatable res += "