From 3e17459591d2bb1546298c9dbf6b3ddb91ff0365 Mon Sep 17 00:00:00 2001 From: ru44 <18311071+ru44@users.noreply.github.com> Date: Sat, 10 Oct 2026 06:19:16 +0300 Subject: [PATCH 1/4] build(deps): update dependencies to latest (2026-10) - rails 8.1.3 -> 8.1.4 (constraint ~> 8.1.4; no 8.2/9 line released) - jwt 2.10 -> 3.3 (constraint ~> 3.3; only explicit-algorithm HS256 encode/decode is used) - puma 6.5 -> 8.0, minitest 5.25 -> 6.0, solid_cable 3.0 -> 4.1, solid_queue 1.1 -> 1.7 - rubocop 1.69 -> 1.91, rubocop-rails-omakase 1.0 -> 1.1, brakeman 8.0.5 -> 8.1.0 - sqlite3 2.5 -> 2.9, bootsnap 1.18 -> 1.26, kamal 2.4 -> 2.12, thruster 0.1.9 -> 0.1.27 - BUNDLED WITH 2.6.2 -> 2.6.7 --- Gemfile | 4 +- Gemfile.lock | 349 +++++++++++++++++++++++++++------------------------ 2 files changed, 185 insertions(+), 168 deletions(-) diff --git a/Gemfile b/Gemfile index e1c943e..804e753 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source "https://rubygems.org" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 8.1.3" +gem "rails", "~> 8.1.4" # Use sqlite3 as the database for Active Record gem "sqlite3", ">= 2.1" # Use the Puma web server [https://github.com/puma/puma] @@ -11,7 +11,7 @@ gem "puma", ">= 5.0" gem "bcrypt", "~> 3.1.7" # JWT for API token authentication -gem "jwt", "~> 2.10" +gem "jwt", "~> 3.3" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem "tzinfo-data", platforms: %i[windows jruby] diff --git a/Gemfile.lock b/Gemfile.lock index 8bdf02c..aa9693f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,31 +1,31 @@ GEM remote: https://rubygems.org/ specs: - action_text-trix (2.1.18) + action_text-trix (2.1.19) railties - actioncable (8.1.3) - actionpack (= 8.1.3) - activesupport (= 8.1.3) + actioncable (8.1.4) + actionpack (= 8.1.4) + activesupport (= 8.1.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (8.1.3) - actionpack (= 8.1.3) - activejob (= 8.1.3) - activerecord (= 8.1.3) - activestorage (= 8.1.3) - activesupport (= 8.1.3) + actionmailbox (8.1.4) + actionpack (= 8.1.4) + activejob (= 8.1.4) + activerecord (= 8.1.4) + activestorage (= 8.1.4) + activesupport (= 8.1.4) mail (>= 2.8.0) - actionmailer (8.1.3) - actionpack (= 8.1.3) - actionview (= 8.1.3) - activejob (= 8.1.3) - activesupport (= 8.1.3) + actionmailer (8.1.4) + actionpack (= 8.1.4) + actionview (= 8.1.4) + activejob (= 8.1.4) + activesupport (= 8.1.4) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.1.3) - actionview (= 8.1.3) - activesupport (= 8.1.3) + actionpack (8.1.4) + actionview (= 8.1.4) + activesupport (= 8.1.4) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -33,36 +33,36 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (8.1.3) + actiontext (8.1.4) action_text-trix (~> 2.1.15) - actionpack (= 8.1.3) - activerecord (= 8.1.3) - activestorage (= 8.1.3) - activesupport (= 8.1.3) + actionpack (= 8.1.4) + activerecord (= 8.1.4) + activestorage (= 8.1.4) + activesupport (= 8.1.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (8.1.3) - activesupport (= 8.1.3) + actionview (8.1.4) + activesupport (= 8.1.4) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (8.1.3) - activesupport (= 8.1.3) + activejob (8.1.4) + activesupport (= 8.1.4) globalid (>= 0.3.6) - activemodel (8.1.3) - activesupport (= 8.1.3) - activerecord (8.1.3) - activemodel (= 8.1.3) - activesupport (= 8.1.3) + activemodel (8.1.4) + activesupport (= 8.1.4) + activerecord (8.1.4) + activemodel (= 8.1.4) + activesupport (= 8.1.4) timeout (>= 0.4.0) - activestorage (8.1.3) - actionpack (= 8.1.3) - activejob (= 8.1.3) - activerecord (= 8.1.3) - activesupport (= 8.1.3) + activestorage (8.1.4) + actionpack (= 8.1.4) + activejob (= 8.1.4) + activerecord (= 8.1.4) + activesupport (= 8.1.4) marcel (~> 1.0) - activesupport (8.1.3) + activesupport (8.1.4) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) @@ -75,141 +75,150 @@ GEM securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) - ast (2.4.2) - base64 (0.2.0) + ast (2.4.3) + base64 (0.3.0) bcrypt (3.1.22) - bcrypt_pbkdf (1.1.1) - bigdecimal (3.1.9) - bootsnap (1.18.4) - msgpack (~> 1.2) - brakeman (8.0.5) + bcrypt_pbkdf (1.1.2) + bigdecimal (4.1.3) + bootsnap (1.26.0) + msgpack (~> 1.5) + brakeman (8.1.0) racc builder (3.3.0) - concurrent-ruby (1.3.4) - connection_pool (2.4.1) - crass (1.0.6) - date (3.4.1) - debug (1.10.0) + concurrent-ruby (1.3.8) + connection_pool (3.0.2) + crass (1.0.7) + date (3.6.0) + debug (1.11.1) irb (~> 1.10) reline (>= 0.3.8) - dotenv (3.1.7) - drb (2.2.1) - ed25519 (1.3.0) + dotenv (3.2.0) + drb (2.2.3) + ed25519 (1.4.0) + erb (6.0.7) erubi (1.13.1) - et-orbi (1.2.11) + et-orbi (1.4.2) tzinfo - fugit (1.11.1) - et-orbi (~> 1, >= 1.2.11) + fugit (1.14.0) + et-orbi (~> 1.4) raabro (~> 1.4) - globalid (1.2.1) + globalid (1.4.0) activesupport (>= 6.1) - i18n (1.14.6) + i18n (1.15.2) concurrent-ruby (~> 1.0) - io-console (0.8.0) - irb (1.14.3) + io-console (0.9.4) + irb (1.18.0) + pp (>= 0.6.0) + prism (>= 1.3.0) rdoc (>= 4.0.0) reline (>= 0.4.2) - json (2.9.1) - jwt (2.10.2) + json (3.0.2) + jwt (3.3.0) base64 - kamal (2.4.0) + kamal (2.12.0) activesupport (>= 7.0) base64 (~> 0.2) bcrypt_pbkdf (~> 1.0) concurrent-ruby (~> 1.2) dotenv (~> 3.1) - ed25519 (~> 1.2) + ed25519 (~> 1.4) net-ssh (~> 7.3) sshkit (>= 1.23.0, < 2.0) thor (~> 1.3) zeitwerk (>= 2.6.18, < 3.0) - language_server-protocol (3.17.0.3) - logger (1.6.4) - loofah (2.24.0) + language_server-protocol (3.17.0.6) + lint_roller (1.1.0) + logger (1.7.0) + loofah (2.25.2) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mail (2.8.1) + mail (2.9.1) + logger mini_mime (>= 0.1.1) net-imap net-pop net-smtp - marcel (1.0.4) + marcel (1.2.1) mini_mime (1.1.5) - minitest (5.25.4) - msgpack (1.7.5) - net-imap (0.5.4) + minitest (6.0.6) + drb (~> 2.0) + prism (~> 1.5) + msgpack (1.8.5) + net-imap (0.6.7) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.2) + net-protocol (0.4.0) timeout - net-scp (4.0.0) + net-scp (4.1.0) net-ssh (>= 2.6.5, < 8.0.0) net-sftp (4.0.0) net-ssh (>= 5.0.0, < 8.0.0) - net-smtp (0.5.1) + net-smtp (0.5.2) net-protocol - net-ssh (7.3.0) - nio4r (2.7.4) - nokogiri (1.18.1-aarch64-linux-gnu) + net-ssh (7.3.6) + nio4r (2.7.5) + nokogiri (1.19.4-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.18.1-aarch64-linux-musl) + nokogiri (1.19.4-aarch64-linux-musl) racc (~> 1.4) - nokogiri (1.18.1-arm-linux-gnu) + nokogiri (1.19.4-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.18.1-arm-linux-musl) + nokogiri (1.19.4-arm-linux-musl) racc (~> 1.4) - nokogiri (1.18.1-x86_64-linux-gnu) + nokogiri (1.19.4-x86_64-linux-gnu) racc (~> 1.4) - nokogiri (1.18.1-x86_64-linux-musl) + nokogiri (1.19.4-x86_64-linux-musl) racc (~> 1.4) - ostruct (0.6.1) - parallel (1.26.3) - parser (3.3.6.0) + ostruct (0.6.3) + parallel (2.3.0) + parser (3.3.12.0) ast (~> 2.4.1) racc - psych (5.2.2) - date - stringio - puma (6.5.0) + pp (0.6.4) + prettyprint + prettyprint (0.2.1) + prism (1.9.0) + puma (8.0.2) nio4r (~> 2.0) - raabro (1.4.0) + raabro (1.5.0) racc (1.8.1) - rack (3.1.8) + rack (3.2.7) rack-cors (3.0.0) logger rack (>= 3.0.14) - rack-session (2.0.0) + rack-session (2.1.2) + base64 (>= 0.1.0) rack (>= 3.0.0) rack-test (2.2.0) rack (>= 1.3) - rackup (2.2.1) + rackup (2.3.1) rack (>= 3) - rails (8.1.3) - actioncable (= 8.1.3) - actionmailbox (= 8.1.3) - actionmailer (= 8.1.3) - actionpack (= 8.1.3) - actiontext (= 8.1.3) - actionview (= 8.1.3) - activejob (= 8.1.3) - activemodel (= 8.1.3) - activerecord (= 8.1.3) - activestorage (= 8.1.3) - activesupport (= 8.1.3) + rails (8.1.4) + actioncable (= 8.1.4) + actionmailbox (= 8.1.4) + actionmailer (= 8.1.4) + actionpack (= 8.1.4) + actiontext (= 8.1.4) + actionview (= 8.1.4) + activejob (= 8.1.4) + activemodel (= 8.1.4) + activerecord (= 8.1.4) + activestorage (= 8.1.4) + activesupport (= 8.1.4) bundler (>= 1.15.0) - railties (= 8.1.3) - rails-dom-testing (2.2.0) + railties (= 8.1.4) + rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.2) - loofah (~> 2.21) + rails-html-sanitizer (1.7.1) + loofah (~> 2.25, >= 2.25.2) 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.1.3) - actionpack (= 8.1.3) - activesupport (= 8.1.3) + railties (8.1.4) + actionpack (= 8.1.4) + activesupport (= 8.1.4) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -217,89 +226,97 @@ GEM tsort (>= 0.2) zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.2.1) - rdoc (6.10.0) - psych (>= 4.0.0) - regexp_parser (2.10.0) - reline (0.6.0) + rake (13.4.2) + rbs (4.2.0) + logger + prism (>= 1.6.0) + tsort + rdoc (8.1.0) + erb + prism (>= 1.6.0) + rbs (>= 4.0.0) + tsort + regexp_parser (2.13.1) + reline (0.7.0) io-console (~> 0.5) rotp (6.3.0) - rubocop (1.69.2) - json (~> 2.3) - language_server-protocol (>= 3.17.0) - parallel (~> 1.10) + rubocop (1.91.0) + json (>= 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (>= 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.36.2, < 2.0) + rubocop-ast (>= 1.49.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.37.0) - parser (>= 3.3.1.0) - rubocop-minitest (0.36.0) - rubocop (>= 1.61, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-performance (1.23.0) - rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails (2.28.0) + rubocop-ast (1.50.0) + parser (>= 3.3.7.2) + prism (~> 1.7) + rubocop-performance (1.27.0) + lint_roller (~> 1.1) + rubocop (>= 1.89.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) + rubocop-rails (2.38.0) activesupport (>= 4.2.0) + lint_roller (~> 1.1) rack (>= 1.1) - rubocop (>= 1.52.0, < 2.0) - rubocop-ast (>= 1.31.1, < 2.0) - rubocop-rails-omakase (1.0.0) - rubocop - rubocop-minitest - rubocop-performance - rubocop-rails + rubocop (>= 1.89.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rails-omakase (1.1.0) + rubocop (>= 1.72) + rubocop-performance (>= 1.24) + rubocop-rails (>= 2.30) ruby-progressbar (1.13.0) securerandom (0.4.1) - solid_cable (3.0.5) + solid_cable (4.1.0) actioncable (>= 7.2) activejob (>= 7.2) activerecord (>= 7.2) railties (>= 7.2) - solid_cache (1.0.6) + solid_cache (1.0.10) activejob (>= 7.2) activerecord (>= 7.2) railties (>= 7.2) - solid_queue (1.1.2) + solid_queue (1.7.0) activejob (>= 7.1) activerecord (>= 7.1) concurrent-ruby (>= 1.3.1) - fugit (~> 1.11.0) + fugit (~> 1.11) railties (>= 7.1) - thor (~> 1.3.1) - sqlite3 (2.5.0-aarch64-linux-gnu) - sqlite3 (2.5.0-aarch64-linux-musl) - sqlite3 (2.5.0-arm-linux-gnu) - sqlite3 (2.5.0-arm-linux-musl) - sqlite3 (2.5.0-x86_64-linux-gnu) - sqlite3 (2.5.0-x86_64-linux-musl) - sshkit (1.23.2) + thor (>= 1.3.1) + sqlite3 (2.9.6-aarch64-linux-gnu) + sqlite3 (2.9.6-aarch64-linux-musl) + sqlite3 (2.9.6-arm-linux-gnu) + sqlite3 (2.9.6-arm-linux-musl) + sqlite3 (2.9.6-x86_64-linux-gnu) + sqlite3 (2.9.6-x86_64-linux-musl) + sshkit (1.25.1) base64 + logger net-scp (>= 1.1.2) net-sftp (>= 2.1.2) net-ssh (>= 2.8.0) ostruct - stringio (3.1.2) - thor (1.3.2) - thruster (0.1.9) - thruster (0.1.9-aarch64-linux) - thruster (0.1.9-x86_64-linux) - timeout (0.4.3) + thor (1.5.0) + thruster (0.1.27) + thruster (0.1.27-aarch64-linux) + thruster (0.1.27-x86_64-linux) + timeout (0.6.1) tsort (0.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (3.1.3) - unicode-emoji (~> 4.0, >= 4.0.4) - unicode-emoji (4.0.4) - uri (1.0.2) + unicode-display_width (3.3.0) + unicode-emoji (~> 4.3) + unicode-emoji (4.3.0) + uri (1.1.2) useragent (0.16.11) - websocket-driver (0.7.6) + websocket-driver (0.8.2) + base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.7.1) + zeitwerk (2.8.3) PLATFORMS aarch64-linux @@ -316,14 +333,14 @@ DEPENDENCIES bootsnap brakeman debug - jwt (~> 2.10) + jwt (~> 3.3) kamal net-imap net-pop net-smtp puma (>= 5.0) rack-cors - rails (~> 8.1.3) + rails (~> 8.1.4) rotp (~> 6.3) rubocop-rails-omakase solid_cable @@ -334,4 +351,4 @@ DEPENDENCIES tzinfo-data BUNDLED WITH - 2.6.2 + 2.6.7 From ebc54932cee062d6a31da1741aa6a080df54ca49 Mon Sep 17 00:00:00 2001 From: ru44 <18311071+ru44@users.noreply.github.com> Date: Sat, 10 Oct 2026 12:01:55 +0300 Subject: [PATCH 2/4] docs: point AI agents at cliuno make and the CLIuno skills --- CLAUDE.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index e86abca..dd1aa2c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -37,3 +37,16 @@ bundle exec rubocop # lint (rails-omakase) rubocop-rails-omakase; conventional commits; controller tests in `test/controllers/api/v1/` assert contract shapes — update them with any envelope change. + +## AI agents (Claude Code and friends) + +- **Check the CLIuno skills first**: `npx cliuno@latest skills status` — if any is + `missing`/`outdated`, run `npx cliuno@latest skills install` (adds `.claude/skills/cliuno-*`: + the generator workflow, the scaffold guide, and the shared REST contract). +- **Generate resources, don't hand-write them**: + `npx cliuno@latest make:resource Product --fields name:string,price:number,inStock:boolean` + creates `app/models/product.rb`, `db/migrate/_create_products.rb`, `app/controllers/api/v1/products_controller.rb`, `test/fixtures/products.yml`, `test/controllers/api/v1/products_controller_test.rb`, `test/models/product_test.rb` and registers it in `config/routes.rb`, `app/models/user.rb`, following this + template's conventions and the `{status, message, data}` contract. `--dry-run` previews, + re-running never duplicates registrations, `--force` overwrites. +- Single pieces: `make:model` (→ `bin/rails generate model`), `make:controller` (→ `bin/rails generate controller`), `make:migration` (→ `bin/rails generate migration`), `make:test`. `npx cliuno@latest make` lists them. +- Then edit fields/business logic only, and run the gates above. From e30f562663c5fceb5ae1c861f1ddb6da0b7eb0af Mon Sep 17 00:00:00 2001 From: ru44 <18311071+ru44@users.noreply.github.com> Date: Sat, 10 Oct 2026 12:55:46 +0300 Subject: [PATCH 3/4] fix(security): only owners may update or delete todos, posts and comments Any authenticated user could previously modify or delete another user's records. Adds an owner check (403) to update, destroy and todo toggle, matching the other backends. --- app/controllers/api/v1/comments_controller.rb | 7 +++++++ app/controllers/api/v1/posts_controller.rb | 7 +++++++ app/controllers/api/v1/todos_controller.rb | 7 +++++++ test/controllers/api/v1/comments_controller_test.rb | 11 +++++++++++ test/controllers/api/v1/posts_controller_test.rb | 10 ++++++++++ test/controllers/api/v1/todos_controller_test.rb | 13 +++++++++++++ 6 files changed, 55 insertions(+) diff --git a/app/controllers/api/v1/comments_controller.rb b/app/controllers/api/v1/comments_controller.rb index f3b9d6a..65ea18f 100644 --- a/app/controllers/api/v1/comments_controller.rb +++ b/app/controllers/api/v1/comments_controller.rb @@ -2,6 +2,7 @@ class Api::V1::CommentsController < ApplicationController before_action :authenticate_user! before_action :set_post before_action :set_comment, only: %i[update destroy] + before_action :authorize_owner!, only: %i[update destroy] # GET /api/v1/posts/:post_id/comments def index @@ -50,4 +51,10 @@ def set_comment def comment_params params.permit(:content) end + + def authorize_owner! + return if @comment.user_id == current_user.id + + render_forbidden("You can only modify your own comments") + end end diff --git a/app/controllers/api/v1/posts_controller.rb b/app/controllers/api/v1/posts_controller.rb index e0baaf3..dbda5c1 100644 --- a/app/controllers/api/v1/posts_controller.rb +++ b/app/controllers/api/v1/posts_controller.rb @@ -1,6 +1,7 @@ class Api::V1::PostsController < ApplicationController before_action :authenticate_user! before_action :set_post, only: %i[show update destroy user] + before_action :authorize_owner!, only: %i[update destroy] # GET /api/v1/posts def index @@ -63,4 +64,10 @@ def post_params permitted[:image_url] = permitted.delete(:imageUrl) if permitted[:image_url].blank? && permitted[:imageUrl].present? permitted.except(:imageUrl) end + + def authorize_owner! + return if @post.user_id == current_user.id + + render_forbidden("You can only modify your own posts") + end end diff --git a/app/controllers/api/v1/todos_controller.rb b/app/controllers/api/v1/todos_controller.rb index e5977ad..bec3af1 100644 --- a/app/controllers/api/v1/todos_controller.rb +++ b/app/controllers/api/v1/todos_controller.rb @@ -1,6 +1,7 @@ class Api::V1::TodosController < ApplicationController before_action :authenticate_user! before_action :set_todo, only: %i[show update destroy toggle] + before_action :authorize_owner!, only: %i[update destroy toggle] # GET /api/v1/todos def index @@ -61,4 +62,10 @@ def set_todo def todo_params params.permit(:title, :description, :is_completed) end + + def authorize_owner! + return if @todo.user_id == current_user.id + + render_forbidden("You can only modify your own todos") + end end diff --git a/test/controllers/api/v1/comments_controller_test.rb b/test/controllers/api/v1/comments_controller_test.rb index 3e4589f..a8b67ba 100644 --- a/test/controllers/api/v1/comments_controller_test.rb +++ b/test/controllers/api/v1/comments_controller_test.rb @@ -49,4 +49,15 @@ class Api::V1::CommentsControllerTest < ActionDispatch::IntegrationTest assert_response :unprocessable_entity end + + test "should not update or delete another user's comment" do + other = users(:other) + patch api_v1_post_comment_url(@post, @comment), params: { content: "Hijacked" }, + headers: auth_headers_for(other), as: :json + assert_response :forbidden + assert_no_difference("Comment.count") do + delete api_v1_post_comment_url(@post, @comment), headers: auth_headers_for(other), as: :json + end + assert_response :forbidden + end end diff --git a/test/controllers/api/v1/posts_controller_test.rb b/test/controllers/api/v1/posts_controller_test.rb index 11febcb..9074f3f 100644 --- a/test/controllers/api/v1/posts_controller_test.rb +++ b/test/controllers/api/v1/posts_controller_test.rb @@ -68,4 +68,14 @@ class Api::V1::PostsControllerTest < ActionDispatch::IntegrationTest assert_response :unprocessable_entity end + + test "should not update or delete another user's post" do + other = users(:other) + patch api_v1_post_url(@post), params: { title: "Hijacked" }, headers: auth_headers_for(other), as: :json + assert_response :forbidden + assert_no_difference("Post.count") do + delete api_v1_post_url(@post), headers: auth_headers_for(other), as: :json + end + assert_response :forbidden + end end diff --git a/test/controllers/api/v1/todos_controller_test.rb b/test/controllers/api/v1/todos_controller_test.rb index 8810123..0e5a2e5 100644 --- a/test/controllers/api/v1/todos_controller_test.rb +++ b/test/controllers/api/v1/todos_controller_test.rb @@ -70,4 +70,17 @@ class Api::V1::TodosControllerTest < ActionDispatch::IntegrationTest assert_response :unprocessable_entity end + + test "should not update or delete another user's todo" do + other = users(:other) + patch api_v1_todo_url(@todo), params: { title: "Hijacked" }, headers: auth_headers_for(other), as: :json + assert_response :forbidden + patch toggle_api_v1_todo_url(@todo), headers: auth_headers_for(other), as: :json + assert_response :forbidden + assert_no_difference("Todo.count") do + delete api_v1_todo_url(@todo), headers: auth_headers_for(other), as: :json + end + assert_response :forbidden + assert_not_equal "Hijacked", @todo.reload.title + end end From 84452ea101d401795272562526be95a899bd5b01 Mon Sep 17 00:00:00 2001 From: ru44 <18311071+ru44@users.noreply.github.com> Date: Sat, 10 Oct 2026 12:58:27 +0300 Subject: [PATCH 4/4] docs: require cliuno 2.2 in the AI-agents guide --- CLAUDE.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index dd1aa2c..9ab86d2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -40,13 +40,15 @@ rubocop-rails-omakase; conventional commits; controller tests in ## AI agents (Claude Code and friends) -- **Check the CLIuno skills first**: `npx cliuno@latest skills status` — if any is - `missing`/`outdated`, run `npx cliuno@latest skills install` (adds `.claude/skills/cliuno-*`: +These commands need **cliuno 2.2 or newer** (`npx cliuno@^2.2` fetches it). + +- **Check the CLIuno skills first**: `npx cliuno@^2.2 skills status` — if any is + `missing`/`outdated`, run `npx cliuno@^2.2 skills install` (adds `.claude/skills/cliuno-*`: the generator workflow, the scaffold guide, and the shared REST contract). - **Generate resources, don't hand-write them**: - `npx cliuno@latest make:resource Product --fields name:string,price:number,inStock:boolean` + `npx cliuno@^2.2 make:resource Product --fields name:string,price:number,inStock:boolean` creates `app/models/product.rb`, `db/migrate/_create_products.rb`, `app/controllers/api/v1/products_controller.rb`, `test/fixtures/products.yml`, `test/controllers/api/v1/products_controller_test.rb`, `test/models/product_test.rb` and registers it in `config/routes.rb`, `app/models/user.rb`, following this template's conventions and the `{status, message, data}` contract. `--dry-run` previews, re-running never duplicates registrations, `--force` overwrites. -- Single pieces: `make:model` (→ `bin/rails generate model`), `make:controller` (→ `bin/rails generate controller`), `make:migration` (→ `bin/rails generate migration`), `make:test`. `npx cliuno@latest make` lists them. +- Single pieces: `make:model` (→ `bin/rails generate model`), `make:controller` (→ `bin/rails generate controller`), `make:migration` (→ `bin/rails generate migration`), `make:test`. `npx cliuno@^2.2 make` lists them. - Then edit fields/business logic only, and run the gates above.