From 30692d014d607f46baffb72a6a990fa6fdf54397 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:16:15 -0700 Subject: [PATCH 01/44] Version bump Ruby, Rails, all gems to latest (2025-08-08) --- Gemfile | 13 +- Gemfile.lock | 548 +++++++++++++++++++++------------- db/schema.rb | 16 +- spec/factories/submissions.rb | 10 +- 4 files changed, 356 insertions(+), 231 deletions(-) diff --git a/Gemfile b/Gemfile index 1e59be6..3abb7f0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,8 +1,9 @@ source 'https://rubygems.org' -ruby '3.2.2' + +ruby file: '.ruby-version' # app server -gem 'rails', '~> 5.2.0' +gem 'rails' # database gem 'pg' @@ -11,7 +12,7 @@ gem 'pg' gem 'puma' # webserver -gem 'microformats', '~> 4.0.7' +gem 'microformats' # assets gem 'autoprefixer-rails' @@ -38,9 +39,9 @@ end # dev group :development do - gem 'listen', '~> 3.1.5' + gem 'listen' gem 'spring' - gem 'spring-watcher-listen', '~> 2.0.0' + gem 'spring-watcher-listen' gem 'web-console' # For measuring page/code performance @@ -56,4 +57,4 @@ group :development do end # windows dev -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem 'tzinfo-data', platforms: [:windows, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock index b825237..23a7f02 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,83 +1,127 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.0) - actionpack (= 5.2.0) + actioncable (8.0.2) + actionpack (= 8.0.2) + activesupport (= 8.0.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.0) - actionpack (= 5.2.0) - actionview (= 5.2.0) - activejob (= 5.2.0) - mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (5.2.0) - actionview (= 5.2.0) - activesupport (= 5.2.0) - rack (~> 2.0) + zeitwerk (~> 2.6) + actionmailbox (8.0.2) + actionpack (= 8.0.2) + activejob (= 8.0.2) + activerecord (= 8.0.2) + activestorage (= 8.0.2) + activesupport (= 8.0.2) + mail (>= 2.8.0) + actionmailer (8.0.2) + actionpack (= 8.0.2) + actionview (= 8.0.2) + activejob (= 8.0.2) + activesupport (= 8.0.2) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (8.0.2) + actionview (= 8.0.2) + activesupport (= 8.0.2) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.0) - activesupport (= 5.2.0) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (8.0.2) + actionpack (= 8.0.2) + activerecord (= 8.0.2) + activestorage (= 8.0.2) + activesupport (= 8.0.2) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (8.0.2) + activesupport (= 8.0.2) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.0) - activesupport (= 5.2.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (8.0.2) + activesupport (= 8.0.2) globalid (>= 0.3.6) - activemodel (5.2.0) - activesupport (= 5.2.0) - activerecord (5.2.0) - activemodel (= 5.2.0) - activesupport (= 5.2.0) - arel (>= 9.0) - activestorage (5.2.0) - actionpack (= 5.2.0) - activerecord (= 5.2.0) - marcel (~> 0.3.1) - activesupport (5.2.0) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - arel (9.0.0) - ast (2.4.0) - autoprefixer-rails (9.1.0) - execjs - bindex (0.5.0) - bootstrap (4.1.3) - autoprefixer-rails (>= 6.0.3) - popper_js (>= 1.12.9, < 2) - sass (>= 3.5.2) - builder (3.2.3) - byebug (10.0.2) - coderay (1.1.2) - concurrent-ruby (1.0.5) - crass (1.0.4) - diff-lcs (1.3) - docile (1.3.1) - erubi (1.7.1) - execjs (2.7.0) - factory_bot (4.10.0) - activesupport (>= 3.0.0) - factory_bot_rails (4.10.0) - factory_bot (~> 4.10.0) - railties (>= 3.0.0) + activemodel (8.0.2) + activesupport (= 8.0.2) + activerecord (8.0.2) + activemodel (= 8.0.2) + activesupport (= 8.0.2) + timeout (>= 0.4.0) + activestorage (8.0.2) + actionpack (= 8.0.2) + activejob (= 8.0.2) + activerecord (= 8.0.2) + activesupport (= 8.0.2) + marcel (~> 1.0) + activesupport (8.0.2) + base64 + benchmark (>= 0.3) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + ast (2.4.3) + autoprefixer-rails (10.4.21.0) + execjs (~> 2) + base64 (0.3.0) + benchmark (0.4.1) + bigdecimal (3.2.2) + bindex (0.8.1) + bootstrap (5.3.5) + popper_js (>= 2.11.8, < 3) + builder (3.3.0) + byebug (12.0.0) + coderay (1.1.3) + concurrent-ruby (1.3.5) + connection_pool (2.5.3) + crass (1.0.6) + date (3.4.1) + diff-lcs (1.6.2) + docile (1.4.1) + drb (2.2.3) + erb (5.0.2) + erubi (1.13.1) + execjs (2.10.0) + factory_bot (6.5.4) + activesupport (>= 6.1.0) + factory_bot_rails (6.5.0) + factory_bot (~> 6.5) + railties (>= 6.1.0) fast_stack (0.2.0) - ffi (1.9.25) + ffi (1.17.2-aarch64-linux-gnu) + ffi (1.17.2-aarch64-linux-musl) + ffi (1.17.2-arm-linux-gnu) + ffi (1.17.2-arm-linux-musl) + ffi (1.17.2-arm64-darwin) + ffi (1.17.2-x86_64-darwin) + ffi (1.17.2-x86_64-linux-gnu) + ffi (1.17.2-x86_64-linux-musl) flamegraph (0.9.5) - formatador (0.2.5) - globalid (0.4.1) - activesupport (>= 4.2.0) - guard (2.14.2) + formatador (1.2.0) + reline + globalid (1.2.1) + activesupport (>= 6.1) + guard (2.19.1) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) + logger (~> 1.6) lumberjack (>= 1.0.12, < 2.0) nenv (~> 0.1) notiffany (~> 0.0) - pry (>= 0.9.12) + ostruct (~> 0.6) + pry (>= 0.13.0) shellany (~> 0.0) thor (>= 0.18.1) guard-compat (1.2.1) @@ -85,176 +129,258 @@ GEM guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - i18n (1.0.1) + i18n (1.14.7) concurrent-ruby (~> 1.0) - jaro_winkler (1.5.1) - jquery-rails (4.3.3) + io-console (0.8.1) + irb (1.15.2) + pp (>= 0.6.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.1.0) - listen (3.1.5) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - ruby_dep (~> 1.2) - loofah (2.2.2) + json (2.13.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + listen (3.9.0) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + logger (1.7.0) + loofah (2.24.1) crass (~> 1.0.2) - nokogiri (>= 1.5.9) - lumberjack (1.0.13) - mail (2.7.0) + nokogiri (>= 1.12.0) + lumberjack (1.4.0) + mail (2.8.1) mini_mime (>= 0.1.1) - marcel (0.3.2) - mimemagic (~> 0.3.2) - memory_profiler (0.9.11) - method_source (0.9.0) - microformats (4.0.7) + net-imap + net-pop + net-smtp + marcel (1.0.4) + memory_profiler (1.1.0) + method_source (1.1.0) + microformats (4.5.0) json nokogiri - mimemagic (0.3.10) - nokogiri (~> 1) - rake - mini_mime (1.0.0) - mini_portile2 (2.3.0) - minitest (5.11.3) + mini_mime (1.1.5) + minitest (5.25.5) nenv (0.3.0) - nio4r (2.3.1) - nokogiri (1.8.4) - mini_portile2 (~> 2.3.0) - notiffany (0.1.1) + net-imap (0.5.9) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.1) + net-protocol + nio4r (2.7.4) + nokogiri (1.18.9-aarch64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.9-aarch64-linux-musl) + racc (~> 1.4) + nokogiri (1.18.9-arm-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.9-arm-linux-musl) + racc (~> 1.4) + nokogiri (1.18.9-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.9-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.18.9-x86_64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.9-x86_64-linux-musl) + racc (~> 1.4) + notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) - parallel (1.12.1) - parser (2.5.1.2) - ast (~> 2.4.0) - pg (1.0.0) - popper_js (1.14.3) - powerpack (0.1.2) - pry (0.11.3) - coderay (~> 1.1.0) - method_source (~> 0.9.0) - puma (3.12.0) - rack (2.0.5) - rack-mini-profiler (1.0.0) + ostruct (0.6.3) + parallel (1.27.0) + parser (3.3.9.0) + ast (~> 2.4.1) + racc + pg (1.6.1) + pg (1.6.1-aarch64-linux) + pg (1.6.1-aarch64-linux-musl) + pg (1.6.1-arm64-darwin) + pg (1.6.1-x86_64-darwin) + pg (1.6.1-x86_64-linux) + pg (1.6.1-x86_64-linux-musl) + popper_js (2.11.8) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) + prism (1.4.0) + pry (0.15.2) + coderay (~> 1.1) + method_source (~> 1.0) + psych (5.2.6) + date + stringio + puma (6.6.1) + nio4r (~> 2.0) + racc (1.8.1) + rack (3.2.0) + rack-mini-profiler (4.0.1) rack (>= 1.2.0) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (5.2.0) - actioncable (= 5.2.0) - actionmailer (= 5.2.0) - actionpack (= 5.2.0) - actionview (= 5.2.0) - activejob (= 5.2.0) - activemodel (= 5.2.0) - activerecord (= 5.2.0) - activestorage (= 5.2.0) - activesupport (= 5.2.0) - bundler (>= 1.3.0) - railties (= 5.2.0) - sprockets-rails (>= 2.0.0) - rails-controller-testing (1.0.2) - actionpack (~> 5.x, >= 5.0.1) - actionview (~> 5.x, >= 5.0.1) - activesupport (~> 5.x) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rack-session (2.1.1) + base64 (>= 0.1.0) + rack (>= 3.0.0) + rack-test (2.2.0) + rack (>= 1.3) + rackup (2.2.1) + rack (>= 3) + rails (8.0.2) + actioncable (= 8.0.2) + actionmailbox (= 8.0.2) + actionmailer (= 8.0.2) + actionpack (= 8.0.2) + actiontext (= 8.0.2) + actionview (= 8.0.2) + activejob (= 8.0.2) + activemodel (= 8.0.2) + activerecord (= 8.0.2) + activestorage (= 8.0.2) + activesupport (= 8.0.2) + bundler (>= 1.15.0) + railties (= 8.0.2) + rails-controller-testing (1.0.5) + actionpack (>= 5.0.1.rc1) + actionview (>= 5.0.1.rc1) + activesupport (>= 5.0.1.rc1) + rails-dom-testing (2.3.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.0.4) - loofah (~> 2.2, >= 2.2.2) - railties (5.2.0) - actionpack (= 5.2.0) - activesupport (= 5.2.0) - method_source - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rainbow (3.0.0) - rake (12.3.1) - rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) - rspec (3.8.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-core (3.8.0) - rspec-support (~> 3.8.0) - rspec-expectations (3.8.0) + rails-html-sanitizer (1.6.2) + loofah (~> 2.21) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (8.0.2) + actionpack (= 8.0.2) + activesupport (= 8.0.2) + irb (~> 1.13) + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.3.0) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rdoc (6.14.2) + erb + psych (>= 4.0.0) + regexp_parser (2.11.1) + reline (0.6.2) + io-console (~> 0.5) + rspec (3.13.1) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.5) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.8.0) - rspec-rails (3.8.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.0) - rubocop (0.58.2) - jaro_winkler (~> 1.5.1) + rspec-support (~> 3.13.0) + rspec-rails (8.0.1) + actionpack (>= 7.2) + activesupport (>= 7.2) + railties (>= 7.2) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.4) + rubocop (1.79.2) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) - parser (>= 2.5, != 2.5.1.1) - powerpack (~> 0.1) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.46.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - rubocop-rspec (1.27.0) - rubocop (>= 0.56.0) - ruby-progressbar (1.9.0) - ruby_dep (1.5.0) - sass (3.5.7) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) - railties (>= 4.0.0, < 6) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.46.0) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-rspec (3.6.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + ruby-progressbar (1.13.0) + sass-rails (6.0.0) + sassc-rails (~> 2.1, >= 2.1.1) + sassc (2.4.0) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + securerandom (0.4.1) shellany (0.0.1) - simplecov (0.16.1) + simplecov (0.22.0) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - spring (2.0.2) - activesupport (>= 4.2) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.13.2) + simplecov_json_formatter (0.1.4) + spring (4.4.0) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - spring-watcher-listen (2.0.1) + spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) - sprockets (3.7.2) + spring (>= 4) + sprockets (4.2.2) concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.2.1) - actionpack (>= 4.0) - activesupport (>= 4.0) + logger + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) sprockets (>= 3.0.0) - stackprof (0.2.12) - thor (0.20.0) - thread_safe (0.3.6) - tilt (2.0.8) - tzinfo (1.2.10) - thread_safe (~> 0.1) - uglifier (4.1.17) + stackprof (0.2.27) + stringio (3.1.7) + thor (1.4.0) + tilt (2.6.1) + timeout (0.4.3) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + uglifier (4.2.1) execjs (>= 0.3.0, < 3) - unicode-display_width (1.4.0) - web-console (3.6.2) - actionview (>= 5.0) - activemodel (>= 5.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) + uri (1.0.3) + useragent (0.16.11) + web-console (4.2.1) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) bindex (>= 0.4.0) - railties (>= 5.0) - websocket-driver (0.7.0) + railties (>= 6.0.0) + websocket-driver (0.8.0) + base64 websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) + websocket-extensions (0.1.5) + zeitwerk (2.7.3) PLATFORMS - ruby + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86_64-darwin + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES autoprefixer-rails @@ -265,14 +391,14 @@ DEPENDENCIES flamegraph guard-rspec jquery-rails - listen (~> 3.1.5) + listen memory_profiler - microformats (~> 4.0.7) + microformats nokogiri pg puma rack-mini-profiler - rails (~> 5.2.0) + rails rails-controller-testing rspec-rails rubocop @@ -281,14 +407,14 @@ DEPENDENCIES simplecov spring spring-commands-rspec - spring-watcher-listen (~> 2.0.0) + spring-watcher-listen stackprof tzinfo-data uglifier web-console RUBY VERSION - ruby 2.5.1p57 + ruby 3.4.5p51 BUNDLED WITH - 1.16.2 + 2.7.1 diff --git a/db/schema.rb b/db/schema.rb index 68bd598..9324442 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,18 +2,17 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2017_05_16_194159) do - +ActiveRecord::Schema[8.0].define(version: 2017_05_16_194159) do # These are extensions that must be enabled in order to support this database - enable_extension "plpgsql" + enable_extension "pg_catalog.plpgsql" create_table "submissions", force: :cascade do |t| t.text "html" @@ -24,5 +23,4 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false end - end diff --git a/spec/factories/submissions.rb b/spec/factories/submissions.rb index acfc922..ac4f619 100644 --- a/spec/factories/submissions.rb +++ b/spec/factories/submissions.rb @@ -1,9 +1,9 @@ FactoryBot.define do factory :submission do - url 'MyText' - html 'MyText' - base_url 'MyText' - save_html false - render_html_in_page false + url {'MyText'} + html {'MyText'} + base_url {'MyText'} + save_html {false} + render_html_in_page {false} end end From c4ee0f9806edfde476790906b08ad9c64392eecb Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:16:26 -0700 Subject: [PATCH 02/44] Add .ruby-version file --- .ruby-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..4f5e697 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.4.5 From 751497621a8dc00f48a1c72d32da45e4ccc74a6d Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:19:30 -0700 Subject: [PATCH 03/44] Create Rubocop TODO --- .rubocop.yml | 113 ++++++++------------------------------------------- Gemfile | 2 + Gemfile.lock | 11 +++++ 3 files changed, 30 insertions(+), 96 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5537838..29c3165 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,100 +1,21 @@ -require: rubocop-rspec +inherit_from: .rubocop_todo.yml -AllCops: - TargetRubyVersion: 2.5 - - Exclude: - - 'db/**/*' - - 'script/*' - - 'bin/*' - - 'log/**/*' - - 'node_modules/**/*' - - 'public/**/*' - - 'vendor/**/*' - - 'tmp/**/*' - - '.git/**/*' - -IndentationConsistency: - EnforcedStyle: 'rails' - -Naming/FileName: - Exclude: - - 'Gemfile' - - 'Guardfile' - - 'Rakefile' - -Rails: - Enabled: true - -Metrics/CyclomaticComplexity: - Max: 15 - -Metrics/PerceivedComplexity: - Max: 15 - -Metrics/ClassLength: - Max: 210 - -Metrics/ParameterLists: - Max: 6 - -Metrics/LineLength: - Max: 200 - -Metrics/MethodLength: - Max: 40 - -Metrics/BlockLength: - Max: 140 - - Exclude: - - 'spec/**/*' - -Metrics/AbcSize: - Max: 65 - -Style/Documentation: - Enabled: false - -Style/SymbolArray: - Enabled: false - -Style/MethodDefParentheses: - Enabled: false - -Style/AsciiComments: - Enabled: false - -Style/NestedParenthesizedCalls: - Enabled: false - -# TEMP: private and def foo() are at the same indentation level -# This should NOT cause an offense but it does. ¯\_(ツ)_/¯ -# https://rubocop.readthedocs.io/en/latest/cops_layout/ -Layout/IndentationWidth: - Enabled: false +plugins: + - rubocop-rails + - rubocop-rspec + - rubocop-factory_bot -Style/FrozenStringLiteralComment: - Enabled: false - -Rails/OutputSafety: - Enabled: false - -RSpec/NestedGroups: - Max: 4 - -RSpec/ExampleLength: - Max: 20 - -RSpec/MultipleExpectations: - Max: 10 - -RSpec/VerifiedDoubles: - Enabled: false - -RSpec/MessageSpies: - Enabled: false +AllCops: + NewCops: enable -RSpec/DescribeClass: Exclude: - - 'spec/system/*' + - "db/schema.rb" + - "vendor/**/*" + - "script/*" + - "bin/*" + - "log/**/*" + - "node_modules/**/*" + - "public/**/*" + - "vendor/**/*" + - "tmp/**/*" + - ".git/**/*" diff --git a/Gemfile b/Gemfile index 3abb7f0..6f62cf7 100644 --- a/Gemfile +++ b/Gemfile @@ -24,6 +24,8 @@ gem 'uglifier' # For codestyle guide and linting gem 'rubocop', require: false gem 'rubocop-rspec' +gem 'rubocop-rails' +gem 'rubocop-factory_bot' # dev and testing group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 23a7f02..2d3fb3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -309,6 +309,15 @@ GEM rubocop-ast (1.46.0) parser (>= 3.3.7.2) prism (~> 1.4) + rubocop-factory_bot (2.27.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rails (2.32.0) + activesupport (>= 4.2.0) + lint_roller (~> 1.1) + rack (>= 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) rubocop-rspec (3.6.0) lint_roller (~> 1.1) rubocop (~> 1.72, >= 1.72.1) @@ -402,6 +411,8 @@ DEPENDENCIES rails-controller-testing rspec-rails rubocop + rubocop-factory_bot + rubocop-rails rubocop-rspec sass-rails simplecov From e727888f9730e5523a7749fb25509f2d862d072a Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:20:53 -0700 Subject: [PATCH 04/44] Rubocop some things --- Gemfile | 4 ++-- spec/factories/submissions.rb | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 6f62cf7..f513f7a 100644 --- a/Gemfile +++ b/Gemfile @@ -23,9 +23,9 @@ gem 'uglifier' # For codestyle guide and linting gem 'rubocop', require: false -gem 'rubocop-rspec' -gem 'rubocop-rails' gem 'rubocop-factory_bot' +gem 'rubocop-rails' +gem 'rubocop-rspec' # dev and testing group :development, :test do diff --git a/spec/factories/submissions.rb b/spec/factories/submissions.rb index ac4f619..21761bf 100644 --- a/spec/factories/submissions.rb +++ b/spec/factories/submissions.rb @@ -1,9 +1,9 @@ FactoryBot.define do factory :submission do - url {'MyText'} - html {'MyText'} - base_url {'MyText'} - save_html {false} - render_html_in_page {false} + url { 'MyText' } + html { 'MyText' } + base_url { 'MyText' } + save_html { false } + render_html_in_page { false } end end From 7f413e2e5353d576fd7c586e9a8c1eef71437213 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:20:59 -0700 Subject: [PATCH 05/44] Rubocop some things --- .rubocop_todo.yml | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..33a6ec9 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,101 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2025-08-09 00:19:24 UTC using RuboCop version 1.79.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: 2 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Max: 15 + +# Offense count: 2 +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 7 + +# Offense count: 1 +# Configuration parameters: AssignmentOnly. +RSpec/InstanceVariable: + Exclude: + - "spec/views/submissions/show.html.erb_spec.rb" + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: slashes, arguments +Rails/FilePath: + Exclude: + - "config/environments/development.rb" + - "spec/rails_helper.rb" + +# Offense count: 1 +Rails/I18nLocaleTexts: + Exclude: + - "app/controllers/submissions_controller.rb" + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Include. +# Include: **/app/controllers/**/*.rb +Rails/StrongParametersExpect: + Exclude: + - "app/controllers/submissions_controller.rb" + +# Offense count: 2 +# Configuration parameters: Include. +# Include: db/**/*.rb +Rails/ThreeStateBooleanColumn: + Exclude: + - "db/migrate/20170516194159_create_submissions.rb" + +# Offense count: 10 +# Configuration parameters: AllowedConstants. +Style/Documentation: + Exclude: + - "app/controllers/application_controller.rb" + - "app/controllers/microformats_controller.rb" + - "app/controllers/submissions_controller.rb" + - "app/helpers/application_helper.rb" + - "app/helpers/microformats_helper.rb" + - "app/helpers/submissions_helper.rb" + - "app/mailers/application_mailer.rb" + - "app/models/application_record.rb" + - "config/application.rb" + - "db/migrate/20170516194159_create_submissions.rb" + +# Offense count: 47 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/GlobalStdStream: + Exclude: + - "config/environments/production.rb" + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantConstantBase: + Exclude: + - "config/environments/production.rb" + - "spec/rails_helper.rb" + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: SafeForConstants. +Style/RedundantFetchBlock: + Exclude: + - "config/puma.rb" + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinSize. +# SupportedStyles: percent, brackets +Style/SymbolArray: + EnforcedStyle: brackets From 088ac0bf5fc5fee8f04ea0c7c7abeb6ef5e1a13e Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:21:24 -0700 Subject: [PATCH 06/44] Rubocop: Rails/FilePath --- .rubocop_todo.yml | 9 --------- config/environments/development.rb | 2 +- spec/rails_helper.rb | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 33a6ec9..330fd65 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -22,15 +22,6 @@ RSpec/InstanceVariable: Exclude: - "spec/views/submissions/show.html.erb_spec.rb" -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: slashes, arguments -Rails/FilePath: - Exclude: - - "config/environments/development.rb" - - "spec/rails_helper.rb" - # Offense count: 1 Rails/I18nLocaleTexts: Exclude: diff --git a/config/environments/development.rb b/config/environments/development.rb index 5e3eb42..5259890 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -13,7 +13,7 @@ config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. - if Rails.root.join('tmp', 'caching-dev.txt').exist? + if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.cache_store = :memory_store diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index fae29fd..a3283de 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -28,7 +28,7 @@ RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_path = "#{Rails.root.join("spec/fixtures")}" # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false From 364381a33905ffdf4219e608cb79121e1055b706 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:21:45 -0700 Subject: [PATCH 07/44] Rubocop: Rails/StrongParametersExpect --- .rubocop_todo.yml | 8 -------- app/controllers/submissions_controller.rb | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 330fd65..a303f24 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -27,14 +27,6 @@ Rails/I18nLocaleTexts: Exclude: - "app/controllers/submissions_controller.rb" -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Include. -# Include: **/app/controllers/**/*.rb -Rails/StrongParametersExpect: - Exclude: - - "app/controllers/submissions_controller.rb" - # Offense count: 2 # Configuration parameters: Include. # Include: db/**/*.rb diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 63f82a2..cd7ffd7 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -58,6 +58,6 @@ def set_submission # Only allow a trusted parameter "white list" through. def submission_params - params.require(:submission).permit(:url, :html, :base_url, :save_html, :render_html_in_page) + params.expect(submission: [:url, :html, :base_url, :save_html, :render_html_in_page]) end end From 63a0d395e18878f629e66f86753e26b16f3378b9 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:22:50 -0700 Subject: [PATCH 08/44] Rubocop: Style/StringLiterals --- .rubocop.yml | 5 +++-- .rubocop_todo.yml | 7 ------- config/environments/development.rb | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 29c3165..a3eaed4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,10 +7,8 @@ plugins: AllCops: NewCops: enable - Exclude: - "db/schema.rb" - - "vendor/**/*" - "script/*" - "bin/*" - "log/**/*" @@ -19,3 +17,6 @@ AllCops: - "vendor/**/*" - "tmp/**/*" - ".git/**/*" + +Style/FrozenStringLiteralComment: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a303f24..5575def 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -49,13 +49,6 @@ Style/Documentation: - "config/application.rb" - "db/migrate/20170516194159_create_submissions.rb" -# Offense count: 47 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: always, always_true, never -Style/FrozenStringLiteralComment: - Enabled: false - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/GlobalStdStream: diff --git a/config/environments/development.rb b/config/environments/development.rb index 5259890..5187e22 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -13,7 +13,7 @@ config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. - if Rails.root.join("tmp/caching-dev.txt").exist? + if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true config.cache_store = :memory_store From e58e8e93b92450e0e6d8063dc212a0bb98b4e639 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:23:25 -0700 Subject: [PATCH 09/44] Rubocop: Style/StringLiteralsInInterpolation --- spec/rails_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index a3283de..b15778c 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -28,7 +28,7 @@ RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{Rails.root.join("spec/fixtures")}" + config.fixture_path = "#{Rails.root.join('spec/fixtures')}" # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false From 6aa4038105917a2d787f0fca3b670a89f31a21d4 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:24:27 -0700 Subject: [PATCH 10/44] RSpecRails/InferredSpecType --- .rubocop.yml | 1 + Gemfile | 1 + Gemfile.lock | 5 +++++ spec/controllers/microformats_controller_spec.rb | 2 +- spec/controllers/submissions_controller_spec.rb | 2 +- spec/helpers/microformats_helper_spec.rb | 2 +- spec/helpers/submissions_helper_spec.rb | 2 +- spec/models/submission_spec.rb | 2 +- spec/requests/submissions_spec.rb | 2 +- spec/routing/submissions_routing_spec.rb | 2 +- spec/views/microformats/show.html.erb_spec.rb | 2 +- spec/views/submissions/new.html.erb_spec.rb | 2 +- spec/views/submissions/show.html.erb_spec.rb | 2 +- 13 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a3eaed4..8b3123e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,7 @@ plugins: - rubocop-rails - rubocop-rspec - rubocop-factory_bot + - rubocop-rspec_rails AllCops: NewCops: enable diff --git a/Gemfile b/Gemfile index f513f7a..a939f89 100644 --- a/Gemfile +++ b/Gemfile @@ -26,6 +26,7 @@ gem 'rubocop', require: false gem 'rubocop-factory_bot' gem 'rubocop-rails' gem 'rubocop-rspec' +gem 'rubocop-rspec_rails' # dev and testing group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index 2d3fb3a..0683c81 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -321,6 +321,10 @@ GEM rubocop-rspec (3.6.0) lint_roller (~> 1.1) rubocop (~> 1.72, >= 1.72.1) + rubocop-rspec_rails (2.31.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) + rubocop-rspec (~> 3.5) ruby-progressbar (1.13.0) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) @@ -414,6 +418,7 @@ DEPENDENCIES rubocop-factory_bot rubocop-rails rubocop-rspec + rubocop-rspec_rails sass-rails simplecov spring diff --git a/spec/controllers/microformats_controller_spec.rb b/spec/controllers/microformats_controller_spec.rb index 06c3ba8..d78d748 100644 --- a/spec/controllers/microformats_controller_spec.rb +++ b/spec/controllers/microformats_controller_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe MicroformatsController, type: :controller do +RSpec.describe MicroformatsController do describe 'GET #show' do it 'returns http redirect' do get :show diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index 69d32bd..17c3029 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -23,7 +23,7 @@ # removed from Rails core in Rails 5, but can be added back in via the # `rails-controller-testing` gem. -RSpec.describe SubmissionsController, type: :controller do +RSpec.describe SubmissionsController do # This should return the minimal set of attributes required to create a valid # Submission. As you add validations to Submission, be sure to # adjust the attributes here as well. diff --git a/spec/helpers/microformats_helper_spec.rb b/spec/helpers/microformats_helper_spec.rb index ffe2f13..5e17f5d 100644 --- a/spec/helpers/microformats_helper_spec.rb +++ b/spec/helpers/microformats_helper_spec.rb @@ -10,6 +10,6 @@ # end # end # end -RSpec.describe MicroformatsHelper, type: :helper do +RSpec.describe MicroformatsHelper do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/helpers/submissions_helper_spec.rb b/spec/helpers/submissions_helper_spec.rb index 591f28c..7455a2b 100644 --- a/spec/helpers/submissions_helper_spec.rb +++ b/spec/helpers/submissions_helper_spec.rb @@ -10,6 +10,6 @@ # end # end # end -RSpec.describe SubmissionsHelper, type: :helper do +RSpec.describe SubmissionsHelper do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb index 68fa859..88d6761 100644 --- a/spec/models/submission_spec.rb +++ b/spec/models/submission_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe Submission, type: :model do +RSpec.describe Submission do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/requests/submissions_spec.rb b/spec/requests/submissions_spec.rb index 2919f0f..3cf0eae 100644 --- a/spec/requests/submissions_spec.rb +++ b/spec/requests/submissions_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe 'Submissions', type: :request do +RSpec.describe 'Submissions' do describe 'GET /submissions' do it 'works! (now write some real specs)' do get submissions_path diff --git a/spec/routing/submissions_routing_spec.rb b/spec/routing/submissions_routing_spec.rb index 4acbf43..2e5a343 100644 --- a/spec/routing/submissions_routing_spec.rb +++ b/spec/routing/submissions_routing_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe SubmissionsController, type: :routing do +RSpec.describe SubmissionsController do describe 'routing' do it 'routes to #index' do expect(get: '/submissions').to route_to('submissions#index') diff --git a/spec/views/microformats/show.html.erb_spec.rb b/spec/views/microformats/show.html.erb_spec.rb index 91ce3ee..4dcc7ac 100644 --- a/spec/views/microformats/show.html.erb_spec.rb +++ b/spec/views/microformats/show.html.erb_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe 'microformats/show.html.erb', type: :view do +RSpec.describe 'microformats/show.html.erb' do pending "add some examples to (or delete) #{__FILE__}" end diff --git a/spec/views/submissions/new.html.erb_spec.rb b/spec/views/submissions/new.html.erb_spec.rb index 165cba1..1068b6e 100644 --- a/spec/views/submissions/new.html.erb_spec.rb +++ b/spec/views/submissions/new.html.erb_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe 'submissions/new', type: :view do +RSpec.describe 'submissions/new' do before do assign(:submission, Submission.new( html: 'MyText', diff --git a/spec/views/submissions/show.html.erb_spec.rb b/spec/views/submissions/show.html.erb_spec.rb index 89afda9..e09b8f2 100644 --- a/spec/views/submissions/show.html.erb_spec.rb +++ b/spec/views/submissions/show.html.erb_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe 'submissions/show', type: :view do +RSpec.describe 'submissions/show' do before do @submission = assign(:submission, Submission.create!( html: 'MyText', From 642f6c2e98dc870af02174c0a07892913bbbd612 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:27:20 -0700 Subject: [PATCH 11/44] Style/RedundantInterpolation --- spec/rails_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index b15778c..6eb5338 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -28,7 +28,7 @@ RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{Rails.root.join('spec/fixtures')}" + config.fixture_path = Rails.root.join('spec/fixtures').to_s # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false From 96e29ffaa721ddc146dd6ee9139575326616aac7 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:35:49 -0700 Subject: [PATCH 12/44] Remove Spring --- Gemfile | 22 ++++++++-------------- Gemfile.lock | 15 --------------- bin/bundle | 2 +- bin/dev | 2 ++ bin/rails | 5 ----- bin/rake | 5 ----- bin/rspec | 3 +++ bin/rubocop | 8 ++++++++ bin/setup | 11 +---------- bin/spring | 17 ----------------- bin/yarn | 11 ----------- config/spring.rb | 6 ------ 12 files changed, 23 insertions(+), 84 deletions(-) create mode 100755 bin/dev create mode 100755 bin/rspec create mode 100755 bin/rubocop delete mode 100755 bin/spring delete mode 100755 bin/yarn delete mode 100644 config/spring.rb diff --git a/Gemfile b/Gemfile index a939f89..4b1f48f 100644 --- a/Gemfile +++ b/Gemfile @@ -11,23 +11,15 @@ gem 'pg' # webserver gem 'puma' -# webserver +# parser gem 'microformats' # assets gem 'autoprefixer-rails' gem 'bootstrap' -gem 'jquery-rails' gem 'sass-rails' gem 'uglifier' -# For codestyle guide and linting -gem 'rubocop', require: false -gem 'rubocop-factory_bot' -gem 'rubocop-rails' -gem 'rubocop-rspec' -gem 'rubocop-rspec_rails' - # dev and testing group :development, :test do gem 'byebug', platform: :mri @@ -37,16 +29,18 @@ group :development, :test do gem 'rails-controller-testing' gem 'rspec-rails' gem 'simplecov', require: false - gem 'spring-commands-rspec' + + # For codestyle guide and linting + gem 'rubocop', require: false + gem 'rubocop-factory_bot' + gem 'rubocop-rails' + gem 'rubocop-rspec' + gem 'rubocop-rspec_rails' end # dev group :development do - gem 'listen' - gem 'spring' - gem 'spring-watcher-listen' gem 'web-console' - # For measuring page/code performance gem 'rack-mini-profiler' diff --git a/Gemfile.lock b/Gemfile.lock index 0683c81..18cb31a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -136,10 +136,6 @@ GEM pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - jquery-rails (4.6.0) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) json (2.13.2) language_server-protocol (3.17.0.5) lint_roller (1.1.0) @@ -344,12 +340,6 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.13.2) simplecov_json_formatter (0.1.4) - 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.2) concurrent-ruby (~> 1.0) logger @@ -403,8 +393,6 @@ DEPENDENCIES fast_stack flamegraph guard-rspec - jquery-rails - listen memory_profiler microformats nokogiri @@ -421,9 +409,6 @@ DEPENDENCIES rubocop-rspec_rails sass-rails simplecov - spring - spring-commands-rspec - spring-watcher-listen stackprof tzinfo-data uglifier diff --git a/bin/bundle b/bin/bundle index 66e9889..f19acf5 100755 --- a/bin/bundle +++ b/bin/bundle @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) load Gem.bin_path('bundler', 'bundle') diff --git a/bin/dev b/bin/dev new file mode 100755 index 0000000..52088a3 --- /dev/null +++ b/bin/dev @@ -0,0 +1,2 @@ +#!/usr/bin/env ruby +exec './bin/rails', 'server', *ARGV diff --git a/bin/rails b/bin/rails index 5badb2f..0739660 100755 --- a/bin/rails +++ b/bin/rails @@ -1,9 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index d87d5f5..1724048 100755 --- a/bin/rake +++ b/bin/rake @@ -1,9 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path('../spring', __FILE__) -rescue LoadError => e - raise unless e.message.include?('spring') -end require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 0000000..d72fadf --- /dev/null +++ b/bin/rspec @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +require 'bundler/setup' +load Gem.bin_path('rspec-core', 'rspec') diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000..b3ed7c5 --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +require 'rubygems' +require 'bundler/setup' + +# explicit rubocop config increases performance slightly while avoiding config confusion. +ARGV.unshift('--config', File.expand_path('../.rubocop.yml', __dir__)) + +load Gem.bin_path('rubocop', 'rubocop') diff --git a/bin/setup b/bin/setup index 78c4e86..8de5867 100755 --- a/bin/setup +++ b/bin/setup @@ -4,7 +4,7 @@ require 'fileutils' include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = Pathname.new File.expand_path('..', __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") @@ -18,15 +18,6 @@ chdir APP_ROOT do system! 'gem install bundler --conservative' system('bundle check') || system!('bundle install') - # Install JavaScript dependencies if using Yarn - # system('bin/yarn') - - - # puts "\n== Copying sample files ==" - # unless File.exist?('config/database.yml') - # cp 'config/database.yml.sample', 'config/database.yml' - # end - puts "\n== Preparing database ==" system! 'bin/rails db:setup' diff --git a/bin/spring b/bin/spring deleted file mode 100755 index fb2ec2e..0000000 --- a/bin/spring +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env ruby - -# This file loads spring without using Bundler, in order to be fast. -# It gets overwritten when you run the `spring binstub` command. - -unless defined?(Spring) - require 'rubygems' - require 'bundler' - - lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) - spring = lockfile.specs.detect { |spec| spec.name == "spring" } - if spring - Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path - gem 'spring', spring.version - require 'spring/binstub' - end -end diff --git a/bin/yarn b/bin/yarn deleted file mode 100755 index c2bacef..0000000 --- a/bin/yarn +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env ruby -VENDOR_PATH = File.expand_path('..', __dir__) -Dir.chdir(VENDOR_PATH) do - begin - exec "yarnpkg #{ARGV.join(" ")}" - rescue Errno::ENOENT - $stderr.puts "Yarn executable was not detected in the system." - $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" - exit 1 - end -end diff --git a/config/spring.rb b/config/spring.rb deleted file mode 100644 index 9fa7863..0000000 --- a/config/spring.rb +++ /dev/null @@ -1,6 +0,0 @@ -%w[ - .ruby-version - .rbenv-vars - tmp/restart.txt - tmp/caching-dev.txt -].each { |path| Spring.watch(path) } From 96d329b09a7d22ef12445fb9cb026f36de3b5fc9 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 17:40:11 -0700 Subject: [PATCH 13/44] HTTPS links in footer --- app/views/layouts/application.html.erb | 7 +++---- db/schema.rb | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e4f2361..c6d70fa 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,8 +7,7 @@ Ruby Microformats Parser <%= csrf_meta_tags %> - <%= stylesheet_link_tag "application", media: "all" %> - <%= javascript_include_tag "application" %> + <%= stylesheet_link_tag "application", media: "all" %> @@ -34,8 +33,8 @@
  • Other Microformats Parser websites: PHP, - Node, - Python, + Node, + Python, Go
  • diff --git a/db/schema.rb b/db/schema.rb index 9324442..18f7709 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -20,7 +20,7 @@ t.text "json" t.boolean "save_html" t.boolean "render_html_in_page" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false end end From 9150d1f05267a3690e99087d62af169bdb1d9881 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 19:17:09 -0700 Subject: [PATCH 14/44] Update Bootstrap-isms and views --- .rubocop.yml | 4 ++ app/assets/stylesheets/application.scss | 19 ------- app/controllers/submissions_controller.rb | 21 ++++---- app/helpers/application_helper.rb | 13 +++++ app/views/layouts/application.html.erb | 51 +++++++++++------- app/views/submissions/_form.html.erb | 55 -------------------- app/views/submissions/_submission.html.erb | 60 ++++++++++++++++++++++ app/views/submissions/new.html.erb | 22 ++++---- app/views/submissions/show.html.erb | 16 +++--- 9 files changed, 136 insertions(+), 125 deletions(-) delete mode 100644 app/views/submissions/_form.html.erb create mode 100644 app/views/submissions/_submission.html.erb diff --git a/.rubocop.yml b/.rubocop.yml index 8b3123e..ab169a0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,3 +21,7 @@ AllCops: Style/FrozenStringLiteralComment: Enabled: false + +Layout/HashAlignment: + EnforcedHashRocketStyle: table + EnforcedColonStyle: table diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 61ad10d..e69de29 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,19 +0,0 @@ -@import "bootstrap"; - -form { - label { - font-weight: bold; - } - - textarea, - input[type=url], - input[type=text] { - font-family: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; - } - - .form-control:disabled { - cursor: default; - background: #efefef; - color: black; - } -} diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index cd7ffd7..154a0d0 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -1,10 +1,9 @@ class SubmissionsController < ApplicationController before_action :set_submission, only: [:show, :edit, :update, :destroy] + before_action :redirect_to_root, only: [:index, :edit, :update, :destroy] # GET /submissions - def index - redirect_to new_submission_path - end + def index; end # GET /submissions/1 def show; end @@ -15,9 +14,7 @@ def new end # GET /submissions/1/edit - def edit - redirect_to new_submission_path - end + def edit; end # POST /submissions def create @@ -40,14 +37,10 @@ def create end # PATCH/PUT /submissions/1 - def update - redirect_to new_submission_path - end + def update; end # DELETE /submissions/1 - def destroy - redirect_to new_submission_path - end + def destroy; end private @@ -56,6 +49,10 @@ def set_submission @submission = Submission.find(params[:id]) end + def redirect_to_root + redirect_to root_path + end + # Only allow a trusted parameter "white list" through. def submission_params params.expect(submission: [:url, :html, :base_url, :save_html, :render_html_in_page]) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..e1c341f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,15 @@ module ApplicationHelper + BOOTSTRAP_VERSION = '5.3.7'.freeze + BOOTSTRAP_CSS_INTEGRITY = 'sha384-LN+7fdVzj6u52u30Kp6M/trliBMCMKTyK833zpbD+pXdCLuTusPj697FH4R/5mcr'.freeze + + def bootstrap_stylesheet_link_tag + stylesheet_link_tag "https://cdn.jsdelivr.net/npm/bootstrap@#{BOOTSTRAP_VERSION}/dist/css/bootstrap.min.css", + media: 'all', + integrity: BOOTSTRAP_CSS_INTEGRITY, + crossorigin: 'anonymous' + end + + def on_results_page? + action_name != 'new' + end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c6d70fa..6133f47 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,45 +1,58 @@ - - - + + Ruby Microformats Parser <%= csrf_meta_tags %> - - <%= stylesheet_link_tag "application", media: "all" %> + <%= bootstrap_stylesheet_link_tag %> + + + -
    - +
    <% if notice.present? %> -
    diff --git a/app/views/submissions/_form.html.erb b/app/views/submissions/_form.html.erb deleted file mode 100644 index fca3d79..0000000 --- a/app/views/submissions/_form.html.erb +++ /dev/null @@ -1,55 +0,0 @@ -<%= form_with model: submission, local: true, class: "mb-5" do |form| %> - <% if submission.errors.any? %> -
    -

    <%= pluralize(submission.errors.count, "error") %> prohibited this submission from being saved:

    - -
      - <% submission.errors.full_messages.each do |message| %> -
    • <%= message %>
    • - <% end %> -
    -
    - <% end %> - -
    - <%= form.label :html, "HTML" %> - <%= form.text_area :html, id: :submission_html, class: "form-control form-control-lg", rows: 6, disabled: submission.id.present? %> -
    - -
    - <%= form.label :base_url, "Base URL" %> - <%= form.url_field :base_url, id: :submission_base_url, class: "form-control form-control-lg", disabled: submission.id.present? %> -
    - - <% unless action_name == "new" %> -
    - <%= form.label :json, "JSON" %> - <%= form.text_area :json, id: :submission_json, class: "form-control form-control-lg", rows: 10, disabled: submission.id.present? %> -
    - <% end %> - - <% if submission.id.blank? %> -
    - -
    - -
    - -
    - -
    - <%= form.submit "Parse", class: "btn btn-lg btn-success" %> -
    - <% end %> - -<% end %> diff --git a/app/views/submissions/_submission.html.erb b/app/views/submissions/_submission.html.erb new file mode 100644 index 0000000..8e22f31 --- /dev/null +++ b/app/views/submissions/_submission.html.erb @@ -0,0 +1,60 @@ +<%= form_with model: submission, class: 'mb-5' do |form| %> + <% if submission.errors.any? %> +
    +

    <%= pluralize(submission.errors.count, 'error') %> prohibited this submission from being saved:

    + +
      + <% submission.errors.full_messages.each do |message| %> +
    • <%= message %>
    • + <% end %> +
    +
    + <% end %> + +
    + <%= form.label :html, :HTML %> + <%= form.text_area :html, + id: :submission_html, + class: 'form-control form-control-lg font-monospace', + rows: 6, + disabled: on_results_page?, + readonly: on_results_page? %> +
    + +
    + <%= form.label :base_url, 'Base URL' %> + <%= form.url_field :base_url, + id: :submission_base_url, + class: 'form-control form-control-lg font-monospace', + disabled: on_results_page?, + readonly: on_results_page? %> +
    + + <% if on_results_page? %> +
    + <%= form.label :json, :JSON %> + <%= form.text_area :json, + id: :submission_json, + class: 'form-control form-control-lg font-monospace', + rows: 10, + disabled: true, + readonly: true %> +
    + <% end %> + + <% unless on_results_page? %> +
    +
    + <%= form.check_box :save_html, id: :submission_save_html, class: 'form-check-input' %> + <%= form.label :save_html, 'Save HTML?', for: :submission_save_html %> +
    + +
    + <%= form.check_box :render_html_in_page, id: :submission_render_html_in_page, class: 'form-check-input' %> + <%= form.label :render_html_in_page, 'Render HTML in Page?', for: :submission_render_html_in_page %> +
    +
    + + <%= form.submit 'Parse', class: 'btn btn-lg btn-success' %> + <% end %> +<% end %> diff --git a/app/views/submissions/new.html.erb b/app/views/submissions/new.html.erb index 6d77bad..49b0561 100644 --- a/app/views/submissions/new.html.erb +++ b/app/views/submissions/new.html.erb @@ -1,16 +1,14 @@ -<%= form_with url: "/microformats", method: "get", local: true do |form| %> -
    - <%= form.label :url, "Enter a URL" %> - <%= form.url_field :url, id: :submission_url, placeholder: "https://example.com/person.html", class: "form-control form-control-lg" %> +<%= form_with url: :microformats, method: :get, class: 'mb-5', enforce_utf8: false do |form| %> +
    + <%= form.label :url, 'Enter a URL' %> + <%= form.url_field :url, + id: :submission_url, + placeholder: 'https://example.com/person.html', + class: 'form-control form-control-lg font-monospace' %>
    -
    - -
    + <%= form.submit :Parse, class: 'btn btn-lg btn-success', name: nil %> <% end %> - -

    OR parse just a snippet of HTML

    - - -<%= render "form", submission: @submission %> +

    OR parse just a snippet of HTML

    +<%= render @submission %> diff --git a/app/views/submissions/show.html.erb b/app/views/submissions/show.html.erb index 2d955fe..9a7ab4e 100644 --- a/app/views/submissions/show.html.erb +++ b/app/views/submissions/show.html.erb @@ -1,13 +1,13 @@ -<%= render "form", submission: @submission %> +<%= render @submission %> <% if @submission.render_html_in_page? %> -
    -
    - Rendered HTML -
    +
    +
    + Rendered HTML +
    -
    - <%= simple_format @submission.html %> +
    + <%= simple_format @submission.html %> +
    -
    <% end %> From 9d71124ca96a78c2b7fde2ad09550200351cb761 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 19:21:47 -0700 Subject: [PATCH 15/44] Remove a bunch of obviated gems --- Gemfile | 35 ++------- Gemfile.lock | 109 ----------------------------- config/environments/development.rb | 6 +- config/initializers/assets.rb | 14 ---- 4 files changed, 8 insertions(+), 156 deletions(-) delete mode 100644 config/initializers/assets.rb diff --git a/Gemfile b/Gemfile index 4b1f48f..6297bf0 100644 --- a/Gemfile +++ b/Gemfile @@ -14,43 +14,18 @@ gem 'puma' # parser gem 'microformats' -# assets -gem 'autoprefixer-rails' -gem 'bootstrap' -gem 'sass-rails' -gem 'uglifier' - # dev and testing group :development, :test do - gem 'byebug', platform: :mri gem 'factory_bot_rails' - gem 'guard-rspec' - gem 'nokogiri' gem 'rails-controller-testing' gem 'rspec-rails' - gem 'simplecov', require: false # For codestyle guide and linting - gem 'rubocop', require: false - gem 'rubocop-factory_bot' - gem 'rubocop-rails' - gem 'rubocop-rspec' - gem 'rubocop-rspec_rails' -end - -# dev -group :development do - gem 'web-console' - # For measuring page/code performance - gem 'rack-mini-profiler' - - # For memory profiling - gem 'memory_profiler' - - # For call-stack profiling flamegraphs - gem 'fast_stack' - gem 'flamegraph' - gem 'stackprof' + gem 'rubocop', require: false + gem 'rubocop-factory_bot', require: false + gem 'rubocop-rails', require: false + gem 'rubocop-rspec', require: false + gem 'rubocop-rspec_rails', require: false end # windows dev diff --git a/Gemfile.lock b/Gemfile.lock index 18cb31a..01fed55 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -73,62 +73,25 @@ GEM tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) ast (2.4.3) - autoprefixer-rails (10.4.21.0) - execjs (~> 2) base64 (0.3.0) benchmark (0.4.1) bigdecimal (3.2.2) - bindex (0.8.1) - bootstrap (5.3.5) - popper_js (>= 2.11.8, < 3) builder (3.3.0) - byebug (12.0.0) - coderay (1.1.3) concurrent-ruby (1.3.5) connection_pool (2.5.3) crass (1.0.6) date (3.4.1) diff-lcs (1.6.2) - docile (1.4.1) drb (2.2.3) erb (5.0.2) erubi (1.13.1) - execjs (2.10.0) factory_bot (6.5.4) activesupport (>= 6.1.0) factory_bot_rails (6.5.0) factory_bot (~> 6.5) railties (>= 6.1.0) - fast_stack (0.2.0) - ffi (1.17.2-aarch64-linux-gnu) - ffi (1.17.2-aarch64-linux-musl) - ffi (1.17.2-arm-linux-gnu) - ffi (1.17.2-arm-linux-musl) - ffi (1.17.2-arm64-darwin) - ffi (1.17.2-x86_64-darwin) - ffi (1.17.2-x86_64-linux-gnu) - ffi (1.17.2-x86_64-linux-musl) - flamegraph (0.9.5) - formatador (1.2.0) - reline globalid (1.2.1) activesupport (>= 6.1) - guard (2.19.1) - formatador (>= 0.2.4) - listen (>= 2.7, < 4.0) - logger (~> 1.6) - lumberjack (>= 1.0.12, < 2.0) - nenv (~> 0.1) - notiffany (~> 0.0) - ostruct (~> 0.6) - pry (>= 0.13.0) - shellany (~> 0.0) - thor (>= 0.18.1) - guard-compat (1.2.1) - guard-rspec (4.7.3) - guard (~> 2.1) - guard-compat (~> 1.1) - rspec (>= 2.99.0, < 4.0) i18n (1.14.7) concurrent-ruby (~> 1.0) io-console (0.8.1) @@ -139,28 +102,21 @@ GEM json (2.13.2) language_server-protocol (3.17.0.5) lint_roller (1.1.0) - listen (3.9.0) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) logger (1.7.0) loofah (2.24.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) - lumberjack (1.4.0) mail (2.8.1) mini_mime (>= 0.1.1) net-imap net-pop net-smtp marcel (1.0.4) - memory_profiler (1.1.0) - method_source (1.1.0) microformats (4.5.0) json nokogiri mini_mime (1.1.5) minitest (5.25.5) - nenv (0.3.0) net-imap (0.5.9) date net-protocol @@ -187,10 +143,6 @@ GEM racc (~> 1.4) nokogiri (1.18.9-x86_64-linux-musl) racc (~> 1.4) - notiffany (0.1.3) - nenv (~> 0.1) - shellany (~> 0.0) - ostruct (0.6.3) parallel (1.27.0) parser (3.3.9.0) ast (~> 2.4.1) @@ -202,14 +154,10 @@ GEM pg (1.6.1-x86_64-darwin) pg (1.6.1-x86_64-linux) pg (1.6.1-x86_64-linux-musl) - popper_js (2.11.8) pp (0.6.2) prettyprint prettyprint (0.2.0) prism (1.4.0) - pry (0.15.2) - coderay (~> 1.1) - method_source (~> 1.0) psych (5.2.6) date stringio @@ -217,8 +165,6 @@ GEM nio4r (~> 2.0) racc (1.8.1) rack (3.2.0) - rack-mini-profiler (4.0.1) - rack (>= 1.2.0) rack-session (2.1.1) base64 (>= 0.1.0) rack (>= 3.0.0) @@ -261,19 +207,12 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.3.0) - rb-fsevent (0.11.2) - rb-inotify (0.11.1) - ffi (~> 1.0) rdoc (6.14.2) erb psych (>= 4.0.0) regexp_parser (2.11.1) reline (0.6.2) io-console (~> 0.5) - rspec (3.13.1) - rspec-core (~> 3.13.0) - rspec-expectations (~> 3.13.0) - rspec-mocks (~> 3.13.0) rspec-core (3.13.5) rspec-support (~> 3.13.0) rspec-expectations (3.13.5) @@ -322,51 +261,17 @@ GEM rubocop (~> 1.72, >= 1.72.1) rubocop-rspec (~> 3.5) ruby-progressbar (1.13.0) - sass-rails (6.0.0) - sassc-rails (~> 2.1, >= 2.1.1) - sassc (2.4.0) - ffi (~> 1.9) - sassc-rails (2.1.2) - railties (>= 4.0.0) - sassc (>= 2.0) - sprockets (> 3.0) - sprockets-rails - tilt securerandom (0.4.1) - shellany (0.0.1) - simplecov (0.22.0) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-html (0.13.2) - simplecov_json_formatter (0.1.4) - 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) - stackprof (0.2.27) stringio (3.1.7) thor (1.4.0) - tilt (2.6.1) timeout (0.4.3) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uglifier (4.2.1) - execjs (>= 0.3.0, < 3) unicode-display_width (3.1.4) unicode-emoji (~> 4.0, >= 4.0.4) unicode-emoji (4.0.4) uri (1.0.3) useragent (0.16.11) - web-console (4.2.1) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) - bindex (>= 0.4.0) - railties (>= 6.0.0) websocket-driver (0.8.0) base64 websocket-extensions (>= 0.1.0) @@ -386,19 +291,10 @@ PLATFORMS x86_64-linux-musl DEPENDENCIES - autoprefixer-rails - bootstrap - byebug factory_bot_rails - fast_stack - flamegraph - guard-rspec - memory_profiler microformats - nokogiri pg puma - rack-mini-profiler rails rails-controller-testing rspec-rails @@ -407,12 +303,7 @@ DEPENDENCIES rubocop-rails rubocop-rspec rubocop-rspec_rails - sass-rails - simplecov - stackprof tzinfo-data - uglifier - web-console RUBY VERSION ruby 3.4.5p51 diff --git a/config/environments/development.rb b/config/environments/development.rb index 5187e22..ee4e300 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -40,15 +40,15 @@ # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. - config.assets.debug = true + # config.assets.debug = true # Suppress logger output for asset requests. - config.assets.quiet = true + # config.assets.quiet = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. - config.file_watcher = ActiveSupport::EventedFileUpdateChecker + # config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb deleted file mode 100644 index 4b828e8..0000000 --- a/config/initializers/assets.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' - -# Add additional assets to the asset load path. -# Rails.application.config.assets.paths << Emoji.images_path -# Add Yarn node_modules folder to the asset load path. -Rails.application.config.assets.paths << Rails.root.join('node_modules') - -# Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in the app/assets -# folder are already added. -# Rails.application.config.assets.precompile += %w( admin.js admin.css ) From 9f78c64ae10b42c8f726272e7b410dcace402555 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 19:27:20 -0700 Subject: [PATCH 16/44] Update code of conduct to latest code covenant --- CODE_OF_CONDUCT.md | 119 +++++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 54 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 0224d95..071f00c 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,74 +1,85 @@ -# Contributor Covenant Code of Conduct +# Contributor Covenant 3.0 Code of Conduct ## Our Pledge -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, gender identity and expression, level of experience, -nationality, personal appearance, race, religion, or sexual identity and -orientation. +We pledge to make our community welcoming, safe, and equitable for all. -## Our Standards +We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of characteristics including race, ethnicity, caste, color, age, physical characteristics, neurodiversity, disability, sex or gender, gender identity or expression, sexual orientation, language, philosophy or religion, national or social origin, socio-economic position, level of education, or other status. The same privileges of participation are extended to everyone who participates in good faith and in accordance with this Covenant. -Examples of behavior that contributes to creating a positive environment -include: +## Encouraged Behaviors -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members +While acknowledging differences in social norms, we all strive to meet our community's expectations for positive behavior. We also understand that our words and actions may be interpreted differently than we intend based on culture, background, or native language. -Examples of unacceptable behavior by participants include: +With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including: -* The use of sexualized language or imagery and unwelcome sexual attention or -advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting +1. Respecting the **purpose of our community**, our activities, and our ways of gathering. +2. Engaging **kindly and honestly** with others. +3. Respecting **different viewpoints** and experiences. +4. **Taking responsibility** for our actions and contributions. +5. Gracefully giving and accepting **constructive feedback**. +6. Committing to **repairing harm** when it occurs. +7. Behaving in other ways that promote and sustain the **well-being of our community**. -## Our Responsibilities +## Restricted Behaviors -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. +We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct. -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. +1. **Harassment.** Violating explicitly expressed boundaries or engaging in unnecessary personal attention after any clear request to stop. +2. **Character attacks.** Making insulting, demeaning, or pejorative comments directed at a community member or group of people. +3. **Stereotyping or discrimination.** Characterizing anyone’s personality or behavior on the basis of immutable identities or traits. +4. **Sexualization.** Behaving in a way that would generally be considered inappropriately intimate in the context or purpose of the community. +5. **Violating confidentiality**. Sharing or acting on someone's personal or private information without their permission. +6. **Endangerment.** Causing, encouraging, or threatening violence or other harm toward any person or group. +7. Behaving in other ways that **threaten the well-being** of our community. -## Scope +### Other Restrictions + +1. **Misleading identity.** Impersonating someone else for any reason, or pretending to be someone else to evade enforcement actions. +2. **Failing to credit sources.** Not properly crediting the sources of content you contribute. +3. **Promotional materials**. Sharing marketing or other commercial content in a way that is outside the norms of the community. +4. **Irresponsible communication.** Failing to responsibly present content which includes, links or describes any other restricted behaviors. + +## Reporting an Issue + +Tensions can occur between community members even when they are trying their best to collaborate. Not every conflict represents a code of conduct violation, and this Code of Conduct reinforces encouraged behaviors and norms that can help avoid conflicts and minimize harm. + +When an incident does occur, it is important to report it promptly. To report a possible violation, **[NOTE: describe your means of reporting here.]** + +Community Moderators take reports of violations seriously and will make every effort to respond in a timely manner. They will investigate all reports of code of conduct violations, reviewing messages, logs, and recordings, or interviewing witnesses and other participants. Community Moderators will keep investigation and enforcement actions as transparent as possible while prioritizing safety and confidentiality. In order to honor these values, enforcement actions are carried out in private with the involved parties, but communicating to the whole community may be part of a mutually agreed upon resolution. -This Code of Conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. Examples of -representing a project or community include using an official project e-mail -address, posting via an official social media account, or acting as an appointed -representative at an online or offline event. Representation of a project may be -further defined and clarified by project maintainers. +## Addressing and Repairing Harm -## Enforcement +**[NOTE: The remedies and repairs outlined below are suggestions based on best practices in code of conduct enforcement. If your community has its own established enforcement process, be sure to edit this section to describe your own policies.]** -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at veganstraightedge@gmail.com. All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. +If an investigation by the Community Moderators finds that this Code of Conduct has been violated, the following enforcement ladder may be used to determine how best to repair harm, based on the incident's impact on the individuals involved and the community as a whole. Depending on the severity of a violation, lower rungs on the ladder may be skipped. -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. +1) Warning + 1) Event: A violation involving a single incident or series of incidents. + 2) Consequence: A private, written warning from the Community Moderators. + 3) Repair: Examples of repair include a private written apology, acknowledgement of responsibility, and seeking clarification on expectations. +2) Temporarily Limited Activities + 1) Event: A repeated incidence of a violation that previously resulted in a warning, or the first incidence of a more serious violation. + 2) Consequence: A private, written warning with a time-limited cooldown period designed to underscore the seriousness of the situation and give the community members involved time to process the incident. The cooldown period may be limited to particular communication channels or interactions with particular community members. + 3) Repair: Examples of repair may include making an apology, using the cooldown period to reflect on actions and impact, and being thoughtful about re-entering community spaces after the period is over. +3) Temporary Suspension + 1) Event: A pattern of repeated violation which the Community Moderators have tried to address with warnings, or a single serious violation. + 2) Consequence: A private written warning with conditions for return from suspension. In general, temporary suspensions give the person being suspended time to reflect upon their behavior and possible corrective actions. + 3) Repair: Examples of repair include respecting the spirit of the suspension, meeting the specified conditions for return, and being thoughtful about how to reintegrate with the community when the suspension is lifted. +4) Permanent Ban + 1) Event: A pattern of repeated code of conduct violations that other steps on the ladder have failed to resolve, or a violation so serious that the Community Moderators determine there is no way to keep the community safe with this person as a member. + 2) Consequence: Access to all community spaces, tools, and communication channels is removed. In general, permanent bans should be rarely used, should have strong reasoning behind them, and should only be resorted to if working through other remedies has failed to change the behavior. + 3) Repair: There is no possible repair in cases of this severity. + +This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping with the best interests of our community. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public or other spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [http://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the Contributor Covenant, version 3.0, permanently available at [https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/). + +Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under CC BY-SA 4.0. To view a copy of this license, visit [https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/) -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ +For answers to common questions about Contributor Covenant, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are provided at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). Additional enforcement and community guideline resources can be found at [https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources). The enforcement ladder was inspired by the work of [Mozilla’s code of conduct team](https://github.com/mozilla/inclusion). From c334f9b9ea9e41c9b9d440ffaea2d2c36059006c Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 19:28:24 -0700 Subject: [PATCH 17/44] Rubocop: Style/GlobalStdStream --- .rubocop_todo.yml | 6 ------ config/environments/production.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5575def..799bb4c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -49,12 +49,6 @@ Style/Documentation: - "config/application.rb" - "db/migrate/20170516194159_create_submissions.rb" -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/GlobalStdStream: - Exclude: - - "config/environments/production.rb" - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). Style/RedundantConstantBase: diff --git a/config/environments/production.rb b/config/environments/production.rb index 779d18f..9279b6f 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -81,7 +81,7 @@ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV['RAILS_LOG_TO_STDOUT'].present? - logger = ActiveSupport::Logger.new(STDOUT) + logger = ActiveSupport::Logger.new($stdout) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end From ef2632f76a228c9af0f74b82cf9db24f96f8603c Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 19:28:41 -0700 Subject: [PATCH 18/44] Style/RedundantConstantBase --- .rubocop_todo.yml | 7 ------- config/environments/production.rb | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 799bb4c..bb87bdd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -49,13 +49,6 @@ Style/Documentation: - "config/application.rb" - "db/migrate/20170516194159_create_submissions.rb" -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantConstantBase: - Exclude: - - "config/environments/production.rb" - - "spec/rails_helper.rb" - # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SafeForConstants. diff --git a/config/environments/production.rb b/config/environments/production.rb index 9279b6f..cde20ac 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -74,7 +74,7 @@ config.active_support.deprecation = :notify # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new + config.log_formatter = Logger::Formatter.new # Use a different logger for distributed setups. # require 'syslog/logger' From 89c2ead8127bbaad58a0cbb3666330e00604a258 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 19:30:23 -0700 Subject: [PATCH 19/44] Style/RedundantFetchBlock --- .rubocop_todo.yml | 7 ------- config/puma.rb | 12 ++++-------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bb87bdd..a440a8a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -49,13 +49,6 @@ Style/Documentation: - "config/application.rb" - "db/migrate/20170516194159_create_submissions.rb" -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: SafeForConstants. -Style/RedundantFetchBlock: - Exclude: - - "config/puma.rb" - # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinSize. diff --git a/config/puma.rb b/config/puma.rb index ccda173..7223b97 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -4,24 +4,21 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 } +threads_count = ENV.fetch 'RAILS_MAX_THREADS', 5 threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. -# -port ENV.fetch('PORT') { 3000 } +port ENV.fetch 'PORT', 3000 # Specifies the `environment` that Puma will run in. -# -environment ENV.fetch('RAILS_ENV') { 'development' } +environment ENV.fetch 'RAILS_ENV', 'development' # Specifies the number of `workers` to boot in clustered mode. # Workers are forked webserver processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). -# -# workers ENV.fetch("WEB_CONCURRENCY") { 2 } +# workers ENV.fetch "WEB_CONCURRENCY", 2 # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code @@ -29,7 +26,6 @@ # process behavior so workers use less memory. If you use this option # you need to make sure to reconnect any threads in the `on_worker_boot` # block. -# # preload_app! # If you are preloading your application and using Active Record, it's From 179d93f9a52ac9045eb31ec683f8b0b87b09859e Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 19:32:44 -0700 Subject: [PATCH 20/44] Layout/HashAlignment --- app/controllers/microformats_controller.rb | 2 +- spec/views/submissions/new.html.erb_spec.rb | 6 +++--- spec/views/submissions/show.html.erb_spec.rb | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/microformats_controller.rb b/app/controllers/microformats_controller.rb index 3025fa6..ead794c 100644 --- a/app/controllers/microformats_controller.rb +++ b/app/controllers/microformats_controller.rb @@ -9,7 +9,7 @@ def show results[:debug] = { package: 'https://rubygems.org/gems/microformats', version: Microformats::VERSION, - note: [ + note: [ 'This output was generated from the microformats-ruby gem available at https://github.com/indieweb/microformats-ruby', 'Please file any issues with the parser at https://github.com/indieweb/microformats-rubygems/issues' ] diff --git a/spec/views/submissions/new.html.erb_spec.rb b/spec/views/submissions/new.html.erb_spec.rb index 1068b6e..0b5c2d5 100644 --- a/spec/views/submissions/new.html.erb_spec.rb +++ b/spec/views/submissions/new.html.erb_spec.rb @@ -3,9 +3,9 @@ RSpec.describe 'submissions/new' do before do assign(:submission, Submission.new( - html: 'MyText', - base_url: 'MyText', - save_html: false, + html: 'MyText', + base_url: 'MyText', + save_html: false, render_html_in_page: false )) end diff --git a/spec/views/submissions/show.html.erb_spec.rb b/spec/views/submissions/show.html.erb_spec.rb index e09b8f2..37bebf4 100644 --- a/spec/views/submissions/show.html.erb_spec.rb +++ b/spec/views/submissions/show.html.erb_spec.rb @@ -3,9 +3,9 @@ RSpec.describe 'submissions/show' do before do @submission = assign(:submission, Submission.create!( - html: 'MyText', - base_url: 'MyText', - save_html: false, + html: 'MyText', + base_url: 'MyText', + save_html: false, render_html_in_page: false )) end From 35057653211f7086d3dffb59ecb64f7dddfd136b Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 19:33:26 -0700 Subject: [PATCH 21/44] Style/SymbolArray --- .rubocop_todo.yml | 7 ------- Gemfile | 2 +- app/controllers/submissions_controller.rb | 6 +++--- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a440a8a..7a91f47 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -48,10 +48,3 @@ Style/Documentation: - "app/models/application_record.rb" - "config/application.rb" - "db/migrate/20170516194159_create_submissions.rb" - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MinSize. -# SupportedStyles: percent, brackets -Style/SymbolArray: - EnforcedStyle: brackets diff --git a/Gemfile b/Gemfile index 6297bf0..18213d8 100644 --- a/Gemfile +++ b/Gemfile @@ -29,4 +29,4 @@ group :development, :test do end # windows dev -gem 'tzinfo-data', platforms: [:windows, :jruby] +gem 'tzinfo-data', platforms: %i[windows jruby] diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 154a0d0..22d720f 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -1,6 +1,6 @@ class SubmissionsController < ApplicationController - before_action :set_submission, only: [:show, :edit, :update, :destroy] - before_action :redirect_to_root, only: [:index, :edit, :update, :destroy] + before_action :set_submission, only: %i[show edit update destroy] + before_action :redirect_to_root, only: %i[index edit update destroy] # GET /submissions def index; end @@ -55,6 +55,6 @@ def redirect_to_root # Only allow a trusted parameter "white list" through. def submission_params - params.expect(submission: [:url, :html, :base_url, :save_html, :render_html_in_page]) + params.expect submission: %i[url html base_url save_html render_html_in_page] end end From 17200152eeee6b99d9d443eed9f60cc942d47d6a Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 19:34:22 -0700 Subject: [PATCH 22/44] Style/Documentation --- .rubocop.yml | 9 ++++++--- .rubocop_todo.yml | 15 --------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ab169a0..f20c545 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -19,9 +19,12 @@ AllCops: - "tmp/**/*" - ".git/**/*" -Style/FrozenStringLiteralComment: - Enabled: false - Layout/HashAlignment: EnforcedHashRocketStyle: table EnforcedColonStyle: table + +Style/Documentation: + Enabled: false + +Style/FrozenStringLiteralComment: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7a91f47..f3475c6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -33,18 +33,3 @@ Rails/I18nLocaleTexts: Rails/ThreeStateBooleanColumn: Exclude: - "db/migrate/20170516194159_create_submissions.rb" - -# Offense count: 10 -# Configuration parameters: AllowedConstants. -Style/Documentation: - Exclude: - - "app/controllers/application_controller.rb" - - "app/controllers/microformats_controller.rb" - - "app/controllers/submissions_controller.rb" - - "app/helpers/application_helper.rb" - - "app/helpers/microformats_helper.rb" - - "app/helpers/submissions_helper.rb" - - "app/mailers/application_mailer.rb" - - "app/models/application_record.rb" - - "config/application.rb" - - "db/migrate/20170516194159_create_submissions.rb" From 4990ad5c905c2ab7d1f4113f83cb0745477728d5 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 19:35:19 -0700 Subject: [PATCH 23/44] Rails/I18nLocaleTexts --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 5 ----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f20c545..b1aaf90 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,6 +23,9 @@ Layout/HashAlignment: EnforcedHashRocketStyle: table EnforcedColonStyle: table +Rails/I18nLocaleTexts: + Enabled: false + Style/Documentation: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f3475c6..ffb6a80 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -22,11 +22,6 @@ RSpec/InstanceVariable: Exclude: - "spec/views/submissions/show.html.erb_spec.rb" -# Offense count: 1 -Rails/I18nLocaleTexts: - Exclude: - - "app/controllers/submissions_controller.rb" - # Offense count: 2 # Configuration parameters: Include. # Include: db/**/*.rb From 1282d9f49720d532d28d8978b67dd03c9962436f Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 20:26:38 -0700 Subject: [PATCH 24/44] Fix tests --- .rubocop.yml | 6 ++ .rubocop_todo.yml | 7 -- config/application.rb | 3 + .../submissions_controller_spec.rb | 71 +++++++++++-------- spec/helpers/microformats_helper_spec.rb | 3 +- spec/helpers/submissions_helper_spec.rb | 3 +- spec/models/submission_spec.rb | 14 +++- spec/rails_helper.rb | 2 +- spec/views/microformats/show.html.erb_spec.rb | 3 +- spec/views/submissions/new.html.erb_spec.rb | 24 +++---- 10 files changed, 81 insertions(+), 55 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b1aaf90..912a898 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,6 +23,9 @@ Layout/HashAlignment: EnforcedHashRocketStyle: table EnforcedColonStyle: table +Metrics/MethodLength: + Max: 15 + Rails/I18nLocaleTexts: Enabled: false @@ -31,3 +34,6 @@ Style/Documentation: Style/FrozenStringLiteralComment: Enabled: false + +RSpec/ExampleLength: + Max: 7 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ffb6a80..e1439fa 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -8,13 +8,6 @@ # Offense count: 2 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. -Metrics/MethodLength: - Max: 15 - -# Offense count: 2 -# Configuration parameters: CountAsOne. -RSpec/ExampleLength: - Max: 7 # Offense count: 1 # Configuration parameters: AssignmentOnly. diff --git a/config/application.rb b/config/application.rb index fa76920..7ddad04 100644 --- a/config/application.rb +++ b/config/application.rb @@ -14,5 +14,8 @@ class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + + # Fix deprecation warning for timezone handling in Rails 8.1 + config.active_support.to_time_preserves_timezone = :zone end end diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index 17c3029..9c431ac 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -28,11 +28,19 @@ # Submission. As you add validations to Submission, be sure to # adjust the attributes here as well. let(:valid_attributes) do - skip('Add a hash of attributes valid for your model') + { + html: '@aaronpk', + base_url: 'https://aaronparecki.com', + save_html: true, + render_html_in_page: true + } end let(:invalid_attributes) do - skip('Add a hash of attributes invalid for your model') + { + html: nil, + base_url: nil + } end # This should return the minimal set of values that should be in the session @@ -41,10 +49,10 @@ let(:valid_session) { {} } describe 'GET #index' do - it 'returns a success response' do + it 'redirects to root' do Submission.create! valid_attributes get :index, params: {}, session: valid_session - expect(response).to be_success + expect(response).to redirect_to(root_path) end end @@ -52,22 +60,25 @@ it 'returns a success response' do submission = Submission.create! valid_attributes get :show, params: { id: submission.to_param }, session: valid_session - expect(response).to be_success + expect(response).to be_successful end end describe 'GET #new' do it 'returns a success response' do get :new, params: {}, session: valid_session - expect(response).to be_success + + # binding.irb + + expect(response).to be_successful end end describe 'GET #edit' do - it 'returns a success response' do + it 'redirects to root' do submission = Submission.create! valid_attributes get :edit, params: { id: submission.to_param }, session: valid_session - expect(response).to be_success + expect(response).to redirect_to(root_path) end end @@ -86,54 +97,52 @@ end context 'with invalid params' do - it "returns a success response (i.e. to display the 'new' template)" do - post :create, params: { submission: invalid_attributes }, session: valid_session - expect(response).to be_success + it 'renders the show template when save_html is false' do + invalid_attrs_without_save_html = invalid_attributes.merge(save_html: false) + post :create, params: { submission: invalid_attrs_without_save_html }, session: valid_session + expect(response).to be_successful + expect(response).to render_template(:show) + end + + it 'redirects to submission when save_html is true (no model validations exist)' do + invalid_attrs_with_save_html = invalid_attributes.merge(save_html: true) + post :create, params: { submission: invalid_attrs_with_save_html }, session: valid_session + expect(response).to redirect_to(Submission.last) end end end describe 'PUT #update' do context 'with valid params' do - let(:new_attributes) do - skip('Add a hash of attributes valid for your model') - end - - it 'updates the requested submission' do + it 'redirects to root without updating' do submission = Submission.create! valid_attributes - put :update, params: { id: submission.to_param, submission: new_attributes }, session: valid_session - submission.reload - skip('Add assertions for updated state') + put :update, params: { id: submission.to_param, submission: valid_attributes }, session: valid_session + expect(response).to redirect_to(root_path) end it 'redirects to the submission' do submission = Submission.create! valid_attributes put :update, params: { id: submission.to_param, submission: valid_attributes }, session: valid_session - expect(response).to redirect_to(submission) + expect(response).to redirect_to(root_path) end end context 'with invalid params' do - it "returns a success response (i.e. to display the 'edit' template)" do + it 'redirects to root' do submission = Submission.create! valid_attributes - put :update, params: { id: submission.to_param, submission: invalid_attributes }, session: valid_session - expect(response).to be_success + put :update, params: { id: submission.to_param, submission: {} }, session: valid_session + expect(response).to redirect_to(root_path) end end end describe 'DELETE #destroy' do - it 'destroys the requested submission' do + it 'redirects to root without destroying' do submission = Submission.create! valid_attributes expect do delete :destroy, params: { id: submission.to_param }, session: valid_session - end.to change(Submission, :count).by(-1) - end - - it 'redirects to the submissions list' do - submission = Submission.create! valid_attributes - delete :destroy, params: { id: submission.to_param }, session: valid_session - expect(response).to redirect_to(submissions_url) + end.to change(Submission, :count).by(0) + expect(response).to redirect_to(root_path) end end end diff --git a/spec/helpers/microformats_helper_spec.rb b/spec/helpers/microformats_helper_spec.rb index 5e17f5d..277afd4 100644 --- a/spec/helpers/microformats_helper_spec.rb +++ b/spec/helpers/microformats_helper_spec.rb @@ -11,5 +11,6 @@ # end # end RSpec.describe MicroformatsHelper do - pending "add some examples to (or delete) #{__FILE__}" + # This helper module is currently empty, so no tests are needed + # If methods are added to this helper in the future, add corresponding tests here end diff --git a/spec/helpers/submissions_helper_spec.rb b/spec/helpers/submissions_helper_spec.rb index 7455a2b..54fd82a 100644 --- a/spec/helpers/submissions_helper_spec.rb +++ b/spec/helpers/submissions_helper_spec.rb @@ -11,5 +11,6 @@ # end # end RSpec.describe SubmissionsHelper do - pending "add some examples to (or delete) #{__FILE__}" + # This helper module is currently empty, so no tests are needed + # If methods are added to this helper in the future, add corresponding tests here end diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb index 88d6761..fe255c8 100644 --- a/spec/models/submission_spec.rb +++ b/spec/models/submission_spec.rb @@ -1,5 +1,17 @@ require 'rails_helper' RSpec.describe Submission do - pending "add some examples to (or delete) #{__FILE__}" + it 'can be created with valid attributes' do + submission = Submission.new( + html: '
    Test
    ', + base_url: 'https://example.com', + save_html: true, + render_html_in_page: true + ) + expect(submission).to be_valid + end + + it 'belongs to ActiveRecord' do + expect(Submission.superclass).to eq(ApplicationRecord) + end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 6eb5338..1b9ef13 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -28,7 +28,7 @@ RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = Rails.root.join('spec/fixtures').to_s + # config.fixture_path = Rails.root.join('spec/fixtures') # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false diff --git a/spec/views/microformats/show.html.erb_spec.rb b/spec/views/microformats/show.html.erb_spec.rb index 4dcc7ac..9d32c79 100644 --- a/spec/views/microformats/show.html.erb_spec.rb +++ b/spec/views/microformats/show.html.erb_spec.rb @@ -1,5 +1,6 @@ require 'rails_helper' RSpec.describe 'microformats/show.html.erb' do - pending "add some examples to (or delete) #{__FILE__}" + # This view template doesn't exist because the microformats controller renders JSON + # If a view template is added in the future, add corresponding tests here end diff --git a/spec/views/submissions/new.html.erb_spec.rb b/spec/views/submissions/new.html.erb_spec.rb index 0b5c2d5..94034ac 100644 --- a/spec/views/submissions/new.html.erb_spec.rb +++ b/spec/views/submissions/new.html.erb_spec.rb @@ -1,26 +1,26 @@ require 'rails_helper' +# TODO: add more tests for the various contexts RSpec.describe 'submissions/new' do before do - assign(:submission, Submission.new( - html: 'MyText', - base_url: 'MyText', + assign :submission, + Submission.new(html: '@aaronpk', + base_url: nil, save_html: false, - render_html_in_page: false - )) + render_html_in_page: false) end it 'renders new submission form' do render + html = Nokogiri::HTML.parse(rendered) - assert_select 'form[action=?][method=?]', submissions_path, 'post' do - assert_select 'textarea[name=?]', 'submission[html]' + submission_form = html.css "form[action='#{submissions_path}'][method=post]" + expect(submission_form).to be_present - assert_select 'input[name=?]', 'submission[base_url]' + html_field = submission_form.css 'textarea#submission_html' + expect(html_field).to be_present - assert_select 'input[name=?]', 'submission[save_html]' - - assert_select 'input[name=?]', 'submission[render_html_in_page]' - end + base_url_field = submission_form.css 'input#submission_base_url' + expect(base_url_field).to be_present end end From 476c04184fe570c8808cdfa492a197402780b937 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 20:27:21 -0700 Subject: [PATCH 25/44] Rubocop tests --- spec/controllers/submissions_controller_spec.rb | 2 +- spec/helpers/microformats_helper_spec.rb | 4 ---- spec/helpers/submissions_helper_spec.rb | 4 ---- spec/models/submission_spec.rb | 4 ++-- spec/views/microformats/show.html.erb_spec.rb | 5 ----- 5 files changed, 3 insertions(+), 16 deletions(-) diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index 9c431ac..bc1bb5b 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -141,7 +141,7 @@ submission = Submission.create! valid_attributes expect do delete :destroy, params: { id: submission.to_param }, session: valid_session - end.to change(Submission, :count).by(0) + end.not_to change(Submission, :count) expect(response).to redirect_to(root_path) end end diff --git a/spec/helpers/microformats_helper_spec.rb b/spec/helpers/microformats_helper_spec.rb index 277afd4..84ebf61 100644 --- a/spec/helpers/microformats_helper_spec.rb +++ b/spec/helpers/microformats_helper_spec.rb @@ -10,7 +10,3 @@ # end # end # end -RSpec.describe MicroformatsHelper do - # This helper module is currently empty, so no tests are needed - # If methods are added to this helper in the future, add corresponding tests here -end diff --git a/spec/helpers/submissions_helper_spec.rb b/spec/helpers/submissions_helper_spec.rb index 54fd82a..c42acca 100644 --- a/spec/helpers/submissions_helper_spec.rb +++ b/spec/helpers/submissions_helper_spec.rb @@ -10,7 +10,3 @@ # end # end # end -RSpec.describe SubmissionsHelper do - # This helper module is currently empty, so no tests are needed - # If methods are added to this helper in the future, add corresponding tests here -end diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb index fe255c8..1f66af5 100644 --- a/spec/models/submission_spec.rb +++ b/spec/models/submission_spec.rb @@ -2,7 +2,7 @@ RSpec.describe Submission do it 'can be created with valid attributes' do - submission = Submission.new( + submission = described_class.new( html: '
    Test
    ', base_url: 'https://example.com', save_html: true, @@ -12,6 +12,6 @@ end it 'belongs to ActiveRecord' do - expect(Submission.superclass).to eq(ApplicationRecord) + expect(described_class.superclass).to eq(ApplicationRecord) end end diff --git a/spec/views/microformats/show.html.erb_spec.rb b/spec/views/microformats/show.html.erb_spec.rb index 9d32c79..63f198b 100644 --- a/spec/views/microformats/show.html.erb_spec.rb +++ b/spec/views/microformats/show.html.erb_spec.rb @@ -1,6 +1 @@ require 'rails_helper' - -RSpec.describe 'microformats/show.html.erb' do - # This view template doesn't exist because the microformats controller renders JSON - # If a view template is added in the future, add corresponding tests here -end From 2084378e1eb7cd7e856d39ac137d86fddf1bdf86 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 20:28:33 -0700 Subject: [PATCH 26/44] TODO --- .rubocop.yml | 6 ------ .rubocop_todo.yml | 22 +++++++++++++++++++--- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 912a898..b1aaf90 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,9 +23,6 @@ Layout/HashAlignment: EnforcedHashRocketStyle: table EnforcedColonStyle: table -Metrics/MethodLength: - Max: 15 - Rails/I18nLocaleTexts: Enabled: false @@ -34,6 +31,3 @@ Style/Documentation: Style/FrozenStringLiteralComment: Enabled: false - -RSpec/ExampleLength: - Max: 7 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e1439fa..dce2a9a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-08-09 00:19:24 UTC using RuboCop version 1.79.2. +# on 2025-08-09 03:28:24 UTC using RuboCop version 1.79.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 @@ -8,16 +8,32 @@ # Offense count: 2 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Max: 15 + +# Offense count: 3 +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 8 # Offense count: 1 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Exclude: - - "spec/views/submissions/show.html.erb_spec.rb" + - 'spec/views/submissions/show.html.erb_spec.rb' + +# Offense count: 3 +RSpec/MultipleExpectations: + Max: 3 + +# Offense count: 2 +RSpec/RepeatedExample: + Exclude: + - 'spec/controllers/submissions_controller_spec.rb' # Offense count: 2 # Configuration parameters: Include. # Include: db/**/*.rb Rails/ThreeStateBooleanColumn: Exclude: - - "db/migrate/20170516194159_create_submissions.rb" + - 'db/migrate/20170516194159_create_submissions.rb' From a36ad4b37a70ce8d5b9059d169c2129a6d316129 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 20:40:17 -0700 Subject: [PATCH 27/44] Fix tests --- .rubocop_todo.yml | 10 +-- spec/views/submissions/new.html.erb_spec.rb | 95 +++++++++++++++++--- spec/views/submissions/show.html.erb_spec.rb | 15 ++-- 3 files changed, 96 insertions(+), 24 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index dce2a9a..3eead4c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-08-09 03:28:24 UTC using RuboCop version 1.79.2. +# on 2025-08-09 03:39:20 UTC using RuboCop version 1.79.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 @@ -11,10 +11,10 @@ Metrics/MethodLength: Max: 15 -# Offense count: 3 +# Offense count: 7 # Configuration parameters: CountAsOne. RSpec/ExampleLength: - Max: 8 + Max: 10 # Offense count: 1 # Configuration parameters: AssignmentOnly. @@ -22,9 +22,9 @@ RSpec/InstanceVariable: Exclude: - 'spec/views/submissions/show.html.erb_spec.rb' -# Offense count: 3 +# Offense count: 8 RSpec/MultipleExpectations: - Max: 3 + Max: 5 # Offense count: 2 RSpec/RepeatedExample: diff --git a/spec/views/submissions/new.html.erb_spec.rb b/spec/views/submissions/new.html.erb_spec.rb index 94034ac..6dc7f2c 100644 --- a/spec/views/submissions/new.html.erb_spec.rb +++ b/spec/views/submissions/new.html.erb_spec.rb @@ -1,26 +1,93 @@ require 'rails_helper' -# TODO: add more tests for the various contexts RSpec.describe 'submissions/new' do before do - assign :submission, - Submission.new(html: '@aaronpk', - base_url: nil, - save_html: false, - render_html_in_page: false) + @submission = assign(:submission, Submission.new( + html: '
    Test
    ', + base_url: 'https://example.com', + save_html: false, + render_html_in_page: false + )) + allow(view).to receive(:on_results_page?).and_return(false) end - it 'renders new submission form' do + it 'renders the URL parsing form' do render - html = Nokogiri::HTML.parse(rendered) + doc = Nokogiri::HTML(rendered) - submission_form = html.css "form[action='#{submissions_path}'][method=post]" - expect(submission_form).to be_present + form = doc.css("form[action='#{microformats_path}'][method='get']") + expect(form).to be_present - html_field = submission_form.css 'textarea#submission_html' - expect(html_field).to be_present + url_input = form.css('input#submission_url[type="url"]') + expect(url_input).to be_present - base_url_field = submission_form.css 'input#submission_base_url' - expect(base_url_field).to be_present + submit_button = form.css('input[type="submit"][value="Parse"]') + expect(submit_button).to be_present + end + + it 'renders the HTML snippet form' do + render + doc = Nokogiri::HTML(rendered) + + form = doc.css("form[action='#{submissions_path}'][method='post']") + expect(form).to be_present + + html_textarea = form.css('textarea#submission_html') + expect(html_textarea).to be_present + + base_url_input = form.css('input#submission_base_url[type="url"]') + expect(base_url_input).to be_present + end + + it 'renders form controls for HTML snippet form' do + render + doc = Nokogiri::HTML(rendered) + + save_html_checkbox = doc.css('input#submission_save_html[type="checkbox"]') + expect(save_html_checkbox).to be_present + + render_html_checkbox = doc.css('input#submission_render_html_in_page[type="checkbox"]') + expect(render_html_checkbox).to be_present + + submit_button = doc.css('input[type="submit"][value="Parse"]') + expect(submit_button).to be_present + end + + it 'renders labels for form fields' do + render + doc = Nokogiri::HTML(rendered) + + expect(doc.css('label').text).to include('Enter a URL') + expect(doc.css('label').text).to include('HTML') + expect(doc.css('label').text).to include('Base URL') + expect(doc.css('label[for="submission_save_html"]').text).to include('Save HTML?') + expect(doc.css('label[for="submission_render_html_in_page"]').text).to include('Render HTML in Page?') + end + + it 'displays the section heading' do + render + doc = Nokogiri::HTML(rendered) + + heading = doc.css('h2') + expect(heading.text).to include('OR parse just a snippet of HTML') + end + + it 'does not render JSON field on new form' do + render + doc = Nokogiri::HTML(rendered) + + json_textarea = doc.css('textarea#submission_json') + expect(json_textarea).to be_empty + end + + it 'renders form fields as enabled (not disabled)' do + render + doc = Nokogiri::HTML(rendered) + + html_textarea = doc.css('textarea#submission_html[disabled]') + expect(html_textarea).to be_empty + + base_url_input = doc.css('input#submission_base_url[disabled]') + expect(base_url_input).to be_empty end end diff --git a/spec/views/submissions/show.html.erb_spec.rb b/spec/views/submissions/show.html.erb_spec.rb index 37bebf4..915e3d6 100644 --- a/spec/views/submissions/show.html.erb_spec.rb +++ b/spec/views/submissions/show.html.erb_spec.rb @@ -12,13 +12,18 @@ it 'renders attributes in

    ' do render + doc = Nokogiri::HTML(rendered) - assert_select 'form[action=?][method=?]', submission_path(@submission.id), 'post' do - assert_select 'textarea[name=?]', 'submission[html]' + form = doc.css("form[action='#{submission_path(@submission.id)}'][method='post']") + expect(form).to be_present - assert_select 'input[name=?][value=?]', 'submission[base_url]', 'MyText' + html_textarea = form.css('textarea[name="submission[html]"]') + expect(html_textarea).to be_present - assert_select 'textarea[name=?]', 'submission[json]' - end + base_url_input = form.css('input[name="submission[base_url]"][value="MyText"]') + expect(base_url_input).to be_present + + json_textarea = form.css('textarea[name="submission[json]"]') + expect(json_textarea).to be_present end end From 95c683348f3a2710f512d761c670efda5ea56d56 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 20:45:32 -0700 Subject: [PATCH 28/44] More Seattle.rb style --- .../submissions_controller_spec.rb | 20 +++++----- spec/models/submission_spec.rb | 2 +- spec/views/submissions/new.html.erb_spec.rb | 40 +++++++++---------- spec/views/submissions/show.html.erb_spec.rb | 14 +++---- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index bc1bb5b..a47bb4e 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -52,7 +52,7 @@ it 'redirects to root' do Submission.create! valid_attributes get :index, params: {}, session: valid_session - expect(response).to redirect_to(root_path) + expect(response).to redirect_to root_path end end @@ -78,7 +78,7 @@ it 'redirects to root' do submission = Submission.create! valid_attributes get :edit, params: { id: submission.to_param }, session: valid_session - expect(response).to redirect_to(root_path) + expect(response).to redirect_to root_path end end @@ -87,12 +87,12 @@ it 'creates a new Submission' do expect do post :create, params: { submission: valid_attributes }, session: valid_session - end.to change(Submission, :count).by(1) + end.to change(Submission, :count).by 1 end it 'redirects to the created submission' do post :create, params: { submission: valid_attributes }, session: valid_session - expect(response).to redirect_to(Submission.last) + expect(response).to redirect_to Submission.last end end @@ -101,13 +101,13 @@ invalid_attrs_without_save_html = invalid_attributes.merge(save_html: false) post :create, params: { submission: invalid_attrs_without_save_html }, session: valid_session expect(response).to be_successful - expect(response).to render_template(:show) + expect(response).to render_template :show end it 'redirects to submission when save_html is true (no model validations exist)' do invalid_attrs_with_save_html = invalid_attributes.merge(save_html: true) post :create, params: { submission: invalid_attrs_with_save_html }, session: valid_session - expect(response).to redirect_to(Submission.last) + expect(response).to redirect_to Submission.last end end end @@ -117,13 +117,13 @@ it 'redirects to root without updating' do submission = Submission.create! valid_attributes put :update, params: { id: submission.to_param, submission: valid_attributes }, session: valid_session - expect(response).to redirect_to(root_path) + expect(response).to redirect_to root_path end it 'redirects to the submission' do submission = Submission.create! valid_attributes put :update, params: { id: submission.to_param, submission: valid_attributes }, session: valid_session - expect(response).to redirect_to(root_path) + expect(response).to redirect_to root_path end end @@ -131,7 +131,7 @@ it 'redirects to root' do submission = Submission.create! valid_attributes put :update, params: { id: submission.to_param, submission: {} }, session: valid_session - expect(response).to redirect_to(root_path) + expect(response).to redirect_to root_path end end end @@ -142,7 +142,7 @@ expect do delete :destroy, params: { id: submission.to_param }, session: valid_session end.not_to change(Submission, :count) - expect(response).to redirect_to(root_path) + expect(response).to redirect_to root_path end end end diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb index 1f66af5..e3f41c1 100644 --- a/spec/models/submission_spec.rb +++ b/spec/models/submission_spec.rb @@ -12,6 +12,6 @@ end it 'belongs to ActiveRecord' do - expect(described_class.superclass).to eq(ApplicationRecord) + expect(described_class.superclass).to eq ApplicationRecord end end diff --git a/spec/views/submissions/new.html.erb_spec.rb b/spec/views/submissions/new.html.erb_spec.rb index 6dc7f2c..554b497 100644 --- a/spec/views/submissions/new.html.erb_spec.rb +++ b/spec/views/submissions/new.html.erb_spec.rb @@ -2,18 +2,18 @@ RSpec.describe 'submissions/new' do before do - @submission = assign(:submission, Submission.new( - html: '

    Test
    ', - base_url: 'https://example.com', - save_html: false, - render_html_in_page: false - )) - allow(view).to receive(:on_results_page?).and_return(false) + @submission = assign :submission, Submission.new( + html: '
    Test
    ', + base_url: 'https://example.com', + save_html: false, + render_html_in_page: false + ) + allow(view).to receive(:on_results_page?).and_return false end it 'renders the URL parsing form' do render - doc = Nokogiri::HTML(rendered) + doc = Nokogiri::HTML rendered form = doc.css("form[action='#{microformats_path}'][method='get']") expect(form).to be_present @@ -27,7 +27,7 @@ it 'renders the HTML snippet form' do render - doc = Nokogiri::HTML(rendered) + doc = Nokogiri::HTML rendered form = doc.css("form[action='#{submissions_path}'][method='post']") expect(form).to be_present @@ -41,7 +41,7 @@ it 'renders form controls for HTML snippet form' do render - doc = Nokogiri::HTML(rendered) + doc = Nokogiri::HTML rendered save_html_checkbox = doc.css('input#submission_save_html[type="checkbox"]') expect(save_html_checkbox).to be_present @@ -55,26 +55,26 @@ it 'renders labels for form fields' do render - doc = Nokogiri::HTML(rendered) + doc = Nokogiri::HTML rendered - expect(doc.css('label').text).to include('Enter a URL') - expect(doc.css('label').text).to include('HTML') - expect(doc.css('label').text).to include('Base URL') - expect(doc.css('label[for="submission_save_html"]').text).to include('Save HTML?') - expect(doc.css('label[for="submission_render_html_in_page"]').text).to include('Render HTML in Page?') + expect(doc.css('label').text).to include 'Enter a URL' + expect(doc.css('label').text).to include 'HTML' + expect(doc.css('label').text).to include 'Base URL' + expect(doc.css('label[for="submission_save_html"]').text).to include 'Save HTML?' + expect(doc.css('label[for="submission_render_html_in_page"]').text).to include 'Render HTML in Page?' end it 'displays the section heading' do render - doc = Nokogiri::HTML(rendered) + doc = Nokogiri::HTML rendered heading = doc.css('h2') - expect(heading.text).to include('OR parse just a snippet of HTML') + expect(heading.text).to include 'OR parse just a snippet of HTML' end it 'does not render JSON field on new form' do render - doc = Nokogiri::HTML(rendered) + doc = Nokogiri::HTML rendered json_textarea = doc.css('textarea#submission_json') expect(json_textarea).to be_empty @@ -82,7 +82,7 @@ it 'renders form fields as enabled (not disabled)' do render - doc = Nokogiri::HTML(rendered) + doc = Nokogiri::HTML rendered html_textarea = doc.css('textarea#submission_html[disabled]') expect(html_textarea).to be_empty diff --git a/spec/views/submissions/show.html.erb_spec.rb b/spec/views/submissions/show.html.erb_spec.rb index 915e3d6..b7a36d4 100644 --- a/spec/views/submissions/show.html.erb_spec.rb +++ b/spec/views/submissions/show.html.erb_spec.rb @@ -2,17 +2,17 @@ RSpec.describe 'submissions/show' do before do - @submission = assign(:submission, Submission.create!( - html: 'MyText', - base_url: 'MyText', - save_html: false, - render_html_in_page: false - )) + @submission = assign :submission, Submission.create!( + html: 'MyText', + base_url: 'MyText', + save_html: false, + render_html_in_page: false + ) end it 'renders attributes in

    ' do render - doc = Nokogiri::HTML(rendered) + doc = Nokogiri::HTML rendered form = doc.css("form[action='#{submission_path(@submission.id)}'][method='post']") expect(form).to be_present From f2cd33f7baa5c1e01f5659e28d458d7cc4ea42f3 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 20:51:12 -0700 Subject: [PATCH 29/44] Symbol routes --- app/controllers/microformats_controller.rb | 2 +- app/controllers/submissions_controller.rb | 2 +- spec/controllers/submissions_controller_spec.rb | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/microformats_controller.rb b/app/controllers/microformats_controller.rb index ead794c..85ad37b 100644 --- a/app/controllers/microformats_controller.rb +++ b/app/controllers/microformats_controller.rb @@ -17,7 +17,7 @@ def show render json: JSON.pretty_generate(results) else - redirect_to new_submission_path + redirect_to %i[new submission] end end end diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index 22d720f..7cdb458 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -50,7 +50,7 @@ def set_submission end def redirect_to_root - redirect_to root_path + redirect_to :root end # Only allow a trusted parameter "white list" through. diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index a47bb4e..81edb49 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -52,7 +52,7 @@ it 'redirects to root' do Submission.create! valid_attributes get :index, params: {}, session: valid_session - expect(response).to redirect_to root_path + expect(response).to redirect_to :root end end @@ -78,7 +78,7 @@ it 'redirects to root' do submission = Submission.create! valid_attributes get :edit, params: { id: submission.to_param }, session: valid_session - expect(response).to redirect_to root_path + expect(response).to redirect_to :root end end @@ -117,13 +117,13 @@ it 'redirects to root without updating' do submission = Submission.create! valid_attributes put :update, params: { id: submission.to_param, submission: valid_attributes }, session: valid_session - expect(response).to redirect_to root_path + expect(response).to redirect_to :root end it 'redirects to the submission' do submission = Submission.create! valid_attributes put :update, params: { id: submission.to_param, submission: valid_attributes }, session: valid_session - expect(response).to redirect_to root_path + expect(response).to redirect_to :root end end @@ -131,7 +131,7 @@ it 'redirects to root' do submission = Submission.create! valid_attributes put :update, params: { id: submission.to_param, submission: {} }, session: valid_session - expect(response).to redirect_to root_path + expect(response).to redirect_to :root end end end @@ -142,7 +142,7 @@ expect do delete :destroy, params: { id: submission.to_param }, session: valid_session end.not_to change(Submission, :count) - expect(response).to redirect_to root_path + expect(response).to redirect_to :root end end end From de1587d339b71a36acf8f65a1fe536e49f59c79d Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 20:55:48 -0700 Subject: [PATCH 30/44] RSpec/InstanceVariable --- .rubocop_todo.yml | 8 +------- spec/views/submissions/new.html.erb_spec.rb | 8 ++++++-- spec/views/submissions/show.html.erb_spec.rb | 10 +++++++--- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3eead4c..61a1c43 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-08-09 03:39:20 UTC using RuboCop version 1.79.2. +# on 2025-08-09 03:55:31 UTC using RuboCop version 1.79.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 @@ -16,12 +16,6 @@ Metrics/MethodLength: RSpec/ExampleLength: Max: 10 -# Offense count: 1 -# Configuration parameters: AssignmentOnly. -RSpec/InstanceVariable: - Exclude: - - 'spec/views/submissions/show.html.erb_spec.rb' - # Offense count: 8 RSpec/MultipleExpectations: Max: 5 diff --git a/spec/views/submissions/new.html.erb_spec.rb b/spec/views/submissions/new.html.erb_spec.rb index 554b497..e639b0e 100644 --- a/spec/views/submissions/new.html.erb_spec.rb +++ b/spec/views/submissions/new.html.erb_spec.rb @@ -1,13 +1,17 @@ require 'rails_helper' RSpec.describe 'submissions/new' do - before do - @submission = assign :submission, Submission.new( + let(:submission) do + Submission.new( html: '

    Test
    ', base_url: 'https://example.com', save_html: false, render_html_in_page: false ) + end + + before do + assign :submission, submission allow(view).to receive(:on_results_page?).and_return false end diff --git a/spec/views/submissions/show.html.erb_spec.rb b/spec/views/submissions/show.html.erb_spec.rb index b7a36d4..d235588 100644 --- a/spec/views/submissions/show.html.erb_spec.rb +++ b/spec/views/submissions/show.html.erb_spec.rb @@ -1,8 +1,8 @@ require 'rails_helper' RSpec.describe 'submissions/show' do - before do - @submission = assign :submission, Submission.create!( + let(:submission) do + Submission.create!( html: 'MyText', base_url: 'MyText', save_html: false, @@ -10,11 +10,15 @@ ) end + before do + assign :submission, submission + end + it 'renders attributes in

    ' do render doc = Nokogiri::HTML rendered - form = doc.css("form[action='#{submission_path(@submission.id)}'][method='post']") + form = doc.css("form[action='#{submission_path(submission.id)}'][method='post']") expect(form).to be_present html_textarea = form.css('textarea[name="submission[html]"]') From 962498b4cdbdc96edbeba5bdeb7fe71f69d8b36b Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 20:58:09 -0700 Subject: [PATCH 31/44] Parens --- spec/views/submissions/new.html.erb_spec.rb | 2 +- spec/views/submissions/show.html.erb_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/views/submissions/new.html.erb_spec.rb b/spec/views/submissions/new.html.erb_spec.rb index e639b0e..7000c19 100644 --- a/spec/views/submissions/new.html.erb_spec.rb +++ b/spec/views/submissions/new.html.erb_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' RSpec.describe 'submissions/new' do - let(:submission) do + let :submission do Submission.new( html: '

    Test
    ', base_url: 'https://example.com', diff --git a/spec/views/submissions/show.html.erb_spec.rb b/spec/views/submissions/show.html.erb_spec.rb index d235588..a84c3fe 100644 --- a/spec/views/submissions/show.html.erb_spec.rb +++ b/spec/views/submissions/show.html.erb_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' RSpec.describe 'submissions/show' do - let(:submission) do + let :submission do Submission.create!( html: 'MyText', base_url: 'MyText', From 1eb4fde74292d427ab7966d39270d04a19c74a93 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 21:02:24 -0700 Subject: [PATCH 32/44] Parens --- spec/controllers/submissions_controller_spec.rb | 4 ++-- spec/views/submissions/new.html.erb_spec.rb | 10 ++++------ spec/views/submissions/show.html.erb_spec.rb | 10 ++++------ 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index 81edb49..8fae571 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -27,7 +27,7 @@ # This should return the minimal set of attributes required to create a valid # Submission. As you add validations to Submission, be sure to # adjust the attributes here as well. - let(:valid_attributes) do + let :valid_attributes do { html: '@aaronpk', base_url: 'https://aaronparecki.com', @@ -36,7 +36,7 @@ } end - let(:invalid_attributes) do + let :invalid_attributes do { html: nil, base_url: nil diff --git a/spec/views/submissions/new.html.erb_spec.rb b/spec/views/submissions/new.html.erb_spec.rb index 7000c19..3279e3c 100644 --- a/spec/views/submissions/new.html.erb_spec.rb +++ b/spec/views/submissions/new.html.erb_spec.rb @@ -2,12 +2,10 @@ RSpec.describe 'submissions/new' do let :submission do - Submission.new( - html: '
    Test
    ', - base_url: 'https://example.com', - save_html: false, - render_html_in_page: false - ) + Submission.new html: '
    Test
    ', + base_url: 'https://example.com', + save_html: false, + render_html_in_page: false end before do diff --git a/spec/views/submissions/show.html.erb_spec.rb b/spec/views/submissions/show.html.erb_spec.rb index a84c3fe..6b1ade3 100644 --- a/spec/views/submissions/show.html.erb_spec.rb +++ b/spec/views/submissions/show.html.erb_spec.rb @@ -2,12 +2,10 @@ RSpec.describe 'submissions/show' do let :submission do - Submission.create!( - html: 'MyText', - base_url: 'MyText', - save_html: false, - render_html_in_page: false - ) + Submission.create! html: 'MyText', + base_url: 'MyText', + save_html: false, + render_html_in_page: false end before do From 796bf393db05e4f9cea64c9973b931da151df35d Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 21:05:34 -0700 Subject: [PATCH 33/44] Delete empty test --- spec/models/submission_spec.rb | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 spec/models/submission_spec.rb diff --git a/spec/models/submission_spec.rb b/spec/models/submission_spec.rb deleted file mode 100644 index e3f41c1..0000000 --- a/spec/models/submission_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'rails_helper' - -RSpec.describe Submission do - it 'can be created with valid attributes' do - submission = described_class.new( - html: '
    Test
    ', - base_url: 'https://example.com', - save_html: true, - render_html_in_page: true - ) - expect(submission).to be_valid - end - - it 'belongs to ActiveRecord' do - expect(described_class.superclass).to eq ApplicationRecord - end -end From a2d3adb6fa7fe48c29466ccce398d5cd72fd1529 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 21:11:32 -0700 Subject: [PATCH 34/44] Remove factorybot --- .rubocop.yml | 1 - Gemfile | 2 -- Gemfile.lock | 10 ------- spec/factories/submissions.rb | 9 ------ spec/requests/submissions_spec.rb | 10 ------- spec/routing/submissions_routing_spec.rb | 37 ------------------------ 6 files changed, 69 deletions(-) delete mode 100644 spec/factories/submissions.rb delete mode 100644 spec/requests/submissions_spec.rb delete mode 100644 spec/routing/submissions_routing_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index b1aaf90..0123173 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,6 @@ inherit_from: .rubocop_todo.yml plugins: - rubocop-rails - rubocop-rspec - - rubocop-factory_bot - rubocop-rspec_rails AllCops: diff --git a/Gemfile b/Gemfile index 18213d8..b6e1b89 100644 --- a/Gemfile +++ b/Gemfile @@ -16,13 +16,11 @@ gem 'microformats' # dev and testing group :development, :test do - gem 'factory_bot_rails' gem 'rails-controller-testing' gem 'rspec-rails' # For codestyle guide and linting gem 'rubocop', require: false - gem 'rubocop-factory_bot', require: false gem 'rubocop-rails', require: false gem 'rubocop-rspec', require: false gem 'rubocop-rspec_rails', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 01fed55..f52f86d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,11 +85,6 @@ GEM drb (2.2.3) erb (5.0.2) erubi (1.13.1) - factory_bot (6.5.4) - activesupport (>= 6.1.0) - factory_bot_rails (6.5.0) - factory_bot (~> 6.5) - railties (>= 6.1.0) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.7) @@ -244,9 +239,6 @@ GEM rubocop-ast (1.46.0) parser (>= 3.3.7.2) prism (~> 1.4) - rubocop-factory_bot (2.27.1) - lint_roller (~> 1.1) - rubocop (~> 1.72, >= 1.72.1) rubocop-rails (2.32.0) activesupport (>= 4.2.0) lint_roller (~> 1.1) @@ -291,7 +283,6 @@ PLATFORMS x86_64-linux-musl DEPENDENCIES - factory_bot_rails microformats pg puma @@ -299,7 +290,6 @@ DEPENDENCIES rails-controller-testing rspec-rails rubocop - rubocop-factory_bot rubocop-rails rubocop-rspec rubocop-rspec_rails diff --git a/spec/factories/submissions.rb b/spec/factories/submissions.rb deleted file mode 100644 index 21761bf..0000000 --- a/spec/factories/submissions.rb +++ /dev/null @@ -1,9 +0,0 @@ -FactoryBot.define do - factory :submission do - url { 'MyText' } - html { 'MyText' } - base_url { 'MyText' } - save_html { false } - render_html_in_page { false } - end -end diff --git a/spec/requests/submissions_spec.rb b/spec/requests/submissions_spec.rb deleted file mode 100644 index 3cf0eae..0000000 --- a/spec/requests/submissions_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'Submissions' do - describe 'GET /submissions' do - it 'works! (now write some real specs)' do - get submissions_path - expect(response).to have_http_status(:redirect) - end - end -end diff --git a/spec/routing/submissions_routing_spec.rb b/spec/routing/submissions_routing_spec.rb deleted file mode 100644 index 2e5a343..0000000 --- a/spec/routing/submissions_routing_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'rails_helper' - -RSpec.describe SubmissionsController do - describe 'routing' do - it 'routes to #index' do - expect(get: '/submissions').to route_to('submissions#index') - end - - it 'routes to #new' do - expect(get: '/submissions/new').to route_to('submissions#new') - end - - it 'routes to #show' do - expect(get: '/submissions/1').to route_to('submissions#show', id: '1') - end - - it 'routes to #edit' do - expect(get: '/submissions/1/edit').to route_to('submissions#edit', id: '1') - end - - it 'routes to #create' do - expect(post: '/submissions').to route_to('submissions#create') - end - - it 'routes to #update via PUT' do - expect(put: '/submissions/1').to route_to('submissions#update', id: '1') - end - - it 'routes to #update via PATCH' do - expect(patch: '/submissions/1').to route_to('submissions#update', id: '1') - end - - it 'routes to #destroy' do - expect(delete: '/submissions/1').to route_to('submissions#destroy', id: '1') - end - end -end From a716deb771d4d9cc33ea45729b78e43be2e5fd5e Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 21:14:19 -0700 Subject: [PATCH 35/44] RSpec style --- app/controllers/microformats_controller.rb | 2 +- spec/controllers/microformats_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/microformats_controller.rb b/app/controllers/microformats_controller.rb index 85ad37b..fb8ac01 100644 --- a/app/controllers/microformats_controller.rb +++ b/app/controllers/microformats_controller.rb @@ -17,7 +17,7 @@ def show render json: JSON.pretty_generate(results) else - redirect_to %i[new submission] + redirect_to :root end end end diff --git a/spec/controllers/microformats_controller_spec.rb b/spec/controllers/microformats_controller_spec.rb index d78d748..007e86d 100644 --- a/spec/controllers/microformats_controller_spec.rb +++ b/spec/controllers/microformats_controller_spec.rb @@ -4,7 +4,7 @@ describe 'GET #show' do it 'returns http redirect' do get :show - expect(response).to have_http_status(:redirect) + expect(response).to redirect_to :root end end end From 1b2c8c08ebf7406b7c738eb8a76f06e768715555 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 21:17:04 -0700 Subject: [PATCH 36/44] RSpec/RepeatedExample --- .rubocop_todo.yml | 9 ++------- spec/controllers/submissions_controller_spec.rb | 8 +------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 61a1c43..4b01014 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-08-09 03:55:31 UTC using RuboCop version 1.79.2. +# on 2025-08-09 04:16:46 UTC using RuboCop version 1.79.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 @@ -11,7 +11,7 @@ Metrics/MethodLength: Max: 15 -# Offense count: 7 +# Offense count: 6 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 10 @@ -20,11 +20,6 @@ RSpec/ExampleLength: RSpec/MultipleExpectations: Max: 5 -# Offense count: 2 -RSpec/RepeatedExample: - Exclude: - - 'spec/controllers/submissions_controller_spec.rb' - # Offense count: 2 # Configuration parameters: Include. # Include: db/**/*.rb diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb index 8fae571..09d57b5 100644 --- a/spec/controllers/submissions_controller_spec.rb +++ b/spec/controllers/submissions_controller_spec.rb @@ -114,13 +114,7 @@ describe 'PUT #update' do context 'with valid params' do - it 'redirects to root without updating' do - submission = Submission.create! valid_attributes - put :update, params: { id: submission.to_param, submission: valid_attributes }, session: valid_session - expect(response).to redirect_to :root - end - - it 'redirects to the submission' do + it 'redirects to root' do submission = Submission.create! valid_attributes put :update, params: { id: submission.to_param, submission: valid_attributes }, session: valid_session expect(response).to redirect_to :root From 9baa901e335e6179ac3281b76b66541673004dcd Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 21:35:29 -0700 Subject: [PATCH 37/44] Add rubocop capybara --- .rubocop.yml | 1 + .rubocop_todo.yml | 10 +- Gemfile | 3 + Gemfile.lock | 30 ++++ .../microformats_controller_spec.rb | 10 -- .../submissions_controller_spec.rb | 142 ------------------ spec/helpers/microformats_helper_spec.rb | 12 -- spec/helpers/submissions_helper_spec.rb | 12 -- spec/rails_helper.rb | 17 +++ spec/system/microformats_parsing_spec.rb | 68 +++++++++ spec/views/microformats/show.html.erb_spec.rb | 1 - spec/views/submissions/new.html.erb_spec.rb | 95 ------------ spec/views/submissions/show.html.erb_spec.rb | 31 ---- 13 files changed, 124 insertions(+), 308 deletions(-) delete mode 100644 spec/controllers/microformats_controller_spec.rb delete mode 100644 spec/controllers/submissions_controller_spec.rb delete mode 100644 spec/helpers/microformats_helper_spec.rb delete mode 100644 spec/helpers/submissions_helper_spec.rb create mode 100644 spec/system/microformats_parsing_spec.rb delete mode 100644 spec/views/microformats/show.html.erb_spec.rb delete mode 100644 spec/views/submissions/new.html.erb_spec.rb delete mode 100644 spec/views/submissions/show.html.erb_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index 0123173..db6c2e5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,7 @@ inherit_from: .rubocop_todo.yml plugins: + - rubocop-capybara - rubocop-rails - rubocop-rspec - rubocop-rspec_rails diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4b01014..81c7145 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-08-09 04:16:46 UTC using RuboCop version 1.79.2. +# on 2025-08-09 04:33:40 UTC using RuboCop version 1.79.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 @@ -11,14 +11,14 @@ Metrics/MethodLength: Max: 15 -# Offense count: 6 +# Offense count: 5 # Configuration parameters: CountAsOne. RSpec/ExampleLength: - Max: 10 + Max: 9 -# Offense count: 8 +# Offense count: 3 RSpec/MultipleExpectations: - Max: 5 + Max: 3 # Offense count: 2 # Configuration parameters: Include. diff --git a/Gemfile b/Gemfile index b6e1b89..d18de06 100644 --- a/Gemfile +++ b/Gemfile @@ -16,11 +16,14 @@ gem 'microformats' # dev and testing group :development, :test do + gem 'capybara' gem 'rails-controller-testing' gem 'rspec-rails' + gem 'selenium-webdriver' # For codestyle guide and linting gem 'rubocop', require: false + gem 'rubocop-capybara', require: false gem 'rubocop-rails', require: false gem 'rubocop-rspec', require: false gem 'rubocop-rspec_rails', require: false diff --git a/Gemfile.lock b/Gemfile.lock index f52f86d..2a7399f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,11 +72,22 @@ GEM securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) ast (2.4.3) base64 (0.3.0) benchmark (0.4.1) bigdecimal (3.2.2) builder (3.3.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) concurrent-ruby (1.3.5) connection_pool (2.5.3) crass (1.0.6) @@ -107,6 +118,7 @@ GEM net-pop net-smtp marcel (1.0.4) + matrix (0.4.3) microformats (4.5.0) json nokogiri @@ -156,6 +168,7 @@ GEM psych (5.2.6) date stringio + public_suffix (6.0.2) puma (6.6.1) nio4r (~> 2.0) racc (1.8.1) @@ -208,6 +221,7 @@ GEM regexp_parser (2.11.1) reline (0.6.2) io-console (~> 0.5) + rexml (3.4.1) rspec-core (3.13.5) rspec-support (~> 3.13.0) rspec-expectations (3.13.5) @@ -239,6 +253,9 @@ GEM rubocop-ast (1.46.0) parser (>= 3.3.7.2) prism (~> 1.4) + rubocop-capybara (2.22.1) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) rubocop-rails (2.32.0) activesupport (>= 4.2.0) lint_roller (~> 1.1) @@ -253,7 +270,14 @@ GEM rubocop (~> 1.72, >= 1.72.1) rubocop-rspec (~> 3.5) ruby-progressbar (1.13.0) + rubyzip (2.4.1) securerandom (0.4.1) + selenium-webdriver (4.34.0) + base64 (~> 0.2) + logger (~> 1.4) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) stringio (3.1.7) thor (1.4.0) timeout (0.4.3) @@ -264,10 +288,13 @@ GEM unicode-emoji (4.0.4) uri (1.0.3) useragent (0.16.11) + websocket (1.2.11) websocket-driver (0.8.0) base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) zeitwerk (2.7.3) PLATFORMS @@ -283,6 +310,7 @@ PLATFORMS x86_64-linux-musl DEPENDENCIES + capybara microformats pg puma @@ -290,9 +318,11 @@ DEPENDENCIES rails-controller-testing rspec-rails rubocop + rubocop-capybara rubocop-rails rubocop-rspec rubocop-rspec_rails + selenium-webdriver tzinfo-data RUBY VERSION diff --git a/spec/controllers/microformats_controller_spec.rb b/spec/controllers/microformats_controller_spec.rb deleted file mode 100644 index 007e86d..0000000 --- a/spec/controllers/microformats_controller_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'rails_helper' - -RSpec.describe MicroformatsController do - describe 'GET #show' do - it 'returns http redirect' do - get :show - expect(response).to redirect_to :root - end - end -end diff --git a/spec/controllers/submissions_controller_spec.rb b/spec/controllers/submissions_controller_spec.rb deleted file mode 100644 index 09d57b5..0000000 --- a/spec/controllers/submissions_controller_spec.rb +++ /dev/null @@ -1,142 +0,0 @@ -require 'rails_helper' - -# This spec was generated by rspec-rails when you ran the scaffold generator. -# It demonstrates how one might use RSpec to specify the controller code that -# was generated by Rails when you ran the scaffold generator. -# -# It assumes that the implementation code is generated by the rails scaffold -# generator. If you are using any extension libraries to generate different -# controller code, this generated spec may or may not pass. -# -# It only uses APIs available in rails and/or rspec-rails. There are a number -# of tools you can use to make these specs even more expressive, but we're -# sticking to rails and rspec-rails APIs to keep things simple and stable. -# -# Compared to earlier versions of this generator, there is very limited use of -# stubs and message expectations in this spec. Stubs are only used when there -# is no simpler way to get a handle on the object needed for the example. -# Message expectations are only used when there is no simpler way to specify -# that an instance is receiving a specific message. -# -# Also compared to earlier versions of this generator, there are no longer any -# expectations of assigns and templates rendered. These features have been -# removed from Rails core in Rails 5, but can be added back in via the -# `rails-controller-testing` gem. - -RSpec.describe SubmissionsController do - # This should return the minimal set of attributes required to create a valid - # Submission. As you add validations to Submission, be sure to - # adjust the attributes here as well. - let :valid_attributes do - { - html: '@aaronpk', - base_url: 'https://aaronparecki.com', - save_html: true, - render_html_in_page: true - } - end - - let :invalid_attributes do - { - html: nil, - base_url: nil - } - end - - # This should return the minimal set of values that should be in the session - # in order to pass any filters (e.g. authentication) defined in - # SubmissionsController. Be sure to keep this updated too. - let(:valid_session) { {} } - - describe 'GET #index' do - it 'redirects to root' do - Submission.create! valid_attributes - get :index, params: {}, session: valid_session - expect(response).to redirect_to :root - end - end - - describe 'GET #show' do - it 'returns a success response' do - submission = Submission.create! valid_attributes - get :show, params: { id: submission.to_param }, session: valid_session - expect(response).to be_successful - end - end - - describe 'GET #new' do - it 'returns a success response' do - get :new, params: {}, session: valid_session - - # binding.irb - - expect(response).to be_successful - end - end - - describe 'GET #edit' do - it 'redirects to root' do - submission = Submission.create! valid_attributes - get :edit, params: { id: submission.to_param }, session: valid_session - expect(response).to redirect_to :root - end - end - - describe 'POST #create' do - context 'with valid params' do - it 'creates a new Submission' do - expect do - post :create, params: { submission: valid_attributes }, session: valid_session - end.to change(Submission, :count).by 1 - end - - it 'redirects to the created submission' do - post :create, params: { submission: valid_attributes }, session: valid_session - expect(response).to redirect_to Submission.last - end - end - - context 'with invalid params' do - it 'renders the show template when save_html is false' do - invalid_attrs_without_save_html = invalid_attributes.merge(save_html: false) - post :create, params: { submission: invalid_attrs_without_save_html }, session: valid_session - expect(response).to be_successful - expect(response).to render_template :show - end - - it 'redirects to submission when save_html is true (no model validations exist)' do - invalid_attrs_with_save_html = invalid_attributes.merge(save_html: true) - post :create, params: { submission: invalid_attrs_with_save_html }, session: valid_session - expect(response).to redirect_to Submission.last - end - end - end - - describe 'PUT #update' do - context 'with valid params' do - it 'redirects to root' do - submission = Submission.create! valid_attributes - put :update, params: { id: submission.to_param, submission: valid_attributes }, session: valid_session - expect(response).to redirect_to :root - end - end - - context 'with invalid params' do - it 'redirects to root' do - submission = Submission.create! valid_attributes - put :update, params: { id: submission.to_param, submission: {} }, session: valid_session - expect(response).to redirect_to :root - end - end - end - - describe 'DELETE #destroy' do - it 'redirects to root without destroying' do - submission = Submission.create! valid_attributes - expect do - delete :destroy, params: { id: submission.to_param }, session: valid_session - end.not_to change(Submission, :count) - expect(response).to redirect_to :root - end - end -end diff --git a/spec/helpers/microformats_helper_spec.rb b/spec/helpers/microformats_helper_spec.rb deleted file mode 100644 index 84ebf61..0000000 --- a/spec/helpers/microformats_helper_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the MicroformatsHelper. For example: -# -# describe MicroformatsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end diff --git a/spec/helpers/submissions_helper_spec.rb b/spec/helpers/submissions_helper_spec.rb deleted file mode 100644 index c42acca..0000000 --- a/spec/helpers/submissions_helper_spec.rb +++ /dev/null @@ -1,12 +0,0 @@ -require 'rails_helper' - -# Specs in this file have access to a helper object that includes -# the SubmissionsHelper. For example: -# -# describe SubmissionsHelper do -# describe "string concat" do -# it "concats two strings with spaces" do -# expect(helper.concat_strings("this","that")).to eq("this that") -# end -# end -# end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 1b9ef13..89befa8 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -5,6 +5,8 @@ # Prevent database truncation if the environment is production abort('The Rails environment is running in production mode!') if Rails.env.production? require 'rspec/rails' +require 'capybara/rails' +require 'capybara/rspec' # Add additional requires below this line. Rails is not loaded until this point! # Requires supporting ruby files with custom matchers and macros, etc, in @@ -55,3 +57,18 @@ # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") end + +# Capybara configuration +Capybara.register_driver :headless_chrome do |app| + capabilities = Selenium::WebDriver::Chrome::Options.new + capabilities.add_argument '--headless' + capabilities.add_argument '--no-sandbox' + capabilities.add_argument '--disable-dev-shm-usage' + + Capybara::Selenium::Driver.new app, + browser: :chrome, + options: capabilities +end + +Capybara.javascript_driver = :headless_chrome +Capybara.default_driver = :rack_test diff --git a/spec/system/microformats_parsing_spec.rb b/spec/system/microformats_parsing_spec.rb new file mode 100644 index 0000000..c8626d5 --- /dev/null +++ b/spec/system/microformats_parsing_spec.rb @@ -0,0 +1,68 @@ +require 'rails_helper' + +RSpec.describe 'Microformats parsing' do + it 'parses microformats from a URL' do + visit '/' + + within 'form[action="/microformats"]' do + fill_in 'url', with: 'https://aaronparecki.com' + click_button 'Parse' + end + + expect(page).to have_content 'package' + expect(page).to have_content 'microformats-ruby' + expect(page).to have_content 'version' + end + + it 'parses microformats from HTML snippet without saving' do + visit '/' + + within 'form[action="/submissions"]' do + fill_in 'submission_html', with: '
    Test
    ' + uncheck 'Save HTML?' + click_button 'Parse' + end + + expect(page).to have_content 'h-card' + end + + it 'parses and saves microformats from HTML snippet' do + visit '/' + + within 'form[action="/submissions"]' do + fill_in 'submission_html', with: '
    Test
    ' + check 'Save HTML?' + click_button 'Parse' + end + + expect(page).to have_content 'Submission was successfully created' + end + + it 'shows form validation when trying to save empty HTML' do + visit '/' + + within 'form[action="/submissions"]' do + fill_in 'submission_html', with: '' + check 'Save HTML?' + click_button 'Parse' + end + + expect(page).to have_content 'items' + expect(page).to have_content '[]' + end + + it 'renders HTML in page when option is selected' do + visit '/' + + html_snippet = '
    Test User
    ' + + within 'form[action="/submissions"]' do + fill_in 'submission_html', with: html_snippet + check 'Render HTML in Page?' + click_button 'Parse' + end + + expect(page).to have_css '.h-card' + expect(page).to have_content 'Test User' + end +end diff --git a/spec/views/microformats/show.html.erb_spec.rb b/spec/views/microformats/show.html.erb_spec.rb deleted file mode 100644 index 63f198b..0000000 --- a/spec/views/microformats/show.html.erb_spec.rb +++ /dev/null @@ -1 +0,0 @@ -require 'rails_helper' diff --git a/spec/views/submissions/new.html.erb_spec.rb b/spec/views/submissions/new.html.erb_spec.rb deleted file mode 100644 index 3279e3c..0000000 --- a/spec/views/submissions/new.html.erb_spec.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'submissions/new' do - let :submission do - Submission.new html: '
    Test
    ', - base_url: 'https://example.com', - save_html: false, - render_html_in_page: false - end - - before do - assign :submission, submission - allow(view).to receive(:on_results_page?).and_return false - end - - it 'renders the URL parsing form' do - render - doc = Nokogiri::HTML rendered - - form = doc.css("form[action='#{microformats_path}'][method='get']") - expect(form).to be_present - - url_input = form.css('input#submission_url[type="url"]') - expect(url_input).to be_present - - submit_button = form.css('input[type="submit"][value="Parse"]') - expect(submit_button).to be_present - end - - it 'renders the HTML snippet form' do - render - doc = Nokogiri::HTML rendered - - form = doc.css("form[action='#{submissions_path}'][method='post']") - expect(form).to be_present - - html_textarea = form.css('textarea#submission_html') - expect(html_textarea).to be_present - - base_url_input = form.css('input#submission_base_url[type="url"]') - expect(base_url_input).to be_present - end - - it 'renders form controls for HTML snippet form' do - render - doc = Nokogiri::HTML rendered - - save_html_checkbox = doc.css('input#submission_save_html[type="checkbox"]') - expect(save_html_checkbox).to be_present - - render_html_checkbox = doc.css('input#submission_render_html_in_page[type="checkbox"]') - expect(render_html_checkbox).to be_present - - submit_button = doc.css('input[type="submit"][value="Parse"]') - expect(submit_button).to be_present - end - - it 'renders labels for form fields' do - render - doc = Nokogiri::HTML rendered - - expect(doc.css('label').text).to include 'Enter a URL' - expect(doc.css('label').text).to include 'HTML' - expect(doc.css('label').text).to include 'Base URL' - expect(doc.css('label[for="submission_save_html"]').text).to include 'Save HTML?' - expect(doc.css('label[for="submission_render_html_in_page"]').text).to include 'Render HTML in Page?' - end - - it 'displays the section heading' do - render - doc = Nokogiri::HTML rendered - - heading = doc.css('h2') - expect(heading.text).to include 'OR parse just a snippet of HTML' - end - - it 'does not render JSON field on new form' do - render - doc = Nokogiri::HTML rendered - - json_textarea = doc.css('textarea#submission_json') - expect(json_textarea).to be_empty - end - - it 'renders form fields as enabled (not disabled)' do - render - doc = Nokogiri::HTML rendered - - html_textarea = doc.css('textarea#submission_html[disabled]') - expect(html_textarea).to be_empty - - base_url_input = doc.css('input#submission_base_url[disabled]') - expect(base_url_input).to be_empty - end -end diff --git a/spec/views/submissions/show.html.erb_spec.rb b/spec/views/submissions/show.html.erb_spec.rb deleted file mode 100644 index 6b1ade3..0000000 --- a/spec/views/submissions/show.html.erb_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'rails_helper' - -RSpec.describe 'submissions/show' do - let :submission do - Submission.create! html: 'MyText', - base_url: 'MyText', - save_html: false, - render_html_in_page: false - end - - before do - assign :submission, submission - end - - it 'renders attributes in

    ' do - render - doc = Nokogiri::HTML rendered - - form = doc.css("form[action='#{submission_path(submission.id)}'][method='post']") - expect(form).to be_present - - html_textarea = form.css('textarea[name="submission[html]"]') - expect(html_textarea).to be_present - - base_url_input = form.css('input[name="submission[base_url]"][value="MyText"]') - expect(base_url_input).to be_present - - json_textarea = form.css('textarea[name="submission[json]"]') - expect(json_textarea).to be_present - end -end From 452a2b5149bf04774d6d2adcee88ba036786bb1a Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 21:41:27 -0700 Subject: [PATCH 38/44] Rename test --- spec/system/microformats_parsing_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/microformats_parsing_spec.rb b/spec/system/microformats_parsing_spec.rb index c8626d5..52b73b1 100644 --- a/spec/system/microformats_parsing_spec.rb +++ b/spec/system/microformats_parsing_spec.rb @@ -38,7 +38,7 @@ expect(page).to have_content 'Submission was successfully created' end - it 'shows form validation when trying to save empty HTML' do + it 'parses empty HTML and shows empty results' do visit '/' within 'form[action="/submissions"]' do From 9cdb593f1318c76d57f5f1178d8b08fb65829f9a Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 21:53:52 -0700 Subject: [PATCH 39/44] Update app to Rails 8 --- .rubocop_todo.yml | 2 +- bin/dev | 2 +- bin/rails | 6 +- bin/rake | 4 +- bin/rubocop | 8 +- bin/setup | 35 ++-- config/application.rb | 16 +- config/environments/development.rb | 64 ++++--- config/environments/production.rb | 114 ++++++----- config/environments/test.rb | 55 +++--- .../initializers/content_security_policy.rb | 25 +++ .../initializers/filter_parameter_logging.rb | 8 +- config/initializers/inflections.rb | 8 +- .../new_framework_defaults_8_0.rb | 30 +++ config/puma.rb | 79 ++++---- config/storage.yml | 34 ++++ ..._to_active_storage_blobs.active_storage.rb | 24 +++ ..._storage_variant_records.active_storage.rb | 28 +++ ...e_storage_blobs_checksum.active_storage.rb | 8 + db/schema.rb | 2 +- public/400.html | 114 +++++++++++ public/404.html | 179 +++++++++++------- public/406-unsupported-browser.html | 114 +++++++++++ public/422.html | 179 +++++++++++------- public/500.html | 178 ++++++++++------- public/icon.png | Bin 0 -> 4166 bytes public/icon.svg | 3 + public/robots.txt | 2 +- 28 files changed, 937 insertions(+), 384 deletions(-) create mode 100644 config/initializers/content_security_policy.rb create mode 100644 config/initializers/new_framework_defaults_8_0.rb create mode 100644 config/storage.yml create mode 100644 db/migrate/20250809045033_add_service_name_to_active_storage_blobs.active_storage.rb create mode 100644 db/migrate/20250809045034_create_active_storage_variant_records.active_storage.rb create mode 100644 db/migrate/20250809045035_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb create mode 100644 public/400.html create mode 100644 public/406-unsupported-browser.html create mode 100644 public/icon.png create mode 100644 public/icon.svg diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 81c7145..3749664 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-08-09 04:33:40 UTC using RuboCop version 1.79.2. +# on 2025-08-09 04:53:37 UTC using RuboCop version 1.79.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 diff --git a/bin/dev b/bin/dev index 52088a3..5f91c20 100755 --- a/bin/dev +++ b/bin/dev @@ -1,2 +1,2 @@ #!/usr/bin/env ruby -exec './bin/rails', 'server', *ARGV +exec "./bin/rails", "server", *ARGV diff --git a/bin/rails b/bin/rails index 0739660..efc0377 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../config/application', __dir__) -require_relative '../config/boot' -require 'rails/commands' +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake index 1724048..4fbf10b 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -require_relative '../config/boot' -require 'rake' +require_relative "../config/boot" +require "rake" Rake.application.run diff --git a/bin/rubocop b/bin/rubocop index b3ed7c5..40330c0 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -1,8 +1,8 @@ #!/usr/bin/env ruby -require 'rubygems' -require 'bundler/setup' +require "rubygems" +require "bundler/setup" # explicit rubocop config increases performance slightly while avoiding config confusion. -ARGV.unshift('--config', File.expand_path('../.rubocop.yml', __dir__)) +ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) -load Gem.bin_path('rubocop', 'rubocop') +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/setup b/bin/setup index 8de5867..be3db3c 100755 --- a/bin/setup +++ b/bin/setup @@ -1,29 +1,34 @@ #!/usr/bin/env ruby -require 'pathname' -require 'fileutils' -include FileUtils +require "fileutils" -# path to your application root. -APP_ROOT = Pathname.new File.expand_path('..', __dir__) +APP_ROOT = File.expand_path("..", __dir__) def system!(*args) - system(*args) || abort("\n== Command #{args} failed ==") + system(*args, exception: true) end -chdir APP_ROOT do - # This script is a starting point to setup your application. +FileUtils.chdir APP_ROOT do + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') + puts "== Installing dependencies ==" + system("bundle check") || system!("bundle install") + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" + # end puts "\n== Preparing database ==" - system! 'bin/rails db:setup' + system! "bin/rails db:prepare" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" - puts "\n== Restarting application server ==" - system! 'bin/rails restart' + unless ARGV.include?("--skip-server") + puts "\n== Starting development server ==" + STDOUT.flush # flush the output before exec(2) so that it displays + exec "bin/dev" + end end diff --git a/config/application.rb b/config/application.rb index 7ddad04..5e7d483 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,11 +11,17 @@ class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. config.load_defaults 5.1 - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w[assets tasks]) - # Fix deprecation warning for timezone handling in Rails 8.1 - config.active_support.to_time_preserves_timezone = :zone + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") end end diff --git a/config/environments/development.rb b/config/environments/development.rb index ee4e300..064bebc 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,10 +1,10 @@ +require 'active_support/core_ext/integer/time' + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development - # since you don't have to restart the web server when you make code changes. - config.cache_classes = false + # Make code changes take effect immediately without server restart. + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -12,43 +12,61 @@ # Show full error reports. config.consider_all_requests_local = true - # Enable/disable caching. By default caching is disabled. + # Enable server timing. + config.server_timing = true + + # Enable/disable Action Controller caching. By default Action Controller caching is disabled. + # Run rails dev:cache to toggle Action Controller caching. if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true - - config.cache_store = :memory_store - config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" - } + config.action_controller.enable_fragment_cache_logging = true + config.public_file_server.headers = { 'cache-control' => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false - - config.cache_store = :null_store end + # Change to :null_store to avoid any caching. + config.cache_store = :memory_store + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + # Make template changes take effect immediately. config.action_mailer.perform_caching = false + # Set localhost to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - # config.assets.debug = true + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Append comments with runtime information tags to SQL queries in logs. + config.active_record.query_log_tags_enabled = true + + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + config.action_view.annotate_rendered_view_with_filenames = true - # Suppress logger output for asset requests. - # config.assets.quiet = true + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true - # Use an evented file watcher to asynchronously detect changes in source code, - # routes, locales, etc. This feature depends on the listen gem. - # config.file_watcher = ActiveSupport::EventedFileUpdateChecker + # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. + # config.generators.apply_rubocop_autocorrect_after_generate! end diff --git a/config/environments/production.rb b/config/environments/production.rb index cde20ac..6c41245 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,91 +1,89 @@ +require 'active_support/core_ext/integer/time' + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + config.enable_reloading = false - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. + # Eager load code on boot for better performance and memory savings (ignored by Rake tasks). config.eager_load = true - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Attempt to read encrypted secrets from `config/secrets.yml.enc`. - # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or - # `config/secrets.yml.key`. - config.read_encrypted_secrets = true - - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + # Full error reports are disabled. + config.consider_all_requests_local = false - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier - # config.assets.css_compressor = :sass - - # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false + # Turn on fragment caching in view templates. + config.action_controller.perform_caching = true - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + # Cache assets for far-future expiry since they are all digest stamped. + config.public_file_server.headers = { 'cache-control' => "public, max-age=#{1.year.to_i}" } # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # config.asset_host = "http://assets.example.com" - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local - # Mount Action Cable outside main process or domain - # config.action_cable.mount_path = nil - # config.action_cable.url = 'wss://example.com/cable' - # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + config.assume_ssl = true # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true + config.force_ssl = true - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug + # Skip http-to-https redirect for the default health check endpoint. + # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } - # Prepend all log lines with the following tags. + # Log to STDOUT with the current request id as a default log tag. config.log_tags = [:request_id] + config.logger = ActiveSupport::TaggedLogging.logger($stdout) + + # Change to "debug" to log everything (including potentially personally-identifiable information!) + config.log_level = ENV.fetch('RAILS_LOG_LEVEL', 'info') + + # Prevent health checks from clogging up the logs. + config.silence_healthcheck_path = '/up' - # Use a different cache store in production. + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Replace the default in-process memory cache store with a durable alternative. # config.cache_store = :mem_cache_store - # Use a real queuing backend for Active Job (and separate queues per environment) - # config.active_job.queue_adapter = :resque - # config.active_job.queue_name_prefix = "microformats-ruby-parser_#{Rails.env}" - config.action_mailer.perform_caching = false + # Replace the default in-process and non-durable queuing backend for Active Job. + # config.active_job.queue_adapter = :resque # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false + # Set host to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: 'example.com' } + + # Specify outgoing SMTP server. Remember to add smtp/* credentials via rails credentials:edit. + # config.action_mailer.smtp_settings = { + # user_name: Rails.application.credentials.dig(:smtp, :user_name), + # password: Rails.application.credentials.dig(:smtp, :password), + # address: "smtp.example.com", + # port: 587, + # authentication: :plain + # } + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = Logger::Formatter.new - - # Use a different logger for distributed setups. - # require 'syslog/logger' - # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') - - if ENV['RAILS_LOG_TO_STDOUT'].present? - logger = ActiveSupport::Logger.new($stdout) - logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) - end - # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false + + # Only use :id for inspections in production. + config.active_record.attributes_for_inspect = [:id] + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } end diff --git a/config/environments/test.rb b/config/environments/test.rb index 8e5cbde..7a026c6 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,42 +1,53 @@ +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! - config.cache_classes = true + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false - # Do not eager load code on boot. This avoids loading your whole application - # just for the purpose of running a single test. If you are using a tool that - # preloads Rails for running tests, you may have to set it to true. - config.eager_load = false + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. + config.eager_load = ENV['CI'].present? - # Configure public file server for tests with Cache-Control for performance. - config.public_file_server.enabled = true - config.public_file_server.headers = { - 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" - } + # Configure public file server for tests with cache-control for performance. + config.public_file_server.headers = { 'cache-control' => 'public, max-age=3600' } - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true + config.cache_store = :null_store - # Raise exceptions instead of rendering exception templates. - config.action_dispatch.show_exceptions = false + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false - config.action_mailer.perform_caching = false + + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Set host to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: 'example.com' } + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - # Raises error for missing translations - # config.action_view.raise_on_missing_translations = true + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..b3076b3 --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header + +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src style-src) +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true +# end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4a994e1..f72dcdf 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,8 @@ # Be sure to restart your server when you modify this file. -# Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. +# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. +Rails.application.config.filter_parameters += %i[ + passw email secret token _key crypt salt certificate otp ssn cvv cvc +] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index ac033bf..3860f65 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -4,13 +4,13 @@ # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| -# inflect.acronym 'RESTful' +# inflect.acronym "RESTful" # end diff --git a/config/initializers/new_framework_defaults_8_0.rb b/config/initializers/new_framework_defaults_8_0.rb new file mode 100644 index 0000000..92efa95 --- /dev/null +++ b/config/initializers/new_framework_defaults_8_0.rb @@ -0,0 +1,30 @@ +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 8.0 framework defaults upgrade. +# +# Uncomment each configuration one by one to switch to the new default. +# Once your application is ready to run with all new defaults, you can remove +# this file and set the `config.load_defaults` to `8.0`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +### +# Specifies whether `to_time` methods preserve the UTC offset of their receivers or preserves the timezone. +# If set to `:zone`, `to_time` methods will use the timezone of their receivers. +# If set to `:offset`, `to_time` methods will use the UTC offset. +# If `false`, `to_time` methods will convert to the local system UTC offset instead. +#++ +# Rails.application.config.active_support.to_time_preserves_timezone = :zone + +### +# When both `If-Modified-Since` and `If-None-Match` are provided by the client +# only consider `If-None-Match` as specified by RFC 7232 Section 6. +# If set to `false` both conditions need to be satisfied. +#++ +# Rails.application.config.action_dispatch.strict_freshness = true + +### +# Set `Regexp.timeout` to `1`s by default to improve security over Regexp Denial-of-Service attacks. +#++ +# Regexp.timeout = 1 diff --git a/config/puma.rb b/config/puma.rb index 7223b97..6899c5a 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,52 +1,41 @@ -# Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers: a minimum and maximum. -# Any libraries that use thread pools should be configured to match -# the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum; this matches the default thread size of Active Record. +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. # -threads_count = ENV.fetch 'RAILS_MAX_THREADS', 5 +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. +# +# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You +# should only set this value when you want to run 2 or more workers. The +# default is already 1. +# +# The ideal number of threads per worker depends both on how much time the +# application spends waiting for IO operations and on how much you wish to +# prioritize throughput over latency. +# +# As a rule of thumb, increasing the number of threads will increase how much +# traffic a given process can handle (throughput), but due to CRuby's +# Global VM Lock (GVL) it has diminishing returns and will degrade the +# response time (latency) of the application. +# +# The default is set to 3 threads as it's deemed a decent compromise between +# throughput and latency for the average Rails application. +# +# Any libraries that use a connection pool or another resource pool should +# be configured to provide at least as many connections as the number of +# threads. This includes Active Record's `pool` parameter in `database.yml`. +threads_count = ENV.fetch('RAILS_MAX_THREADS', 3) threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. -port ENV.fetch 'PORT', 3000 - -# Specifies the `environment` that Puma will run in. -environment ENV.fetch 'RAILS_ENV', 'development' - -# Specifies the number of `workers` to boot in clustered mode. -# Workers are forked webserver processes. If using threads and workers together -# the concurrency of the application would be max `threads` * `workers`. -# Workers do not work on JRuby or Windows (both of which do not support -# processes). -# workers ENV.fetch "WEB_CONCURRENCY", 2 +port ENV.fetch('PORT', 3000) -# Use the `preload_app!` method when specifying a `workers` number. -# This directive tells Puma to first boot the application and load code -# before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. If you use this option -# you need to make sure to reconnect any threads in the `on_worker_boot` -# block. -# preload_app! - -# If you are preloading your application and using Active Record, it's -# recommended that you close any connections to the database before workers -# are forked to prevent connection leakage. -# -# before_fork do -# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) -# end +# Allow puma to be restarted by `bin/rails restart` command. +plugin :tmp_restart -# The code in the `on_worker_boot` will be called if you are using -# clustered mode by specifying a number of `workers`. After each worker -# process is booted, this block will be run. If you are using the `preload_app!` -# option, you will want to use this block to reconnect to any threads -# or connections that may have been created at application boot, as Ruby -# cannot share connections between processes. -# -# on_worker_boot do -# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) -# end -# +# Run the Solid Queue supervisor inside of Puma for single-server deployments +plugin :solid_queue if ENV['SOLID_QUEUE_IN_PUMA'] -# Allow puma to be restarted by `rails restart` command. -plugin :tmp_restart +# Specify the PID file. Defaults to tmp/pids/server.pid in development. +# In other environments, only set the PID file if requested. +pidfile ENV['PIDFILE'] if ENV['PIDFILE'] diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 0000000..4942ab6 --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket-<%= Rails.env %> + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket-<%= Rails.env %> + +# Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name-<%= Rails.env %> + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/db/migrate/20250809045033_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20250809045033_add_service_name_to_active_storage_blobs.active_storage.rb new file mode 100644 index 0000000..898f9d0 --- /dev/null +++ b/db/migrate/20250809045033_add_service_name_to_active_storage_blobs.active_storage.rb @@ -0,0 +1,24 @@ +# This migration comes from active_storage (originally 20190112182829) +class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] + def up + return unless table_exists?(:active_storage_blobs) + + return if column_exists?(:active_storage_blobs, :service_name) + + add_column :active_storage_blobs, :service_name, :string + + # rubocop:disable Rails/SkipsModelValidations + if (configured_service = ActiveStorage::Blob.service.name) + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + end + # rubocop:enable Rails/SkipsModelValidations + + change_column :active_storage_blobs, :service_name, :string, null: false + end + + def down + return unless table_exists?(:active_storage_blobs) + + remove_column :active_storage_blobs, :service_name + end +end diff --git a/db/migrate/20250809045034_create_active_storage_variant_records.active_storage.rb b/db/migrate/20250809045034_create_active_storage_variant_records.active_storage.rb new file mode 100644 index 0000000..58cc779 --- /dev/null +++ b/db/migrate/20250809045034_create_active_storage_variant_records.active_storage.rb @@ -0,0 +1,28 @@ +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + # Use Active Record's configured type for primary key + create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| + t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type + t.string :variation_digest, null: false + + t.index %i[blob_id variation_digest], name: 'index_active_storage_variant_records_uniqueness', unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end +end diff --git a/db/migrate/20250809045035_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb b/db/migrate/20250809045035_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb new file mode 100644 index 0000000..93c8b85 --- /dev/null +++ b/db/migrate/20250809045035_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb @@ -0,0 +1,8 @@ +# This migration comes from active_storage (originally 20211119233751) +class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + change_column_null(:active_storage_blobs, :checksum, true) + end +end diff --git a/db/schema.rb b/db/schema.rb index 18f7709..d32e2b3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2017_05_16_194159) do +ActiveRecord::Schema[8.0].define(version: 2025_08_09_045035) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" diff --git a/public/400.html b/public/400.html new file mode 100644 index 0000000..282dbc8 --- /dev/null +++ b/public/400.html @@ -0,0 +1,114 @@ + + + + + + + The server cannot process the request due to a client error (400 Bad Request) + + + + + + + + + + + + + +

    +
    + +
    +
    +

    The server cannot process the request due to a client error. Please check the request and try again. If you’re the application owner check the logs for more information.

    +
    +
    + + + + diff --git a/public/404.html b/public/404.html index 2be3af2..c0670bc 100644 --- a/public/404.html +++ b/public/404.html @@ -1,67 +1,114 @@ - - - - The page you were looking for doesn't exist (404) - - - - - - -
    -
    -

    The page you were looking for doesn't exist.

    -

    You may have mistyped the address or the page may have moved.

    -
    -

    If you are the application owner check the logs for more information.

    -
    - + + + + + + + The page you were looking for doesn’t exist (404 Not found) + + + + + + + + + + + + + +
    +
    + +
    +
    +

    The page you were looking for doesn’t exist. You may have mistyped the address or the page may have moved. If you’re the application owner check the logs for more information.

    +
    +
    + + + diff --git a/public/406-unsupported-browser.html b/public/406-unsupported-browser.html new file mode 100644 index 0000000..9532a9c --- /dev/null +++ b/public/406-unsupported-browser.html @@ -0,0 +1,114 @@ + + + + + + + Your browser is not supported (406 Not Acceptable) + + + + + + + + + + + + + +
    +
    + +
    +
    +

    Your browser is not supported.
    Please upgrade your browser to continue.

    +
    +
    + + + + diff --git a/public/422.html b/public/422.html index c08eac0..8bcf060 100644 --- a/public/422.html +++ b/public/422.html @@ -1,67 +1,114 @@ - - - - The change you wanted was rejected (422) - - - - - - -
    -
    -

    The change you wanted was rejected.

    -

    Maybe you tried to change something you didn't have access to.

    -
    -

    If you are the application owner check the logs for more information.

    -
    - + + + + + + + The change you wanted was rejected (422 Unprocessable Entity) + + + + + + + + + + + + + +
    +
    + +
    +
    +

    The change you wanted was rejected. Maybe you tried to change something you didn’t have access to. If you’re the application owner check the logs for more information.

    +
    +
    + + + diff --git a/public/500.html b/public/500.html index 78a030a..d77718c 100644 --- a/public/500.html +++ b/public/500.html @@ -1,66 +1,114 @@ - - - - We're sorry, but something went wrong (500) - - - - - - -
    -
    -

    We're sorry, but something went wrong.

    -
    -

    If you are the application owner check the logs for more information.

    -
    - + + + + + + + We’re sorry, but something went wrong (500 Internal Server Error) + + + + + + + + + + + + + +
    +
    + +
    +
    +

    We’re sorry, but something went wrong.
    If you’re the application owner check the logs for more information.

    +
    +
    + + + diff --git a/public/icon.png b/public/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c4c9dbfbbd2f7c1421ffd5727188146213abbcef GIT binary patch literal 4166 zcmd6qU;WFw?|v@m)Sk^&NvB8tcujdV-r1b=i(NJxn&7{KTb zX$3(M+3TP2o^#KAo{#tIjl&t~(8D-k004kqPglzn0HFG(Q~(I*AKsD#M*g7!XK0T7 zN6P7j>HcT8rZgKl$v!xr806dyN19Bd4C0x_R*I-a?#zsTvb_89cyhuC&T**i|Rc zq5b8M;+{8KvoJ~uj9`u~d_f6`V&3+&ZX9x5pc8s)d175;@pjm(?dapmBcm0&vl9+W zx1ZD2o^nuyUHWj|^A8r>lUorO`wFF;>9XL-Jy!P}UXC{(z!FO%SH~8k`#|9;Q|eue zqWL0^Bp(fg_+Pkm!fDKRSY;+^@BF?AJE zCUWpXPst~hi_~u)SzYBDZroR+Z4xeHIlm_3Yc_9nZ(o_gg!jDgVa=E}Y8uDgem9`b zf=mfJ_@(BXSkW53B)F2s!&?_R4ptb1fYXlF++@vPhd=marQgEGRZS@B4g1Mu?euknL= z67P~tZ?*>-Hmi7GwlisNHHJDku-dSm7g@!=a}9cSL6Pa^w^2?&?$Oi8ibrr>w)xqx zOH_EMU@m05)9kuNR>>4@H%|){U$^yvVQ(YgOlh;5oU_-vivG-p4=LrN-k7D?*?u1u zsWly%tfAzKd6Fb=`eU2un_uaTXmcT#tlOL+aRS=kZZf}A7qT8lvcTx~7j` z*b>=z)mwg7%B2_!D0!1IZ?Nq{^Y$uI4Qx*6T!E2Col&2{k?ImCO=dD~A&9f9diXy^$x{6CwkBimn|1E09 zAMSezYtiL?O6hS37KpvDM?22&d{l)7h-!F)C-d3j8Z`c@($?mfd{R82)H>Qe`h{~G z!I}(2j(|49{LR?w4Jspl_i!(4T{31|dqCOpI52r5NhxYV+cDAu(xp*4iqZ2e-$YP= zoFOPmm|u*7C?S{Fp43y+V;>~@FFR76bCl@pTtyB93vNWy5yf;HKr8^0d7&GVIslYm zo3Tgt@M!`8B6IW&lK{Xk>%zp41G%`(DR&^u z5^pwD4>E6-w<8Kl2DzJ%a@~QDE$(e87lNhy?-Qgep!$b?5f7+&EM7$e>|WrX+=zCb z=!f5P>MxFyy;mIRxjc(H*}mceXw5a*IpC0PEYJ8Y3{JdoIW)@t97{wcUB@u+$FCCO z;s2Qe(d~oJC^`m$7DE-dsha`glrtu&v&93IZadvl_yjp!c89>zo;Krk+d&DEG4?x$ zufC1n+c1XD7dolX1q|7}uelR$`pT0Z)1jun<39$Sn2V5g&|(j~Z!wOddfYiZo7)A< z!dK`aBHOOk+-E_xbWCA3VR-+o$i5eO9`rMI#p_0xQ}rjEpGW;U!&&PKnivOcG(|m9 z!C8?WC6nCXw25WVa*eew)zQ=h45k8jSIPbq&?VE{oG%?4>9rwEeB4&qe#?-y_es4c|7ufw%+H5EY#oCgv!Lzv291#-oNlX~X+Jl5(riC~r z=0M|wMOP)Tt8@hNg&%V@Z9@J|Q#K*hE>sr6@oguas9&6^-=~$*2Gs%h#GF@h)i=Im z^iKk~ipWJg1VrvKS;_2lgs3n1zvNvxb27nGM=NXE!D4C!U`f*K2B@^^&ij9y}DTLB*FI zEnBL6y{jc?JqXWbkIZd7I16hA>(f9T!iwbIxJj~bKPfrO;>%*5nk&Lf?G@c2wvGrY&41$W{7HM9+b@&XY@>NZM5s|EK_Dp zQX60CBuantx>|d#DsaZ*8MW(we|#KTYZ=vNa#d*DJQe6hr~J6{_rI#?wi@s|&O}FR zG$kfPxheXh1?IZ{bDT-CWB4FTvO-k5scW^mi8?iY5Q`f8JcnnCxiy@m@D-%lO;y0pTLhh6i6l@x52j=#^$5_U^os}OFg zzdHbo(QI`%9#o*r8GCW~T3UdV`szO#~)^&X_(VW>o~umY9-ns9-V4lf~j z`QBD~pJ4a#b`*6bJ^3RS5y?RAgF7K5$ll97Y8#WZduZ`j?IEY~H(s^doZg>7-tk*t z4_QE1%%bb^p~4F5SB$t2i1>DBG1cIo;2(xTaj*Y~hlM{tSDHojL-QPg%Mo%6^7FrpB*{ z4G0@T{-77Por4DCMF zB_5Y~Phv%EQ64W8^GS6h?x6xh;w2{z3$rhC;m+;uD&pR74j+i22P5DS-tE8ABvH(U~indEbBUTAAAXfHZg5QpB@TgV9eI<)JrAkOI z8!TSOgfAJiWAXeM&vR4Glh;VxH}WG&V$bVb`a`g}GSpwggti*&)taV1@Ak|{WrV|5 zmNYx)Ans=S{c52qv@+jmGQ&vd6>6yX6IKq9O$3r&0xUTdZ!m1!irzn`SY+F23Rl6# zFRxws&gV-kM1NX(3(gnKpGi0Q)Dxi~#?nyzOR9!en;Ij>YJZVFAL*=R%7y%Mz9hU% zs>+ZB?qRmZ)nISx7wxY)y#cd$iaC~{k0avD>BjyF1q^mNQ1QcwsxiTySe<6C&cC6P zE`vwO9^k-d`9hZ!+r@Jnr+MF*2;2l8WjZ}DrwDUHzSF{WoG zucbSWguA!3KgB3MU%HH`R;XqVv0CcaGq?+;v_A5A2kpmk5V%qZE3yzQ7R5XWhq=eR zyUezH=@V)y>L9T-M-?tW(PQYTRBKZSVb_!$^H-Pn%ea;!vS_?M<~Tm>_rWIW43sPW z=!lY&fWc1g7+r?R)0p8(%zp&vl+FK4HRkns%BW+Up&wK8!lQ2~bja|9bD12WrKn#M zK)Yl9*8$SI7MAwSK$%)dMd>o+1UD<2&aQMhyjS5R{-vV+M;Q4bzl~Z~=4HFj_#2V9 zB)Gfzx3ncy@uzx?yzi}6>d%-?WE}h7v*w)Jr_gBl!2P&F3DX>j_1#--yjpL%<;JMR z*b70Gr)MMIBWDo~#<5F^Q0$VKI;SBIRneuR7)yVsN~A9I@gZTXe)E?iVII+X5h0~H zx^c(fP&4>!*q>fb6dAOC?MI>Cz3kld#J*;uik+Ps49cwm1B4 zZc1|ZxYyTv;{Z!?qS=D)sgRKx^1AYf%;y_V&VgZglfU>d+Ufk5&LV$sKv}Hoj+s; xK3FZRYdhbXT_@RW*ff3@`D1#ps#~H)p+y&j#(J|vk^lW{fF9OJt5(B-_&*Xgn9~3N literal 0 HcmV?d00001 diff --git a/public/icon.svg b/public/icon.svg new file mode 100644 index 0000000..04b34bf --- /dev/null +++ b/public/icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/robots.txt b/public/robots.txt index 37b576a..c19f78a 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1 +1 @@ -# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file From 24b34527977397b111072a37a8a3330a796a2bb9 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 21:55:30 -0700 Subject: [PATCH 40/44] Apply new defaults --- config/application.rb | 2 +- .../new_framework_defaults_8_0.rb | 26 ------------------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/config/application.rb b/config/application.rb index 5e7d483..6d275bf 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,7 @@ module MicroformatsRubyParserWebsite class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 5.1 + config.load_defaults 8.0 # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. diff --git a/config/initializers/new_framework_defaults_8_0.rb b/config/initializers/new_framework_defaults_8_0.rb index 92efa95..dc3d3f8 100644 --- a/config/initializers/new_framework_defaults_8_0.rb +++ b/config/initializers/new_framework_defaults_8_0.rb @@ -1,29 +1,3 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 8.0 framework defaults upgrade. -# -# Uncomment each configuration one by one to switch to the new default. -# Once your application is ready to run with all new defaults, you can remove -# this file and set the `config.load_defaults` to `8.0`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -### -# Specifies whether `to_time` methods preserve the UTC offset of their receivers or preserves the timezone. -# If set to `:zone`, `to_time` methods will use the timezone of their receivers. -# If set to `:offset`, `to_time` methods will use the UTC offset. -# If `false`, `to_time` methods will convert to the local system UTC offset instead. -#++ -# Rails.application.config.active_support.to_time_preserves_timezone = :zone - -### -# When both `If-Modified-Since` and `If-None-Match` are provided by the client -# only consider `If-None-Match` as specified by RFC 7232 Section 6. -# If set to `false` both conditions need to be satisfied. -#++ -# Rails.application.config.action_dispatch.strict_freshness = true - ### # Set `Regexp.timeout` to `1`s by default to improve security over Regexp Denial-of-Service attacks. #++ From eb804440290f44f4dbffc9262a4a9f95996c8433 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Fri, 8 Aug 2025 22:12:00 -0700 Subject: [PATCH 41/44] HTML linter fixes --- app/views/layouts/application.html.erb | 14 +++++++------- app/views/submissions/_submission.html.erb | 14 +++++++------- app/views/submissions/new.html.erb | 4 ++-- app/views/submissions/show.html.erb | 6 +++--- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6133f47..19cf2f2 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,8 +1,8 @@ - - + + Ruby Microformats Parser <%= csrf_meta_tags %> <%= bootstrap_stylesheet_link_tag %> @@ -24,21 +24,21 @@ -
    +
    <% if notice.present? %> -