diff --git a/.rubocop.yml b/.rubocop.yml index 42be2b6ce..9a529428a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,6 +3,8 @@ inherit_from: .rubocop_todo.yml require: - rubocop-rails - rubocop-rspec + - rubocop-capybara + - rubocop-factory_bot AllCops: NewCops: enable diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cbbec263b..7c4a47e3d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,52 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-05-26 14:15:44 UTC using RuboCop version 1.50.2. +# on 2024-01-26 16:46:38 UTC using RuboCop version 1.60.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 16 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: link_or_button, strict +Capybara/ClickLinkOrButtonStyle: + Exclude: + - 'spec/integration/balancing_spec.rb' + - 'spec/integration/home_spec.rb' + - 'spec/integration/supplier_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: DefaultSelector. +Capybara/RSpec/HaveSelector: + Exclude: + - 'spec/integration/product_distribution_example_spec.rb' + +# Offense count: 4 +Capybara/SpecificMatcher: + Exclude: + - 'spec/integration/login_spec.rb' + - 'spec/integration/session_spec.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Include, EnforcedStyle, ExplicitOnly. +# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb +# SupportedStyles: create_list, n_times +FactoryBot/CreateList: + Exclude: + - 'spec/models/ordergroup_spec.rb' + +# Offense count: 6 +# Configuration parameters: Include. +# Include: **/*_spec.rb, **/spec/**/*, **/test/**/*, **/features/support/factories/**/*.rb +FactoryBot/FactoryAssociationWithStrategy: + Exclude: + - 'spec/factories/delivery.rb' + - 'spec/factories/group_order.rb' + - 'spec/factories/invoice.rb' + - 'spec/factories/order.rb' + # Offense count: 2 # Configuration parameters: EnforcedStyle, AllowedGems, Include. # SupportedStyles: Gemfile, gems.rb, gemspec @@ -30,128 +71,6 @@ Gemspec/RequiredRubyVersion: - 'plugins/uservoice/foodsoft_uservoice.gemspec' - 'plugins/wiki/foodsoft_wiki.gemspec' -# Offense count: 12 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_argument, with_fixed_indentation -Layout/ArgumentAlignment: - Exclude: - - 'app/controllers/articles_controller.rb' - - 'app/models/ordergroup.rb' - - 'config/initializers/currency_display.rb' - - 'db/migrate/001_create_users.rb' - - 'db/migrate/002_create_groups.rb' - - 'db/migrate/008_create_orders.rb' - - 'plugins/current_orders/app/helpers/current_orders_helper.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith. -# SupportedStylesAlignWith: either, start_of_block, start_of_line -Layout/BlockAlignment: - Exclude: - - 'app/lib/foodsoft_config.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/BlockEndNewline: - Exclude: - - 'app/lib/foodsoft_config.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/ClosingParenthesisIndentation: - Exclude: - - 'app/controllers/concerns/auth.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLineAfterGuardClause: - Exclude: - - 'db/migrate/20130622095040_move_weekly_tasks.rb' - - 'db/migrate/20230106144438_add_service_name_to_active_storage_blobs.active_storage.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLinesAroundMethodBody: - Exclude: - - 'db/migrate/20230106144438_add_service_name_to_active_storage_blobs.active_storage.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'db/migrate/021_remove_table_article_prices.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstArgumentIndentation: - Exclude: - - 'app/controllers/concerns/auth.rb' - -# Offense count: 12 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/HashAlignment: - Exclude: - - 'app/controllers/admin/ordergroups_controller.rb' - - 'app/controllers/orders_controller.rb' - - 'app/documents/order_fax.rb' - - 'db/migrate/001_create_users.rb' - - 'db/migrate/002_create_groups.rb' - - 'db/migrate/008_create_orders.rb' - - 'db/migrate/20190101000000_create_active_storage_tables.active_storage.rb' - - 'spec/lib/bank_transaction_reference_spec.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: normal, indented_internal_methods -Layout/IndentationConsistency: - Exclude: - - 'db/migrate/20090120184410_road_to_version_three.rb' - - 'db/migrate/20230106144438_add_service_name_to_active_storage_blobs.active_storage.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Width, AllowedPatterns. -Layout/IndentationWidth: - Exclude: - - 'app/lib/foodsoft_config.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'app/controllers/concerns/auth.rb' - -# Offense count: 15 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowInHeredoc. -Layout/TrailingWhitespace: - Exclude: - - 'app/controllers/admin/ordergroups_controller.rb' - - 'app/controllers/articles_controller.rb' - - 'app/controllers/orders_controller.rb' - - 'app/documents/order_fax.rb' - - 'app/models/ordergroup.rb' - - 'config/initializers/currency_display.rb' - - 'db/migrate/001_create_users.rb' - - 'db/migrate/002_create_groups.rb' - - 'db/migrate/008_create_orders.rb' - - 'db/migrate/20190101000000_create_active_storage_tables.active_storage.rb' - - 'db/migrate/20230106144438_add_service_name_to_active_storage_blobs.active_storage.rb' - - 'plugins/current_orders/app/helpers/current_orders_helper.rb' - - 'spec/lib/bank_transaction_reference_spec.rb' - # Offense count: 41 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSafeAssignment. @@ -219,6 +138,11 @@ Lint/ReturnInVoidContext: Exclude: - 'app/lib/foodsoft_config.rb' +# Offense count: 1 +Lint/SelfAssignment: + Exclude: + - 'db/migrate/20181201000100_create_message_recipients.foodsoft_messages.rb' + # Offense count: 1 # Configuration parameters: IgnoreImplicitReferences. Lint/ShadowedArgument: @@ -249,6 +173,7 @@ Lint/UnderscorePrefixedVariableName: - 'app/models/order_article.rb' # Offense count: 14 +# This cop supports unsafe autocorrection (--autocorrect-all). Lint/UselessAssignment: Exclude: - 'app/controllers/admin/ordergroups_controller.rb' @@ -264,29 +189,23 @@ Lint/UselessAssignment: - 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb' - 'spec/lib/foodsoft_config_spec.rb' -# Offense count: 1 -# Configuration parameters: CheckForMethodsWithNoSideEffects. -Lint/Void: - Exclude: - - 'app/lib/foodsoft_config.rb' - -# Offense count: 161 +# Offense count: 163 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 143 -# Offense count: 13 +# Offense count: 12 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: - Max: 66 + Max: 60 # Offense count: 2 # Configuration parameters: CountBlocks. Metrics/BlockNesting: Max: 4 -# Offense count: 19 +# Offense count: 18 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: Max: 294 @@ -299,7 +218,7 @@ Metrics/CyclomaticComplexity: # Offense count: 164 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Max: 112 + Max: 115 # Offense count: 4 # Configuration parameters: CountComments, CountAsOne. @@ -331,6 +250,7 @@ Naming/BlockParameterName: - 'db/migrate/008_create_orders.rb' # Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyleForLeadingUnderscores. # SupportedStylesForLeadingUnderscores: disallowed, required, optional Naming/MemoizedInstanceVariableName: @@ -408,12 +328,6 @@ RSpec/Capybara/FeatureMethods: - 'spec/integration/session_spec.rb' - 'spec/integration/supplier_spec.rb' -# Offense count: 4 -RSpec/Capybara/SpecificMatcher: - Exclude: - - 'spec/integration/login_spec.rb' - - 'spec/integration/session_spec.rb' - # Offense count: 12 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without @@ -422,25 +336,12 @@ RSpec/ContextWording: - 'spec/models/order_article_spec.rb' - 'spec/models/supplier_spec.rb' -# Offense count: 7 -# Configuration parameters: IgnoredMetadata. -RSpec/DescribeClass: - Exclude: - - 'spec/integration/balancing_spec.rb' - - 'spec/integration/config_spec.rb' - - 'spec/integration/home_spec.rb' - - 'spec/integration/product_distribution_example_spec.rb' - - 'spec/integration/receive_spec.rb' - - 'spec/integration/session_spec.rb' - - 'spec/integration/supplier_spec.rb' - -# Offense count: 128 +# Offense count: 126 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle. # SupportedStyles: described_class, explicit RSpec/DescribedClass: Exclude: - - 'spec/integration/order_spec.rb' - 'spec/lib/bank_transaction_reference_spec.rb' - 'spec/lib/foodsoft_config_spec.rb' - 'spec/lib/foodsoft_mail_receiver_spec.rb' @@ -451,11 +352,21 @@ RSpec/DescribedClass: - 'spec/models/ordergroup_spec.rb' - 'spec/models/user_spec.rb' -# Offense count: 14 +# Offense count: 15 # This cop supports unsafe autocorrection (--autocorrect-all). RSpec/EmptyExampleGroup: Exclude: - - 'spec/requests/api/**/*_spec.rb' + - 'spec/requests/api/v1/article_categories_controller_spec.rb' + - 'spec/requests/api/v1/configs_controller_spec.rb' + - 'spec/requests/api/v1/financial_transaction_classes_controller_spec.rb' + - 'spec/requests/api/v1/financial_transaction_types_controller_spec.rb' + - 'spec/requests/api/v1/financial_transactions_controller_spec.rb' + - 'spec/requests/api/v1/navigations_controller_spec.rb' + - 'spec/requests/api/v1/order_articles_controller_spec.rb' + - 'spec/requests/api/v1/orders_controller_spec.rb' + - 'spec/requests/api/v1/user/financial_transactions_spec.rb' + - 'spec/requests/api/v1/user/group_order_articles_spec.rb' + - 'spec/requests/api/v1/user/users_spec.rb' # Offense count: 69 # Configuration parameters: CountAsOne. @@ -471,6 +382,17 @@ RSpec/FilePath: - 'spec/integration/login_spec.rb' - 'spec/lib/bank_account_information_importer_spec.rb' +# Offense count: 41 +# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns. +RSpec/IndexedLet: + Exclude: + - 'spec/controllers/finance/ordergroups_controller_spec.rb' + - 'spec/integration/balancing_spec.rb' + - 'spec/integration/receive_spec.rb' + - 'spec/models/bank_transaction_spec.rb' + - 'spec/models/order_article_spec.rb' + - 'spec/models/ordergroup_spec.rb' + # Offense count: 6 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: @@ -501,7 +423,7 @@ RSpec/MissingExampleGroupArgument: RSpec/MultipleExpectations: Max: 22 -# Offense count: 36 +# Offense count: 38 # Configuration parameters: AllowSubject. RSpec/MultipleMemoizedHelpers: Max: 15 @@ -520,6 +442,17 @@ RSpec/PredicateMatcher: - 'spec/models/article_spec.rb' - 'spec/models/user_spec.rb' +# Offense count: 7 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: not_to, be_invalid +RSpec/Rails/NegationBeValid: + Exclude: + - 'spec/models/article_spec.rb' + - 'spec/models/order_spec.rb' + - 'spec/models/supplier_spec.rb' + - 'spec/models/user_spec.rb' + # Offense count: 6 RSpec/RepeatedDescription: Exclude: @@ -533,11 +466,14 @@ RSpec/RepeatedExample: - 'spec/lib/bank_transaction_reference_spec.rb' - 'spec/lib/foodsoft_mail_receiver_spec.rb' -# Offense count: 5 -RSpec/ScatteredSetup: +# Offense count: 3 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: Exclude: - - 'spec/integration/balancing_spec.rb' + - 'spec/integration/articles_spec.rb' - 'spec/integration/login_spec.rb' + - 'spec/lib/bank_account_information_importer_spec.rb' # Offense count: 1 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. @@ -571,13 +507,31 @@ Rails/ApplicationRecord: - 'plugins/printer/app/models/printer_job.rb' - 'plugins/printer/app/models/printer_job_update.rb' -# Offense count: 35 +# Offense count: 12 +# Configuration parameters: Database, Include. +# SupportedDatabases: mysql, postgresql +# Include: db/**/*.rb +Rails/BulkChangeTable: + Exclude: + - 'db/migrate/20130624085246_remove_weekly_task_from_groups.rb' + - 'db/migrate/20130930132511_add_quantities_to_order_article.rb' + - 'db/migrate/20150227161931_add_replyto_and_groupid_to_messages.rb' + - 'db/migrate/20160217164552_add_break_to_group.rb' + - 'db/migrate/20160218151041_add_attachment_to_invoice.rb' + - 'db/migrate/20160226000000_add_email_to_message.foodsoft_messages_engine.rb' + - 'db/migrate/20160309153440_create_doorkeeper_tables.rb' + - 'db/migrate/20171201000000_add_name_short_to_financial_transaction_type.rb' + - 'db/migrate/20181201000100_create_message_recipients.foodsoft_messages.rb' + - 'db/migrate/20181201000200_add_deleted_to_financial_transaction_type.rb' + +# Offense count: 34 # Configuration parameters: Include. -# Include: db/migrate/*.rb +# Include: db/**/*.rb Rails/CreateTableWithTimestamps: Enabled: false # Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowToTime. # SupportedStyles: strict, flexible Rails/Date: @@ -597,14 +551,22 @@ Rails/Date: Rails/DynamicFindBy: Enabled: false -# Offense count: 4 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: slashes, arguments -Rails/FilePath: +# Offense count: 16 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods, AllowedPatterns. +# AllowedMethods: order, limit, select, lock +Rails/FindEach: Exclude: - - 'config/application.rb' - - 'config/initializers/secret_token.rb' - - 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb' + - 'app/lib/financial_transactions_csv.rb' + - 'app/lib/order_txt.rb' + - 'db/migrate/20090120184410_road_to_version_three.rb' + - 'db/migrate/20090731132547_add_stats_to_groups.rb' + - 'db/migrate/20130622095040_move_weekly_tasks.rb' + - 'db/migrate/20181201000100_create_message_recipients.foodsoft_messages.rb' + - 'db/migrate/20210205090257_introduce_received_state_in_orders.rb' + - 'db/migrate/20230215085312_migrate_message_body_to_action_text.rb' + - 'db/seeds/seed_helper.rb' + - 'lib/tasks/foodsoft.rake' # Offense count: 26 # Configuration parameters: Include. @@ -691,7 +653,7 @@ Rails/Output: - 'db/migrate/20090120184410_road_to_version_three.rb' - 'db/migrate/20130622095040_move_weekly_tasks.rb' -# Offense count: 28 +# Offense count: 25 Rails/OutputSafety: Exclude: - 'app/helpers/admin/configs_helper.rb' @@ -703,10 +665,12 @@ Rails/OutputSafety: - 'plugins/wiki/app/helpers/pages_helper.rb' # Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Rails/Presence: +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: conservative, aggressive +Rails/PluckInWhere: Exclude: - - 'db/migrate/021_remove_table_article_prices.rb' + - 'db/migrate/20140921104907_remove_stale_memberships.rb' # Offense count: 6 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -717,6 +681,15 @@ Rails/RakeEnvironment: - 'lib/tasks/foodsoft_setup.rake' - 'lib/tasks/resque.rake' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: ActionMailer::Preview, ActiveSupport::TimeZone +Rails/RedundantActiveRecordAllMethod: + Exclude: + - 'app/models/ordergroup.rb' + - 'db/migrate/20181201000100_create_message_recipients.foodsoft_messages.rb' + # Offense count: 14 # This cop supports unsafe autocorrection (--autocorrect-all). Rails/RedundantPresenceValidationOnBelongsTo: @@ -741,6 +714,12 @@ Rails/RootPathnameMethods: Exclude: - 'lib/tasks/foodsoft_setup.rake' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Rails/SelectMap: + Exclude: + - 'app/lib/foodsoft/expansion_variables.rb' + # Offense count: 64 # Configuration parameters: ForbiddenMethods, AllowedMethods. # ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all @@ -755,6 +734,19 @@ Rails/SquishedSQLHeredocs: - 'app/models/financial_link.rb' - 'db/migrate/20181201000305_ensure_article_for_article_price.rb' +# Offense count: 10 +# Configuration parameters: Include. +# Include: db/**/*.rb +Rails/ThreeStateBooleanColumn: + Exclude: + - 'db/migrate/014_create_tasks.rb' + - 'db/migrate/20090120184410_road_to_version_three.rb' + - 'db/migrate/20090811144901_add_weekly_to_tasks.rb' + - 'db/migrate/20120929155541_add_ignore_apple_restriction_to_groups.rb' + - 'db/migrate/20121216180646_remove_assigned_from_tasks.rb' + - 'db/migrate/20130624084223_remove_weekly_from_tasks.rb' + - 'db/migrate/20130624085246_remove_weekly_task_from_groups.rb' + # Offense count: 42 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. @@ -763,6 +755,7 @@ Rails/TimeZone: Enabled: false # Offense count: 1 +# Configuration parameters: TransactionMethods. Rails/TransactionExitStatement: Exclude: - 'app/models/bank_transaction.rb' @@ -780,7 +773,7 @@ Rails/UniqueValidationWithoutIndex: - 'app/models/user.rb' # Offense count: 2 -# Configuration parameters: Environments. +# Configuration parameters: Severity, Environments. # Environments: development, test, production Rails/UnknownEnv: Exclude: @@ -802,13 +795,6 @@ Rails/WhereExists: Exclude: - 'app/models/concerns/mark_as_deleted_with_name.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Rails/WhereNot: - Exclude: - - 'db/migrate/20140921104907_remove_stale_memberships.rb' - - 'db/migrate/20210205090257_introduce_received_state_in_orders.rb' - # Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). Security/YAMLLoad: @@ -828,20 +814,6 @@ Style/AndOr: - 'plugins/documents/app/controllers/documents_controller.rb' - 'spec/support/coverage.rb' -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces -# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object -# FunctionalMethods: let, let!, subject, watch -# AllowedMethods: lambda, proc, it -Style/BlockDelimiters: - Exclude: - - 'app/lib/foodsoft_config.rb' - - 'db/migrate/008_create_orders.rb' - - 'spec/factories/user.rb' - - 'spec/support/coverage.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowOnConstant, AllowOnSelfClass. @@ -873,7 +845,7 @@ Style/CommentedKeyword: - 'config/routes.rb' - 'db/migrate/20090120184410_road_to_version_three.rb' -# Offense count: 337 +# Offense count: 338 # Configuration parameters: AllowedConstants. Style/Documentation: Enabled: false @@ -886,19 +858,6 @@ Style/DoubleNegation: Exclude: - 'app/controllers/tasks_controller.rb' -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: compact, expanded -Style/EmptyMethod: - Exclude: - - 'db/migrate/024_add_deposit_defaults.rb' - - 'db/migrate/20090120184410_road_to_version_three.rb' - - 'db/migrate/20090907120012_add_missing_indexes.rb' - - 'db/migrate/20130702113610_update_group_order_totals.rb' - - 'db/migrate/20130718183101_migrate_user_settings.rb' - - 'db/migrate/20140318173000_delete_empty_group_order_articles.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. @@ -928,10 +887,11 @@ Style/For: # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns. # SupportedStyles: annotated, template, unannotated +# AllowedMethods: redirect Style/FormatStringToken: EnforcedStyle: unannotated -# Offense count: 511 +# Offense count: 514 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -946,14 +906,22 @@ Style/GlobalStdStream: - 'lib/tasks/foodsoft.rake' - 'lib/tasks/foodsoft_setup.rake' -# Offense count: 2 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: Exclude: - - 'db/migrate/20230106144438_add_service_name_to_active_storage_blobs.active_storage.rb' - 'plugins/wiki/app/controllers/pages_controller.rb' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: + Exclude: + - 'app/models/group_order.rb' + - 'spec/integration/config_spec.rb' + # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). Style/HashExcept: @@ -973,20 +941,6 @@ Style/HashLikeCase: - 'plugins/documents/app/controllers/documents_controller.rb' - 'plugins/wiki/app/controllers/pages_controller.rb' -# Offense count: 375 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -# SupportedShorthandSyntax: always, never, either, consistent -Style/HashSyntax: - Enabled: false - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/IfUnlessModifier: - Exclude: - - 'db/migrate/20090120184410_road_to_version_three.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods. @@ -1028,18 +982,6 @@ Style/MultilineBlockChain: - 'app/helpers/group_orders_helper.rb' - 'app/models/order.rb' -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -Style/MultilineIfModifier: - Exclude: - - 'app/controllers/admin/ordergroups_controller.rb' - - 'app/controllers/articles_controller.rb' - - 'app/controllers/orders_controller.rb' - - 'app/documents/order_fax.rb' - - 'app/lib/foodsoft_config.rb' - - 'app/models/ordergroup.rb' - - 'config/initializers/currency_display.rb' - # Offense count: 24 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. @@ -1047,20 +989,6 @@ Style/MultilineIfModifier: Style/MutableConstant: Enabled: false -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, MinBodyLength. -# SupportedStyles: skip_modifier_ifs, always -Style/Next: - Exclude: - - 'db/migrate/20130622095040_move_weekly_tasks.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns. -Style/NumericLiterals: - MinDigits: 6 - # Offense count: 60 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. @@ -1087,13 +1015,6 @@ Style/PreferredHashMethods: - 'app/helpers/admin/configs_helper.rb' - 'app/helpers/articles_helper.rb' -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -Style/RandomWithOffset: - Exclude: - - 'db/migrate/007_create_article_prices.rb' - - 'db/migrate/008_create_orders.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Methods. @@ -1108,27 +1029,30 @@ Style/RedundantFetchBlock: Exclude: - 'config/puma.rb' -# Offense count: 4 +# Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). Style/RedundantInterpolation: Exclude: - 'db/migrate/20130718183101_migrate_user_settings.rb' + - 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb' - 'spec/i18n_spec.rb' - 'spec/models/user_spec.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantParentheses: - Exclude: - - 'db/migrate/021_remove_table_article_prices.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/RedundantSort: Exclude: - 'app/models/article_category.rb' -# Offense count: 8 +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods, AllowedPatterns. +Style/ReturnNilInPredicateMethodDefinition: + Exclude: + - 'app/controllers/group_orders_controller.rb' + - 'app/models/article.rb' + +# Offense count: 9 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. # AllowedMethods: present?, blank?, presence, try, try! @@ -1137,18 +1061,12 @@ Style/SafeNavigation: - 'app/controllers/concerns/auth_api.rb' - 'app/controllers/group_order_articles_controller.rb' - 'app/models/article_category.rb' + - 'app/models/bank_account.rb' - 'app/models/financial_transaction.rb' - 'app/models/user.rb' - 'plugins/printer/app/controllers/printer_controller.rb' - 'spec/factories/order.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowAsExpressionSeparator. -Style/Semicolon: - Exclude: - - 'db/migrate/20090120184410_road_to_version_three.rb' - # Offense count: 4 # This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: @@ -1163,27 +1081,12 @@ Style/SlicingWithRange: Style/SpecialGlobalVars: EnforcedStyle: use_perl_names -# Offense count: 34 +# Offense count: 35 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. Style/StringConcatenation: Enabled: false -# Offense count: 140 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiterals: - Enabled: false - -# Offense count: 19 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: . -# SupportedStyles: percent, brackets -Style/SymbolArray: - EnforcedStyle: percent - MinSize: 5 - # Offense count: 20 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. @@ -1203,14 +1106,6 @@ Style/SymbolProc: - 'db/migrate/20090731132547_add_stats_to_groups.rb' - 'spec/factories/order.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: WordRegex. -# SupportedStyles: percent, brackets -Style/WordArray: - EnforcedStyle: percent - MinSize: 4 - # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). Style/ZeroLengthPredicate: @@ -1219,7 +1114,7 @@ Style/ZeroLengthPredicate: - 'plugins/current_orders/app/documents/multiple_orders_by_articles.rb' - 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb' -# Offense count: 282 +# Offense count: 270 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. # URISchemes: http, https diff --git a/Dockerfile b/Dockerfile index e8f6a4c00..1bf896b50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ruby:2.7 +FROM ruby:2.7.8 RUN supercronicUrl=https://github.com/aptible/supercronic/releases/download/v0.1.3/supercronic-linux-amd64 && \ supercronicBin=/usr/local/bin/supercronic && \ @@ -22,7 +22,7 @@ RUN buildDeps='libmagic-dev' && \ apt-get update && \ apt-get install --no-install-recommends -y $buildDeps && \ echo 'gem: --no-document' >> ~/.gemrc && \ - gem install bundler && \ + gem install bundler -v 2.4.22 && \ bundle config build.nokogiri "--use-system-libraries" && \ bundle install --deployment --without development test -j 4 && \ apt-get purge -y --auto-remove $buildDeps && \ diff --git a/Dockerfile-dev b/Dockerfile-dev index 37dce5f6b..be9c77cd0 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -1,4 +1,4 @@ -FROM ruby:2.7 +FROM ruby:2.7.8 # Install dependencies RUN deps='libmagic-dev chromium nodejs' && \ @@ -19,7 +19,7 @@ ENV PORT=3000 \ WORKDIR /app -RUN gem install bundler +RUN gem install bundler -v 2.4.22 RUN bundle config build.nokogiri "--use-system-libraries" EXPOSE 3000 diff --git a/Gemfile b/Gemfile index 5dc923692..781e7d852 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ # A sample Gemfile source 'https://rubygems.org' -gem 'rails', '~> 7.0', '>=7.0.4.1' +gem 'rails', '~> 7.0.8' gem 'less-rails' gem 'sassc-rails' @@ -45,13 +45,14 @@ gem 'simple-navigation', '~> 3.14.0' # 3.x for simple_navigation_bootstrap gem 'simple-navigation-bootstrap' gem 'sprockets', '< 4' gem 'twitter-bootstrap-rails', '~> 2.2.8' +gem 'uri', '= 0.10.0.2' # TODO: remove this when updated to ruby 3.x gem 'whenever', require: false # For defining cronjobs, see config/schedule.rb # At time of development 01-06-2022 mmddyyyy necessary fix for config_helper.rb form builder was not in rubygems so we pull from github, see: https://github.com/gregschmit/recurring_select/pull/152 gem 'exception_notification' gem 'gaffe' gem 'hashie', '~> 3.4.6', require: false # https://github.com/westfieldlabs/apivore/issues/114 -gem "image_processing", "~> 1.12" -gem "importmap-rails", "~> 1.1" +gem 'image_processing', '~> 1.12' +gem 'importmap-rails', '~> 1.1' gem 'midi-smtp-server' gem 'mime-types' gem 'recurring_select', git: 'https://github.com/gregschmit/recurring_select' @@ -61,7 +62,7 @@ gem 'rswag-api' gem 'rswag-ui' gem 'ruby-filemagic' gem 'spreadsheet' -gem "terser", "~> 1.1" +gem 'terser', '~> 1.1' # we use the git version of acts_as_versioned, and need to include it in this Gemfile gem 'acts_as_versioned', git: 'https://github.com/technoweenie/acts_as_versioned.git' diff --git a/Gemfile.lock b/Gemfile.lock index 7665a67f2..a026f1894 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,13 +1,11 @@ GIT remote: https://github.com/gregschmit/recurring_select - revision: 29febc4c4abdd6c30636c33a7d2daecb09973ecf + revision: a2ad1d0791db7abcda46215778a18569d3657643 specs: - recurring_select (3.0.0) - coffee-rails (>= 3.1) + recurring_select (4.0.0) ice_cube (>= 0.11) - jquery-rails (>= 3.0) - rails (>= 5.2) - sass-rails (>= 4.0) + rails (>= 6.1) + sass-rails (>= 6.0) GIT remote: https://github.com/technoweenie/acts_as_versioned.git @@ -115,9 +113,9 @@ GEM erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - active_model_serializers (0.10.13) - actionpack (>= 4.1, < 7.1) - activemodel (>= 4.1, < 7.1) + active_model_serializers (0.10.14) + actionpack (>= 4.1) + activemodel (>= 4.1) case_transform (>= 0.2) jsonapi-renderer (>= 0.1.1.beta1, < 0.3) activejob (7.0.8) @@ -142,7 +140,7 @@ GEM tzinfo (~> 2.0) acts_as_tree (2.9.1) activerecord (>= 3.0.0) - addressable (2.8.1) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) apparition (0.6.0) capybara (~> 3.13, < 4) @@ -150,22 +148,24 @@ GEM ast (2.4.2) attribute_normalizer (1.2.0) base32 (0.3.4) - better_errors (2.9.1) - coderay (>= 1.0.0) + base64 (0.2.0) + better_errors (2.10.1) erubi (>= 1.0.0) rack (>= 0.9.0) + rouge (>= 1.0.0) + bigdecimal (3.1.6) bindex (0.8.1) binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) - bootsnap (1.15.0) + bootsnap (1.17.1) msgpack (~> 1.2) - bootstrap-datepicker-rails (1.9.0.1) + bootstrap-datepicker-rails (1.10.0.1) railties (>= 3.0) builder (3.2.4) - bullet (7.0.7) + bullet (7.1.6) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) - capybara (3.38.0) + capybara (3.39.2) addressable matrix mini_mime (>= 0.1.3) @@ -178,29 +178,22 @@ GEM activesupport chronic (0.10.2) coderay (1.1.3) - coffee-rails (5.0.0) - coffee-script (>= 2.2.0) - railties (>= 5.2.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.12.2) commonjs (0.2.7) - concurrent-ruby (1.2.2) - connection_pool (2.3.0) + concurrent-ruby (1.2.3) + connection_pool (2.4.1) content_for_in_controllers (0.0.2) crass (1.0.6) daemons (1.4.1) - database_cleaner (2.0.1) - database_cleaner-active_record (~> 2.0.0) - database_cleaner-active_record (2.0.1) + database_cleaner (2.0.2) + database_cleaner-active_record (>= 2, < 3) + database_cleaner-active_record (2.1.0) activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.3.3) + date (3.3.4) date_time_attribute (0.1.2) activesupport (>= 3.0.0) - debug_inspector (1.1.0) + debug_inspector (1.2.0) deface (1.9.0) actionview (>= 5.2) nokogiri (>= 1.6) @@ -210,9 +203,9 @@ GEM diff-lcs (1.5.0) diffy (3.4.2) docile (1.4.0) - doorkeeper (5.6.6) + doorkeeper (5.6.8) railties (>= 5) - doorkeeper-i18n (5.2.6) + doorkeeper-i18n (5.2.7) doorkeeper (>= 5.2) email_reply_trimmer (0.1.13) erubi (1.12.0) @@ -220,20 +213,20 @@ GEM exception_notification (4.5.0) actionmailer (>= 5.2, < 8) activesupport (>= 5.2, < 8) - execjs (2.8.1) + execjs (2.9.1) expression_parser (0.9.0) - factory_bot (6.2.1) + factory_bot (6.4.5) activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) + factory_bot_rails (6.4.3) + factory_bot (~> 6.4) railties (>= 5.0.0) - faker (3.1.0) + faker (3.2.3) i18n (>= 1.8.11, < 2) - ffi (1.15.5) + ffi (1.16.3) gaffe (1.2.0) rails (>= 4.0.0) - globalid (1.0.1) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) haml (5.2.2) temple (>= 0.8.0) tilt @@ -242,7 +235,7 @@ GEM activesupport (>= 5.1) haml (>= 4.0.6) railties (>= 5.1) - has_scope (0.8.0) + has_scope (0.8.2) actionpack (>= 5.2) activesupport (>= 5.2) hashie (3.4.6) @@ -257,23 +250,24 @@ GEM image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) - importmap-rails (1.1.5) + importmap-rails (1.2.3) actionpack (>= 6.0.0) + activesupport (>= 6.0.0) railties (>= 6.0.0) - inherited_resources (1.13.1) - actionpack (>= 5.2, < 7.1) - has_scope (~> 0.6) - railties (>= 5.2, < 7.1) - responders (>= 2, < 4) + inherited_resources (1.14.0) + actionpack (>= 6.0) + has_scope (>= 0.6) + railties (>= 6.0) + responders (>= 2) interception (0.5) iso (0.4.0) i18n - jquery-rails (4.5.1) + jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.6.3) - json-schema (3.0.0) + json (2.7.1) + json-schema (4.1.1) addressable (>= 2.8) jsonapi-renderer (0.2.2) kaminari (1.2.2) @@ -288,17 +282,18 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) + language_server-protocol (3.17.0.3) less (2.6.0) commonjs (~> 0.2.7) less-rails (5.0.0) actionpack (>= 5.0) less (~> 2.6.0) sprockets (~> 3.0) - libv8 (3.16.14.19-x86_64-linux) - listen (3.7.1) + libv8 (3.16.14.19.1-x86_64-linux) + listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.21.3) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -319,39 +314,40 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) - midi-smtp-server (3.0.3) - mime-types (3.4.1) + midi-smtp-server (3.2.1) + mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) + mime-types-data (3.2023.1205) mini_magick (4.12.0) - mini_mime (1.1.2) - minitest (5.18.0) - mono_logger (1.1.1) - msgpack (1.6.0) + mini_mime (1.1.5) + minitest (5.21.2) + mono_logger (1.1.2) + msgpack (1.7.2) multi_json (1.15.0) mustermann (3.0.0) ruby2_keywords (~> 0.0.1) - mysql2 (0.5.4) - net-ftp (0.2.0) + mysql2 (0.5.5) + net-ftp (0.3.4) net-protocol time - net-http (0.3.2) + net-http (0.4.1) uri - net-imap (0.3.4) + net-imap (0.4.9.1) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.4.0.1) net-protocol - nio4r (2.5.9) - nokogiri (1.15.2-x86_64-linux) + nio4r (2.7.0) + nokogiri (1.15.5-x86_64-linux) racc (~> 1.4) - parallel (1.23.0) - parser (3.2.2.1) + parallel (1.24.0) + parser (3.3.0.5) ast (~> 2.4.1) + racc pdf-core (0.9.0) polyglot (0.3.5) prawn (2.4.0) @@ -359,24 +355,25 @@ GEM ttfunk (~> 1.7) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) - pry (0.14.1) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - pry-rescue (1.5.2) + pry-rescue (1.6.0) interception (>= 0.5) pry (>= 0.12.0) pry-stack_explorer (0.6.1) binding_of_caller (~> 1.0) pry (~> 0.13) - public_suffix (5.0.1) - puma (6.3.1) + public_suffix (5.0.4) + puma (6.4.2) nio4r (~> 2.0) - racc (1.7.0) - rack (2.2.7) - rack-cors (1.1.1) + racc (1.7.3) + rack (2.2.8) + rack-cors (2.0.1) rack (>= 2.0.0) - rack-protection (3.0.5) - rack + rack-protection (3.2.0) + base64 (>= 0.1.0) + rack (~> 2.2, >= 2.2.4) rack-test (2.1.0) rack (>= 1.3) rails (7.0.8) @@ -395,13 +392,14 @@ GEM railties (= 7.0.8) rails-assets-listjs (0.2.0.beta.4) railties (>= 3.1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - rails-i18n (7.0.6) + rails-i18n (7.0.8) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) rails-settings-cached (0.4.3) @@ -416,95 +414,105 @@ GEM thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.0.6) - ransack (3.2.1) + rake (13.1.0) + ransack (4.0.0) activerecord (>= 6.1.5) activesupport (>= 6.1.5) i18n rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - redis (5.0.5) - redis-client (>= 0.9.0) - redis-client (0.11.2) + redis (5.0.8) + redis-client (>= 0.17.0) + redis-client (0.19.1) connection_pool - redis-namespace (1.10.0) + redis-namespace (1.11.0) redis (>= 4) ref (2.0.0) - regexp_parser (2.8.0) - responders (3.0.1) - actionpack (>= 5.0) - railties (>= 5.0) - resque (2.4.0) + regexp_parser (2.9.0) + responders (3.1.1) + actionpack (>= 5.2) + railties (>= 5.2) + resque (2.6.0) mono_logger (~> 1.0) multi_json (~> 1.0) redis-namespace (~> 1.6) sinatra (>= 0.9.2) - rexml (3.2.5) - roo (2.9.0) + rexml (3.2.6) + roo (2.10.1) nokogiri (~> 1) rubyzip (>= 1.3.0, < 3.0.0) roo-xls (1.2.0) nokogiri roo (>= 2.0.0, < 3) spreadsheet (> 0.9.0) + rouge (4.2.0) rspec (3.12.0) rspec-core (~> 3.12.0) rspec-expectations (~> 3.12.0) rspec-mocks (~> 3.12.0) - rspec-core (3.12.0) + rspec-core (3.12.2) rspec-support (~> 3.12.0) - rspec-expectations (3.12.1) + rspec-expectations (3.12.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-mocks (3.12.1) + rspec-mocks (3.12.6) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-rails (6.0.1) + rspec-rails (6.1.1) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) - rspec-core (~> 3.11) - rspec-expectations (~> 3.11) - rspec-mocks (~> 3.11) - rspec-support (~> 3.11) + rspec-core (~> 3.12) + rspec-expectations (~> 3.12) + rspec-mocks (~> 3.12) + rspec-support (~> 3.12) rspec-rerun (1.1.0) rspec (~> 3.0) - rspec-support (3.12.0) - rswag-api (2.7.0) - railties (>= 3.1, < 7.1) - rswag-specs (2.9.0) - activesupport (>= 3.1, < 7.1) - json-schema (>= 2.2, < 4.0) - railties (>= 3.1, < 7.1) + rspec-support (3.12.1) + rswag-api (2.13.0) + activesupport (>= 3.1, < 7.2) + railties (>= 3.1, < 7.2) + rswag-specs (2.13.0) + activesupport (>= 3.1, < 7.2) + json-schema (>= 2.2, < 5.0) + railties (>= 3.1, < 7.2) rspec-core (>= 2.14) - rswag-ui (2.7.0) - actionpack (>= 3.1, < 7.1) - railties (>= 3.1, < 7.1) - rubocop (1.50.2) + rswag-ui (2.13.0) + actionpack (>= 3.1, < 7.2) + railties (>= 3.1, < 7.2) + rubocop (1.60.2) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.30.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.28.1) + rubocop-ast (1.30.0) parser (>= 3.2.1.0) - rubocop-rails (2.17.4) + rubocop-capybara (2.20.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.25.1) + rubocop (~> 1.41) + rubocop-rails (2.23.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) - rubocop-rspec (2.16.0) - rubocop (~> 1.33) + rubocop-ast (>= 1.30.0, < 2.0) + rubocop-rspec (2.26.1) + rubocop (~> 1.40) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) ruby-filemagic (0.7.3) ruby-ole (1.2.12.2) - ruby-prof (1.4.5) + ruby-prof (1.6.3) ruby-progressbar (1.13.0) - ruby-units (3.0.0) - ruby-vips (2.1.4) + ruby-units (4.0.1) + ruby-vips (2.2.0) ffi (~> 1.12) ruby2_keywords (0.0.5) rubyzip (2.3.2) @@ -524,7 +532,7 @@ GEM simple-navigation-bootstrap (1.0.2) railties (>= 3.1) simple-navigation (>= 3.7.0, < 4.0.0) - simple_form (5.1.0) + simple_form (5.3.0) actionpack (>= 5.2) activemodel (>= 5.2) simplecov (0.22.0) @@ -534,15 +542,16 @@ GEM simplecov-html (0.12.3) simplecov-lcov (0.8.0) simplecov_json_formatter (0.1.4) - sinatra (3.0.5) + sinatra (3.2.0) mustermann (~> 3.0) rack (~> 2.2, >= 2.2.4) - rack-protection (= 3.0.5) + rack-protection (= 3.2.0) tilt (~> 2.0) skinny (0.2.4) eventmachine (~> 1.0.0) thin (>= 1.5, < 1.7) - spreadsheet (1.3.0) + spreadsheet (1.3.1) + bigdecimal ruby-ole sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -555,8 +564,8 @@ GEM sqlite3-ruby (1.3.3) sqlite3 (>= 1.3.3) table_print (1.5.7) - temple (0.9.1) - terser (1.1.13) + temple (0.10.3) + terser (1.2.0) execjs (>= 0.3.0, < 3) therubyracer (0.12.3) libv8 (~> 3.16.14.15) @@ -565,11 +574,11 @@ GEM daemons (>= 1.0.9) eventmachine (>= 1.0.0) rack (>= 1.0.0) - thor (1.2.2) - tilt (2.0.11) - time (0.2.2) + thor (1.3.0) + tilt (2.3.0) + time (0.3.0) date - timeout (0.3.1) + timeout (0.4.1) ttfunk (1.7.0) twitter-bootstrap-rails (2.2.8) actionpack (>= 3.1) @@ -582,16 +591,16 @@ GEM concurrent-ruby (~> 1.0) unf (0.1.4) unf_ext - unf_ext (0.0.8.2) - unicode-display_width (2.4.2) + unf_ext (0.0.9.1) + unicode-display_width (2.5.0) uniform_notifier (1.16.0) uri (0.10.0.2) - web-console (4.2.0) + web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - websocket-driver (0.7.5) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) whenever (1.0.0) @@ -604,7 +613,7 @@ GEM twitter-text xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.8) + zeitwerk (2.6.12) PLATFORMS x86_64-linux @@ -662,7 +671,7 @@ DEPENDENCIES pry-stack_explorer puma rack-cors - rails (~> 7.0, >= 7.0.4.1) + rails (~> 7.0.8) rails-assets-listjs (= 0.2.0.beta.4) rails-i18n rails-settings-cached (= 0.4.3) @@ -698,8 +707,9 @@ DEPENDENCIES terser (~> 1.1) therubyracer twitter-bootstrap-rails (~> 2.2.8) + uri (= 0.10.0.2) web-console whenever BUNDLED WITH - 2.4.5 + 2.4.22 diff --git a/app/controllers/concerns/auth.rb b/app/controllers/concerns/auth.rb index edf6ec6f8..87c5d594a 100644 --- a/app/controllers/concerns/auth.rb +++ b/app/controllers/concerns/auth.rb @@ -61,9 +61,9 @@ def authenticate(role = 'any') when 'pickups' then current_user.role_pickups? when 'suppliers' then current_user.role_suppliers? when 'orders' then current_user.role_orders? - when 'finance_or_invoices' then (current_user.role_finance? || current_user.role_invoices?) - when 'finance_or_orders' then (current_user.role_finance? || current_user.role_orders?) - when 'pickups_or_orders' then (current_user.role_pickups? || current_user.role_orders?) + when 'finance_or_invoices' then current_user.role_finance? || current_user.role_invoices? + when 'finance_or_orders' then current_user.role_finance? || current_user.role_orders? + when 'pickups_or_orders' then current_user.role_pickups? || current_user.role_orders? when 'any' then true # no role required else false # any unknown role will always fail end diff --git a/app/controllers/group_order_articles_controller.rb b/app/controllers/group_order_articles_controller.rb index 5f58c48a2..c9273b79a 100644 --- a/app/controllers/group_order_articles_controller.rb +++ b/app/controllers/group_order_articles_controller.rb @@ -2,7 +2,7 @@ class GroupOrderArticlesController < ApplicationController before_action :authenticate_finance before_action :find_group_order_article, except: %i[new create] - layout false # We only use this controller to server js snippets, no need for layout rendering + layout false # We only use this controller to server js snippets, no need for layout rendering def new @order_article = OrderArticle.find(params[:order_article_id]) diff --git a/app/controllers/order_articles_controller.rb b/app/controllers/order_articles_controller.rb index 43a0ea145..433e07bb9 100644 --- a/app/controllers/order_articles_controller.rb +++ b/app/controllers/order_articles_controller.rb @@ -3,7 +3,7 @@ class OrderArticlesController < ApplicationController before_action :authenticate_finance_or_invoices, except: %i[new create] before_action :authenticate_finance_orders_or_pickup, except: %i[edit update destroy] - layout false # We only use this controller to serve js snippets, no need for layout rendering + layout false # We only use this controller to serve js snippets, no need for layout rendering def new @order_article = @order.order_articles.build(params[:order_article]) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8b8a5f95c..b81acd31c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -97,10 +97,10 @@ def heading_helper(model, attribute, options = {}) s = model.human_attribute_name(attribute, i18nopts) if options[:short] desc = options[:desc] - desc ||= model.human_attribute_name("#{attribute}_desc".to_sym, + desc ||= model.human_attribute_name(:"#{attribute}_desc", options.merge({ fallback: true, default: '', count: 2 })) desc.blank? && desc = s - sshort = model.human_attribute_name("#{attribute}_short".to_sym, + sshort = model.human_attribute_name(:"#{attribute}_short", options.merge({ fallback: true, default: '', count: 2 })) s = raw "#{sshort}" if sshort.present? end diff --git a/app/lib/foodsoft_config.rb b/app/lib/foodsoft_config.rb index c7dda5906..6162da765 100644 --- a/app/lib/foodsoft_config.rb +++ b/app/lib/foodsoft_config.rb @@ -146,7 +146,6 @@ def []=(key, value) # or store RailsSettings::CachedSettings["foodcoop.#{scope}.#{key}"] = value end - true end # @return [Array] Configuration keys that are set (either in +app_config.yml+ or database). diff --git a/app/models/article.rb b/app/models/article.rb index 561deaf8e..289be1664 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -189,6 +189,7 @@ def shared_article(supplier = self.supplier) # returns nil if units are eqal def convert_units(new_article = shared_article) return unless unit != new_article.unit + return false if new_article.unit.include?(',') # legacy, used by foodcoops in Germany if new_article.unit == 'KI' && unit == 'ST' # 'KI' means a box, with a different amount of items in it diff --git a/app/models/bank_account.rb b/app/models/bank_account.rb index f433b48a1..b4d8fa1ef 100644 --- a/app/models/bank_account.rb +++ b/app/models/bank_account.rb @@ -13,7 +13,7 @@ class BankAccount < ApplicationRecord # @return [Function] Method wich can be called to import transaction from a bank or nil if unsupported def find_connector klass = BankAccountConnector.find iban - return klass.new self if klass + klass.new self if klass end def assign_unlinked_transactions diff --git a/app/models/ordergroup.rb b/app/models/ordergroup.rb index 6770fc554..d9a0d80aa 100644 --- a/app/models/ordergroup.rb +++ b/app/models/ordergroup.rb @@ -27,7 +27,7 @@ def contact end def non_members - User.natural_order.all.reject { |u| (users.include?(u) || u.ordergroup) } + User.natural_order.all.reject { |u| users.include?(u) || u.ordergroup } end def self.include_transaction_class_sum diff --git a/config/application.rb b/config/application.rb index 696d66477..7905cdfd1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -28,8 +28,8 @@ class Application < Rails::Application # config.time_zone = 'Central Time (US & Canada)' # Internationalization. - config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*.yml')] - config.i18n.available_locales = Pathname.glob(Rails.root.join('config', 'locales', '{??,???}{-*,}.yml')).map do |p| + config.i18n.load_path += Dir[Rails.root.join('config/locales/*.yml')] + config.i18n.available_locales = Pathname.glob(Rails.root.join('config/locales/{??,???}{-*,}.yml')).map do |p| p.basename('.yml').to_s end config.i18n.default_locale = :en diff --git a/config/importmap.rb b/config/importmap.rb index 3ba2318b4..ad3122044 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -1,5 +1,5 @@ # Pin npm packages by running ./bin/importmap -pin "application", preload: true -pin "trix" -pin "@rails/actiontext", to: "actiontext.js" -pin "trix-editor-overrides" +pin 'application', preload: true +pin 'trix' +pin '@rails/actiontext', to: 'actiontext.js' +pin 'trix-editor-overrides' diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb index fe62df4ae..142c48497 100644 --- a/config/initializers/secret_token.rb +++ b/config/initializers/secret_token.rb @@ -12,7 +12,7 @@ elsif Rails.env.test? SecureRandom.hex(30) # doesn't really matter else - sf = Rails.root.join('tmp', 'secret_key_base') + sf = Rails.root.join('tmp/secret_key_base') if File.exist?(sf) File.read(sf) else diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb index b0447b7eb..0d1241eef 100644 --- a/config/initializers/time_formats.rb +++ b/config/initializers/time_formats.rb @@ -1 +1 @@ -Time::DATE_FORMATS[:foodsoft_datetime] = "%d.%m.%Y %H:%M" +Time::DATE_FORMATS[:foodsoft_datetime] = '%d.%m.%Y %H:%M' diff --git a/config/navigation.rb b/config/navigation.rb index f483989fa..360f831ca 100644 --- a/config/navigation.rb +++ b/config/navigation.rb @@ -12,7 +12,9 @@ primary.item :dashboard_nav_item, I18n.t('navigation.dashboard'), root_path(anchor: '') primary.item :foodcoop, I18n.t('navigation.foodcoop'), '#' do |subnav| - subnav.item :members, I18n.t('navigation.members'), foodcoop_users_path, unless: proc { FoodsoftConfig[:disable_members_overview] } + subnav.item :members, I18n.t('navigation.members'), foodcoop_users_path, unless: proc { + FoodsoftConfig[:disable_members_overview] + } subnav.item :workgroups, I18n.t('navigation.workgroups'), foodcoop_workgroups_path subnav.item :ordergroups, I18n.t('navigation.ordergroups'), foodcoop_ordergroups_path subnav.item :tasks, I18n.t('navigation.tasks'), tasks_path diff --git a/db/migrate/20090120184410_road_to_version_three.rb b/db/migrate/20090120184410_road_to_version_three.rb index d271aee3c..51d5766e5 100644 --- a/db/migrate/20090120184410_road_to_version_three.rb +++ b/db/migrate/20090120184410_road_to_version_three.rb @@ -46,7 +46,10 @@ def self.up add_column :groups, :contact_address, :string Ordergroup.all.each do |ordergroup| contact = ordergroup.users.first - ordergroup.update(contact_person: contact.name, contact_phone: contact.phone, contact_address: contact.address) if contact + if contact + ordergroup.update(contact_person: contact.name, contact_phone: contact.phone, + contact_address: contact.address) + end end remove_column :users, :address diff --git a/db/migrate/20230209105256_create_action_text_tables.action_text.rb b/db/migrate/20230209105256_create_action_text_tables.action_text.rb index e9c30fac5..b5fe6038d 100644 --- a/db/migrate/20230209105256_create_action_text_tables.action_text.rb +++ b/db/migrate/20230209105256_create_action_text_tables.action_text.rb @@ -11,7 +11,7 @@ def change t.timestamps - t.index [:record_type, :record_id, :name], name: "index_action_text_rich_texts_uniqueness", unique: true + t.index %i[record_type record_id name], name: 'index_action_text_rich_texts_uniqueness', unique: true end end diff --git a/db/migrate/20230215085312_migrate_message_body_to_action_text.rb b/db/migrate/20230215085312_migrate_message_body_to_action_text.rb index 37f8a69ca..3c829c6ba 100644 --- a/db/migrate/20230215085312_migrate_message_body_to_action_text.rb +++ b/db/migrate/20230215085312_migrate_message_body_to_action_text.rb @@ -16,7 +16,7 @@ def change remove_column :messages, :body_old, :text end dir.down do - execute "ALTER TABLE `messages` ADD `body_old` text" + execute 'ALTER TABLE `messages` ADD `body_old` text' execute "UPDATE `messages` m INNER JOIN `action_text_rich_texts` a ON m.id = a.record_id @@ -25,7 +25,7 @@ def change message.update(body_old: strip_tags(message.body_old)) end execute "DELETE FROM `action_text_rich_texts` WHERE `action_text_rich_texts`.`record_type` = 'Message'" - execute "ALTER TABLE `messages` CHANGE `body_old` `body` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL;" + execute 'ALTER TABLE `messages` CHANGE `body_old` `body` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL;' end end end diff --git a/lib/tasks/foodsoft.rake b/lib/tasks/foodsoft.rake index caa54a1ab..872c7d6d0 100644 --- a/lib/tasks/foodsoft.rake +++ b/lib/tasks/foodsoft.rake @@ -84,7 +84,8 @@ namespace :foodsoft do # rubocop:disable Metrics/BlockLength task prune_old_attachments: :environment do if FoodsoftConfig[:attachment_retention_days] rake_say "Pruning attachments older than #{FoodsoftConfig[:attachment_retention_days]} days" - ActiveStorage::Attachment.where("created_at < ?", FoodsoftConfig[:attachment_retention_days].days.ago).each do |attachment| + ActiveStorage::Attachment.where('created_at < ?', + FoodsoftConfig[:attachment_retention_days].days.ago).each do |attachment| rake_say attachment.inspect attachment.purge_later end diff --git a/plugins/current_orders/app/documents/multiple_orders_by_articles.rb b/plugins/current_orders/app/documents/multiple_orders_by_articles.rb index 95b2e3b63..9ea55020d 100644 --- a/plugins/current_orders/app/documents/multiple_orders_by_articles.rb +++ b/plugins/current_orders/app/documents/multiple_orders_by_articles.rb @@ -69,7 +69,7 @@ def body protected def pdf_add_page_breaks? - super 'order_by_articles' + super('order_by_articles') end def order_articles diff --git a/plugins/current_orders/app/documents/multiple_orders_by_groups.rb b/plugins/current_orders/app/documents/multiple_orders_by_groups.rb index a09ef1d49..9c4bdf535 100644 --- a/plugins/current_orders/app/documents/multiple_orders_by_groups.rb +++ b/plugins/current_orders/app/documents/multiple_orders_by_groups.rb @@ -56,7 +56,7 @@ def body I18n.t('shared.articles.ordered'), I18n.t('shared.articles.received'), I18n.t('shared.articles_by.price_sum'), - { image: "#{Rails.root}/app/assets/images/package-bg.png", scale: 0.6, position: :center } + { image: "#{Rails.root.join('app/assets/images/package-bg.png')}", scale: 0.6, position: :center } ] # last column showing unit_quantity is useless if they're all one @@ -100,7 +100,7 @@ def body protected def pdf_add_page_breaks? - super 'order_by_groups' + super('order_by_groups') end def ordergroups diff --git a/plugins/messages/app/controllers/messages_controller.rb b/plugins/messages/app/controllers/messages_controller.rb index aadaad774..8206ec1d6 100644 --- a/plugins/messages/app/controllers/messages_controller.rb +++ b/plugins/messages/app/controllers/messages_controller.rb @@ -21,8 +21,9 @@ def new @message.subject = I18n.t('messages.model.reply_subject', subject: original_message.subject) @message.body = I18n.t('messages.model.reply_header', user: original_message.sender.display, when: I18n.l(original_message.created_at, format: :short)) + "\n" - @message.body = I18n.t('messages.model.reply_header', user: original_message.sender.display, when: I18n.l(original_message.created_at, format: :short)) + "\n" \ - + "
" + original_message.body.to_trix_html + "
" + @message.body = I18n.t('messages.model.reply_header', user: original_message.sender.display, + when: I18n.l(original_message.created_at, format: :short)) + "\n" \ + + '
' + original_message.body.to_trix_html + '
' else redirect_to new_message_url, alert: I18n.t('messages.new.error_private') end diff --git a/plugins/messages/app/mail_receivers/messages_mail_receiver.rb b/plugins/messages/app/mail_receivers/messages_mail_receiver.rb index 006c3f8d5..7b8a03569 100644 --- a/plugins/messages/app/mail_receivers/messages_mail_receiver.rb +++ b/plugins/messages/app/mail_receivers/messages_mail_receiver.rb @@ -67,7 +67,7 @@ def get_mail_part(mail) class BlankBodyException < MidiSmtpServer::SmtpdException def initialize(msg = nil) - super msg, 541, 'The recipient address rejected your message because of a blank plain body' + super(msg, 541, 'The recipient address rejected your message because of a blank plain body') end end end diff --git a/plugins/printer/app/controllers/printer_controller.rb b/plugins/printer/app/controllers/printer_controller.rb index 78f133774..f07ac8056 100644 --- a/plugins/printer/app/controllers/printer_controller.rb +++ b/plugins/printer/app/controllers/printer_controller.rb @@ -51,6 +51,7 @@ def bearer_token def authenticate_printer return head(:unauthorized) unless bearer_token - return head(:forbidden) if bearer_token != FoodsoftConfig[:printer_token] + + head(:forbidden) if bearer_token != FoodsoftConfig[:printer_token] end end diff --git a/plugins/wiki/app/helpers/pages_helper.rb b/plugins/wiki/app/helpers/pages_helper.rb index 869f59d12..70ddafd6c 100644 --- a/plugins/wiki/app/helpers/pages_helper.rb +++ b/plugins/wiki/app/helpers/pages_helper.rb @@ -30,7 +30,7 @@ def link_to_wikipage_by_permalink(permalink, text = nil) if text.nil? link_to permalink, new_page_path(title: permalink) else - link_to text, new_page_path(title: permalink) + link_to text, new_page_path(title: permalink) end else link_to_wikipage(page, text) diff --git a/spec/factories/user.rb b/spec/factories/user.rb index 9563c15cc..1f34f3a36 100644 --- a/spec/factories/user.rb +++ b/spec/factories/user.rb @@ -22,7 +22,7 @@ end %i[ordergroup finance invoices article_meta suppliers pickups orders].each do |role| - trait "role_#{role}".to_sym do + trait :"role_#{role}" do after :create do |user, _evaluator| create(:workgroup, "role_#{role}" => true, user_ids: [user.id]) end @@ -42,7 +42,9 @@ sequence(:name) { |n| "Order group ##{n}" } # workaround to avoid needing to save the ordergroup # avoids e.g. error after logging in related to applebar - after :create do |group| Ordergroup.find(group.id).update_stats! end + after :create do |group| + Ordergroup.find(group.id).update_stats! + end end end end diff --git a/spec/integration/articles_spec.rb b/spec/integration/articles_spec.rb index bddd80d6a..888b43c29 100644 --- a/spec/integration/articles_spec.rb +++ b/spec/integration/articles_spec.rb @@ -7,7 +7,7 @@ before { login user } - describe ':index', js: true do + describe ':index', :js do before { visit supplier_articles_path(supplier_id: supplier.id) } it 'can visit supplier articles path' do @@ -17,7 +17,7 @@ it 'can create a new article' do click_on I18n.t('articles.index.new') - expect(page).to have_selector('form#new_article') + expect(page).to have_css('form#new_article') article = build(:article, supplier: supplier, article_category: article_category) within('#new_article') do fill_in 'article_name', with: article.name diff --git a/spec/integration/balancing_spec.rb b/spec/integration/balancing_spec.rb index d8e58e6da..2d08561b2 100644 --- a/spec/integration/balancing_spec.rb +++ b/spec/integration/balancing_spec.rb @@ -1,6 +1,6 @@ require_relative '../spec_helper' -feature 'settling an order', js: true do +feature 'settling an order', :js do let(:ftt) { create(:financial_transaction_type) } let(:admin) { create(:user, groups: [create(:workgroup, role_finance: true)]) } let(:user) { create(:user, groups: [create(:ordergroup)]) } @@ -20,11 +20,10 @@ order.finish!(admin) goa1.reload goa2.reload + visit new_finance_order_path(order_id: order.id) + login admin end - before { visit new_finance_order_path(order_id: order.id) } - before { login admin } - it 'has correct order result' do expect(oa.quantity).to eq(4) expect(oa.tolerance).to eq(0) @@ -34,20 +33,20 @@ it 'has product ordered visible' do expect(page).to have_content(article.name) - expect(page).to have_selector("#order_article_#{oa.id}") + expect(page).to have_css("#order_article_#{oa.id}") end it 'shows order result' do click_link article.name - expect(page).to have_selector("#group_order_articles_#{oa.id}") + expect(page).to have_css("#group_order_articles_#{oa.id}") within("#group_order_articles_#{oa.id}") do # make sure these ordergroup names are in the list for this product expect(page).to have_content(go1.ordergroup_name) expect(page).to have_content(go2.ordergroup_name) # and that their order results match what we expect - expect(page).to have_selector("#r_#{goa1.id}") + expect(page).to have_css("#r_#{goa1.id}") expect(find("#r_#{goa1.id}").value.to_f).to eq(3) - expect(page).to have_selector("#r_#{goa2.id}") + expect(page).to have_css("#r_#{goa2.id}") expect(find("#r_#{goa2.id}").value.to_f).to eq(1) end end @@ -58,7 +57,7 @@ click_link I18n.t('ui.delete') end end - expect(page).not_to have_selector("#order_article_#{oa.id}") + expect(page).to have_no_css("#order_article_#{oa.id}") expect(OrderArticle.exists?(oa.id)).to be true oa.reload expect(oa.quantity).to eq(4) @@ -76,17 +75,17 @@ click_link I18n.t('ui.delete') end end - expect(page).not_to have_selector("#order_article_#{oa.id}") + expect(page).to have_no_css("#order_article_#{oa.id}") expect(OrderArticle.exists?(oa.id)).to be false end it 'keeps ordered quantities when GroupOrderArticle is deleted from resulting order' do click_link article.name - expect(page).to have_selector("#group_order_article_#{goa1.id}") + expect(page).to have_css("#group_order_article_#{goa1.id}") within("#group_order_article_#{goa1.id}") do click_link I18n.t('ui.delete') end - expect(page).not_to have_selector("#group_order_article_#{goa1.id}") + expect(page).to have_no_css("#group_order_article_#{goa1.id}") expect(OrderArticle.exists?(oa.id)).to be true expect(GroupOrderArticle.exists?(goa1.id)).to be true goa1.reload @@ -98,11 +97,11 @@ it 'deletes a GroupOrderArticle with no ordered amounts' do goa1.update(quantity: 0, tolerance: 0) click_link article.name - expect(page).to have_selector("#group_order_article_#{goa1.id}") + expect(page).to have_css("#group_order_article_#{goa1.id}") within("#group_order_article_#{goa1.id}") do click_link I18n.t('ui.delete') end - expect(page).not_to have_selector("#group_order_article_#{goa1.id}") + expect(page).to have_no_css("#group_order_article_#{goa1.id}") expect(OrderArticle.exists?(oa.id)).to be true expect(GroupOrderArticle.exists?(goa1.id)).to be false end @@ -116,10 +115,10 @@ sleep 0.25 find('input[type="submit"]').click end - expect(page).to have_selector("#order_article_#{oa.id}") + expect(page).to have_css("#order_article_#{oa.id}") # make sure it still works after reloading visit new_finance_order_path(order_id: order.id) - expect(page).to have_selector("#order_article_#{oa.id}") + expect(page).to have_css("#order_article_#{oa.id}") expect(OrderArticle.exists?(oa.id)).to be true oa.reload expect(oa.units_to_order).to eq(0) @@ -131,19 +130,19 @@ within("#group_order_articles_#{oa.id}") do click_link I18n.t('finance.balancing.group_order_articles.add_group') end - expect(page).to have_selector('form#new_group_order_article') + expect(page).to have_css('form#new_group_order_article') within('#new_group_order_article') do select user.ordergroup.name, from: 'group_order_article_ordergroup_id' find_by_id('group_order_article_result').set(8) sleep 0.25 find('input[type="submit"]').click end - expect(page).not_to have_selector('form#new_group_order_article') + expect(page).to have_no_css('form#new_group_order_article') expect(page).to have_content(user.ordergroup.name) goa = GroupOrderArticle.last expect(goa).not_to be_nil expect(goa.result).to eq 8 - expect(page).to have_selector("#group_order_article_#{goa.id}") + expect(page).to have_css("#group_order_article_#{goa.id}") expect(find("#r_#{goa.id}").value.to_f).to eq 8 end @@ -152,7 +151,7 @@ within("#group_order_articles_#{oa.id}") do find("#r_#{goa1.id}").set(5).send_keys(:tab) # tab to blur and let js update end - expect(page).to have_selector('#summaryChangedWarning') # becomes visible after request is done + expect(page).to have_css('#summaryChangedWarning') # becomes visible after request is done expect(goa1.reload.result).to eq 5 expect(find("#group_order_articles_#{oa.id} tfoot td:nth-child(3)").text.to_f).to eq 6 end @@ -162,22 +161,22 @@ within("#group_order_article_#{goa1.id}") do 4.times { find('button[data-increment]').click } end - expect(page).to have_selector('#summaryChangedWarning') # becomes visible after request is done + expect(page).to have_css('#summaryChangedWarning') # becomes visible after request is done expect(goa1.reload.result).to eq 7 expect(find("#group_order_articles_#{oa.id} tfoot td:nth-child(3)").text.to_f).to eq 8 end it 'can add an article' do new_article = create(:article, supplier: supplier) - expect(page).not_to have_content(new_article.name) + expect(page).to have_no_content(new_article.name) click_link I18n.t('finance.balancing.edit_results_by_articles.add_article') - expect(page).to have_selector('form#new_order_article') + expect(page).to have_css('form#new_order_article') within('#new_order_article') do find_by_id('order_article_article_id').select(new_article.name) sleep 0.25 find('input[type="submit"]').click end - expect(page).not_to have_selector('form#new_order_article') + expect(page).to have_no_css('form#new_order_article') expect(page).to have_content(new_article.name) expect(order.order_articles.where(article_id: new_article.id)).not_to be_nil end diff --git a/spec/integration/home_spec.rb b/spec/integration/home_spec.rb index 87390bd97..d291cfbdb 100644 --- a/spec/integration/home_spec.rb +++ b/spec/integration/home_spec.rb @@ -17,7 +17,7 @@ fill_in 'user_first_name', with: 'foo' click_button I18n.t('ui.save') expect(User.find(user.id).first_name).to eq 'foo' - expect(page).to have_selector '.alert-success' + expect(page).to have_css '.alert-success' end end end diff --git a/spec/integration/login_spec.rb b/spec/integration/login_spec.rb index 747d170f1..f4be09f82 100644 --- a/spec/integration/login_spec.rb +++ b/spec/integration/login_spec.rb @@ -7,13 +7,13 @@ before { visit forgot_password_path } it 'is accessible' do - expect(page).to have_selector 'input[id=user_email]' + expect(page).to have_css 'input[id=user_email]' end it 'sends a reset email' do fill_in 'user_email', with: user.email find('input[type=submit]').click - expect(page).to have_selector '.alert-success' + expect(page).to have_css '.alert-success' email = ActionMailer::Base.deliveries.first expect(email.to).to eq [user.email] end @@ -23,20 +23,21 @@ let(:token) { user.reset_password_token } let(:newpass) { user.new_random_password } - before { user.request_password_reset! } - - before { visit new_password_path(id: user.id, token: token) } + before do + user.request_password_reset! + visit new_password_path(id: user.id, token: token) + end it 'is accessible' do - expect(page).to have_selector 'input[type=password]' + expect(page).to have_css 'input[type=password]' end describe 'with wrong token' do let(:token) { 'foobar' } it 'is not accessible' do - expect(page).to have_selector '.alert-error' - expect(page).not_to have_selector 'input[type=password]' + expect(page).to have_css '.alert-error' + expect(page).to have_no_css 'input[type=password]' end end diff --git a/spec/integration/order_spec.rb b/spec/integration/order_spec.rb index 37b9e60a4..56abc59ad 100644 --- a/spec/integration/order_spec.rb +++ b/spec/integration/order_spec.rb @@ -1,6 +1,6 @@ require_relative '../spec_helper' -feature Order, js: true do +feature Order, :js do let(:admin) { create(:user, groups: [create(:workgroup, role_orders: true)]) } let(:article) { create(:article, unit_quantity: 1) } let(:order) { create(:order, supplier: article.supplier, article_ids: [article.id]) } # need to ref article @@ -32,7 +32,7 @@ visit new_order_path(supplier_id: article.supplier_id) expect(page).to have_text I18n.t('orders.new.title') find('input[type="submit"]').click - expect(page).to have_selector('.alert-success') + expect(page).to have_css('.alert-success') expect(Order.count).to eq 1 expect(Order.first.supplier).to eq article.supplier end @@ -40,7 +40,7 @@ it 'can close an order' do setup_and_close_order expect(order).to be_finished - expect(page).not_to have_link I18n.t('orders.index.action_end') + expect(page).to have_no_link I18n.t('orders.index.action_end') expect(oa.units_to_order).to eq 1 end @@ -53,7 +53,7 @@ def setup_and_close_order accept_confirm do click_link_or_button I18n.t('orders.index.action_end') end - expect(page).to have_selector('.alert-success') + expect(page).to have_css('.alert-success') order.reload oa.reload end diff --git a/spec/integration/product_distribution_example_spec.rb b/spec/integration/product_distribution_example_spec.rb index 2c1af327b..b1cf4801d 100644 --- a/spec/integration/product_distribution_example_spec.rb +++ b/spec/integration/product_distribution_example_spec.rb @@ -1,6 +1,6 @@ require_relative '../spec_helper' -feature 'product distribution', js: true do +feature 'product distribution', :js do let(:ftt) { create(:financial_transaction_type) } let(:admin) { create(:admin) } let(:user_a) { create(:user, groups: [create(:ordergroup)]) } @@ -34,7 +34,7 @@ scrolldown 2.times { find("[data-increase_quantity='#{oa.id}']").click } find('input[type=submit]').click - expect(page).to have_selector('body') + expect(page).to have_css('body') # gruppe a faellt ein dass sie doch noch mehr braucht von x und aendert auf 4(1). login user_a visit edit_group_order_path(id: order.group_order(user_a.ordergroup).id, order_id: order.id) @@ -42,7 +42,7 @@ 2.times { find("[data-increase_quantity='#{oa.id}']").click } 2.times { find("[data-decrease_tolerance='#{oa.id}']").click } find('input[type=submit]').click - expect(page).to have_selector('body') + expect(page).to have_css('body') # die zuteilung order.finish!(admin) oa.reload diff --git a/spec/integration/receive_spec.rb b/spec/integration/receive_spec.rb index 6bf021e83..a889e095f 100644 --- a/spec/integration/receive_spec.rb +++ b/spec/integration/receive_spec.rb @@ -1,6 +1,6 @@ require_relative '../spec_helper' -feature 'receiving an order', js: true do +feature 'receiving an order', :js do let(:admin) { create(:user, groups: [create(:workgroup, role_orders: true)]) } let(:supplier) { create(:supplier) } let(:article) { create(:article, supplier: supplier, unit_quantity: 3) } @@ -40,13 +40,13 @@ def check_quantities(units, q1, q2) set_quantities [3, 0], [0, 0] visit receive_order_path(id: order.id) expect(page).to have_content(article.name) - expect(page).to have_selector("#order_article_#{oa.id}") + expect(page).to have_css("#order_article_#{oa.id}") end it 'has product not ordered invisible' do set_quantities [0, 0], [0, 0] visit receive_order_path(id: order.id) - expect(page).not_to have_selector("#order_article_#{oa.id}") + expect(page).to have_no_css("#order_article_#{oa.id}") end it 'is not received by default' do @@ -60,7 +60,7 @@ def check_quantities(units, q1, q2) visit receive_order_path(id: order.id) fill_in "order_articles_#{oa.id}_units_received", with: oa.units_to_order find('input[type="submit"]').click - expect(page).to have_selector('body') + expect(page).to have_css('body') check_quantities 2, 2, 4 end @@ -69,7 +69,7 @@ def check_quantities(units, q1, q2) visit receive_order_path(id: order.id) fill_in "order_articles_#{oa.id}_units_received", with: 3 find('input[type="submit"]').click - expect(page).to have_selector('body') + expect(page).to have_css('body') check_quantities 3, 2, 5 end @@ -78,7 +78,7 @@ def check_quantities(units, q1, q2) visit receive_order_path(id: order.id) fill_in "order_articles_#{oa.id}_units_received", with: 1 find('input[type="submit"]').click - expect(page).to have_selector('body') + expect(page).to have_css('body') check_quantities 1, 2, 1 end @@ -96,7 +96,7 @@ def check_quantities(units, q1, q2) goa1.save! visit receive_order_path(id: order.id) find('input[type="submit"]').click - expect(page).to have_selector('body') + expect(page).to have_css('body') check_quantities 2, 3, 4 end end diff --git a/spec/integration/session_spec.rb b/spec/integration/session_spec.rb index e264efcbe..8a6a28aa9 100644 --- a/spec/integration/session_spec.rb +++ b/spec/integration/session_spec.rb @@ -6,17 +6,17 @@ describe 'login page' do it 'is accessible' do visit login_path - expect(page).to have_selector('input[type=password]') + expect(page).to have_css('input[type=password]') end it 'logs me in' do login user - expect(page).not_to have_selector('.alert-error') + expect(page).to have_no_css('.alert-error') end it 'does not log me in with wrong password' do login user.nick, 'XX' + user.password - expect(page).to have_selector('.alert-error') + expect(page).to have_css('.alert-error') end it 'can log me in using an email address' do @@ -24,7 +24,7 @@ fill_in 'nick', with: user.email fill_in 'password', with: user.password find('input[type=submit]').click - expect(page).not_to have_selector('.alert-error') + expect(page).to have_no_css('.alert-error') end end end diff --git a/spec/integration/supplier_spec.rb b/spec/integration/supplier_spec.rb index 5683d8dad..fc1328969 100644 --- a/spec/integration/supplier_spec.rb +++ b/spec/integration/supplier_spec.rb @@ -27,7 +27,7 @@ end end - describe 'existing', js: true do + describe 'existing', :js do it 'can be shown' do supplier visit suppliers_path @@ -53,7 +53,7 @@ accept_confirm do click_link I18n.t('ui.delete') end - expect(page).not_to have_content(supplier.name) + expect(page).to have_no_content(supplier.name) expect(supplier.reload.deleted?).to be true end end diff --git a/spec/models/group_order_article_spec.rb b/spec/models/group_order_article_spec.rb index 434f9a298..e0e9c76d8 100644 --- a/spec/models/group_order_article_spec.rb +++ b/spec/models/group_order_article_spec.rb @@ -6,10 +6,21 @@ let(:go) { create(:group_order, order: order, ordergroup: user.ordergroup) } let(:goa) { create(:group_order_article, group_order: go, order_article: order.order_articles.first) } - it 'has zero quantity by default' do expect(goa.quantity).to eq(0) end - it 'has zero tolerance by default' do expect(goa.tolerance).to eq(0) end - it 'has zero result by default' do expect(goa.result).to eq(0) end - it 'has zero total price by default' do expect(goa.total_price).to eq(0) end + it 'has zero quantity by default' do + expect(goa.quantity).to eq(0) + end + + it 'has zero tolerance by default' do + expect(goa.tolerance).to eq(0) + end + + it 'has zero result by default' do + expect(goa.result).to eq(0) + end + + it 'has zero total price by default' do + expect(goa.total_price).to eq(0) + end describe do let(:article) { create(:article, supplier: order.supplier, unit_quantity: 1) } diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index 71c46a849..18a478b4d 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -96,9 +96,17 @@ describe 'with articles' do let(:order) { create(:order) } - it 'is open by default' do expect(order).to be_open end - it 'is not finished by default' do expect(order).not_to be_finished end - it 'is not closed by default' do expect(order).not_to be_closed end + it 'is open by default' do + expect(order).to be_open + end + + it 'is not finished by default' do + expect(order).not_to be_finished + end + + it 'is not closed by default' do + expect(order).not_to be_closed + end it 'has valid order articles' do order.order_articles.each { |oa| expect(oa).to be_valid } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index def2d1f8d..36768320d 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -16,11 +16,25 @@ describe 'does not have the role' do let(:user) { create(:user) } - it 'admin' do expect(user.role_admin?).to be_falsey end - it 'finance' do expect(user.role_finance?).to be_falsey end - it 'article_meta' do expect(user.role_article_meta?).to be_falsey end - it 'suppliers' do expect(user.role_suppliers?).to be_falsey end - it 'orders' do expect(user.role_orders?).to be_falsey end + it 'admin' do + expect(user.role_admin?).to be_falsey + end + + it 'finance' do + expect(user.role_finance?).to be_falsey + end + + it 'article_meta' do + expect(user.role_article_meta?).to be_falsey + end + + it 'suppliers' do + expect(user.role_suppliers?).to be_falsey + end + + it 'orders' do + expect(user.role_orders?).to be_falsey + end end describe do @@ -76,7 +90,9 @@ describe 'admin' do let(:user) { create(:admin) } - it 'default admin role' do expect(user.role_admin?).to be_truthy end + it 'default admin role' do + expect(user.role_admin?).to be_truthy + end end describe 'sort correctly' do diff --git a/spec/requests/api/v1/order_articles_controller_spec.rb b/spec/requests/api/v1/order_articles_controller_spec.rb index 97fea3bb0..31d6510f1 100644 --- a/spec/requests/api/v1/order_articles_controller_spec.rb +++ b/spec/requests/api/v1/order_articles_controller_spec.rb @@ -51,7 +51,7 @@ run_test! do |response| json_order_articles = JSON.parse(response.body)['order_articles'] json_order_article_ids = json_order_articles.map { |d| d['id'].to_i } - expect(json_order_article_ids).to match_array [order_articles[3].id] + expect(json_order_article_ids).to contain_exactly(order_articles[3].id) end end diff --git a/spec/requests/api/v1/user/financial_transactions_spec.rb b/spec/requests/api/v1/user/financial_transactions_spec.rb index c37d5b22c..91a6fff0b 100644 --- a/spec/requests/api/v1/user/financial_transactions_spec.rb +++ b/spec/requests/api/v1/user/financial_transactions_spec.rb @@ -49,7 +49,9 @@ response '422', 'invalid parameter value' do schema '$ref' => '#/components/schemas/Error422' - let(:financial_transaction) { { amount: "abc", financial_transaction_type_id: create(:financial_transaction_type).id, note: "foo bar" } } + let(:financial_transaction) do + { amount: 'abc', financial_transaction_type_id: create(:financial_transaction_type).id, note: 'foo bar' } + end run_test! end end diff --git a/spec/support/api_helper.rb b/spec/support/api_helper.rb index 3a6e78941..57a9d4b4c 100644 --- a/spec/support/api_helper.rb +++ b/spec/support/api_helper.rb @@ -7,11 +7,11 @@ module ApiHelper let(:api_access_token) do create(:oauth2_access_token, resource_owner_id: user.id, scopes: api_scopes&.join(' ')).token end - let(:Authorization) { "Bearer #{api_access_token}" } # rubocop:disable RSpec/VariableName + let(:Authorization) { "Bearer #{api_access_token}" } def self.it_handles_invalid_token context 'with invalid access token' do - let(:Authorization) { 'abc' } # rubocop:disable RSpec/VariableName + let(:Authorization) { 'abc' } response 401, 'not logged-in' do schema '$ref' => '#/components/schemas/Error401' @@ -22,7 +22,7 @@ def self.it_handles_invalid_token def self.it_handles_invalid_token_with_id context 'with invalid access token' do - let(:Authorization) { 'abc' } # rubocop:disable RSpec/VariableName + let(:Authorization) { 'abc' } let(:id) { 42 } # id doesn't matter here response 401, 'not logged-in' do diff --git a/spec/support/coverage.rb b/spec/support/coverage.rb index b4142c3db..443da12d8 100644 --- a/spec/support/coverage.rb +++ b/spec/support/coverage.rb @@ -16,11 +16,23 @@ def cov_no_plugins(source_file, path) SimpleCov.start do add_filter '/spec/' add_filter '/test/' - add_group 'Models' do |s| cov_no_plugins s, '/app/models/' end - add_group 'Controllers' do |s| cov_no_plugins s, '/app/controllers/' end - add_group 'Helpers' do |s| cov_no_plugins s, '/app/helpers/' end - add_group 'Documents' do |s| cov_no_plugins s, '/app/documents/' end - add_group 'Libraries' do |s| cov_no_plugins s, '/lib/' end - add_group 'Plugins' do |s| s.filename =~ %r{/lib/foodsoft_.*/} end + add_group 'Models' do |s| + cov_no_plugins s, '/app/models/' + end + add_group 'Controllers' do |s| + cov_no_plugins s, '/app/controllers/' + end + add_group 'Helpers' do |s| + cov_no_plugins s, '/app/helpers/' + end + add_group 'Documents' do |s| + cov_no_plugins s, '/app/documents/' + end + add_group 'Libraries' do |s| + cov_no_plugins s, '/lib/' + end + add_group 'Plugins' do |s| + s.filename =~ %r{/lib/foodsoft_.*/} + end end end