inline_forms 8.1.67 → 8.1.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: faafc3188dc88f06ee65cc379452eb7dde62753fe63b488b0250841c4cdb641d
4
- data.tar.gz: 880f68f083664c8bf6de77fb522577365c43069523da92ca42a01bdd2fa7378a
3
+ metadata.gz: d69ec6821783dbbfd063d6da1f553bd14db6340d5e32e0603d4e7b20ac460715
4
+ data.tar.gz: a5c49b819eb32b2926ae306970747a6c1c42427246323bebd058282ff253b460
5
5
  SHA512:
6
- metadata.gz: e378f136a965b95f21f0e09e55776b1019eb3fa8a3ada7c1117ab101f2f2a117d654ebfe1b3cbf2c02b01cfd01c7e2096de3cf3d00ffa1d73b6c5474b0b81c3d
7
- data.tar.gz: 86d6a6d5553a2b98227a3367b0f8cbdc703646bfa01b5a5f55a59dcf798a1c9bf029a0dfcfe7506d2a18e0eaf960155743266e146e4b9ab62d5678ac45b1bf51
6
+ metadata.gz: 9235600ce6dc610d52de4d092b16cad9e7b795074d7659dab9f468bf59bf72950959541ed2f2d9e989e38c8613c7ee251c6336ef8f8f2a285d2435eeef6997be
7
+ data.tar.gz: 9d058e992f4eec4ed8965406d1fbd526e241daa1ac7f4a83ba05e8ce23b479e20e1ab4dc4e9b4e1ed16d1aed356e49d72faca54cc9980764b47e29eb12b4184f
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Brakeman on a generated app together with the engine code.
4
+ #
5
+ # .forgejo/brakeman-engine.sh APP [extra brakeman options]
6
+ #
7
+ # Brakeman skips gem code, so scanning the app alone never looks at the
8
+ # engine's controllers, helpers and views. Scanning the engine alone does not
9
+ # work either: without an app Brakeman cannot tell the Rails version and the
10
+ # templates do not parse. So: a temporary copy of APP with the engine's code
11
+ # in engines/, scanned as one application. APP itself is not touched.
12
+ #
13
+ # Accepted warnings, each with its reason, are in brakeman.ignore beside this
14
+ # file; --ensure-ignore-notes fails on one without a reason, and
15
+ # --ensure-no-obsolete-ignore-entries on one that no longer occurs. The paths
16
+ # in the copy are relative and fixed (engines/...), because Brakeman's
17
+ # fingerprints include them.
18
+ #
19
+ # Not scanned: lib/installer_templates and lib/generators (they produce code;
20
+ # what they produce is in APP).
21
+
22
+ set -euo pipefail
23
+
24
+ here=$(cd "$(dirname "$0")" && pwd)
25
+ root=$(dirname "$here")
26
+ app=$(cd "${1:?usage: brakeman-engine.sh APP [brakeman options]}" && pwd)
27
+ shift
28
+
29
+ work=$(mktemp -d)
30
+ trap 'rm -rf "$work"' EXIT
31
+ mkdir -p "$work/app/engines/inline_forms" "$work/app/engines/inline_forms_schema_edit"
32
+
33
+ # No keys or credentials: Brakeman does not need them.
34
+ tar -C "$app" --exclude='*.key' --exclude='credentials*' -cf - \
35
+ app config lib Gemfile Gemfile.lock | tar -C "$work/app" -xf -
36
+
37
+ for part in app config lib; do
38
+ if [ -d "$root/$part" ]; then
39
+ cp -R "$root/$part" "$work/app/engines/inline_forms/"
40
+ fi
41
+ if [ -d "$root/inline_forms_schema_edit/$part" ]; then
42
+ cp -R "$root/inline_forms_schema_edit/$part" "$work/app/engines/inline_forms_schema_edit/"
43
+ fi
44
+ done
45
+ rm -rf "$work/app/engines/inline_forms/lib/installer_templates" \
46
+ "$work/app/engines/inline_forms/lib/generators"
47
+
48
+ brakeman --no-pager \
49
+ --add-engines-path engines/inline_forms,engines/inline_forms_schema_edit \
50
+ -i "$here/brakeman.ignore" --ensure-ignore-notes --ensure-no-obsolete-ignore-entries \
51
+ --path "$work/app" "$@"
@@ -0,0 +1,211 @@
1
+ {
2
+ "ignored_warnings": [
3
+ {
4
+ "warning_type": "SQL Injection",
5
+ "warning_code": 0,
6
+ "fingerprint": "09d9d139a9c55d2f8ddc853b4e488d8b90a22e81f9b808d5ac60503296a17c40",
7
+ "check_name": "SQL",
8
+ "message": "Possible SQL injection",
9
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
10
+ "line": 181,
11
+ "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
12
+ "code": "(self.controller_name.classify.constantize.accessible_by(current_ability) or self.controller_name.classify.constantize.all).merge(self.controller_name.classify.constantize.inline_forms_list).merge(self.controller_name.classify.constantize.inline_forms_search(params[:search])).where((nil or [\"#{(self.controller_name.classify.constantize.reflect_on_association(params[:parent_class].underscore.to_sym).options[:foreign_key] or params[:parent_class].foreign_key)} = ?\", params[:parent_id]]))",
13
+ "render_path": null,
14
+ "location": {
15
+ "type": "method",
16
+ "class": "InlineFormsController",
17
+ "method": "create"
18
+ },
19
+ "user_input": "params[:parent_class].underscore.to_sym",
20
+ "confidence": "Medium",
21
+ "cwe_id": [
22
+ 89
23
+ ],
24
+ "note": "parent_class and parent_id are refused (400) by refuse_malformed_parent_params unless parent_class names a belongs_to association of the model and parent_id is all digits; foreign_key comes from the model's reflection or that class name, and parent_id is a bind value. Tests: test/integration/list_params_test.rb."
25
+ },
26
+ {
27
+ "warning_type": "SQL Injection",
28
+ "warning_code": 0,
29
+ "fingerprint": "0ea384debe73789ae09a12359f268b7362bec05090e670f180ab1434d822a012",
30
+ "check_name": "SQL",
31
+ "message": "Possible SQL injection",
32
+ "file": "engines/inline_forms/app/views/inline_forms/_list.html.erb",
33
+ "line": 41,
34
+ "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
35
+ "code": "(parent_class.find(parent_id).send(attribute) or parent_class.find(parent_id).send(attribute).accessible_by(current_ability)).merge(attribute.to_s.singularize.camelcase.constantize.inline_forms_list).where([\"#{attribute.to_s.singularize.camelcase.constantize.table_name}.#{(parent_class.reflect_on_association(attribute.to_sym).options[:foreign_key] or parent_class.name.foreign_key)} = ?\", parent_id])",
36
+ "render_path": [
37
+ {
38
+ "type": "controller",
39
+ "class": "InlineFormsController",
40
+ "method": "index",
41
+ "line": 105,
42
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
43
+ "rendered": {
44
+ "name": "inline_forms/_list",
45
+ "file": "engines/inline_forms/app/views/inline_forms/_list.html.erb"
46
+ }
47
+ }
48
+ ],
49
+ "location": {
50
+ "type": "template",
51
+ "template": "inline_forms/_list"
52
+ },
53
+ "user_input": "parent_class.reflect_on_association(attribute.to_sym).options[:foreign_key]",
54
+ "confidence": "Weak",
55
+ "cwe_id": [
56
+ 89
57
+ ],
58
+ "note": "In this branch parent_class is a class passed by _show.html.erb, not a param, and foreign_key is the association's foreign key or the class name's. parent_id is a bind value."
59
+ },
60
+ {
61
+ "warning_type": "Remote Code Execution",
62
+ "warning_code": 24,
63
+ "fingerprint": "61c8f32dd8829cb209a4136d62ff04f729a3f04ea1d1c69b64728ecabc1f4c66",
64
+ "check_name": "UnsafeReflection",
65
+ "message": "Unsafe reflection method `constantize` called on parameter value",
66
+ "file": "engines/inline_forms/app/views/inline_forms/_list.html.erb",
67
+ "line": 19,
68
+ "link": "https://brakemanscanner.org/docs/warning_types/remote_code_execution/",
69
+ "code": "params[:parent_class].constantize",
70
+ "render_path": [
71
+ {
72
+ "type": "controller",
73
+ "class": "InlineFormsController",
74
+ "method": "index",
75
+ "line": 105,
76
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
77
+ "rendered": {
78
+ "name": "inline_forms/_list",
79
+ "file": "engines/inline_forms/app/views/inline_forms/_list.html.erb"
80
+ }
81
+ }
82
+ ],
83
+ "location": {
84
+ "type": "template",
85
+ "template": "inline_forms/_list"
86
+ },
87
+ "user_input": "params[:parent_class]",
88
+ "confidence": "High",
89
+ "cwe_id": [
90
+ 470
91
+ ],
92
+ "note": "@parent_class is only set in index, new and create, and the before_action refuse_malformed_parent_params covers index, new, create and show: parent_class is blank or the class name of a non-polymorphic belongs_to of the controller's model, so no other class is constantized. Tests: test/integration/list_params_test.rb."
93
+ },
94
+ {
95
+ "warning_type": "Dangerous Send",
96
+ "warning_code": 23,
97
+ "fingerprint": "67076d627523cb3c2746069c8e98d2261b3fcfe04a11463f6eb56e4f10e789a4",
98
+ "check_name": "Send",
99
+ "message": "User controlled method execution",
100
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
101
+ "line": 221,
102
+ "link": "https://brakemanscanner.org/docs/warning_types/dangerous_send/",
103
+ "code": "send(\"#{params[:form_element]}_update\", referenced_object, params[:attribute])",
104
+ "render_path": null,
105
+ "location": {
106
+ "type": "method",
107
+ "class": "InlineFormsController",
108
+ "method": "update"
109
+ },
110
+ "user_input": "params[:form_element]",
111
+ "confidence": "High",
112
+ "cwe_id": [
113
+ 77
114
+ ],
115
+ "note": "field_request_permitted?(:update) runs first and refuses (400) unless attribute and form_element name a row of the model's own attribute list, so only the *_update method of a declared form element can be called."
116
+ },
117
+ {
118
+ "warning_type": "Dangerous Send",
119
+ "warning_code": 23,
120
+ "fingerprint": "6988827dc9c767b44428caabc78a6c8596ad933a406ae1a32b85ae3fd4a4ed23",
121
+ "check_name": "Send",
122
+ "message": "User controlled method execution",
123
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
124
+ "line": 259,
125
+ "link": "https://brakemanscanner.org/docs/warning_types/dangerous_send/",
126
+ "code": "referenced_object.send(params[:attribute])",
127
+ "render_path": null,
128
+ "location": {
129
+ "type": "method",
130
+ "class": "InlineFormsController",
131
+ "method": "show"
132
+ },
133
+ "user_input": "params[:attribute]",
134
+ "confidence": "High",
135
+ "cwe_id": [
136
+ 77
137
+ ],
138
+ "note": "field_request_permitted?(:read) refuses (400) unless attribute and form_element name a row of the model's own attribute list, then authorizes the attribute. With no attribute the send is of nil, which raises. Covers the associated and has_one branches of show."
139
+ },
140
+ {
141
+ "warning_type": "Command Injection",
142
+ "warning_code": 14,
143
+ "fingerprint": "70ea329216e82770ca0de3975a7082e37fe86e417b021e68f95cc6e823e14a77",
144
+ "check_name": "Execute",
145
+ "message": "Possible command injection",
146
+ "file": "engines/inline_forms/lib/inline_forms_installer/create_log.rb",
147
+ "line": 55,
148
+ "link": "https://brakemanscanner.org/docs/warning_types/command_injection/",
149
+ "code": "system(\"bash\", \"-c\", \"#{shell_command} 2>&1 | tee -a #{Shellwords.escape(File.expand_path(basename_for(started_at)))}; exit ${PIPESTATUS[0]}\")",
150
+ "render_path": null,
151
+ "location": {
152
+ "type": "method",
153
+ "class": "InlineFormsInstaller::CreateLog",
154
+ "method": "tee_rails_new"
155
+ },
156
+ "user_input": "shell_command",
157
+ "confidence": "Medium",
158
+ "cwe_id": [
159
+ 77
160
+ ],
161
+ "note": "Installer command line, not reachable from a web request. shell_command is built by Creator#create from the rails command, the app name (checked against its regex first) and a path in the installer; the operator runs it as themself."
162
+ },
163
+ {
164
+ "warning_type": "Dangerous Send",
165
+ "warning_code": 23,
166
+ "fingerprint": "a858a85120c0ef89f96452d8bcb0d01664507ceb2ae4d834cfc237403b4b93a8",
167
+ "check_name": "Send",
168
+ "message": "User controlled method execution",
169
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
170
+ "line": 258,
171
+ "link": "https://brakemanscanner.org/docs/warning_types/dangerous_send/",
172
+ "code": "referenced_object.send((params[:attribute].to_s.singularize + \"_ids\"))",
173
+ "render_path": null,
174
+ "location": {
175
+ "type": "method",
176
+ "class": "InlineFormsController",
177
+ "method": "show"
178
+ },
179
+ "user_input": "(params[:attribute].to_s.singularize + \"_ids\")",
180
+ "confidence": "High",
181
+ "cwe_id": [
182
+ 77
183
+ ],
184
+ "note": "field_request_permitted?(:read) refuses (400) unless attribute and form_element name a row of the model's own attribute list, so only <association>_ids of a declared association is called."
185
+ },
186
+ {
187
+ "warning_type": "SQL Injection",
188
+ "warning_code": 0,
189
+ "fingerprint": "ad2b4dd8ced8aa1edf48bfbb80730b2bd4dadc84a15de67fd9dde25d81c46e00",
190
+ "check_name": "SQL",
191
+ "message": "Possible SQL injection",
192
+ "file": "engines/inline_forms/app/controllers/inline_forms_controller.rb",
193
+ "line": 64,
194
+ "link": "https://brakemanscanner.org/docs/warning_types/sql_injection/",
195
+ "code": "self.controller_name.classify.constantize.all.merge(self.controller_name.classify.constantize.inline_forms_list).merge(self.controller_name.classify.constantize.inline_forms_search(params[:search])).where((nil or [\"#{(self.controller_name.classify.constantize.reflect_on_association(params[:parent_class].underscore.to_sym).options[:foreign_key] or params[:parent_class].foreign_key)} = ?\", params[:parent_id]]))",
196
+ "render_path": null,
197
+ "location": {
198
+ "type": "method",
199
+ "class": "InlineFormsController",
200
+ "method": "index"
201
+ },
202
+ "user_input": "params[:parent_class].underscore.to_sym",
203
+ "confidence": "Medium",
204
+ "cwe_id": [
205
+ 89
206
+ ],
207
+ "note": "parent_class and parent_id are refused (400) by refuse_malformed_parent_params unless parent_class names a belongs_to association of the model and parent_id is all digits; foreign_key comes from the model's reflection or that class name, and parent_id is a bind value. Tests: test/integration/list_params_test.rb."
208
+ }
209
+ ],
210
+ "brakeman_version": "8.1.1"
211
+ }
@@ -1,7 +1,9 @@
1
1
  # CI for Forgejo Actions (runner on dev02, jobs run in Docker containers).
