diff --git a/app/components/open_project/common/attribute_component.rb b/app/components/open_project/common/attribute_component.rb index e675f3b1c662..6690f494622b 100644 --- a/app/components/open_project/common/attribute_component.rb +++ b/app/components/open_project/common/attribute_component.rb @@ -30,7 +30,6 @@ module OpenProject module Common class AttributeComponent < Primer::Component - def initialize(id, name, description, **args) super @id = id diff --git a/app/components/projects/row_component.rb b/app/components/projects/row_component.rb index 5219058453ae..8e2b41fbb2bb 100644 --- a/app/components/projects/row_component.rb +++ b/app/components/projects/row_component.rb @@ -112,14 +112,19 @@ def status_explanation return nil unless user_can_view_project? if project.status_explanation.present? && project.status_explanation - render OpenProject::Common::AttributeComponent.new("dialog-#{project.id}-status-explanation", I18n.t('activerecord.attributes.project.status_explanation'), project.status_explanation) + render OpenProject::Common::AttributeComponent.new("dialog-#{project.id}-status-explanation", + I18n.t('activerecord.attributes.project.status_explanation'), + project.status_explanation) end end def description return nil unless user_can_view_project? + if project.description.present? - render OpenProject::Common::AttributeComponent.new("dialog-#{project.id}-description", I18n.t('activerecord.attributes.project.description'), project.description) + render OpenProject::Common::AttributeComponent.new("dialog-#{project.id}-description", + I18n.t('activerecord.attributes.project.description'), + project.description) end end diff --git a/app/helpers/toolbar_helper.rb b/app/helpers/toolbar_helper.rb index 4d4870a50e45..f5642ab5f45f 100644 --- a/app/helpers/toolbar_helper.rb +++ b/app/helpers/toolbar_helper.rb @@ -26,8 +26,8 @@ def editable_toolbar(form:, field_name:, html: {}) end end - def breadcrumb_toolbar(*elements, subtitle: '', html: {}, &block) - toolbar(title: safe_join(elements, ' » '.html_safe), subtitle:, html:, &block) + def breadcrumb_toolbar(*elements, subtitle: '', html: {}, &) + toolbar(title: safe_join(elements, ' » '.html_safe), subtitle:, html:, &) end protected diff --git a/app/models/journable/historic_active_record_relation.rb b/app/models/journable/historic_active_record_relation.rb index 853a07e84878..885ec86d163a 100644 --- a/app/models/journable/historic_active_record_relation.rb +++ b/app/models/journable/historic_active_record_relation.rb @@ -258,7 +258,7 @@ def journals_join_statement # The `created_at` column is not present in the `work_package_journals` table. # def add_join_on_journables_table_with_created_at_column(relation) - relation \ + relation .joins("INNER JOIN (SELECT id, created_at " \ "FROM \"#{model.table_name}\") AS journables " \ "ON \"journables\".\"id\" = \"journals\".\"journable_id\"") @@ -319,7 +319,7 @@ def column_select_definitions "journals.updated_at as updated_at", "CASE #{timestamp_case_when_statements} END as timestamp", "journals.id as journal_id" - ] + \ + ] + model.column_names_missing_in_journal.collect do |missing_column_name| "null as #{missing_column_name}" end diff --git a/app/services/base_services/base_contracted.rb b/app/services/base_services/base_contracted.rb index 074f16f1a9c3..2799c059d053 100644 --- a/app/services/base_services/base_contracted.rb +++ b/app/services/base_services/base_contracted.rb @@ -50,8 +50,8 @@ def initialize(user:, contract_class: nil, contract_options: {}) # Determine the type of context # this service is running in # e.g., within a resource lock or just executing as the given user - def service_context(send_notifications:, &block) - in_context(model, send_notifications:, &block) + def service_context(send_notifications:, &) + in_context(model, send_notifications:, &) end def perform(params = {}) diff --git a/app/services/base_services/create.rb b/app/services/base_services/create.rb index c0457ca01fef..c01dc2b045c5 100644 --- a/app/services/base_services/create.rb +++ b/app/services/base_services/create.rb @@ -30,8 +30,8 @@ module BaseServices class Create < Write protected - def service_context(send_notifications:, &block) - in_user_context(send_notifications:, &block) + def service_context(send_notifications:, &) + in_user_context(send_notifications:, &) end def instance(_params) diff --git a/app/services/custom_actions/base_service.rb b/app/services/custom_actions/base_service.rb index b8d7faff4a83..51a7eaa76f06 100644 --- a/app/services/custom_actions/base_service.rb +++ b/app/services/custom_actions/base_service.rb @@ -33,7 +33,7 @@ class CustomActions::BaseService def call(attributes:, action:, - &block) + &) set_attributes(action, attributes) contract = CustomActions::CuContract.new(action) @@ -41,7 +41,7 @@ def call(attributes:, result: action, errors: contract.errors) - block_with_result(result, &block) + block_with_result(result, &) end private diff --git a/app/services/custom_actions/update_work_package_service.rb b/app/services/custom_actions/update_work_package_service.rb index 010e1399d0fe..c7d6d9ee0a54 100644 --- a/app/services/custom_actions/update_work_package_service.rb +++ b/app/services/custom_actions/update_work_package_service.rb @@ -39,7 +39,7 @@ def initialize(action:, user:) self.contract_class = ::WorkPackages::UpdateContract end - def call(work_package:, &block) + def call(work_package:, &) apply_actions(work_package, action.actions) result = ::WorkPackages::UpdateService @@ -47,7 +47,7 @@ def call(work_package:, &block) model: work_package) .call - block_with_result(result, &block) + block_with_result(result, &) end private diff --git a/app/services/work_packages/copy_service.rb b/app/services/work_packages/copy_service.rb index 6f2f0e0616bb..3b8fd7f50dca 100644 --- a/app/services/work_packages/copy_service.rb +++ b/app/services/work_packages/copy_service.rb @@ -107,9 +107,9 @@ def copy_watchers(copied) def copy_work_package_attachments(copy) copy_attachments( 'WorkPackage', - from: work_package, - to: copy, - references: %i[description] - ) + from: work_package, + to: copy, + references: %i[description] + ) end end diff --git a/config/initializers/friendly_id.rb b/config/initializers/friendly_id.rb index 8df30a2c3d9e..1fb50fcb20a4 100644 --- a/config/initializers/friendly_id.rb +++ b/config/initializers/friendly_id.rb @@ -90,9 +90,9 @@ # Work around for issue norman/friendly_id#959 module FriendlyIdPatch def to_param - if friendly_id_config.routes == :friendly \ - && errors.key?(friendly_id_config.query_field) \ - && attribute_changed?(friendly_id_config.query_field) + if friendly_id_config.routes == :friendly && + errors.key?(friendly_id_config.query_field) && + attribute_changed?(friendly_id_config.query_field) diff = changes[friendly_id_config.query_field] diff.first || diff.second else diff --git a/lib/api/root_api.rb b/lib/api/root_api.rb index 7d11031b367e..569e0483c335 100644 --- a/lib/api/root_api.rb +++ b/lib/api/root_api.rb @@ -150,13 +150,13 @@ def authorize_by_with_raise(callable) # @param project [Project] the project the permission needs to be checked on # # @raise [API::Errors::Unauthorized] when permission is not met - def authorize_in_project(permission_or_permissions, project:, user: current_user, &block) + def authorize_in_project(permission_or_permissions, project:, user: current_user, &) permissions = Array.wrap(permission_or_permissions) authorized = permissions.any? do |permission| user.allowed_in_project?(permission, project) end - authorize_by_with_raise(authorized, &block) + authorize_by_with_raise(authorized, &) end # Checks that the current user has the given permission in any of the given projects or raise {API::Errors::Unauthorized}. @@ -168,7 +168,7 @@ def authorize_in_project(permission_or_permissions, project:, user: current_user # @param projects [[Project]] the projects the permission needs to be checked on # # @raise [API::Errors::Unauthorized] when permission is not met - def authorize_in_projects(permission_or_permissions, projects:, user: current_user, &block) + def authorize_in_projects(permission_or_permissions, projects:, user: current_user, &) raise ArgumentError if projects.blank? permissions = Array.wrap(permission_or_permissions) @@ -180,7 +180,7 @@ def authorize_in_projects(permission_or_permissions, projects:, user: current_us projects.intersect?(allowed_projects) end - authorize_by_with_raise(authorized, &block) + authorize_by_with_raise(authorized, &) end # Checks that the current user has the given permission on any project or raise {API::Errors::Unauthorized}. @@ -190,13 +190,13 @@ def authorize_in_projects(permission_or_permissions, projects:, user: current_us # those permissions, not all. # # @raise [API::Errors::Unauthorized] when permission is not met - def authorize_in_any_project(permission_or_permissions, user: current_user, &block) + def authorize_in_any_project(permission_or_permissions, user: current_user, &) permissions = Array.wrap(permission_or_permissions) authorized = permissions.any? do |permission| user.allowed_in_any_project?(permission) end - authorize_by_with_raise(authorized, &block) + authorize_by_with_raise(authorized, &) end # Checks that the current user has the given permission on any work package or project or raise {API::Errors::Unauthorized}. @@ -206,13 +206,13 @@ def authorize_in_any_project(permission_or_permissions, user: current_user, &blo # those permissions, not all. # # @raise [API::Errors::Unauthorized] when permission is not met - def authorize_in_any_work_package(permission_or_permissions, user: current_user, in_project: nil, &block) + def authorize_in_any_work_package(permission_or_permissions, user: current_user, in_project: nil, &) permissions = Array.wrap(permission_or_permissions) authorized = permissions.any? do |permission| user.allowed_in_any_work_package?(permission, in_project:) end - authorize_by_with_raise(authorized, &block) + authorize_by_with_raise(authorized, &) end # Checks that the current user has the given permission on the given work package or raise {API::Errors::Unauthorized}. @@ -224,13 +224,13 @@ def authorize_in_any_work_package(permission_or_permissions, user: current_user, # @param work_package [Project] the work package the permission needs to be checked on # # @raise [API::Errors::Unauthorized] when permission is not met - def authorize_in_work_package(permission_or_permissions, work_package:, user: current_user, &block) + def authorize_in_work_package(permission_or_permissions, work_package:, user: current_user, &) permissions = Array.wrap(permission_or_permissions) authorized = permissions.any? do |permission| user.allowed_in_work_package?(permission, work_package) end - authorize_by_with_raise(authorized, &block) + authorize_by_with_raise(authorized, &) end # Checks that the current user has the given permission globally or raise {API::Errors::Unauthorized}. @@ -240,13 +240,13 @@ def authorize_in_work_package(permission_or_permissions, work_package:, user: cu # those permissions, not all. # # @raise [API::Errors::Unauthorized] when permission is not met - def authorize_globally(permission_or_permissions, user: current_user, &block) + def authorize_globally(permission_or_permissions, user: current_user, &) permissions = Array.wrap(permission_or_permissions) authorized = permissions.any? do |permission| user.allowed_globally?(permission) end - authorize_by_with_raise(authorized, &block) + authorize_by_with_raise(authorized, &) end def authorize_admin diff --git a/modules/meeting/spec/requests/meetings_spec.rb b/modules/meeting/spec/requests/meetings_spec.rb index 1623a789ca01..21aca1fe69ce 100644 --- a/modules/meeting/spec/requests/meetings_spec.rb +++ b/modules/meeting/spec/requests/meetings_spec.rb @@ -31,7 +31,6 @@ RSpec.describe 'Meeting requests', :skip_csrf, type: :rails_request do - shared_let(:project) { create(:project, enabled_module_names: %i[meetings]) } shared_let(:user) { create(:user, member_with_permissions: { project => %i[view_meetings create_meetings] }) } diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 5df956abd3ab..ac603f200b37 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -440,7 +440,7 @@ it 'sends an email to the correct user in the correct language' do perform_enqueued_jobs mail = ActionMailer::Base.deliveries.last - refute_nil mail + expect(mail).not_to be_nil expect([registered_user.mail]).to eq(mail.to) mail.parts.each do |part| expect(part.body.encoded).to include(I18n.t(:notice_account_activated, locale: 'de')) diff --git a/spec/features/projects/projects_index_spec.rb b/spec/features/projects/projects_index_spec.rb index 0785f25889e0..58c54bd6b8a3 100644 --- a/spec/features/projects/projects_index_spec.rb +++ b/spec/features/projects/projects_index_spec.rb @@ -254,12 +254,14 @@ def expect_projects_in_order(*projects) development_project.update( description: 'I am a nice project with a very long long long long long long long long long description', status_explanation: '
I am a nice project status description with a figure
', - custom_field_values: { custom_field.id => 'This is a short value', long_text_custom_field.id => 'This is a very long long long long long long long value' } + custom_field_values: { custom_field.id => 'This is a short value', + long_text_custom_field.id => 'This is a very long long long long long long long value' } ) development_project.save! login_as(admin) - Setting.enabled_projects_columns += [custom_field.column_name, long_text_custom_field.column_name, 'description', 'status_explanation'] + Setting.enabled_projects_columns += [custom_field.column_name, long_text_custom_field.column_name, 'description', + 'status_explanation'] projects_page.visit! tr_project_development = page.first('tr', text: 'Development project') @@ -275,12 +277,15 @@ def expect_projects_in_order(*projects) expect(td_project_development_status_description).to have_css('button', text: 'Expand') expect(td_project_development_status_description).to have_text('Preview not available') - # Check if a long-text costum field which has a short text as value is not truncated and there is no Expand button there + # Check if a long-text custom field which has a short text as value is not truncated and there is no Expand button there td_project_development_short_cf = tr_project_development.first('td', text: 'This is a short value') expect(td_project_development_short_cf).to have_no_css('button', text: 'Expand') - # Check if a long-text costum field which has a long text as value is truncated and there is an Expand button there - td_project_development_long_cf = tr_project_development.first('td', text: 'This is a very long long long long long long long value') + # Check if a long-text custom field which has a long text as value is truncated and there is an Expand button there + td_project_development_long_cf = tr_project_development.first( + 'td', + text: 'This is a very long long long long long long long value' + ) expect(td_project_development_long_cf).to have_css('button', text: 'Expand') end end diff --git a/spec/features/work_packages/table/queries/version_cf_filter_spec.rb b/spec/features/work_packages/table/queries/version_cf_filter_spec.rb index fffd4600f232..939560142d79 100644 --- a/spec/features/work_packages/table/queries/version_cf_filter_spec.rb +++ b/spec/features/work_packages/table/queries/version_cf_filter_spec.rb @@ -80,7 +80,7 @@ subject: "WP 1->1, 2->2").tap do |wp| wp.custom_field_values = { version_cf1.id => [version_1.id.to_s], - version_cf2.id => [version_2.id.to_s], + version_cf2.id => [version_2.id.to_s] } wp.save! end diff --git a/spec/services/workflows/bulk_update_service_integration_spec.rb b/spec/services/workflows/bulk_update_service_integration_spec.rb index dd8a41bb98d0..19ce622fcdee 100644 --- a/spec/services/workflows/bulk_update_service_integration_spec.rb +++ b/spec/services/workflows/bulk_update_service_integration_spec.rb @@ -75,8 +75,14 @@ expect(Workflow.where(type_id: type.id, role_id: role.id).count) .to be 3 - refute_nil Workflow.where(role_id: role.id, type_id: type.id, old_status_id: status3.id, new_status_id: status2.id).first - assert_nil Workflow.where(role_id: role.id, type_id: type.id, old_status_id: status5.id, new_status_id: status4.id).first + expect(Workflow.where(role_id: role.id, + type_id: type.id, + old_status_id: status3.id, + new_status_id: status2.id).first).not_to be_nil + expect(Workflow.where(role_id: role.id, + type_id: type.id, + old_status_id: status5.id, + new_status_id: status4.id).first).to be_nil end end diff --git a/spec/support/rspec_retry.rb b/spec/support/rspec_retry.rb index 3542241c2d08..f1c6841302dc 100644 --- a/spec/support/rspec_retry.rb +++ b/spec/support/rspec_retry.rb @@ -45,7 +45,7 @@ ## # Helper to pass options to retriable while logging # failures -def retry_block(args: {}, screenshot: false, &block) +def retry_block(args: {}, screenshot: false, &) if ENV["RSPEC_RETRY_RETRY_COUNT"] == "0" yield return @@ -76,7 +76,7 @@ def retry_block(args: {}, screenshot: false, &block) end end - Retriable.retriable(on_retry: log_errors, **args, &block) + Retriable.retriable(on_retry: log_errors, **args, &) end def backtrace_up_to_spec_file(exception) diff --git a/spec/support/shared_let.rb b/spec/support/shared_let.rb index 84b7c3dbd527..07c6d164fe1a 100644 --- a/spec/support/shared_let.rb +++ b/spec/support/shared_let.rb @@ -38,8 +38,8 @@ # # Since test-prof added `let_it_be` this is only a wrapper for it # before_all / let_it_be fixture -def shared_let(key, reload: true, refind: false, &block) - let_it_be(key, reload:, refind:, &block) +def shared_let(key, reload: true, refind: false, &) + let_it_be(key, reload:, refind:, &) end # Defines an object to be used by default for all FactoryBot association @@ -55,9 +55,9 @@ def shared_let(key, reload: true, refind: false, &block) # # shared_association_default(:user) { create(:user) } # -def shared_association_default(key, factory_name: key, &block) +def shared_association_default(key, factory_name: key, &) # unique let identifier to prevent clashes - let_it_be(key, reload: true, &block) + let_it_be(key, reload: true, &) before_all do set_factory_default(factory_name, send(key))