diff --git a/.rubocop.yml b/.rubocop.yml index 86266fead8..40f584cdac 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -141,6 +141,16 @@ Metrics/BlockLength: AllowedMethods: ['describe', 'context', 'task', 'namespace'] +# ---------- +# - NAMING - +# ---------- +# TODO: Temporarily disabled for release v5.0.2 +Naming/MethodName: + Enabled: false +# TODO: Temporarily disabled for release v5.0.2 +Naming/PredicateMethod: + Enabled: false + # ------------ # - SECURITY - # ------------ diff --git a/Gemfile.lock b/Gemfile.lock index f3766cbc77..56db857b5c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,8 +89,8 @@ GEM annotate_gem (0.0.14) bundler (>= 1.1) api-pagination (6.0.0) - ast (2.4.2) - autoprefixer-rails (10.4.19.0) + ast (2.4.3) + autoprefixer-rails (10.4.21.0) execjs (~> 2) base64 (0.3.0) bcrypt (3.1.20) @@ -103,12 +103,12 @@ GEM bindex (0.8.1) binding_of_caller (1.0.1) debug_inspector (>= 1.2.0) - bootsnap (1.18.4) + bootsnap (1.18.6) msgpack (~> 1.2) - brakeman (6.2.2) + brakeman (7.1.0) racc builder (3.3.0) - bullet (8.0.1) + bullet (8.0.8) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) bundle-audit (0.1.0) @@ -116,7 +116,7 @@ GEM bundler-audit (0.9.2) bundler (>= 1.2.0, < 3) thor (~> 1.0) - byebug (11.1.3) + byebug (12.0.0) capybara (3.40.0) addressable matrix @@ -126,6 +126,7 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + cgi (0.5.0) claide (1.1.0) claide-plugins (0.9.2) cork @@ -145,26 +146,26 @@ GEM crass (1.0.6) cssbundling-rails (1.4.3) railties (>= 6.0.0) - csv (3.3.2) - danger (9.5.1) + csv (3.3.5) + danger (9.5.3) base64 (~> 0.2) claide (~> 1.0) claide-plugins (>= 0.9.2) - colored2 (~> 3.1) + colored2 (>= 3.1, < 5) cork (~> 0.1) faraday (>= 0.9.0, < 3.0) faraday-http-cache (~> 2.0) - git (~> 1.13) - kramdown (~> 2.3) + git (>= 1.13, < 3.0) + kramdown (>= 2.5.1, < 3.0) kramdown-parser-gfm (~> 1.0) octokit (>= 4.0) pstore (~> 0.1) - terminal-table (>= 1, < 4) + terminal-table (>= 1, < 5) database_cleaner (2.1.0) database_cleaner-active_record (>= 2, < 3) - database_cleaner-active_record (2.2.0) + database_cleaner-active_record (2.2.2) activerecord (>= 5.a) - database_cleaner-core (~> 2.0.0) + database_cleaner-core (~> 2.0) database_cleaner-core (2.0.1) date (3.4.1) debug_inspector (1.2.0) @@ -174,13 +175,13 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) - devise_invitable (2.0.9) + devise_invitable (2.0.11) actionmailer (>= 5.0) devise (>= 4.6) - diff-lcs (1.6.0) - dotenv (3.1.7) - dotenv-rails (3.1.7) - dotenv (= 3.1.7) + diff-lcs (1.6.2) + dotenv (3.1.8) + dotenv-rails (3.1.8) + dotenv (= 3.1.8) railties (>= 6.1) dragonfly (1.4.1) addressable (~> 2.3) @@ -191,27 +192,29 @@ GEM dragonfly (~> 1.0) fog-aws drb (2.2.3) + erb (4.0.4) + cgi (>= 0.3.3) erubi (1.13.1) - excon (1.2.5) + excon (1.3.0) logger execjs (2.10.0) - factory_bot (6.5.1) + factory_bot (6.5.5) activesupport (>= 6.1.0) - factory_bot_rails (6.4.4) + factory_bot_rails (6.5.1) factory_bot (~> 6.5) - railties (>= 5.0.0) - faker (3.5.1) + railties (>= 6.1.0) + faker (3.5.2) i18n (>= 1.8.11, < 2) - faraday (2.12.2) + faraday (2.14.0) faraday-net_http (>= 2.0, < 3.5) json logger faraday-http-cache (2.5.1) faraday (>= 0.8) - faraday-net_http (3.4.0) + faraday-net_http (3.4.1) net-http (>= 0.5.0) - ffi (1.17.1-arm64-darwin) - ffi (1.17.1-x86_64-linux-gnu) + ffi (1.17.2-arm64-darwin) + ffi (1.17.2-x86_64-linux-gnu) flag_shih_tzu (0.3.23) fog-aws (3.33.0) base64 (>= 0.2, < 0.4) @@ -229,7 +232,8 @@ GEM fog-xml (0.1.5) fog-core nokogiri (>= 1.5.11, < 2.0.0) - formatador (1.1.0) + formatador (1.2.1) + reline forwardable (1.3.3) fuubar (2.5.1) rspec-core (~> 3.0) @@ -240,10 +244,12 @@ GEM prime racc text (>= 1.3.0) - git (1.19.1) + git (2.3.3) + activesupport (>= 5.0) addressable (~> 2.8) + process_executer (~> 1.1) rchardet (~> 1.8) - globalid (1.2.1) + globalid (1.3.0) activesupport (>= 6.1) guard (2.19.1) formatador (>= 0.2.4) @@ -257,7 +263,7 @@ GEM shellany (~> 0.0) thor (>= 0.18.1) hana (1.3.7) - hashdiff (1.1.2) + hashdiff (1.2.1) hashie (5.0.0) highline (3.1.2) reline @@ -265,29 +271,29 @@ GEM actionpack nokogiri rubyzip (>= 1.0) - httparty (0.22.0) + httparty (0.23.1) csv mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) i18n (1.14.7) concurrent-ruby (~> 1.0) - io-console (0.8.0) - irb (1.15.1) + io-console (0.8.1) + irb (1.15.2) pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - jbuilder (2.13.0) - actionview (>= 5.0.0) - activesupport (>= 5.0.0) + jbuilder (2.14.1) + actionview (>= 7.0.0) + activesupport (>= 7.0.0) jsbundling-rails (1.3.1) railties (>= 6.0.0) - json (2.10.2) + json (2.15.1) json_schemer (2.4.0) bigdecimal hana (~> 1.3) regexp_parser (~> 2.0) simpleidn (~> 0.2) - jwt (2.10.1) + jwt (3.1.2) base64 kaminari (1.2.2) activesupport (>= 4.1.0) @@ -305,7 +311,7 @@ GEM rexml (>= 3.3.9) kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) - language_server-protocol (3.17.0.4) + language_server-protocol (3.17.0.5) ledermann-rails-settings (2.6.2) activerecord (>= 6.1) lint_roller (1.1.0) @@ -314,19 +320,19 @@ GEM rb-inotify (~> 0.9, >= 0.9.10) locale (2.1.4) logger (1.7.0) - loofah (2.24.0) + loofah (2.24.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) - lumberjack (1.2.10) + lumberjack (1.4.2) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (1.0.4) - matrix (0.4.2) + marcel (1.1.0) + matrix (0.4.3) method_source (1.1.0) - mime-types (3.6.0) + mime-types (3.7.0) logger - mime-types-data (~> 3.2015) - mime-types-data (3.2025.0304) + mime-types-data (~> 3.2025, >= 3.2025.0507) + mime-types-data (3.2025.0924) mimemagic (0.4.3) nokogiri (~> 1) rake @@ -335,15 +341,17 @@ GEM mocha (2.7.1) ruby2_keywords (>= 0.0.5) msgpack (1.8.0) - multi_json (1.15.0) - multi_xml (0.6.0) + multi_json (1.17.0) + multi_xml (0.7.1) + bigdecimal (~> 3.1) mutex_m (0.3.0) - mysql2 (0.5.6) + mysql2 (0.5.7) + bigdecimal nap (1.1.0) nenv (0.3.0) net-http (0.6.0) uri - net-imap (0.4.20) + net-imap (0.5.12) date net-protocol net-pop (0.1.2) @@ -353,25 +361,27 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.4) - nokogiri (1.18.9-arm64-darwin) + nokogiri (1.18.10-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.9-x86_64-linux-gnu) + nokogiri (1.18.10-x86_64-linux-gnu) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - oauth2 (2.0.9) - faraday (>= 0.17.3, < 3.0) - jwt (>= 1.0, < 3.0) + oauth2 (2.0.17) + faraday (>= 0.17.3, < 4.0) + jwt (>= 1.0, < 4.0) + logger (~> 1.2) multi_xml (~> 0.5) rack (>= 1.2, < 4) - snaky_hash (~> 2.0) - version_gem (~> 1.1) - octokit (9.2.0) + snaky_hash (~> 2.0, >= 2.0.3) + version_gem (~> 1.1, >= 1.1.9) + octokit (10.0.0) faraday (>= 1, < 3) sawyer (~> 0.9) - omniauth (2.1.3) + omniauth (2.1.4) hashie (>= 3.4.6) + logger rack (>= 2.2.3) rack-protection omniauth-oauth2 (1.8.0) @@ -388,18 +398,21 @@ GEM open4 (1.3.4) options (2.3.2) orm_adapter (0.5.0) - ostruct (0.6.1) - parallel (1.26.3) - parser (3.3.7.1) + ostruct (0.6.3) + parallel (1.27.0) + parser (3.3.9.0) ast (~> 2.4.1) racc - pg (1.5.9) - pp (0.6.2) + pg (1.6.2-arm64-darwin) + pg (1.6.2-x86_64-linux) + pp (0.6.3) prettyprint prettyprint (0.2.0) - prime (0.1.3) + prime (0.1.4) forwardable singleton + prism (1.5.1) + process_executer (1.3.0) progress_bar (1.3.4) highline (>= 1.6) options (~> 2.3.0) @@ -407,15 +420,15 @@ GEM coderay (~> 1.1) method_source (~> 1.0) pstore (0.2.0) - psych (5.2.3) + psych (5.2.6) date stringio - public_suffix (6.0.1) - puma (6.6.0) + public_suffix (6.0.2) + puma (7.0.4) nio4r (~> 2.0) - pundit (2.5.0) + pundit (2.5.2) activesupport (>= 3.0.0) - pundit-matchers (3.1.2) + pundit-matchers (4.0.0) rspec-core (~> 3.12) rspec-expectations (~> 3.12) rspec-mocks (~> 3.12) @@ -424,7 +437,7 @@ GEM rack (3.2.2) rack-attack (6.7.0) rack (>= 1.0, < 4) - rack-mini-profiler (3.3.1) + rack-mini-profiler (4.0.1) rack (>= 1.2.0) rack-protection (4.1.1) base64 (>= 0.1.0) @@ -455,7 +468,7 @@ GEM actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.2.0) + rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) @@ -471,31 +484,33 @@ GEM thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.2.1) + rake (13.3.0) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rchardet (1.9.0) - rdoc (6.12.0) + rchardet (1.10.0) + rdoc (6.15.0) + erb psych (>= 4.0.0) - recaptcha (5.19.0) - regexp_parser (2.10.0) - reline (0.6.0) + tsort + recaptcha (5.21.1) + regexp_parser (2.11.3) + reline (0.6.2) io-console (~> 0.5) responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) - rexml (3.4.2) - rollbar (3.6.1) - rouge (4.5.1) + rexml (3.4.4) + rollbar (3.6.2) + rouge (4.6.1) rspec-collection_matchers (1.2.1) rspec-expectations (>= 2.99.0.beta1) - rspec-core (3.13.3) + rspec-core (3.13.5) rspec-support (~> 3.13.0) - rspec-expectations (3.13.3) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.2) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-rails (7.1.1) @@ -506,8 +521,8 @@ GEM rspec-expectations (~> 3.13) rspec-mocks (~> 3.13) rspec-support (~> 3.13) - rspec-support (3.13.2) - rubocop (1.74.0) + rspec-support (3.13.6) + rubocop (1.81.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -515,18 +530,19 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.38.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.38.1) - parser (>= 3.3.1.0) + rubocop-ast (1.47.1) + parser (>= 3.3.7.2) + prism (~> 1.4) rubocop-i18n (3.2.3) lint_roller (~> 1.1) rubocop (>= 1.72.1) - rubocop-performance (1.24.0) + rubocop-performance (1.26.0) lint_roller (~> 1.1) - rubocop (>= 1.72.1, < 2.0) - rubocop-ast (>= 1.38.0, < 2.0) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) ruby_dig (0.0.2) @@ -535,7 +551,7 @@ GEM addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) securerandom (0.4.1) - selenium-webdriver (4.26.0) + selenium-webdriver (4.32.0) base64 (~> 0.2) logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) @@ -550,40 +566,44 @@ GEM activesupport (>= 4.2.0) simpleidn (0.2.3) singleton (0.3.0) - snaky_hash (2.0.1) - hashie - version_gem (~> 1.1, >= 1.1.1) - spring (4.3.0) + snaky_hash (2.0.3) + hashie (>= 0.1.0, < 6) + version_gem (>= 1.1.8, < 3) + spring (4.4.0) spring-commands-rspec (1.0.4) spring (>= 0.9.1) spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) spring (>= 4) - sprockets (4.2.1) + sprockets (4.2.2) concurrent-ruby (~> 1.0) + logger rack (>= 2.2.4, < 4) sprockets-rails (3.5.2) actionpack (>= 6.1) activesupport (>= 6.1) sprockets (>= 3.0.0) - stringio (3.1.5) - terminal-table (3.0.2) - unicode-display_width (>= 1.1.1, < 3) + stringio (3.1.7) + terminal-table (4.0.0) + unicode-display_width (>= 1.1.1, < 4) text (1.3.1) - thor (1.3.2) + thor (1.4.0) timeout (0.4.3) tomparse (0.4.2) translation (1.41) gettext (~> 3.2, >= 3.2.5, <= 3.4.9) - turbo-rails (2.0.12) - actionpack (>= 6.0.0) - railties (>= 6.0.0) + tsort (0.2.0) + turbo-rails (2.0.17) + actionpack (>= 7.1.0) + railties (>= 7.1.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.6.0) - uniform_notifier (1.16.0) - uri (1.0.3) - version_gem (1.1.6) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.1.0) + uniform_notifier (1.18.0) + uri (1.0.4) + version_gem (1.1.9) warden (1.2.9) rack (>= 2.0.9) web-console (4.2.1) @@ -596,14 +616,14 @@ GEM crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) websocket (1.2.11) - websocket-driver (0.7.7) + websocket-driver (0.8.0) base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) wicked_pdf (2.8.2) activesupport ostruct - wkhtmltopdf-binary (0.12.6.8) + wkhtmltopdf-binary (0.12.6.10) xpath (3.2.0) nokogiri (~> 1.8) yard (0.9.37) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0518a79d69..1e2c29fcce 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -15,6 +15,7 @@ class ApplicationController < ActionController::Base include GlobalHelpers include Pundit::Authorization + helper_method GlobalHelpers.instance_methods rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized diff --git a/app/controllers/concerns/paginable.rb b/app/controllers/concerns/paginable.rb index 7d558e3db4..c3d309706b 100644 --- a/app/controllers/concerns/paginable.rb +++ b/app/controllers/concerns/paginable.rb @@ -4,6 +4,7 @@ # rubocop:disable Metrics/ModuleLength module Paginable extend ActiveSupport::Concern + require 'sort_direction' ## diff --git a/app/controllers/contributors_controller.rb b/app/controllers/contributors_controller.rb index 9ba2aeab02..e260dbd731 100644 --- a/app/controllers/contributors_controller.rb +++ b/app/controllers/contributors_controller.rb @@ -3,6 +3,7 @@ # Controller for the Contributors page class ContributorsController < ApplicationController include OrgSelectable + helper PaginableHelper before_action :fetch_plan diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index bba42c8bd8..c5ff0e0cc3 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -3,6 +3,7 @@ # Controller for the Comments section of the Write Plan page class NotesController < ApplicationController include ConditionalUserMailer + after_action :verify_authorized respond_to :html diff --git a/app/controllers/org_admin/sections_controller.rb b/app/controllers/org_admin/sections_controller.rb index 2b8c74a698..686d1439f7 100644 --- a/app/controllers/org_admin/sections_controller.rb +++ b/app/controllers/org_admin/sections_controller.rb @@ -14,8 +14,8 @@ def index authorize Section.new phase = Phase.includes(:template, :sections).find(params[:phase_id]) edit = phase.template.latest? && - (current_user.can_modify_templates? && - (phase.template.org_id == current_user.org_id)) + current_user.can_modify_templates? && + (phase.template.org_id == current_user.org_id) render partial: 'index', locals: { template: phase.template, diff --git a/app/controllers/org_admin/template_customizations_controller.rb b/app/controllers/org_admin/template_customizations_controller.rb index 15c37f533b..94a245bbcb 100644 --- a/app/controllers/org_admin/template_customizations_controller.rb +++ b/app/controllers/org_admin/template_customizations_controller.rb @@ -5,6 +5,7 @@ module OrgAdmin class TemplateCustomizationsController < ApplicationController include Paginable include Versionable + after_action :verify_authorized # POST /org_admin/templates/:id/customize diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index b40c559f61..14c3775e1d 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -3,6 +3,7 @@ # Controller that handles adding/updating/removing collaborators from a plan class RolesController < ApplicationController include ConditionalUserMailer + respond_to :html after_action :verify_authorized @@ -30,8 +31,7 @@ def create user = User.where_case_insensitive('email', role_params[:user][:email]).first if user.present? && Role.where(plan: @role.plan, user: user, active: true) - .count - .positive? # role already exists + .any? # role already exists flash[:notice] = format(_('Plan is already shared with %{email}.'), email: role_params[:user][:email]) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index def9e66356..20b9e442c0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -5,6 +5,7 @@ class UsersController < ApplicationController helper PaginableHelper helper PermsHelper include ConditionalUserMailer + after_action :verify_authorized respond_to :html diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index 56267ee547..8048e2c257 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -5,6 +5,7 @@ class UserMailer < ActionMailer::Base prepend_view_path 'app/views/branded/' include MailerHelper + helper MailerHelper helper FeedbacksHelper diff --git a/app/models/identifier.rb b/app/models/identifier.rb index c5b1b9794e..6ec4ec5bd1 100644 --- a/app/models/identifier.rb +++ b/app/models/identifier.rb @@ -61,7 +61,7 @@ def self.by_scheme_name(scheme, identifiable_type) # Ensure that the value of attrs is a hash # TODO: evaluate this vs the Serialize approach in condition.rb def attrs=(hash) - super(hash.is_a?(Hash) ? hash.to_json.to_s : '{}') + super(hash.is_a?(Hash) ? hash.to_json : '{}') end # Appends the identifier scheme's prefix to the identifier if necessary diff --git a/app/models/org.rb b/app/models/org.rb index 92122900e7..6a6eac55d2 100644 --- a/app/models/org.rb +++ b/app/models/org.rb @@ -38,6 +38,7 @@ class Org < ApplicationRecord include Identifiable extend Dragonfly::Model::Validations + validates_with OrgLinksValidator LOGO_FORMATS = %w[jpeg png gif jpg bmp].freeze diff --git a/app/models/template.rb b/app/models/template.rb index 9975a79b12..cf4d547510 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -457,12 +457,12 @@ def publishability publishable = false # all phases must have atleast 1 section end - unless phases.map { |p| p.sections.count.positive? }.reduce(true) { |fin, val| fin && val } + unless phases.map { |p| p.sections.any? }.reduce(true) { |fin, val| fin && val } error += _('You can not publish a template without sections in a phase. ') publishable = false # all sections must have atleast one question end - unless sections.map { |s| s.questions.count.positive? }.reduce(true) { |fin, val| fin && val } + unless sections.map { |s| s.questions.any? }.reduce(true) { |fin, val| fin && val } error += _('You can not publish a template without questions in a section. ') publishable = false end diff --git a/app/policies/token_permission_type_policy.rb b/app/policies/token_permission_type_policy.rb index eb5b5f4372..1a054b0c22 100644 --- a/app/policies/token_permission_type_policy.rb +++ b/app/policies/token_permission_type_policy.rb @@ -6,6 +6,6 @@ class TokenPermissionTypePolicy < ApplicationPolicy # NOTE: @user is the signed_in_user def index? - @user.can_use_api? && @user.org.token_permission_types.count.positive? + @user.can_use_api? && @user.org.token_permission_types.any? end end diff --git a/spec/controllers/usage_controller_spec.rb b/spec/controllers/usage_controller_spec.rb index 05d7b979fd..b85e4ae7c1 100644 --- a/spec/controllers/usage_controller_spec.rb +++ b/spec/controllers/usage_controller_spec.rb @@ -52,7 +52,7 @@ it 'returns the expected data' do # Controller returns results in date ascending order so resort the # records after extracting the ones we want first - expected = @annual[0..months - 1].sort_by(&:date).map { |stat| obj_to_hash(obj: stat) } + expected = @annual[0..(months - 1)].sort_by(&:date).map { |stat| obj_to_hash(obj: stat) } expect(assigns(:plans_per_month)).to eql(expected.flatten) end end diff --git a/spec/factories/contributors.rb b/spec/factories/contributors.rb index c0f3e16f73..4d38bfafbf 100644 --- a/spec/factories/contributors.rb +++ b/spec/factories/contributors.rb @@ -37,7 +37,7 @@ end before(:create) do |contributor, evaluator| - (0..evaluator.roles_count - 1).each do |idx| + (0..(evaluator.roles_count - 1)).each do |idx| contributor.send(:"#{contributor.all_roles[idx]}=", true) end end diff --git a/spec/factories/identifier_schemes.rb b/spec/factories/identifier_schemes.rb index 24fd508511..3e52d43b66 100644 --- a/spec/factories/identifier_schemes.rb +++ b/spec/factories/identifier_schemes.rb @@ -28,7 +28,7 @@ end after(:create) do |identifier_scheme, evaluator| - (0..evaluator.context_count - 1).each do |idx| + (0..(evaluator.context_count - 1)).each do |idx| identifier_scheme.update("#{identifier_scheme.all_context[idx]}": true) end end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 09f76fc861..870772ec93 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -86,14 +86,14 @@ expect(results.include?(@by_facet)).to eql(true) end it 'returns repositories with subjects like the search term' do - results = described_class.search(@by_subject.name[1..@by_subject.name.length - 1]) + results = described_class.search(@by_subject.name[1..(@by_subject.name.length - 1)]) expect(results.include?(@never_found)).to eql(false) expect(results.include?(@by_type)).to eql(false) expect(results.include?(@by_subject)).to eql(true) end it 'returns repositories with name like the search term' do repo = create(:repository, name: [Faker::Lorem.word, @by_subject.name].join(' ')) - results = described_class.search(@by_subject.name[1..@by_subject.name.length - 1]) + results = described_class.search(@by_subject.name[1..(@by_subject.name.length - 1)]) expect(results.include?(@never_found)).to eql(false) expect(results.include?(repo)).to eql(true) end