2
- # Mirrors the Papiamentu setup: runner label `docker`, shared CI image
3
- # `papiamentu-ci:ruby-4.0.4-node20` (same Ruby as these gems; node for the
4
- # checkout/cache actions). See stuff/2026-07-06-forgejo-ci-rubocop-brakeman.md.
2
+ #
3
+ # No Node: the job runs in the official ruby image (same Ruby as these gems) and
4
+ # uses only shell steps. actions/checkout and actions/cache are JavaScript and
5
+ # need node inside the container, so the checkouts are plain git and the gems
6
+ # are installed fresh each run.
5
7
  #
6
8
  # GitHub deliberately has NO workflows (.github/workflows was removed in
7
9
  # 8.1.34): pushing to GitHub triggers nothing; CI runs only on Forgejo.
@@ -18,29 +20,38 @@ jobs:
18
20
  test:
19
21
  runs-on: docker
20
22
  container:
21
- image: papiamentu-ci:ruby-4.0.4-node20
23
+ image: docker.io/library/ruby:4.0.10
22
24
  steps:
23
- - uses: actions/checkout@v4
24
- with:
25
- path: inline_forms
25
+ - name: Check out inline_forms
26
+ env:
27
+ TOKEN: ${{ github.token }}
28
+ SERVER: ${{ github.server_url }}
29
+ REPO: ${{ github.repository }}
30
+ SHA: ${{ github.sha }}
31
+ run: |
32
+ auth=$(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)
33
+ git init -q inline_forms
34
+ cd inline_forms
35
+ git -c http.extraHeader="Authorization: basic $auth" fetch -q --depth 1 "$SERVER/$REPO.git" "$SHA"
36
+ git checkout -q FETCH_HEAD
37
+ git log --oneline -1
26
38
 
