diff --git a/Gemfile b/Gemfile index 7e40d2c8e..a11b72121 100644 --- a/Gemfile +++ b/Gemfile @@ -103,11 +103,11 @@ group :development do gem 'letter_opener' gem 'rails-erd' gem 'rdoc' - gem 'rubocop', '1.62.0', require: false + gem 'rubocop', '1.68.0', require: false gem 'rubocop-graphql', '1.5.4', require: false gem 'rubocop-minitest', '0.35.1', require: false gem 'rubocop-performance', '1.22.1', require: false - gem 'rubocop-rails', '2.24.1', require: false + gem 'rubocop-rails', '2.27.0', require: false gem 'rubocop-rake', require: false gem 'spring' # gem 'spring-watcher-listen' diff --git a/Gemfile.lock b/Gemfile.lock index b9a03c26c..ca086963b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -135,7 +135,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) connection_pool (2.4.1) crack (0.4.5) rexml @@ -219,8 +219,8 @@ GEM invisible_captcha (2.2.0) rails (>= 5.2) io-console (0.7.2) - irb (1.11.2) - rdoc + irb (1.14.1) + rdoc (>= 4.0.0) reline (>= 0.4.2) jquery-rails (4.5.0) rails-dom-testing (>= 1, < 3) @@ -228,7 +228,7 @@ GEM thor (>= 0.14, < 2.0) jsbundling-rails (1.0.2) railties (>= 6.0.0) - json (2.7.2) + json (2.7.5) json-canonicalization (0.3.0) json-ld (3.2.3) htmlentities (~> 4.3) @@ -253,8 +253,11 @@ GEM loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mail (2.7.1) + mail (2.8.1) mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp marcel (1.0.4) matrix (0.4.2) method_source (1.0.0) @@ -265,9 +268,9 @@ GEM mini_mime (1.1.5) mini_portile2 (2.8.7) minitest (5.22.3) - minitest-rails (7.1.0) + minitest-rails (7.1.1) minitest (~> 5.20) - railties (~> 7.1.0) + railties (>= 7.1.0, < 8.0.0) minitest-rails-capybara (0.0.2) capybara minitest-rails @@ -385,15 +388,14 @@ GEM mime-types (>= 1.16, < 4.0) netrc (~> 0.8) rexml (3.3.7) - rubocop (1.62.0) + rubocop (1.68.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) 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.31.1, < 2.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.32.3) @@ -406,10 +408,10 @@ GEM rubocop-performance (1.22.1) rubocop (>= 1.48.1, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.24.1) + rubocop-rails (2.27.0) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) + rubocop (>= 1.52.0, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) rubocop-rake (0.6.0) rubocop (~> 1.0) @@ -555,11 +557,11 @@ DEPENDENCIES rails-controller-testing rails-erd rdoc - rubocop (= 1.62.0) + rubocop (= 1.68.0) rubocop-graphql (= 1.5.4) rubocop-minitest (= 0.35.1) rubocop-performance (= 1.22.1) - rubocop-rails (= 2.24.1) + rubocop-rails (= 2.27.0) rubocop-rake sass-rails (= 6.0.0) select2-rails diff --git a/app/graphql/types/event_queries.rb b/app/graphql/types/event_queries.rb index ce5f22d13..720489f5b 100644 --- a/app/graphql/types/event_queries.rb +++ b/app/graphql/types/event_queries.rb @@ -61,7 +61,7 @@ def events_by_filter(**args) end end - query = query.where('dtstart >= ?', from_date) + query = query.where(dtstart: from_date..) if args[:to_date].present? if args[:to_date] =~ /^\s*(\d{4})-(\d{2})-(\d{2})[ T](\d{2}):(\d{2})/ @@ -80,7 +80,7 @@ def events_by_filter(**args) raise GraphQL::ExecutionError, "toDate not in 'YYYY-MM-DD HH:MM' format" end - query = query.where('dtstart < ?', to_date) + query = query.where(dtstart: ...to_date) end if args[:neighbourhood_id].present? diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index d79663fc3..f6220e320 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -45,7 +45,7 @@ def next_url(next_event) period: @period, sort: @sort, repeating: @repeating - }.keep_if { |_key, value| value.present? } + }.compact_blank! events_by_date_path(opts) end diff --git a/app/jobs/calendar_importer/events/linked_data_event.rb b/app/jobs/calendar_importer/events/linked_data_event.rb index 174373f52..942afaa31 100644 --- a/app/jobs/calendar_importer/events/linked_data_event.rb +++ b/app/jobs/calendar_importer/events/linked_data_event.rb @@ -5,7 +5,7 @@ class LinkedDataEvent < Base attr_reader :uid, :start_time, :end_time, :summary, :description, :location def initialize(data) - super data + super @url = data['url'] @description = data['description'] diff --git a/app/jobs/calendar_importer/parsers/ld_json.rb b/app/jobs/calendar_importer/parsers/ld_json.rb index 27567a8d2..b7c3e4c73 100644 --- a/app/jobs/calendar_importer/parsers/ld_json.rb +++ b/app/jobs/calendar_importer/parsers/ld_json.rb @@ -6,7 +6,7 @@ class LdJson < Base KEY = 'ld-json' def initialize(calendar, options = {}) - super calendar, options + super end DOMAINS = ['various'].freeze diff --git a/app/jobs/calendar_importer/parsers/manchester_uni.rb b/app/jobs/calendar_importer/parsers/manchester_uni.rb index 8c1f520ce..d8efb4255 100644 --- a/app/jobs/calendar_importer/parsers/manchester_uni.rb +++ b/app/jobs/calendar_importer/parsers/manchester_uni.rb @@ -15,13 +15,9 @@ def self.allowlist_pattern end def import_events_from(data) - events = [] - - data.xpath('//ns:event').each do |event| - events << CalendarImporter::Events::ManchesterUniEvent.new(event) + events = data.xpath('//ns:event').map do |event| + CalendarImporter::Events::ManchesterUniEvent.new(event) end - - events end end end diff --git a/app/models/calendar.rb b/app/models/calendar.rb index 46bf0144e..b1db1c774 100644 --- a/app/models/calendar.rb +++ b/app/models/calendar.rb @@ -83,7 +83,7 @@ def requires_default_location? # This uses PaperTrail to get historical records of the Event models, including deletes # It does this to show a "event added" / "event removed" thing def recent_activity - versions = PaperTrail::Version.with_item_keys('Event', event_ids).where('created_at >= ?', 2.weeks.ago) + versions = PaperTrail::Version.with_item_keys('Event', event_ids).where(created_at: 2.weeks.ago..) versions = versions.or(PaperTrail::Version.destroys .where("item_type = 'Event' AND object @> ? AND created_at >= ?", { calendar_id: id }.to_json, 2.weeks.ago)) diff --git a/app/models/event.rb b/app/models/event.rb index 43731cff5..5cec71e34 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -44,8 +44,7 @@ class Event < ApplicationRecord # Find by day onwards scope :future, lambda { |day| day_start = day.midnight # 2024-04-01 00:00:00 +0100 - where('dtstart >= ?', - day_start) + where(dtstart: day_start..) } # For the API eventFilter find by neighbourhood @@ -81,7 +80,7 @@ class Event < ApplicationRecord 'lower(addresses.postcode) in (:partner_postcodes))', partner_ids: partners.map(&:id), partner_names: partners.map { |p| p.name.downcase }, - partner_postcodes: partners.map(&:address).keep_if(&:present?).map { |a| a.postcode.downcase } + partner_postcodes: partners.map(&:address).compact_blank!.map { |a| a.postcode.downcase } ) else left_joins(:address) @@ -115,11 +114,11 @@ class Event < ApplicationRecord scope :one_off_events_only, -> { where(rrule: false) } scope :one_off_events_first, -> { order(rrule: :asc) } - scope :upcoming, -> { where('dtstart >= ?', DateTime.current.beginning_of_day) } - scope :past, -> { where('dtstart <= ?', DateTime.current.beginning_of_day) } + scope :upcoming, -> { where(dtstart: DateTime.current.beginning_of_day..) } + scope :past, -> { where(dtstart: ..DateTime.current.beginning_of_day) } # Global feed - scope :ical_feed, -> { where('dtstart >= ?', Time.now - 1.week).where('dtend < ?', Time.now + 1.month) } + scope :ical_feed, -> { where(dtstart: (Time.now - 1.week)..).where(dtend: ...(Time.now + 1.month)) } def repeat_frequency rrule[0]['table']['frequency'].titleize if rrule diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index f4556db39..6d56e4390 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index d0f0d3b5d..4b63f2893 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index 98230c980..87fd451f0 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Define an application-wide content security policy diff --git a/config/initializers/new_framework_defaults_6_0.rb b/config/initializers/new_framework_defaults_6_0.rb index a48d4eb00..0c410fe9e 100644 --- a/config/initializers/new_framework_defaults_6_0.rb +++ b/config/initializers/new_framework_defaults_6_0.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 6.0 upgrade. diff --git a/test/integration/robots_integration_test.rb b/test/integration/robots_integration_test.rb index 2e9dfd646..b3dc0c932 100644 --- a/test/integration/robots_integration_test.rb +++ b/test/integration/robots_integration_test.rb @@ -10,13 +10,13 @@ class RobotsIntegrationTest < ActionDispatch::IntegrationTest test 'robots.txt blocks site if site is unpublished' do get "http://#{@unpublished_site.slug}.lvh.me:3000/robots.txt" - assert_response 200 + assert_response :ok assert_equal forbid_string, response.body end test 'robots.txt has default comment if site is published' do get "http://#{@published_site.slug}.lvh.me:3000/robots.txt" - assert_response 200 + assert_response :ok assert_equal '# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file', response.body end diff --git a/test/system/collections_test.rb b/test/system/collections_test.rb index 45232f817..b7eecd99a 100644 --- a/test/system/collections_test.rb +++ b/test/system/collections_test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + ## frozen_string_literal: true # # require 'application_system_test_case'