mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
Style/ItBlockParameter: Use it block parameter.RuboCopStyle/ItBlockParameter (#19318)
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
#++
|
||||
|
||||
module Shares
|
||||
class ManageSharesComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
|
||||
class ManageSharesComponent < ApplicationComponent
|
||||
include ApplicationHelper
|
||||
include MemberHelper
|
||||
include OpPrimer::ComponentHelpers
|
||||
@@ -106,7 +106,7 @@ module Shares
|
||||
|
||||
return false if role_filter_value.nil?
|
||||
|
||||
selected_role = strategy.available_roles.find { _1[:value] == option[:value] }
|
||||
selected_role = strategy.available_roles.find { it[:value] == option[:value] }
|
||||
|
||||
selected_role[:value] == role_filter_value.to_i
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
module Users
|
||||
module Profile
|
||||
class AttributesComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
|
||||
class AttributesComponent < ApplicationComponent
|
||||
include ApplicationHelper
|
||||
include OpTurbo::Streamable
|
||||
include OpPrimer::ComponentHelpers
|
||||
@@ -40,7 +40,7 @@ module Users
|
||||
end
|
||||
|
||||
def render?
|
||||
user_is_allowed_to_see_email || @user.visible_custom_field_values.any? { _1.value.present? }
|
||||
user_is_allowed_to_see_email || @user.visible_custom_field_values.any? { it.value.present? }
|
||||
end
|
||||
|
||||
def visible_custom_fields
|
||||
|
||||
@@ -54,7 +54,7 @@ module Shares
|
||||
end
|
||||
|
||||
def role_grantable
|
||||
errors.add(:roles, :ungrantable) unless active_roles.all? { _1.is_a?(assignable_role_class) }
|
||||
errors.add(:roles, :ungrantable) unless active_roles.all? { it.is_a?(assignable_role_class) }
|
||||
end
|
||||
|
||||
def active_roles
|
||||
|
||||
@@ -126,7 +126,7 @@ class WorkPackages::MovesController < ApplicationController
|
||||
hierarchies = WorkPackageHierarchy
|
||||
.includes(:ancestor)
|
||||
.where(ancestor_id: @work_packages.select(:id))
|
||||
Type.where(id: hierarchies.map { _1.ancestor.type_id })
|
||||
Type.where(id: hierarchies.map { it.ancestor.type_id })
|
||||
.select("distinct id")
|
||||
.pluck(:id)
|
||||
.difference(@types.pluck(:id))
|
||||
|
||||
@@ -142,7 +142,7 @@ class WorkPackages::ProgressController < ApplicationController
|
||||
"remaining_hours_touched",
|
||||
"done_ratio_touched",
|
||||
"status_id_touched")
|
||||
.transform_values { _1 == "true" }
|
||||
.transform_values { it == "true" }
|
||||
.permit!
|
||||
end
|
||||
|
||||
@@ -153,7 +153,7 @@ class WorkPackages::ProgressController < ApplicationController
|
||||
end
|
||||
|
||||
def allowed_touched_params
|
||||
allowed_params.filter { touched?(_1) }
|
||||
allowed_params.filter { touched?(it) }
|
||||
end
|
||||
|
||||
def allowed_params
|
||||
|
||||
@@ -173,7 +173,7 @@ class WorkPackages::ProgressForm < ApplicationForm
|
||||
|
||||
def field_value(name)
|
||||
errors = @work_package.errors.where(name)
|
||||
if (user_value = errors.map { |error| error.options[:value] }.find { !_1.nil? })
|
||||
if (user_value = errors.map { |error| error.options[:value] }.find { !it.nil? })
|
||||
user_value
|
||||
elsif name == :done_ratio
|
||||
as_percent(@work_package.public_send(name))
|
||||
|
||||
@@ -63,7 +63,7 @@ class Members::RolesDiff
|
||||
|
||||
def user_previous_member_roles_ids
|
||||
Set.new(user_member.member_roles
|
||||
.reject { group_member.member_roles.map(&:id).include?(_1.inherited_from) }
|
||||
.reject { group_member.member_roles.map(&:id).include?(it.inherited_from) }
|
||||
.map(&:role_id).uniq)
|
||||
end
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ class Principal < ApplicationRecord
|
||||
def self.columns_for_name(formatter = nil)
|
||||
raise NotImplementedError, "Redefine in subclass" unless self == Principal
|
||||
|
||||
[User, Group, PlaceholderUser].map { _1.columns_for_name(formatter) }.inject(:|)
|
||||
[User, Group, PlaceholderUser].map { it.columns_for_name(formatter) }.inject(:|)
|
||||
end
|
||||
|
||||
# Select columns for formatting the user's name.
|
||||
|
||||
@@ -34,6 +34,6 @@ class Queries::Projects::Selects::Default < Queries::Selects::Base
|
||||
end
|
||||
|
||||
def self.all_available
|
||||
KEYS.map { new(_1) }
|
||||
KEYS.map { new(it) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,7 +45,7 @@ module Types
|
||||
end
|
||||
|
||||
def initialize(patterns:)
|
||||
transformed = patterns.transform_values { Pattern.new(**_1) }.freeze
|
||||
transformed = patterns.transform_values { Pattern.new(**it) }.freeze
|
||||
|
||||
super(patterns: transformed)
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@ class CompositeSeeder < Seeder
|
||||
seed_with(data_seeders)
|
||||
|
||||
if discovered_seeders.any?
|
||||
print_status "Loading discovered seeders: #{discovered_seeders.map { seeder_name(_1) }.join(', ')}"
|
||||
print_status "Loading discovered seeders: #{discovered_seeders.map { seeder_name(it) }.join(', ')}"
|
||||
seed_with(discovered_seeders)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,8 +65,8 @@ module Source::Translate
|
||||
|
||||
def translatable_keys(hash)
|
||||
hash.keys
|
||||
.filter { translatable?(_1) }
|
||||
.map { remove_translatable_prefix(_1) }
|
||||
.filter { translatable?(it) }
|
||||
.map { remove_translatable_prefix(it) }
|
||||
end
|
||||
|
||||
def translate_value(value, i18n_key)
|
||||
|
||||
@@ -42,7 +42,7 @@ class Journals::CreateService
|
||||
|
||||
def self.for(journable)
|
||||
ASSOCIATION_NAMES
|
||||
.map { "Journals::CreateService::#{_1}".constantize.new(journable) }
|
||||
.map { "Journals::CreateService::#{it}".constantize.new(journable) }
|
||||
.select(&:associated?)
|
||||
end
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ module Shares::Concerns::RoleAssignment
|
||||
# into account are those that have not been inherited.
|
||||
def existing_ids
|
||||
model.member_roles
|
||||
.select { _1.inherited_from.nil? }
|
||||
.select { it.inherited_from.nil? }
|
||||
.map(&:role_id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -58,7 +58,7 @@ class WorkPackages::UpdateAncestorsService < BaseServices::BaseCallable
|
||||
end
|
||||
|
||||
def ancestors(work_packages)
|
||||
work_packages.reject { initiator?(_1) }
|
||||
work_packages.reject { initiator?(it) }
|
||||
end
|
||||
|
||||
def update_current_and_former_ancestors(attributes)
|
||||
@@ -73,7 +73,7 @@ class WorkPackages::UpdateAncestorsService < BaseServices::BaseCallable
|
||||
end
|
||||
|
||||
def save_updated_work_packages(updated_work_packages)
|
||||
updated_initiators, updated_ancestors = updated_work_packages.partition { initiator?(_1) }
|
||||
updated_initiators, updated_ancestors = updated_work_packages.partition { initiator?(it) }
|
||||
|
||||
# Send notifications for initiator updates
|
||||
success = updated_initiators.all? { |wp| wp.save(validate: false) }
|
||||
|
||||
@@ -32,7 +32,7 @@ module API
|
||||
module Schemas
|
||||
class QueryFilterInstanceSchemaCollectionRepresenter < ::API::V3::Schemas::SchemaCollectionRepresenter
|
||||
def initialize(filters, ...)
|
||||
filters = filters.reject { ::Queries::Register.excluded_filters.include?(_1.class) }
|
||||
filters = filters.reject { ::Queries::Register.excluded_filters.include?(it.class) }
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
@@ -131,7 +131,7 @@ module API
|
||||
end
|
||||
|
||||
def property_supported?(property)
|
||||
ALL_SUPPORTED_PROPERTIES.any? { _1.is_a?(Regexp) ? property =~ _1 : property == _1 }
|
||||
ALL_SUPPORTED_PROPERTIES.any? { it.is_a?(Regexp) ? property =~ it : property == it }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -95,7 +95,7 @@ module OpenProject
|
||||
@mapped_permissions.select { |p| p.name == action }
|
||||
end
|
||||
|
||||
permissions.any? && permissions.all? { !_1.enabled? }
|
||||
permissions.any? && permissions.all? { !it.enabled? }
|
||||
end
|
||||
|
||||
def public_permissions
|
||||
|
||||
@@ -35,7 +35,7 @@ module Plugins
|
||||
|
||||
# fetch load paths for available plugins
|
||||
def self.plugin_load_paths
|
||||
Rails.application.config.plugins_to_test_paths.map { _1.relative_path_from(Rails.root).to_s }
|
||||
Rails.application.config.plugins_to_test_paths.map { it.relative_path_from(Rails.root).to_s }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -55,7 +55,7 @@ module BasicData
|
||||
end
|
||||
|
||||
def backlogs_configured?
|
||||
BACKLOGS_SETTINGS_KEYS.all? { configured?(_1) }
|
||||
BACKLOGS_SETTINGS_KEYS.all? { configured?(it) }
|
||||
end
|
||||
|
||||
def configured?(key)
|
||||
|
||||
@@ -62,7 +62,7 @@ module OpenProject::Bim::BcfJson
|
||||
elsif array_of_hashes?(array)
|
||||
if array_of_similar_hashes?(array)
|
||||
# array of values like [{x: 1, y: 2}, {x: -3, y: 12}, ...]
|
||||
array.map! { make_ox_hash_look_like_loaded_by_rexml(_1) }
|
||||
array.map! { make_ox_hash_look_like_loaded_by_rexml(it) }
|
||||
else
|
||||
hash = merge_hashes_together(array)
|
||||
make_ox_hash_look_like_loaded_by_rexml(hash)
|
||||
@@ -79,7 +79,7 @@ module OpenProject::Bim::BcfJson
|
||||
end
|
||||
|
||||
def array_of_hashes?(array)
|
||||
array.all? { _1.is_a?(Hash) }
|
||||
array.all? { it.is_a?(Hash) }
|
||||
end
|
||||
|
||||
def array_of_similar_hashes?(array)
|
||||
|
||||
@@ -75,7 +75,7 @@ RSpec.describe Boards::BasicBoardCreateService do
|
||||
subject
|
||||
|
||||
query_filter = queries.flat_map(&:filters).map(&:to_hash).first
|
||||
widget_filter = widgets.flat_map { _1.options["filters"] }.first
|
||||
widget_filter = widgets.flat_map { it.options["filters"] }.first
|
||||
|
||||
expect(query_filter).to have_key :manual_sort
|
||||
expect(query_filter).to eq widget_filter
|
||||
|
||||
@@ -76,7 +76,7 @@ RSpec.describe Boards::StatusBoardCreateService do
|
||||
subject
|
||||
|
||||
query_filter = queries.flat_map(&:filters).map(&:to_hash).first
|
||||
widget_filter = widgets.flat_map { _1.options["filters"] }.first
|
||||
widget_filter = widgets.flat_map { it.options["filters"] }.first
|
||||
|
||||
expect(query_filter).to match_array(widget_filter)
|
||||
end
|
||||
|
||||
@@ -80,7 +80,7 @@ RSpec.describe Boards::VersionBoardCreateService do
|
||||
|
||||
context "when there are no versions that apply for the project" do
|
||||
before do
|
||||
versions.each { _1.update!(status: "closed") }
|
||||
versions.each { it.update!(status: "closed") }
|
||||
end
|
||||
|
||||
it "sets the column_count to the default value" do
|
||||
@@ -108,7 +108,7 @@ RSpec.describe Boards::VersionBoardCreateService do
|
||||
subject
|
||||
|
||||
queries_filters = queries.flat_map(&:filters).map(&:to_hash)
|
||||
widgets_filters = widgets.flat_map { _1.options["filters"] }
|
||||
widgets_filters = widgets.flat_map { it.options["filters"] }
|
||||
|
||||
expect(queries_filters).to match_array(widgets_filters)
|
||||
end
|
||||
|
||||
+3
-3
@@ -49,13 +49,13 @@ module Storages
|
||||
def call(auth_strategy:, source_path:, destination_path:)
|
||||
with_tagged_logger do
|
||||
Authentication[auth_strategy].call(storage: @storage) do |http|
|
||||
valid_input_result = validate_inputs(source_path, destination_path).on_failure { return _1 }
|
||||
valid_input_result = validate_inputs(source_path, destination_path).on_failure { return it }
|
||||
|
||||
remote_urls = build_origin_urls(**valid_input_result.result)
|
||||
|
||||
ensure_remote_folder_does_not_exist(http, remote_urls[:destination_url]).on_failure { return _1 }
|
||||
ensure_remote_folder_does_not_exist(http, remote_urls[:destination_url]).on_failure { return it }
|
||||
|
||||
copy_folder(http, **remote_urls).on_failure { return _1 }
|
||||
copy_folder(http, **remote_urls).on_failure { return it }
|
||||
|
||||
get_folder_id(auth_strategy, valid_input_result.result[:destination_path])
|
||||
end
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ module Storages
|
||||
|
||||
def call(auth_strategy:, folder:, depth:)
|
||||
origin_user_id = Util.origin_user_id(caller: self.class, storage: @storage, auth_strategy:)
|
||||
.on_failure { return _1 }
|
||||
.on_failure { return it }
|
||||
.result
|
||||
|
||||
Authentication[auth_strategy].call(storage: @storage, http_options: headers(depth)) do |http|
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ module Storages
|
||||
info "Retrieving file information for #{file_ids.join(', ')}"
|
||||
http_options = Util.ocs_api_request.deep_merge(Util.accept_json)
|
||||
Authentication[auth_strategy].call(storage: @storage, http_options:) do |http|
|
||||
parsed_response = files_info(http, file_ids).on_failure { return _1 }.result
|
||||
parsed_response = files_info(http, file_ids).on_failure { return it }.result
|
||||
create_storage_file_infos(parsed_response)
|
||||
end
|
||||
end
|
||||
|
||||
+2
-2
@@ -42,10 +42,10 @@ module Storages
|
||||
end
|
||||
|
||||
def call(auth_strategy:, folder:)
|
||||
validate_input_data(folder).on_failure { return _1 }
|
||||
validate_input_data(folder).on_failure { return it }
|
||||
|
||||
origin_user = Util.origin_user_id(caller: self.class, storage: @storage, auth_strategy:)
|
||||
.on_failure { return _1 }
|
||||
.on_failure { return it }
|
||||
.result
|
||||
|
||||
@location_prefix = CGI.unescape UrlBuilder.path(@storage.uri.path, "remote.php/dav/files", origin_user)
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ module Storages
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def call(auth_strategy:, input_data:)
|
||||
username = Util.origin_user_id(caller: self.class, storage: @storage, auth_strategy:)
|
||||
.on_failure { return _1 }
|
||||
.on_failure { return it }
|
||||
.result
|
||||
|
||||
permissions = parse_permission_mask(input_data.user_permissions)
|
||||
@@ -66,7 +66,7 @@ module Storages
|
||||
with_tagged_logger do
|
||||
info "Getting the folder information"
|
||||
folder_info = FileInfoQuery.call(storage: @storage, auth_strategy:, file_id: input_data.file_id)
|
||||
.on_failure { return _1 }
|
||||
.on_failure { return it }
|
||||
.result
|
||||
|
||||
info "Setting permissions #{permissions.inspect} on #{folder_info.location}"
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ module Storages
|
||||
def call(auth_strategy:, folder:, depth:)
|
||||
Authentication[auth_strategy].call(storage: @storage) do |http|
|
||||
fetched_folder = fetch_folder(http, folder)
|
||||
.on_failure { return _1 }
|
||||
.on_failure { return it }
|
||||
.result
|
||||
|
||||
file_ids_dictionary = fetched_folder
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ module Storages
|
||||
def call(auth_strategy:, folder:)
|
||||
with_tagged_logger do
|
||||
info "Getting data on all files under folder '#{folder}' using #{auth_strategy.key}"
|
||||
validate_input_data(folder).on_failure { return _1 }
|
||||
validate_input_data(folder).on_failure { return it }
|
||||
|
||||
Authentication[auth_strategy].call(storage: @storage) do |http|
|
||||
response = handle_response(http.get(children_url_for(folder) + FIELDS), :value)
|
||||
|
||||
+2
-2
@@ -63,9 +63,9 @@ module Storages
|
||||
with_tagged_logger do
|
||||
Authentication[auth_strategy].call(storage: @storage) do |http|
|
||||
item = input_data.file_id
|
||||
item_exists?(http, item).on_failure { return _1 }
|
||||
item_exists?(http, item).on_failure { return it }
|
||||
|
||||
current_permissions = get_current_permissions(http, item).on_failure { return _1 }.result
|
||||
current_permissions = get_current_permissions(http, item).on_failure { return it }.result
|
||||
info "Read and write permissions found: #{current_permissions}"
|
||||
|
||||
role_to_user_map(input_data).each_pair do |role, user_ids|
|
||||
|
||||
@@ -183,7 +183,7 @@ RSpec.describe API::V3::Storages::StorageRepresenter, "rendering" do
|
||||
|
||||
expect(generated).to have_json_size(2).at_path("_links/prepareUpload")
|
||||
|
||||
project_ids = JSON.parse(generated).dig("_links", "prepareUpload").map { _1.dig("payload", "projectId") }
|
||||
project_ids = JSON.parse(generated).dig("_links", "prepareUpload").map { it.dig("payload", "projectId") }
|
||||
expect(project_ids)
|
||||
.to contain_exactly(project_linked_with_upload_permission.id, another_project_linked_with_upload_permission.id)
|
||||
end
|
||||
|
||||
@@ -41,7 +41,7 @@ RSpec.describe Storages::FileLinks::CopyFileLinksService, :webmock do
|
||||
let(:source_wp) { create_list(:work_package, 5, project: source_storage.project) }
|
||||
let(:target_wp) { create_list(:work_package, 5, project: target_storage.project) }
|
||||
|
||||
let(:source_links) { source_wp.map { create(:file_link, container: _1, storage: source) } }
|
||||
let(:source_links) { source_wp.map { create(:file_link, container: it, storage: source) } }
|
||||
|
||||
# Caller is sending the ids as strings as they need to be serialized for the calling job.
|
||||
let(:wp_map) { source_wp.map(&:id).zip(target_wp.map(&:id)).to_h.stringify_keys }
|
||||
|
||||
+1
-1
@@ -355,7 +355,7 @@ RSpec.describe Storages::OneDriveManagedFolderCreateService, :webmock do
|
||||
.value!
|
||||
Storages::Peripherals::Registry.resolve("one_drive.commands.set_permissions")
|
||||
.call(storage:, auth_strategy:, input_data:)
|
||||
.on_failure { p _1.inspect }
|
||||
.on_failure { p it.inspect }
|
||||
end
|
||||
|
||||
def delete_created_folders
|
||||
|
||||
@@ -106,7 +106,7 @@ class CldrTranslations
|
||||
end
|
||||
|
||||
def available_locales
|
||||
@available_locales ||= Set.new(Cldr::Export::Data.locales.map { _1.tr("_", "-") })
|
||||
@available_locales ||= Set.new(Cldr::Export::Data.locales.map { it.tr("_", "-") })
|
||||
end
|
||||
|
||||
def ensure_cldr_database_is_downloaded
|
||||
|
||||
@@ -59,7 +59,7 @@ class GenerateSeederSourceTranslationFiles
|
||||
|
||||
def call
|
||||
Source::SeedFile.all
|
||||
.group_by { _1.path.dirname }
|
||||
.group_by { it.path.dirname }
|
||||
.each do |dir, seed_files|
|
||||
create_crowdin_source_file(dir, seed_files)
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ RSpec.describe ErrorMessageHelper do
|
||||
let(:description) { error_flash[:description] }
|
||||
|
||||
def escape_html(array)
|
||||
array.map { CGI.escapeHTML _1 }
|
||||
array.map { CGI.escapeHTML it }
|
||||
end
|
||||
|
||||
before do
|
||||
|
||||
@@ -243,7 +243,7 @@ RSpec.describe OpenProject::AccessControl do
|
||||
|
||||
subject(:dependencies) do
|
||||
described_class.modules
|
||||
.find { _1[:name] == :dependent_module }[:dependencies]
|
||||
.find { it[:name] == :dependent_module }[:dependencies]
|
||||
end
|
||||
|
||||
it "can store specified dependencies" do
|
||||
@@ -481,7 +481,7 @@ RSpec.describe OpenProject::AccessControl do
|
||||
permissible_on: :project
|
||||
end
|
||||
end
|
||||
permission_to_disable = described_class.permissions.find { _1.name == :disabled_permission }
|
||||
permission_to_disable = described_class.permissions.find { it.name == :disabled_permission }
|
||||
permission_to_disable.disable!
|
||||
end
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ RSpec.describe Projects::Menu do
|
||||
end
|
||||
|
||||
describe "queries order" do
|
||||
subject(:titles) { menu_items.map { _1.children.map(&:title) } }
|
||||
subject(:titles) { menu_items.map { it.children.map(&:title) } }
|
||||
|
||||
shared_let(:another_current_user_query) do
|
||||
ProjectQuery.create!(name: "Another current user query", user: current_user)
|
||||
|
||||
@@ -37,8 +37,8 @@ RSpec.describe AddValidityPeriodToJournals, type: :model do
|
||||
ActiveRecord::Migration.suppress_messages do
|
||||
described_class
|
||||
.new
|
||||
.tap { _1.migrate(:down) }
|
||||
.tap { _1.migrate(:up) }
|
||||
.tap { it.migrate(:down) }
|
||||
.tap { it.migrate(:up) }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ RSpec.describe RemoveProjectDetailsWidget, type: :model do
|
||||
ActiveRecord::Migration.suppress_messages do
|
||||
described_class
|
||||
.new
|
||||
.tap { _1.migrate(:up) }
|
||||
.tap { it.migrate(:up) }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ RSpec.describe CustomAction do
|
||||
expect do
|
||||
stubbed_instance
|
||||
.all_actions
|
||||
.select { _1.type == :associated_property }
|
||||
.select { it.type == :associated_property }
|
||||
.each(&:allowed_values)
|
||||
end.not_to raise_error
|
||||
end
|
||||
|
||||
@@ -171,7 +171,7 @@ RSpec.describe ProjectQuery, "order using CustomFieldOrder" do
|
||||
|
||||
context "for list format" do
|
||||
let(:possible_values) { %w[100 3 20] }
|
||||
let(:id_by_value) { custom_field.possible_values.to_h { [_1.value, _1.id] } }
|
||||
let(:id_by_value) { custom_field.possible_values.to_h { [it.value, it.id] } }
|
||||
|
||||
context "if not allowing multi select" do
|
||||
include_examples "it sorts" do
|
||||
@@ -183,7 +183,7 @@ RSpec.describe ProjectQuery, "order using CustomFieldOrder" do
|
||||
# sorting is done by position, and not by value
|
||||
project_with_cf_value(id_by_value.fetch("100")),
|
||||
project_with_cf_value(id_by_value.fetch("3")),
|
||||
project_with_cf_value(id_by_value.fetch("20")),
|
||||
project_with_cf_value(id_by_value.fetch("20"))
|
||||
]
|
||||
end
|
||||
end
|
||||
@@ -207,7 +207,7 @@ RSpec.describe ProjectQuery, "order using CustomFieldOrder" do
|
||||
project_with_cf_value(*id_by_value.fetch_values("20", "100")), # 100, 20
|
||||
project_with_cf_value(*id_by_value.fetch_values("3")), # 3
|
||||
project_with_cf_value(*id_by_value.fetch_values("3", "20")), # 3, 20
|
||||
project_with_cf_value(*id_by_value.fetch_values("20")), # 20
|
||||
project_with_cf_value(*id_by_value.fetch_values("20")) # 20
|
||||
]
|
||||
end
|
||||
|
||||
@@ -230,7 +230,7 @@ RSpec.describe ProjectQuery, "order using CustomFieldOrder" do
|
||||
create(:user, lastname: "A", firstname: "X", login: "ax", mail: "ax@o.p")
|
||||
]
|
||||
end
|
||||
shared_let(:id_by_login) { users.to_h { [_1.login, _1.id] } }
|
||||
shared_let(:id_by_login) { users.to_h { [it.login, it.id] } }
|
||||
|
||||
shared_let(:role) { create(:project_role) }
|
||||
|
||||
@@ -254,7 +254,7 @@ RSpec.describe ProjectQuery, "order using CustomFieldOrder" do
|
||||
id_by_login.fetch("ax"),
|
||||
id_by_login.fetch("ba"),
|
||||
id_by_login.fetch("bb1"),
|
||||
id_by_login.fetch("bb2"),
|
||||
id_by_login.fetch("bb2")
|
||||
]
|
||||
end
|
||||
|
||||
@@ -280,7 +280,7 @@ RSpec.describe ProjectQuery, "order using CustomFieldOrder" do
|
||||
id_by_login.fetch_values("ax", "bb1"), # ax, bb1
|
||||
id_by_login.fetch_values("ba"), # ba
|
||||
id_by_login.fetch_values("bb1", "ba"), # ba, bb1
|
||||
id_by_login.fetch_values("ba", "bb2"), # ba, bb2
|
||||
id_by_login.fetch_values("ba", "bb2") # ba, bb2
|
||||
]
|
||||
end
|
||||
|
||||
@@ -310,7 +310,7 @@ RSpec.describe ProjectQuery, "order using CustomFieldOrder" do
|
||||
create(:version, project:, sharing: "system", name: "9")
|
||||
]
|
||||
end
|
||||
let(:id_by_name) { versions.to_h { [_1.name, _1.id] } }
|
||||
let(:id_by_name) { versions.to_h { [it.name, it.id] } }
|
||||
|
||||
context "if not allowing multi select" do
|
||||
include_examples "it sorts" do
|
||||
@@ -322,7 +322,7 @@ RSpec.describe ProjectQuery, "order using CustomFieldOrder" do
|
||||
project_with_cf_value(id_by_name.fetch("9")),
|
||||
project_with_cf_value(id_by_name.fetch("10.2")),
|
||||
project_with_cf_value(id_by_name.fetch("10.10.2")),
|
||||
project_with_cf_value(id_by_name.fetch("10.10.10")),
|
||||
project_with_cf_value(id_by_name.fetch("10.10.10"))
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -366,7 +366,7 @@ RSpec.describe ProjectQuery do
|
||||
let(:orders) { { name: :asc, project_status: :desc, "cf_#{custom_field.id}": :desc } }
|
||||
|
||||
it "leaves the values untouched" do
|
||||
expect(instance.orders.to_h { [_1.attribute, _1.direction] })
|
||||
expect(instance.orders.to_h { [it.attribute, it.direction] })
|
||||
.to eq orders
|
||||
end
|
||||
end
|
||||
@@ -375,7 +375,7 @@ RSpec.describe ProjectQuery do
|
||||
let(:orders) { { bogus: :desc, cf_1: :desc } } # rubocop:disable Naming/VariableNumber
|
||||
|
||||
it "removes the values" do
|
||||
expect(instance.orders.to_h { [_1.attribute, _1.direction] })
|
||||
expect(instance.orders.to_h { [it.attribute, it.direction] })
|
||||
.to be_empty
|
||||
end
|
||||
end
|
||||
@@ -385,7 +385,7 @@ RSpec.describe ProjectQuery do
|
||||
let(:orders) { { bogus: :desc, name: :desc, cf_0: :desc, "cf_#{custom_field.id}": :desc } } # rubocop:disable Naming/VariableNumber
|
||||
|
||||
it "removes only the offending values" do
|
||||
expect(instance.orders.to_h { [_1.attribute, _1.direction] })
|
||||
expect(instance.orders.to_h { [it.attribute, it.direction] })
|
||||
.to eq(name: :desc, "cf_#{custom_field.id}": :desc)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,11 +41,11 @@ RSpec.describe Queries::Projects::Selects::Default do
|
||||
end
|
||||
|
||||
it "doesn't match any key with prefix" do
|
||||
expect(keys.map { "x#{_1}" }).to all(not_match(described_class.key))
|
||||
expect(keys.map { "x#{it}" }).to all(not_match(described_class.key))
|
||||
end
|
||||
|
||||
it "doesn't match any key with suffix" do
|
||||
expect(keys.map { "#{_1}x" }).to all(not_match(described_class.key))
|
||||
expect(keys.map { "#{it}x" }).to all(not_match(described_class.key))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,7 +79,7 @@ RSpec.describe Token::ICal do
|
||||
# therefore a user needs to be allowed to have N ical tokens per query
|
||||
ical_token1 = described_class.create(
|
||||
user:,
|
||||
ical_token_query_assignment_attributes: { query:, name: "#{name}_1" }
|
||||
ical_token_query_assignment_attributes: { query:, name: "#{name}it" }
|
||||
)
|
||||
ical_token2 = described_class.create(
|
||||
user:,
|
||||
@@ -109,11 +109,11 @@ RSpec.describe Token::ICal do
|
||||
it "a user cannot have N ical tokens per query with the same name" do
|
||||
ical_token1 = described_class.create(
|
||||
user:,
|
||||
ical_token_query_assignment_attributes: { query:, name: "#{name}_1" }
|
||||
ical_token_query_assignment_attributes: { query:, name: "#{name}it" }
|
||||
)
|
||||
ical_token2 = described_class.create(
|
||||
user:,
|
||||
ical_token_query_assignment_attributes: { query:, name: "#{name}_1" }
|
||||
ical_token_query_assignment_attributes: { query:, name: "#{name}it" }
|
||||
)
|
||||
|
||||
expect(ical_token2.errors["ical_token_query_assignment.name"].first).to eq(
|
||||
@@ -130,7 +130,7 @@ RSpec.describe Token::ICal do
|
||||
|
||||
ical_token3 = described_class.create(
|
||||
user:,
|
||||
ical_token_query_assignment_attributes: { query: query2, name: "#{name}_1" }
|
||||
ical_token_query_assignment_attributes: { query: query2, name: "#{name}it" }
|
||||
)
|
||||
|
||||
expect(described_class.where(user_id: user.id)).to contain_exactly(
|
||||
|
||||
@@ -62,7 +62,7 @@ RSpec.shared_examples_for "API V3 collection response" do |total, count, element
|
||||
it "returns a collection successfully" do
|
||||
aggregate_failures do
|
||||
expect(last_response).to have_http_status(expected_status_code)
|
||||
errors = JSON.parse(subject).dig("_embedded", "errors")&.map { _1["message"] }
|
||||
errors = JSON.parse(subject).dig("_embedded", "errors")&.map { it["message"] }
|
||||
expect(errors).to eq([]) if errors # make errors visible in console if any
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,7 +79,7 @@ RSpec.describe BasicData::GlobalRoleSeeder do
|
||||
|
||||
it "gives all assignable permissions to the role" do
|
||||
expect(GlobalRole.find_by(name: "Project admin").permissions)
|
||||
.to match_array(Roles::CreateContract.new(GlobalRole.new, nil).assignable_permissions.map { _1.name.to_sym })
|
||||
.to match_array(Roles::CreateContract.new(GlobalRole.new, nil).assignable_permissions.map { it.name.to_sym })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -87,7 +87,7 @@ RSpec.describe BasicData::ProjectQueryRoleSeeder do
|
||||
|
||||
it "gives all assignable permissions to the role" do
|
||||
role = ProjectQueryRole.find_by(name: "All Project Query Permissions")
|
||||
expected_roles = Roles::CreateContract.new(ProjectQueryRole.new, nil).assignable_permissions.map { _1.name.to_sym }
|
||||
expected_roles = Roles::CreateContract.new(ProjectQueryRole.new, nil).assignable_permissions.map { it.name.to_sym }
|
||||
expect(role.permissions).to match_array(expected_roles)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -117,7 +117,7 @@ RSpec.describe BasicData::ProjectRoleSeeder do
|
||||
|
||||
it "gives all assignable permissions to the role" do
|
||||
expect(Role.find_by(name: "Project admin").permissions)
|
||||
.to match_array(Roles::CreateContract.new(Role.new, nil).assignable_permissions(keep_public: true).map { _1.name.to_sym })
|
||||
.to match_array(Roles::CreateContract.new(Role.new, nil).assignable_permissions(keep_public: true).map { it.name.to_sym })
|
||||
end
|
||||
|
||||
it "includes the project attributes permissions to the role" do
|
||||
|
||||
@@ -104,7 +104,7 @@ RSpec.describe BasicData::WorkPackageRoleSeeder do
|
||||
it "gives all assignable permissions to the role" do
|
||||
expect(Role.find_by(name: "Edit work package").permissions)
|
||||
.to match_array(Roles::CreateContract.new(WorkPackageRole.new, nil)
|
||||
.assignable_permissions.map { _1.name.to_sym })
|
||||
.assignable_permissions.map { it.name.to_sym })
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ RSpec.describe BasicData::SettingSeeder do
|
||||
it "does not seed settings whose default value is undefined" do
|
||||
setting_seeder.seed!
|
||||
|
||||
names_of_undefined_settings = Settings::Definition.all.values.select { _1.value == nil }.map(&:name)
|
||||
names_of_undefined_settings = Settings::Definition.all.values.select { it.value == nil }.map(&:name)
|
||||
# these ones are special as their value is set based on database ids
|
||||
names_of_undefined_settings -= ["new_project_user_role_id", "commit_fix_status_id"]
|
||||
expect(Setting.where(name: names_of_undefined_settings).pluck(:name)).to be_empty
|
||||
|
||||
@@ -116,7 +116,7 @@ RSpec.describe Members::SetAttributesService, type: :model do
|
||||
|
||||
it "adds the new role and marks the other for destruction" do
|
||||
expect(subject.result.member_roles.map(&:role_id)).to contain_exactly(first_role.id, second_role.id, third_role.id)
|
||||
expect(subject.result.member_roles.detect { _1.role_id == first_role.id }).to be_marked_for_destruction
|
||||
expect(subject.result.member_roles.detect { it.role_id == first_role.id }).to be_marked_for_destruction
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ RSpec.describe ServiceResult, type: :model do
|
||||
let(:message) { "some message" }
|
||||
|
||||
subject(:flash) do
|
||||
{}.tap { service_result.apply_flash_message!(_1) }
|
||||
{}.tap { service_result.apply_flash_message!(it) }
|
||||
end
|
||||
|
||||
context "when successful" do
|
||||
|
||||
@@ -163,7 +163,7 @@ RSpec.describe Shares::SetAttributesService, type: :model do
|
||||
|
||||
it "adds the new role and marks the other for destruction" do
|
||||
expect(subject.result.member_roles.map(&:role_id)).to contain_exactly(first_role.id, second_role.id, third_role.id)
|
||||
expect(subject.result.member_roles.detect { _1.role_id == first_role.id }).to be_marked_for_destruction
|
||||
expect(subject.result.member_roles.detect { it.role_id == first_role.id }).to be_marked_for_destruction
|
||||
end
|
||||
|
||||
context "when a role being assigned is already inherited via a group" do
|
||||
@@ -172,7 +172,7 @@ RSpec.describe Shares::SetAttributesService, type: :model do
|
||||
end
|
||||
|
||||
before do
|
||||
allow(member.member_roles.detect { _1.role_id == third_role.id })
|
||||
allow(member.member_roles.detect { it.role_id == third_role.id })
|
||||
.to receive(:inherited_from)
|
||||
.and_return(true)
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ RSpec.describe WorkPackages::ScheduleDependency::Dependency do
|
||||
def checked_dependency_for(work_package)
|
||||
dependency_for(work_package).tap do |dependency|
|
||||
if dependency.nil?
|
||||
available = schedule_dependency.dependencies.keys.map { _1.subject.inspect }.to_sentence
|
||||
available = schedule_dependency.dependencies.keys.map { it.subject.inspect }.to_sentence
|
||||
raise ArgumentError, "Unable to find dependency for work package #{work_package.subject.inspect}; " \
|
||||
"ScheduleDependency instance has dependencies for work packages #{available}"
|
||||
end
|
||||
|
||||
@@ -93,7 +93,7 @@ RSpec.shared_examples_for "update progress values" do |description:, expected_hi
|
||||
expect(work_package).to have_attributes(all_expected_attributes)
|
||||
expect(work_package).to have_attributes(set_attributes.except(*all_expected_attributes.keys))
|
||||
if expected_hints
|
||||
expected_hints = expected_hints.transform_keys { to_work_package_field(_1) }
|
||||
expected_hints = expected_hints.transform_keys { to_work_package_field(it) }
|
||||
expect(compact_progress_hints(work_package)).to eq(expected_hints)
|
||||
end
|
||||
# work package is not saved and no errors are created
|
||||
|
||||
@@ -43,7 +43,7 @@ module Components
|
||||
end
|
||||
|
||||
def wait_until_visible
|
||||
element.tap { scroll_to_element(_1) }
|
||||
element.tap { scroll_to_element(it) }
|
||||
end
|
||||
|
||||
def element
|
||||
|
||||
@@ -285,7 +285,7 @@ class ProgressEditField < EditField
|
||||
def input_aria_related_element(describedby:)
|
||||
input_element["aria-describedby"]
|
||||
.split
|
||||
.find { _1.start_with?("#{describedby}-") }
|
||||
.find { it.start_with?("#{describedby}-") }
|
||||
&.then { |id| find(id:) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
# Differ is private, so this can break at any moment
|
||||
# Example:
|
||||
# expect([1, 2, 3]).to eq_array [2, 3, 4]
|
||||
# expect(actual).to eq_array(expected) { [_1.id, _1.value] }
|
||||
# expect(actual).to eq_array(expected) { [it.id, it.value] }
|
||||
RSpec::Matchers.define :eq_array do |expected|
|
||||
match { |actual| expected == actual }
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ module Pages
|
||||
end
|
||||
|
||||
def click_row_action!(row, action)
|
||||
action_menu_button = row.find(:link_or_button) { _1.has_selector?("svg.octicon-kebab-horizontal") }
|
||||
action_menu_button = row.find(:link_or_button) { it.has_selector?("svg.octicon-kebab-horizontal") }
|
||||
|
||||
action_menu_button.click
|
||||
|
||||
|
||||
@@ -43,10 +43,10 @@ module PermissionSpecs
|
||||
def self.controller_actions
|
||||
Rails.application.routes.routes
|
||||
.map(&:defaults)
|
||||
.select { _1[:controller] == described_class.controller_path }
|
||||
.select { it[:controller] == described_class.controller_path }
|
||||
.pluck(:action)
|
||||
.uniq
|
||||
.select { described_class.action_methods.include?(_1) }
|
||||
.select { described_class.action_methods.include?(it) }
|
||||
.sort
|
||||
end
|
||||
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ RSpec.configure do |config|
|
||||
config.after(pry: true) do |example|
|
||||
if example.exception
|
||||
exception_message = example.exception.message
|
||||
backtrace_locations = example.exception.backtrace_locations.filter { _1.to_s.include? "/spec/" }
|
||||
backtrace_locations = example.exception.backtrace_locations.filter { it.to_s.include? "/spec/" }
|
||||
|
||||
puts
|
||||
puts exception_message
|
||||
|
||||
@@ -64,7 +64,7 @@ def retry_block(args: {}, screenshot: false, &)
|
||||
#{exception.class}: '#{exception.message}'
|
||||
occurred on #{exception_source_lines.first}
|
||||
backtrace:
|
||||
#{exception_source_lines.map { " #{_1}" }.join("\n")}
|
||||
#{exception_source_lines.map { " #{it}" }.join("\n")}
|
||||
ran #{try} #{'try'.pluralize(try)} in #{elapsed_time} seconds, #{next_try_message}.
|
||||
--
|
||||
MSG
|
||||
|
||||
@@ -48,7 +48,7 @@ RSpec.shared_context "with basic seed data" do |edition: "standard"|
|
||||
shared_let(:needed_seeders_keys) do
|
||||
# warning: there is one limitation: RoleSeeder will only pick 'roles' key,
|
||||
# and not 'modules_permissions' key.
|
||||
needed_seeders.map { _1.try(:seed_data_model_key) }.compact
|
||||
needed_seeders.map { it.try(:seed_data_model_key) }.compact
|
||||
end
|
||||
shared_let(:basic_seed_data) do
|
||||
Source::SeedDataLoader.get_data(edition:).only(*needed_seeders_keys)
|
||||
|
||||
@@ -69,8 +69,8 @@ module TableHelpers
|
||||
work_packages_data
|
||||
.slice(0, data[:index])
|
||||
.reverse
|
||||
.find { _1[:hierarchy_indent] < hierarchy_indent }
|
||||
.then { _1&.fetch(:identifier) }
|
||||
.find { it[:hierarchy_indent] < hierarchy_indent }
|
||||
.then { it&.fetch(:identifier) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -128,12 +128,12 @@ RSpec.describe TableHelpers::TableParser do
|
||||
end
|
||||
|
||||
it "sets the parent attribute by its identifier" do
|
||||
attributes = parsed_data.flat_map { _1[:attributes] }
|
||||
attributes = parsed_data.flat_map { it[:attributes] }
|
||||
expect(attributes.pluck(:parent)).to eq([nil, :parent, :child, :parent, :parent, :child3, nil])
|
||||
end
|
||||
|
||||
it "sets the subject attribute" do
|
||||
attributes = parsed_data.flat_map { _1[:attributes] }
|
||||
attributes = parsed_data.flat_map { it[:attributes] }
|
||||
expect(attributes.pluck(:subject))
|
||||
.to eq(["Parent", "Child", "Grand-Child", "Child 2", "Child 3", "Another child", "Root sibling"])
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user