27
39
  # The dev Gemfile points at the validation_hints sibling
28
40
  # (gem "validation_hints", path: "../validation_hints"). The job's
29
41
  # automatic token is scoped to this repo only and validation_hints is
30
42
  # private, so the repo secret VALIDATION_HINTS (a token with read
31
43
  # access to ace/validation_hints) authorizes the checkout.
32
- - uses: actions/checkout@v4
33
- with:
34
- repository: ace/validation_hints
35
- token: ${{ secrets.VALIDATION_HINTS }}
36
- path: validation_hints
37
-
38
- - name: Cache gems
39
- uses: actions/cache@v4
40
- with:
41
- path: inline_forms/vendor/bundle
42
- key: gems-inline_forms-${{ hashFiles('inline_forms/Gemfile', 'inline_forms/inline_forms.gemspec') }}
43
- restore-keys: gems-inline_forms-
44
+ - name: Check out validation_hints
45
+ env:
46
+ TOKEN: ${{ secrets.VALIDATION_HINTS }}
47
+ SERVER: ${{ github.server_url }}
48
+ run: |
49
+ auth=$(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)
50
+ git init -q validation_hints
51
+ cd validation_hints
52
+ git -c http.extraHeader="Authorization: basic $auth" fetch -q --depth 1 "$SERVER/ace/validation_hints.git" HEAD
53
+ git checkout -q FETCH_HEAD
54
+ git log --oneline -1
44
55
 
45
56
  - name: Install gems
46
57
  working-directory: inline_forms
@@ -2,14 +2,20 @@
2
2
  # generate the example app (which runs its own 150+ test suite as part of
3
3
  # `inline_forms create`), then run Brakeman against the generated app.
4
4
  #
5
- # Brakeman is aimed at Rails *applications*; scanning the generated MyApp
6
- # covers the engine's controllers/views in their real app context plus
7
- # everything the installer writes — scanning the bare engine repo would
8
- # skip most checks. bundler-audit for the engine runs in ci.yml.
5
+ # Brakeman is aimed at Rails *applications* and skips gem code, so it runs
6
+ # twice: on the generated MyApp (everything the installer writes), and on
7
+ # MyApp together with the engine's own controllers, helpers and views
8
+ # (.forgejo/brakeman-engine.sh; accepted warnings, with their reasons, in
9
+ # .forgejo/brakeman.ignore). bundler-audit for the engine runs in ci.yml.
9
10
  #
10
11
  # Heavy (~3-4 min: rails new + bundle + migrations + tests), so it runs on
11
12
  # demand and weekly, not per push. Requires network access to rubygems.org
12
13
  # from the runner (same as Papiamentu's bundle install).
14
+ #
15
+ # No Node: the official ruby image and plain git, as in ci.yml. The generated
16
+ # app's autoprefixer-rails needs a JavaScript runtime; ExecJS takes mini_racer,
17
+ # which `bundle install` installs because no group is excluded (it is in the
18
+ # app's production group).
13
19
  name: Full gate
14
20
 
15
21
  on:
@@ -21,17 +27,33 @@ jobs:
21
27
  full-gate:
22
28
  runs-on: docker
23
29
  container:
24
- image: papiamentu-ci:ruby-4.0.4-node20
30
+ image: docker.io/library/ruby:4.0.10
25
31
  steps:
26
- - uses: actions/checkout@v4
27
- with:
28
- path: inline_forms
32
+ - name: Check out inline_forms
33
+ env:
34
+ TOKEN: ${{ github.token }}
35
+ SERVER: ${{ github.server_url }}
36
+ REPO: ${{ github.repository }}
37
+ SHA: ${{ github.sha }}
38
+ run: |
39
+ auth=$(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)
40
+ git init -q inline_forms
41
+ cd inline_forms
42
+ git -c http.extraHeader="Authorization: basic $auth" fetch -q --depth 1 "$SERVER/$REPO.git" "$SHA"
43
+ git checkout -q FETCH_HEAD
44
+ git log --oneline -1
29
45
 
30
- - uses: actions/checkout@v4
31
- with:
32
- repository: ace/validation_hints
33
- token: ${{ secrets.VALIDATION_HINTS }}
34
- path: validation_hints
46
+ - name: Check out validation_hints
47
+ env:
48
+ TOKEN: ${{ secrets.VALIDATION_HINTS }}
49
+ SERVER: ${{ github.server_url }}
50
+ run: |
51
+ auth=$(printf 'x-access-token:%s' "$TOKEN" | base64 -w0)
52
+ git init -q validation_hints
53
+ cd validation_hints
54
+ git -c http.extraHeader="Authorization: basic $auth" fetch -q --depth 1 "$SERVER/ace/validation_hints.git" HEAD
55
+ git checkout -q FETCH_HEAD
56
+ git log --oneline -1
35
57
 
36
58
  - name: Build the four gems
37
59
  run: |
@@ -75,3 +97,8 @@ jobs:
75
97
  # Pedantic full set stays informational: it includes checks that
76
98
  # can fire on perfectly reasonable future code.
77
99
  brakeman --run-all-checks --no-pager || true
100
+
101
+ # ENFORCING: a warning that is not in .forgejo/brakeman.ignore fails, and
102
+ # so does an entry there that has no reason or no longer occurs.
103
+ - name: Brakeman against the app together with the engine
104
+ run: bash inline_forms/.forgejo/brakeman-engine.sh apps/MyApp
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-4.0.4
1
+ ruby-4.0.10
data/CHANGELOG.md CHANGED
@@ -8,6 +8,95 @@ All notable changes to this project are documented in this file.
8
8
 
9
9
  - Known issues, parked (local note `stuff/2026-10-31-dropdown-rule-3-parked.md`) with dropdown order rule 3: `includes`, `group` or `select` in `inline_forms_list` make `dropdown` and `dropdown_with_other` raise while `/index` works, so 8.1.65's fix for a list order on a joined table holds only for `joins`, `left_joins` and `eager_load`; a has_many join gives duplicate options. Present since 8.1.60. No host's list scope has these today. Parked; not changed.
10
10
 
11
+ ## [8.1.75] - 2026-11-22
12
+
13
+ ### Removed
14
+
15
+ - **Installer: no importmap in generated apps.** `importmap-rails`, and 8.1.73's `bin/importmap` and `config/importmap.rb`, are gone, and `rails new` runs with `--skip-javascript`, so `bin/ci` has no importmap audit. Nothing used it (JavaScript comes from gems through Sprockets), and `bin/importmap pin` downloads npm packages. Existing apps are not changed.
16
+
17
+ ### Tests
18
+
19
+ - The example app checks that importmap is not there, instead of running its audit.
20
+
21
+ ## [8.1.74] - 2026-11-22
22
+
23
+ ### Fixed
24
+
25
+ - **Installer: the users/roles join table migration rolls back.** Its `down` said `drop_table roles_users`, without the colon, and raised `NoMethodError`. An existing app can correct that line in its own `db/migrate/*_inline_forms_create_join_table_*_role.rb`.
26
+
27
+ ### Tests
28
+
29
+ - The example app rolls that migration back and runs it again (`example_app_roles_join_table_rollback_test.rb`).
30
+
31
+ ## [8.1.73] - 2026-11-22
32
+
33
+ ### Fixed
34
+
35
+ - **Installer: generated apps have `bin/importmap`** and a `config/importmap.rb` without pins. `bin/ci` runs `bin/importmap audit`, which failed because the file was missing; the app's JavaScript still comes from Sprockets. Existing apps are not changed.
36
+
37
+ ### Tests
38
+
39
+ - The example app runs `bin/importmap audit`.
40
+
41
+ ## [8.1.72] - 2026-11-22
42
+
43
+ ### Changed
44
+
45
+ - **Installer: generated apps have `rubocop-rails-omakase`** (development and test groups), the gem behind `bin/rubocop`, which `bin/ci` runs. The generated app had 335 offenses (all style); it now has none. Existing apps are not changed.
46
+ - **Generators write RuboCop's style:** double quotes and new hash syntax, no trailing spaces, no blank line at the start or end of a class, and no comma after the last `inline_forms_attribute_list` row. `inline_forms_addto` adds that comma when it appends a row, also before a trailing comment. Lists with the comma keep working, as does `MODEL_TABS = %w( )`, which is now written as `%w[ ]`. Re-running `inline_forms_addto` recognises the `:dependent => :destroy` line it wrote before.
47
+ - The installer runs `bin/rubocop -a` on the files Devise's and PaperTrail's generators write (`config/initializers/devise.rb` and the versions migrations).
48
+
49
+ ### Fixed
50
+
51
+ - The installer's Devise mailer settings are indented and on their own lines in `config/environments/*.rb`; in development.rb the first line was glued to Rails' last comment.
52
+
53
+ ### Tests
54
+
55
+ - The example app's suite runs `bin/rubocop` on the whole app.
56
+ - Generator tests for the style of the model and migration, lists with and without the last comma, and the pre-8.1.72 `MODEL_TABS` and `has_many` lines.
57
+
58
+ ## [8.1.71] - 2026-11-22
59
+
60
+ ### Fixed
61
+
62
+ - **Installer: generated apps have `brakeman` and `bundler-audit`** (development and test groups, `require: false`). `rails new` writes `bin/brakeman` and `bin/bundler-audit`, and `bin/ci` runs them, but the installer's own Gemfile left the gems out, so both failed. Existing apps are not changed.
63
+
64
+ ### Tests
65
+
66
+ - The example app runs both binstubs (`example_app_security_tools_test.rb`).
67
+
68
+ ## [8.1.70] - 2026-11-22
69
+
70
+ ### Changed
71
+
72
+ - **Rails 8.1.4.1 is the minimum** (was 8.1.0; still `< 8.2`). Older 8.1 releases have known vulnerabilities, up to critical (Active Storage file read and write, CVE-2026-122006). A host on an older Rails updates Rails together with inline_forms: `bundle update --conservative rails inline_forms inline_forms_installer inline_forms_schema_edit validation_hints`, naming the ones it uses.
73
+
74
+ ### CI
75
+
76
+ - The full gate runs Brakeman on the engine's own code too: `.forgejo/brakeman-engine.sh` scans the generated app together with the engine and `inline_forms_schema_edit`. Brakeman skips gem code, so until now the engine was not scanned. Accepted warnings are in `.forgejo/brakeman.ignore`, each with its reason.
77
+
78
+ ## [8.1.69] - 2026-11-22
79
+
80
+ ### Changed
81
+
82
+ - **Installer: generated apps use terser instead of uglifier,** and compress JavaScript on `assets:precompile`: the production group has `terser` next to `mini_racer` (its ExecJS runtime, so no Node), and `config/environments/production.rb` gets `config.assets.js_compressor = :terser`. Before, uglifier was in the Gemfile but nothing set a compressor. Existing apps are not changed.
83
+
84
+ ### Tests
85
+
86
+ - The example app checks the setting and the production group (`example_app_production_js_compressor_test.rb`).
87
+
88
+ ## [8.1.68] - 2026-11-22
89
+
90
+ ### Security
91
+
92
+ - **Ruby 4.0.10 instead of 4.0.4.** Ruby 4.0.4 has eight advisories in ruby-advisory-db (31efd9aa, 2026-11-22), among them CVE-2026-132825 (heap buffer overflow in string case conversion, fixed in 4.0.10) and CVE-2026-46727 (use-after-free in `getaddrinfo`, fixed in 4.0.5). `bundler-audit` does not check the interpreter.
93
+
94
+ ### Changed
95
+
96
+ - **Installer: generated apps pin Ruby 4.0.10** in `.ruby-version` (`InlineFormsInstaller::TARGET_RUBY_VERSION` and the template's fallback). That Ruby must be installed before `inline_forms create`. Existing apps keep the `.ruby-version` they have.
97
+ - The repo's own `.ruby-version` follows. `required_ruby_version` stays `>= 4.0.0`.
98
+ - **CI runs without Node.** `ci.yml`, `full-gate.yml` and the `inline_forms_schema_edit` example workflow run in the official `ruby:4.0.10` image and check out with plain git instead of `actions/checkout` and `actions/cache`, which are JavaScript. Gems are installed fresh each run.
99
+
11
100
  ## [8.1.67] - 2026-11-06
12
101
 
13
102
  Fixes from a code review of 8.1.66.
data/README.rdoc CHANGED
@@ -4,13 +4,13 @@ Inline Forms is almost a complete admin application. You can try it out easily.
4
4
 
5
5
  = Requirements
6
6
 
7
- * Ruby **>= 4.0** (generated apps pin **4.0.4** via +.ruby-version+)
8
- * Rails **8.1.x** (+rails ~> 8.1+, +config.load_defaults 8.1+)
7
+ * Ruby **>= 4.0** (generated apps pin **4.0.10** via +.ruby-version+)
8
+ * Rails **8.1.x**, at least **8.1.4.1** (+rails ~> 8.1+, +config.load_defaults 8.1+)
9
9
  * **validation_hints** **~> 8** (companion gem; same version line as +inline_forms+ / +inline_forms_installer+)
10
10
 
11
11
  = Ruby version managers (RVM is optional)
12
12
 
13
- +inline_forms+ does *not* require RVM. Generated apps get a +.ruby-version+ whose format matches the version manager you are using: a *bare* +4.0.4+ for +rbenv+ / +chruby+ / +asdf+ / +mise+, or +ruby-4.0.4+ for RVM (whose +.ruby-version+ reader needs the +ruby-+ prefix). So any version manager — or none — works. Bundler isolates each app's gems through its own +Gemfile.lock+.
13
+ +inline_forms+ does *not* require RVM. Generated apps get a +.ruby-version+ whose format matches the version manager you are using: a *bare* +4.0.10+ for +rbenv+ / +chruby+ / +asdf+ / +mise+, or +ruby-4.0.10+ for RVM (whose +.ruby-version+ reader needs the +ruby-+ prefix). So any version manager — or none — works. Bundler isolates each app's gems through its own +Gemfile.lock+.
14
14
 
15
15
  RVM integration is purely opt-in. If the +rvm+ gem is installed *and* your shell is inside an RVM environment, +inline_forms create+ additionally writes a +.ruby-gemset+ and installs into a per-app gemset. To enable that, +gem install rvm+ before creating the app. To skip RVM even when it is present, pass +--no-rvm+:
16
16
 
@@ -279,8 +279,8 @@ LONGBLOB column plus a content-type column). Declare the slot on the model:
279
279
 
280
280
  # routes.rb
281
281
  resources :clients do
282
- post 'revert', :on => :member
283
- get 'list_versions', :on => :member
282
+ post "revert", on: :member
283
+ get "list_versions", on: :member
284
284
  InlineForms.file_routes(self)
285
285
  end
286
286
  InlineForms.draw_file_trash_routes(self) # global trash page, /file_trash
data/inline_forms.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.require_paths = [ "lib" ]
22
22
 
23
23
  s.add_dependency("validation_hints", ">= 8.1.4", "< 9.0")
24
- s.add_dependency("rails", ">= 8.1", "< 8.2")
24
+ s.add_dependency("rails", ">= 8.1.4.1", "< 8.2")
25
25
  s.add_dependency("rails-i18n", ">= 8.1", "< 9.0")
26
26
 
27
27
  s.add_development_dependency("minitest", "~> 5.0")
@@ -1,7 +1,5 @@
1
1
  class <%= migration_class_name %> < ActiveRecord::Migration[8.1]
2
-
3
2
  def change
4
3
  <%= @migration_lines -%>
5
4
  end
6
-
7
5
  end
@@ -157,7 +157,7 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
157
157
  when :has_many
158
158
  inject_class_line!(" has_many :#{attribute.name}\n")
159
159
  when :has_many_destroy
160
- inject_class_line!(" has_many :#{attribute.name}, :dependent => :destroy\n")
160
+ inject_class_line!(" has_many :#{attribute.name}, dependent: :destroy\n")
161
161
  when :has_one
162
162
  inject_class_line!(" has_one :#{attribute.name}\n")
163
163
  when :habtm, :has_and_belongs_to_many, :check_list
@@ -277,7 +277,8 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
277
277
  def inject_class_line!(line)
278
278
  content = File.read(File.join(destination_root, model_file_path))
279
279
  probe = line.rstrip
280
- if content.include?(probe)
280
+ # `:dependent => :destroy` is what this generator wrote before 8.1.72.
281
+ if content.gsub(":dependent => ", "dependent: ").include?(probe)
281
282
  say_status :identical, "#{model_file_path}: #{probe.strip}", :blue
282
283
  return
283
284
  end
@@ -309,11 +310,10 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
309
310
  bounds = attribute_list_bounds(content)
310
311
  unless bounds
311
312
  say_status :warn, "#{model_file_path}: no inline_forms_attribute_list found, appending a fresh method", :yellow
312
- body = <<~RUBY.gsub(/^/, " ")
313
-
313
+ body = <<~RUBY.gsub(/^(?=.)/, " ")
314
314
  def inline_forms_attribute_list
315
315
  @inline_forms_attribute_list ||= [
316
- #{attribute_row_literal(attribute)},
316
+ #{attribute_row_literal(attribute)}
317
317
  ]
318
318
  end
319
319
  RUBY
@@ -327,16 +327,18 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
327
327
  inner = content[(open_idx + 1)...close_idx]
328
328
  lines = inner.lines
329
329
  indent = detect_row_indent(lines)
330
- new_line = "#{indent}#{attribute_row_literal(attribute)},\n"
331
330
 
332
331
  insert_at, note = insertion_index(lines, attribute)
333
332
 
333
+ # A comma only when a row follows (RuboCop omakase wants none after the
334
+ # last one).
335
+ comma = lines.drop(insert_at).any? { |l| l.match?(/\A\s*\[/) } ? "," : ""
336
+ new_line = "#{indent}#{attribute_row_literal(attribute)}#{comma}\n"
337
+
334
338
  # Keep the array valid: ensure the row we insert after ends with a comma.
335
339
  if insert_at.positive?
336
340
  prev = lines[insert_at - 1]
337
- if prev && prev.match?(/\S/) && !prev.match?(/,\s*\z/)
338
- lines[insert_at - 1] = prev.sub(/(\S)(\s*)\z/, "\\1,\\2")
339
- end
341
+ lines[insert_at - 1] = with_trailing_comma(prev) if prev
340
342
  end
341
343
 
342
344
  lines.insert(insert_at, new_line)
@@ -345,6 +347,32 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
345
347
  say_status :insert, "#{model_file_path}: row :#{attribute.name}#{note}", :green
346
348
  end
347
349
 
350
+ # `line` with a comma after its row, before a trailing comment if it has
351
+ # one. Blank and comment lines, and rows that have their comma, unchanged.
352
+ def with_trailing_comma(line)
353
+ row = line.match(/\A(\s*)\[/)
354
+ return line if line.match?(/\A\s*(#|\z)/)
355
+
356
+ if row
357
+ depth = 0
358
+ ending = nil
359
+ line.each_char.with_index do |char, index|
360
+ depth += 1 if char == "["
361
+ depth -= 1 if char == "]"
362
+ if char == "]" && depth.zero?
363
+ ending = index
364
+ break
365
+ end
366
+ end
367
+ end
368
+ # Not a whole row on one line (the end of a longer one): its last `]`
369
+ # outside a comment.
370
+ ending ||= line.sub(/\s#.*/, "").rindex("]")
371
+ return line if ending.nil? || line[(ending + 1)..].match?(/\A\s*,/)
372
+
373
+ line.dup.insert(ending + 1, ",")
374
+ end
375
+
348
376
  # Returns [open_bracket_index, close_bracket_index] for the
349
377
  # `@inline_forms_attribute_list ||= [ ... ]` array literal, or nil when the
350
378
  # model has no such list. Bracket-depth scan; nested `[ ]` (e.g. an
@@ -433,12 +461,12 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
433
461
  " " # 6 spaces, matching the create-time template
434
462
  end
435
463
 
436
- # `[ :name, :element ]`, or `[ :name, :element, { 1 => 'one', 2 => 'two' } ]`
464
+ # `[ :name, :element ]`, or `[ :name, :element, { 1 => "one", 2 => "two" } ]`
437
465
  # for value-bearing choice elements (a placeholder the user then edits).
438
466
  def attribute_row_literal(attribute)
439
467
  el = attribute.attribute_type
440
468
  if VALUE_BEARING_ELEMENTS.include?(el)
441
- "[ :#{attribute.name}, :#{el}, { 1 => 'one', 2 => 'two' } ]"
469
+ "[ :#{attribute.name}, :#{el}, { 1 => \"one\", 2 => \"two\" } ]"
442
470
  else
443
471
  "[ :#{attribute.name}, :#{el} ]"
444
472
  end
@@ -449,7 +477,7 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
449
477
 
450
478
  say_status :warn,
451
479
  "#{model_file_path}: :#{attribute.name} is a #{attribute.attribute_type}; " \
452
- "edit the placeholder values hash { 1 => 'one', ... }",
480
+ "edit the placeholder values hash { 1 => \"one\", ... }",
453
481
  :yellow
454
482
  end
455
483
 
@@ -471,7 +499,7 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
471
499
  / def _presentation\b.*?\n end\n/m,
472
500
  new_method
473
501
  else
474
- inject_into_class model_file_path, model_class_name, "\n#{new_method}"
502
+ inject_into_class model_file_path, model_class_name, "#{new_method}\n"
475
503
  end
476
504
  when "_list_order", "_order"
477
505
  col = attribute.type
@@ -487,7 +515,7 @@ class InlineFormsAddtoGenerator < Rails::Generators::NamedBase
487
515
  if content.match?(/def <=>\(other\)/)
488
516
  gsub_file model_file_path, / def <=>\(other\).*?\n end\n/m, new_spaceship
489
517
  else
490
- inject_into_class model_file_path, model_class_name, "\n#{new_spaceship}"
518
+ inject_into_class model_file_path, model_class_name, "#{new_spaceship}\n"
491
519
  end
492
520
  when "_list_search"
493
521
  col = attribute.type
@@ -68,6 +68,7 @@ module InlineForms
68
68
  @carrierwave_mounters = "\n"
69
69
  @stored_files = String.new
70
70
  @inline_forms_attribute_list = String.new
71
+ rows = []
71
72
 
72
73
  for attribute in attributes
73
74
  if attribute.column_type == :belongs_to
@@ -81,7 +82,7 @@ module InlineForms
81
82
  if attribute.type == :has_many ||
82
83
  attribute.type == :has_many_destroy
83
84
  @has_many << ' has_many :' + attribute.name
84
- @has_many << ', :dependent => :destroy' if attribute.type == :has_many_destroy
85
+ @has_many << ', dependent: :destroy' if attribute.type == :has_many_destroy
85
86
  @has_many << "\n"
86
87
  end
87
88
  if attribute.type == :has_one
@@ -126,15 +127,17 @@ module InlineForms
126
127
  @list_scopes << " inline_forms_search_on :#{attribute.type}\n"
127
128
  end
128
129
  if attribute.attribute?
129
- attribute.attribute_type == :unknown ? commenter = '#' : commenter = ' '
130
- @inline_forms_attribute_list << commenter +
131
- ' [ :' +
132
- attribute.name +
133
- ', :' + attribute.attribute_type.to_s +
134
- " ], \n"
130
+ commenter = attribute.attribute_type == :unknown ? '#' : ' '
131
+ rows << "#{commenter} [ :#{attribute.name}, :#{attribute.attribute_type} ]"
135
132
  end
136
133
  end
137
- unless @inline_forms_attribute_list.empty?
134
+ unless rows.empty?
135
+ # No comma after the last row that is not commented out (RuboCop
136
+ # omakase); inline_forms_addto adds it when it appends a row.
137
+ last_row = rows.rindex { |row| !row.start_with?('#') }
138
+ rows.each_with_index do |row, index|
139
+ @inline_forms_attribute_list << row << (index == last_row ? "\n" : ",\n")
140
+ end
138
141
  @inline_forms_attribute_list = "\n" +
139
142
  " def inline_forms_attribute_list\n" +
140
143
  " @inline_forms_attribute_list ||= [\n" +
@@ -143,7 +146,7 @@ module InlineForms
143
146
  " end\n" +
144
147
  "\n"
145
148
  end
146
- template "model.erb", "app/models/#{model_file_name}.rb"
149
+ template("model.erb", "app/models/#{model_file_name}.rb") { |content| tidy_class_body(content) }
147
150
  end
148
151
  end
149
152
 
@@ -152,8 +155,8 @@ module InlineForms
152
155
  file_routes = file_slot_attributes.any? ? "\n InlineForms.file_routes(self)" : ""
153
156
  route <<-ROUTE.strip_heredoc
154
157
  resources :#{resource_name} do
155
- post 'revert', :on => :member
156
- get 'list_versions', :on => :member#{file_routes}
158
+ post "revert", on: :member
159
+ get "list_versions", on: :member#{file_routes}
157
160
  end
158
161
  ROUTE
159
162
  end
@@ -200,7 +203,7 @@ module InlineForms
200
203
  " :" +
201
204
  attribute.name +
202
205
  column_opts +
203
- " \n"
206
+ "\n"
204
207
  end
205
208
  end
206
209
  end
@@ -212,7 +215,8 @@ module InlineForms
212
215
  def add_tab
213
216
  return if @flag_not_accessible_through_html
214
217
 
215
- # The installer seeds `MODEL_TABS = %w(<user_model_route> )` in
218
+ # The installer seeds `MODEL_TABS = %w[<user_model_route> ]` (`%w( )`
219
+ # before 8.1.72) in
216
220
  # `config/initializers/inline_forms.rb` before any `rails g inline_forms`
217
221
  # runs. Inject each generated model's pluralised route token into that
218
222
  # list so the inline_forms top-bar dropdown (rendered by
@@ -221,13 +225,13 @@ module InlineForms
221
225
  # consumer running `rails g inline_forms` in a non-installer-shaped app)
222
226
  # or when the token is already present (idempotent re-run).
223
227
  relative_path = "config/initializers/inline_forms.rb"
224
- marker = "MODEL_TABS = %w("
228
+ marker = /MODEL_TABS = %w[\[(]/
225
229
  tab_token = "#{name.pluralize.underscore} "
226
230
  full_path = File.join(destination_root, relative_path)
227
231
  return unless File.exist?(full_path)
228
232
 
229
233
  content = File.read(full_path)
230
- return unless content.include?(marker)
234
+ return unless content.match?(marker)
231
235
  return if content.include?(tab_token.rstrip)
232
236
 
233
237
  inject_into_file relative_path, tab_token, after: marker
@@ -243,6 +247,14 @@ module InlineForms
243
247
 
244
248
 
245
249
  private
250
+ # The optional parts of model.erb each bring their own blank lines: none
251
+ # right after `class` or before its `end`, and never two in a row.
252
+ def tidy_class_body(content)
253
+ content.gsub(/\n{3,}/, "\n\n")
254
+ .sub(/\A(class [^\n]*\n)\n+/, '\1')
255
+ .sub(/\n+end\s*\z/, "\nend\n")
256
+ end
257
+
246
258
  def file_slot_attributes
247
259
  attributes.select { |attribute| attribute.type == :simple_file_field }
248
260
  end
@@ -1,5 +1,4 @@
1
1
  class InlineFormsCreate<%= table_name.camelize %> < ActiveRecord::Migration[8.1]
2
-
3
2
  def self.up
4
3
  create_table :<%= table_name + @primary_key_option %> do |t|
5
4
  <%= @columns -%>
@@ -10,5 +9,4 @@ class InlineFormsCreate<%= table_name.camelize %> < ActiveRecord::Migration[8.1]
10
9
  def self.down
11
10
  drop_table :<%= table_name %>
12
11
  end
13
-
14
12
  end
@@ -3,4 +3,4 @@ class <%= test_name %> < ActiveSupport::TestCase
3
3
  test "the truth" do
4
4
  assert true
5
5
  end
6
- end
6
+ end
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module InlineForms
4
- VERSION = "8.1.67"
4
+ VERSION = "8.1.75"
5
5
  end
@@ -331,6 +331,55 @@ class InlineFormsAddtoGeneratorTest < Minitest::Test
331
331
  assert(model.index("[ :occupation") < model.index("[ :category"))
332
332
  end
333
333
 
334
+ # What `rails g inline_forms` writes: no comma after the last row.
335
+ def test_list_without_a_trailing_comma
336
+ write_model("widget.rb", widget_with_rows("[ :name, :text_field ],", "[ :size, :integer_field ]"))
337
+
338
+ capture_io { run_generator("Widget", "color:string") }
339
+
340
+ assert_includes(read("app/models/widget.rb"),
341
+ " [ :size, :integer_field ],\n [ :color, :text_field ]\n ]")
342
+ assert_valid_ruby("app/models/widget.rb")
343
+ end
344
+
345
+ def test_last_row_with_a_trailing_comment
346
+ write_model("widget.rb", widget_with_rows("[ :size, :dropdown_with_values, { 1 => \"a\" }, [ 1 ] ] # see [x], y"))
347
+
348
+ capture_io { run_generator("Widget", "color:string") }
349
+
350
+ assert_includes(read("app/models/widget.rb"),
351
+ "[ 1 ] ], # see [x], y\n [ :color, :text_field ]\n ]")
352
+ assert_valid_ruby("app/models/widget.rb")
353
+ end
354
+
355
+ def test_row_that_already_has_its_comma_before_a_comment
356
+ write_model("widget.rb", widget_with_rows("[ :size, :integer_field ], # cm"))
357
+
358
+ capture_io { run_generator("Widget", "color:string") }
359
+
360
+ assert_includes(read("app/models/widget.rb"), "[ :size, :integer_field ], # cm\n [ :color, :text_field ]\n")
361
+ assert_valid_ruby("app/models/widget.rb")
362
+ end
363
+
364
+ def test_row_before_another_gets_a_comma
365
+ write_model("widget.rb", widget_with_rows("[ :name, :text_field ],", "[ :size, :integer_field ]"))
366
+
367
+ capture_io { run_generator("Widget", "color:string", "--before=size") }
368
+
369
+ assert_includes(read("app/models/widget.rb"),
370
+ " [ :color, :text_field ],\n [ :size, :integer_field ]\n ]")
371
+ assert_valid_ruby("app/models/widget.rb")
372
+ end
373
+
374
+ def test_rerun_recognises_the_has_many_destroy_line_from_before_8_1_72
375
+ write_model("widget.rb", widget_with_rows("[ :name, :text_field ]")
376
+ .sub("ApplicationRecord\n", "ApplicationRecord\n has_many :parts, :dependent => :destroy\n"))
377
+
378
+ capture_io { run_generator("Widget", "parts:has_many_destroy") }
379
+
380
+ assert_equal(1, read("app/models/widget.rb").scan("has_many :parts").size)
381
+ end
382
+
334
383
  def test_missing_anchor_warns_and_falls_back_to_default
335
384
  write_model("widget.rb", GENERATOR_SHAPED_MODEL)
336
385
 
@@ -351,7 +400,7 @@ class InlineFormsAddtoGeneratorTest < Minitest::Test
351
400
  end
352
401
 
353
402
  model = read("app/models/widget.rb")
354
- assert_includes(model, "[ :status, :dropdown_with_values, { 1 => 'one', 2 => 'two' } ]")
403
+ assert_includes(model, '[ :status, :dropdown_with_values, { 1 => "one", 2 => "two" } ]')
355
404
  assert_includes(out, "values hash")
356
405
  end
357
406
 
@@ -493,6 +542,23 @@ class InlineFormsAddtoGeneratorTest < Minitest::Test
493
542
  end
494
543
  end
495
544
 
545
+ def widget_with_rows(*rows)
546
+ list = rows.map { |row| " #{row}\n" }.join
547
+ <<~RUBY
548
+ class Widget < ApplicationRecord
549
+ def inline_forms_attribute_list
550
+ @inline_forms_attribute_list ||= [
551
+ #{list.chomp}
552
+ ]
553
+ end
554
+ end
555
+ RUBY
556
+ end
557
+
558
+ def assert_valid_ruby(path)
559
+ assert(RubyVM::InstructionSequence.compile(read(path)))
560
+ end
561
+
496
562
  def write_model(file, content)
497
563
  File.write(File.join(@destination_root, "app/models", file), content)
498
564
  end
@@ -51,10 +51,10 @@ class InlineFormsGeneratorTest < Minitest::Test
51
51
  assert_includes(controller, "set_tab :thing")
52
52
 
53
53
  assert_includes(routes, "resources :things do")
54
- assert_includes(routes, "post 'revert', :on => :member")
55
- assert_includes(routes, "get 'list_versions', :on => :member")
54
+ assert_includes(routes, 'post "revert", on: :member')
55
+ assert_includes(routes, 'get "list_versions", on: :member')
56
56
 
57
- assert_includes(inline_forms_initializer, "MODEL_TABS = %w(things ")
57
+ assert_includes(inline_forms_initializer, "MODEL_TABS = %w[things ")
58
58
 
59
59
  assert_includes(migration, "class InlineFormsCreateThings < ActiveRecord::Migration[8.1]")
60
60
  assert_includes(migration, "create_table :things do |t|")
@@ -188,6 +188,46 @@ class InlineFormsGeneratorTest < Minitest::Test
188
188
  assert_includes(routes, "InlineForms.file_routes(self)")
189
189
  end
190
190
 
191
+ # RuboCop omakase, which generated apps run in bin/ci.
192
+ def test_model_and_migration_follow_the_style_of_a_generated_app
193
+ run_generator(
194
+ "Thing",
195
+ "name:string",
196
+ "category:dropdown",
197
+ "photos:has_many_destroy",
198
+ "_enabled:yes",
199
+ "_list_order:name",
200
+ "_presentation:\\#{name}"
201
+ )
202
+
203
+ model = read("app/models/thing.rb")
204
+ assert_includes(model, " [ :name, :text_field ],\n [ :category, :dropdown ]\n ]\n")
205
+ assert_includes(model, "has_many :photos, dependent: :destroy")
206
+ [ model, read_single_migration_for("things"), read("test/unit/thing_test.rb") ].each do |content|
207
+ refute_match(/[ \t]$/, content)
208
+ refute_match(/\Aclass [^\n]*\n\n/, content)
209
+ refute_match(/\n\nend\n\z/, content)
210
+ refute_match(/\n{3}/, content)
211
+ assert(content.end_with?("end\n"))
212
+ end
213
+ end
214
+
215
+ def test_a_commented_out_row_leaves_the_last_real_row_without_a_comma
216
+ run_generator("Mystery", "name:string", "payload:not_a_real_type", "--allow-unknown")
217
+
218
+ model = read("app/models/mystery.rb")
219
+ assert_includes(model, " [ :name, :text_field ]\n# [ :payload, :unknown ],\n ]")
220
+ RubyVM::InstructionSequence.compile(model)
221
+ end
222
+
223
+ def test_tab_injection_into_an_initializer_from_before_8_1_72
224
+ write("config/initializers/inline_forms.rb", "MODEL_TABS = %w(users )\n")
225
+
226
+ run_generator("Thing", "name:string", "_enabled:yes")
227
+
228
+ assert_equal("MODEL_TABS = %w(things users )\n", read("config/initializers/inline_forms.rb"))
229
+ end
230
+
191
231
  def test_no_file_routes_without_a_file_field
192
232
  run_generator("Thing", "name:string", "_enabled:yes")
193
233
 
@@ -222,12 +262,12 @@ class InlineFormsGeneratorTest < Minitest::Test
222
262
  )
223
263
 
224
264
  # Matches the file the installer writes; the generator's `add_tab` step
225
- # injects `<plural_route> ` tokens after the `MODEL_TABS = %w(` marker.
265
+ # injects `<plural_route> ` tokens after the `MODEL_TABS = %w[` marker.
226
266
  write(
227
267
  "config/initializers/inline_forms.rb",
228
268
  <<~RUBY
229
269
  Rails.application.reloader.to_prepare do
230
- MODEL_TABS = %w()
270
+ MODEL_TABS = %w[]
231
271
  end
232
272
  RUBY
233
273
  )
@@ -8,7 +8,7 @@ class UserModelConfigTest < Minitest::Test
8
8
  cfg = InlineFormsInstaller::UserModelConfig.from_name("User")
9
9
  assert cfg.default?
10
10
  assert_equal "users", cfg.table_name
11
- assert_equal "devise_for :users, :path_prefix => 'auth'", cfg.devise_route_line
11
+ assert_equal 'devise_for :users, path_prefix: "auth"', cfg.devise_route_line
12
12
  assert_equal "/auth/users/sign_in", cfg.sign_in_path_fragment
13
13
  end
14
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.67
4
+ version: 8.1.75
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -37,7 +37,7 @@ dependencies:
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '8.1'
40
+ version: 8.1.4.1
41
41
  - - "<"
42
42
  - !ruby/object:Gem::Version
43
43
  version: '8.2'
@@ -47,7 +47,7 @@ dependencies:
47
47
  requirements:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: '8.1'
50
+ version: 8.1.4.1
51
51
  - - "<"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '8.2'
@@ -95,6 +95,8 @@ extensions: []
95
95
  extra_rdoc_files: []
96
96
  files:
97
97
  - ".document"
98
+ - ".forgejo/brakeman-engine.sh"
99
+ - ".forgejo/brakeman.ignore"
98
100
  - ".forgejo/workflows/ci.yml"
99
101
  - ".forgejo/workflows/full-gate.yml"
100
102
  - ".gitignore"
@@ -367,7 +369,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
367
369
  - !ruby/object:Gem::Version
368
370
  version: '0'
369
371
  requirements: []
370
- rubygems_version: 4.0.12
372
+ rubygems_version: 4.0.20
371
373
  specification_version: 4
372
374
  summary: Inline editing of forms for Rails 8.
373
375
  test_files: