inline_forms 8.1.75 → 8.1.76
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 +4 -4
- data/CHANGELOG.md +25 -1
- data/README.rdoc +1 -1
- data/inline_forms.gemspec +0 -1
- data/lib/generators/USAGE +1 -1
- data/lib/generators/inline_forms_addto/USAGE +1 -1
- data/lib/generators/inline_forms_addto_generator.rb +30 -139
- data/lib/generators/inline_forms_attribute_list_editor.rb +211 -0
- data/lib/generators/inline_forms_attribute_overrides.rb +9 -0
- data/lib/generators/inline_forms_generator.rb +16 -35
- data/lib/inline_forms/gem_files.rb +20 -17
- data/lib/inline_forms/version.rb +1 -1
- metadata +3 -142
- data/.document +0 -5
- data/.forgejo/brakeman-engine.sh +0 -51
- data/.forgejo/brakeman.ignore +0 -211
- data/.forgejo/workflows/ci.yml +0 -74
- data/.forgejo/workflows/full-gate.yml +0 -104
- data/.gitignore +0 -39
- data/.rubocop.yml +0 -31
- data/.rubocop_todo.yml +0 -151
- data/.ruby-version +0 -1
- data/Gemfile +0 -28
- data/Rakefile +0 -103
- data/script/migrate_form_elements.rb +0 -62
- data/test/archived_form_elements_test.rb +0 -101
- data/test/attribute_list_test.rb +0 -165
- data/test/dummy/app/controllers/application_controller.rb +0 -32
- data/test/dummy/app/controllers/daily_reports_controller.rb +0 -4
- data/test/dummy/app/controllers/documents_controller.rb +0 -4
- data/test/dummy/app/controllers/dossiers_controller.rb +0 -4
- data/test/dummy/app/controllers/gizmos_controller.rb +0 -4
- data/test/dummy/app/controllers/machines_controller.rb +0 -4
- data/test/dummy/app/controllers/parts_controller.rb +0 -4
- data/test/dummy/app/controllers/stats_controller.rb +0 -10
- data/test/dummy/app/controllers/widgets_controller.rb +0 -4
- data/test/dummy/app/helpers/application_helper.rb +0 -13
- data/test/dummy/app/models/ability.rb +0 -15
- data/test/dummy/app/models/application_record.rb +0 -27
- data/test/dummy/app/models/daily_report.rb +0 -21
- data/test/dummy/app/models/document.rb +0 -33
- data/test/dummy/app/models/dossier.rb +0 -38
- data/test/dummy/app/models/gizmo.rb +0 -25
- data/test/dummy/app/models/kind.rb +0 -8
- data/test/dummy/app/models/machine.rb +0 -24
- data/test/dummy/app/models/part.rb +0 -17
- data/test/dummy/app/models/phase.rb +0 -9
- data/test/dummy/app/models/widget.rb +0 -40
- data/test/dummy/app/views/_gizmos_search.html.erb +0 -3
- data/test/dummy/app/views/stats/show.html.erb +0 -1
- data/test/dummy/config/application.rb +0 -49
- data/test/dummy/config/database.yml +0 -3
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/initializers/inline_forms.rb +0 -6
- data/test/dummy/config/initializers/paper_trail_yaml_safe_load.rb +0 -28
- data/test/dummy/config/routes.rb +0 -51
- data/test/form_element_from_callee_test.rb +0 -73
- data/test/gem_package_modes_test.rb +0 -86
- data/test/inline_edit_polymorphic_path_test.rb +0 -81
- data/test/inline_forms_addto_generator_test.rb +0 -584
- data/test/inline_forms_generator_test.rb +0 -301
- data/test/integration/csp_nonce_test.rb +0 -50
- data/test/integration/dropdown_test.rb +0 -186
- data/test/integration/field_authorization_test.rb +0 -131
- data/test/integration/file_slots_test.rb +0 -665
- data/test/integration/html_refusal_test.rb +0 -152
- data/test/integration/inline_forms_crud_test.rb +0 -165
- data/test/integration/layout_title_test.rb +0 -56
- data/test/integration/legacy_elements_test.rb +0 -99
- data/test/integration/list_params_test.rb +0 -200
- data/test/integration/locale_test.rb +0 -234
- data/test/integration/model_top_bar_test.rb +0 -85
- data/test/integration/native_inputs_test.rb +0 -138
- data/test/integration/open_after_create_test.rb +0 -85
- data/test/integration/pending_migration_gate_test.rb +0 -75
- data/test/integration/presentation_escaping_test.rb +0 -80
- data/test/integration/revert_skipped_columns_test.rb +0 -59
- data/test/integration/schema_batch_pipeline_test.rb +0 -189
- data/test/integration/schema_edit_test.rb +0 -141
- data/test/integration/schema_preview_test.rb +0 -65
- data/test/integration/turbo_menu_test.rb +0 -60
- data/test/integration_test_helper.rb +0 -203
- data/test/plain_text_configuration_test.rb +0 -90
- data/test/schema_apply_test.rb +0 -73
- data/test/schema_intent_test.rb +0 -53
- data/test/schema_label_test.rb +0 -61
- data/test/tabs_test.rb +0 -98
- data/test/test_helper.rb +0 -10
- data/test/user_model_config_test.rb +0 -44
data/test/attribute_list_test.rb
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "test_helper"
|
|
4
|
-
|
|
5
|
-
class AttributeListTest < Minitest::Test
|
|
6
|
-
def build_sample
|
|
7
|
-
InlineForms::AttributeList.build do
|
|
8
|
-
header :basics
|
|
9
|
-
field :name, :text_field
|
|
10
|
-
field :priority, :dropdown_with_values, values: { 1 => "low", 2 => "high" }
|
|
11
|
-
field :flag, :dropdown_with_values, values: { 1 => "a", 2 => "b" }, disabled: [ 2 ]
|
|
12
|
-
info :created_at, :updated_at
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# -- array compatibility (the whole point) -----------------------------
|
|
17
|
-
|
|
18
|
-
def test_is_an_array
|
|
19
|
-
assert_kind_of Array, build_sample
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def test_destructures_like_the_legacy_literal
|
|
23
|
-
seen = []
|
|
24
|
-
build_sample.each { |attribute, form_element| seen << [ attribute, form_element ] }
|
|
25
|
-
assert_includes seen, [ :name, :text_field ]
|
|
26
|
-
assert_includes seen, [ :priority, :dropdown_with_values ]
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def test_assoc_positional_values_hash_still_works
|
|
30
|
-
list = build_sample
|
|
31
|
-
# Consumers fetch the values hash as list.assoc(attr)[2].
|
|
32
|
-
assert_equal({ 1 => "low", 2 => "high" }, list.assoc(:priority)[2])
|
|
33
|
-
assert_equal([ 2 ], list.assoc(:flag)[3])
|
|
34
|
-
assert_nil list.assoc(:name)[2]
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def test_build_produces_expected_rows
|
|
38
|
-
list = build_sample
|
|
39
|
-
assert_equal(
|
|
40
|
-
[
|
|
41
|
-
[ :basics, :header ],
|
|
42
|
-
[ :name, :text_field ],
|
|
43
|
-
[ :priority, :dropdown_with_values, { 1 => "low", 2 => "high" } ],
|
|
44
|
-
[ :flag, :dropdown_with_values, { 1 => "a", 2 => "b" }, [ 2 ] ],
|
|
45
|
-
[ :created_at, :info ],
|
|
46
|
-
[ :updated_at, :info ]
|
|
47
|
-
],
|
|
48
|
-
list.to_a
|
|
49
|
-
)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# -- append -------------------------------------------------------------
|
|
53
|
-
|
|
54
|
-
def test_field_appends_and_returns_self_for_chaining
|
|
55
|
-
list = InlineForms::AttributeList.new
|
|
56
|
-
result = list.field(:a, :text_field).field(:b, :check_box)
|
|
57
|
-
assert_same list, result
|
|
58
|
-
assert_equal %i[a b], list.names
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def test_disabled_without_values_raises
|
|
62
|
-
assert_raises(ArgumentError) do
|
|
63
|
-
InlineForms::AttributeList.new.field(:x, :dropdown_with_values, disabled: [ 1 ])
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# -- insertion ----------------------------------------------------------
|
|
68
|
-
|
|
69
|
-
def test_insert_after
|
|
70
|
-
list = build_sample.insert_after(:name, :nickname, :text_field)
|
|
71
|
-
assert_equal :nickname, list.names[list.index_of(:name) + 1]
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def test_insert_before
|
|
75
|
-
list = build_sample.insert_before(:priority, :urgent, :check_box)
|
|
76
|
-
assert_equal :urgent, list.names[list.index_of(:priority) - 1]
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def test_insert_after_missing_anchor_raises
|
|
80
|
-
assert_raises(ArgumentError) { build_sample.insert_after(:nope, :x, :text_field) }
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# -- removal ------------------------------------------------------------
|
|
84
|
-
|
|
85
|
-
def test_remove_present
|
|
86
|
-
list = build_sample.remove(:priority)
|
|
87
|
-
refute list.include_attribute?(:priority)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def test_remove_absent_is_noop
|
|
91
|
-
list = build_sample
|
|
92
|
-
before = list.dup
|
|
93
|
-
list.remove(:does_not_exist)
|
|
94
|
-
assert_equal before.to_a, list.to_a
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
# -- reordering ---------------------------------------------------------
|
|
98
|
-
|
|
99
|
-
def test_move_after
|
|
100
|
-
list = build_sample.move_after(:name, :updated_at)
|
|
101
|
-
assert_equal :name, list.names.last
|
|
102
|
-
assert_equal 1, list.names.count(:name)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def test_move_before
|
|
106
|
-
list = build_sample.move_before(:updated_at, :basics)
|
|
107
|
-
assert_equal 0, list.index_of(:updated_at)
|
|
108
|
-
assert_equal 1, list.names.count(:updated_at)
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
def test_move_relative_to_itself_raises
|
|
112
|
-
assert_raises(ArgumentError) { build_sample.move_after(:name, :name) }
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
# -- replacement --------------------------------------------------------
|
|
116
|
-
|
|
117
|
-
def test_replace_element_preserves_position
|
|
118
|
-
list = build_sample
|
|
119
|
-
pos = list.index_of(:priority)
|
|
120
|
-
list.replace_element(:priority, :radio_button, values: { 1 => "x" })
|
|
121
|
-
assert_equal pos, list.index_of(:priority)
|
|
122
|
-
assert_equal :radio_button, list.form_element_for(:priority)
|
|
123
|
-
assert_equal({ 1 => "x" }, list.values_for(:priority))
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def test_replace_element_absent_is_noop
|
|
127
|
-
list = build_sample
|
|
128
|
-
before = list.dup
|
|
129
|
-
list.replace_element(:nope, :text_field)
|
|
130
|
-
assert_equal before.to_a, list.to_a
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
# -- queries ------------------------------------------------------------
|
|
134
|
-
|
|
135
|
-
def test_query_helpers
|
|
136
|
-
list = build_sample
|
|
137
|
-
assert_equal 1, list.index_of(:name)
|
|
138
|
-
assert list.include_attribute?(:flag)
|
|
139
|
-
refute list.include_attribute?(:ghost)
|
|
140
|
-
assert_equal :dropdown_with_values, list.form_element_for(:priority)
|
|
141
|
-
assert_equal({ 1 => "low", 2 => "high" }, list.values_for(:priority))
|
|
142
|
-
assert_equal [ :name, :text_field ], list.row_for(:name)
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
# -- wrap ---------------------------------------------------------------
|
|
146
|
-
|
|
147
|
-
def test_wrap_existing_array_enables_editing
|
|
148
|
-
legacy = [ [ :name, :text_field ], [ :email, :text_field ] ]
|
|
149
|
-
list = InlineForms::AttributeList.wrap(legacy)
|
|
150
|
-
assert_kind_of InlineForms::AttributeList, list
|
|
151
|
-
list.insert_after(:name, :phone, :text_field)
|
|
152
|
-
assert_equal %i[name phone email], list.names
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
def test_wrap_is_idempotent_for_attribute_list
|
|
156
|
-
list = build_sample
|
|
157
|
-
assert_same list, InlineForms::AttributeList.wrap(list)
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
def test_module_level_builder
|
|
161
|
-
list = InlineForms.attribute_list { field :a, :text_field }
|
|
162
|
-
assert_kind_of InlineForms::AttributeList, list
|
|
163
|
-
assert_equal %i[a], list.names
|
|
164
|
-
end
|
|
165
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class ApplicationController < ActionController::Base
|
|
4
|
-
# Devise/role stand-in. The full `layouts/inline_forms` chrome (rendered by
|
|
5
|
-
# create/new HTML responses) calls `current_user.name` and
|
|
6
|
-
# `current_user.role?`, so a nil current_user cannot render it. The stub is
|
|
7
|
-
# superadmin so `destroy_permitted?` allows hard destroy, matching the
|
|
8
|
-
# generated apps' test user. A test can switch that off with
|
|
9
|
-
# dummy_user_superadmin (reset in InlineFormsIntegrationTestCase#setup).
|
|
10
|
-
mattr_accessor :dummy_user_superadmin, default: true
|
|
11
|
-
|
|
12
|
-
DummyUser = Struct.new(:id, :name) do
|
|
13
|
-
def role?(role)
|
|
14
|
-
role.to_sym == :superadmin && ApplicationController.dummy_user_superadmin
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
helper_method :current_user
|
|
19
|
-
|
|
20
|
-
# Generated apps redirect HTML with a notice; a bare 403 is easier to assert.
|
|
21
|
-
rescue_from CanCan::AccessDenied do
|
|
22
|
-
head :forbidden
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def current_user
|
|
26
|
-
@current_user ||= DummyUser.new(1, "Dummy User")
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def devise_controller?
|
|
30
|
-
false
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Bespoke report page: uses the inline_forms admin layout but is not an
|
|
4
|
-
# InlineFormsController, so @Klass is never set (mirrors StProject Stats).
|
|
5
|
-
class StatsController < ApplicationController
|
|
6
|
-
layout "inline_forms"
|
|
7
|
-
|
|
8
|
-
def show
|
|
9
|
-
end
|
|
10
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Mirrors the helper the installer writes into host apps (installer_core.rb);
|
|
4
|
-
# the full `layouts/inline_forms` chrome needs it.
|
|
5
|
-
module ApplicationHelper
|
|
6
|
-
def application_name
|
|
7
|
-
"Dummy"
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def application_title
|
|
11
|
-
"Dummy"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Grants everything (the generated superadmin branch). A test narrows it by
|
|
4
|
-
# setting Ability.restrictions to a block of `cannot` rules, evaluated after
|
|
5
|
-
# the grant so they win; InlineFormsIntegrationTestCase resets it.
|
|
6
|
-
class Ability
|
|
7
|
-
include CanCan::Ability
|
|
8
|
-
|
|
9
|
-
cattr_accessor :restrictions
|
|
10
|
-
|
|
11
|
-
def initialize(_user)
|
|
12
|
-
can :manage, :all
|
|
13
|
-
instance_exec(&restrictions) if restrictions
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Mirrors the host-app contract the installer's application_record.rb template
|
|
4
|
-
# establishes (lib/generators/templates/application_record.rb): paper_trail on
|
|
5
|
-
# every model, will_paginate per_page, inline_forms list/search scopes, and
|
|
6
|
-
# the not_accessible_through_html? default the engine controller consults.
|
|
7
|
-
class ApplicationRecord < ActiveRecord::Base
|
|
8
|
-
self.abstract_class = true
|
|
9
|
-
|
|
10
|
-
include InlineForms::Searchable
|
|
11
|
-
|
|
12
|
-
has_paper_trail on: [ :create, :update, :destroy ]
|
|
13
|
-
|
|
14
|
-
attr_writer :inline_forms_attribute_list
|
|
15
|
-
|
|
16
|
-
self.per_page = 7
|
|
17
|
-
|
|
18
|
-
scope :inline_forms_list, -> { all }
|
|
19
|
-
|
|
20
|
-
def human_attribute_name(*args)
|
|
21
|
-
self.class.human_attribute_name(*args)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def self.not_accessible_through_html?
|
|
25
|
-
false
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Child of Machine that has no top-level HTML surface: it is only shown
|
|
4
|
-
# nested in its machine (like StProject's Dagrapportage inside a Client tab).
|
|
5
|
-
class DailyReport < ApplicationRecord
|
|
6
|
-
belongs_to :machine, optional: true
|
|
7
|
-
|
|
8
|
-
def self.not_accessible_through_html?
|
|
9
|
-
true
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def _presentation
|
|
13
|
-
"#{name}"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def inline_forms_attribute_list
|
|
17
|
-
@inline_forms_attribute_list ||= [
|
|
18
|
-
[ :name, :text_field ]
|
|
19
|
-
]
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Declared file slots (InlineForms::StoredFiles), shaped like StProject's
|
|
4
|
-
# Client: two slots with the default column naming (`filename` -> data /
|
|
5
|
-
# content_type, `plan_filename` -> plan_data / plan_content_type). An
|
|
6
|
-
# ApplicationRecord subclass on purpose: has_paper_trail is inherited, so the
|
|
7
|
-
# slot columns' skip must be set on Document without leaking to Widget.
|
|
8
|
-
# See test/integration/file_slots_test.rb.
|
|
9
|
-
class Document < ApplicationRecord
|
|
10
|
-
include InlineForms::StoredFiles
|
|
11
|
-
|
|
12
|
-
inline_forms_file :filename
|
|
13
|
-
inline_forms_file :plan_filename
|
|
14
|
-
|
|
15
|
-
# StProject's Attachment/Incident/Zorgformulier validate the filename; a
|
|
16
|
-
# test switches this on to prove undo-of-destroy puts files back BEFORE save.
|
|
17
|
-
cattr_accessor :require_filename, default: false
|
|
18
|
-
validates :filename, presence: true, if: -> { self.class.require_filename }
|
|
19
|
-
|
|
20
|
-
validates :title, presence: true
|
|
21
|
-
|
|
22
|
-
def _presentation
|
|
23
|
-
"#{title}"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def inline_forms_attribute_list
|
|
27
|
-
@inline_forms_attribute_list ||= [
|
|
28
|
-
[ :title, :text_field ],
|
|
29
|
-
[ :filename, :simple_file_field ],
|
|
30
|
-
[ :plan_filename, :simple_file_field ]
|
|
31
|
-
]
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Models StProject's Client/Attachment: file bytes stored in a binary column
|
|
4
|
-
# that is excluded from PaperTrail (`skip:`), filename kept versioned. Reverting
|
|
5
|
-
# an unrelated edit must not touch `data`. See
|
|
6
|
-
# test/integration/revert_skipped_columns_test.rb.
|
|
7
|
-
#
|
|
8
|
-
# Not an ApplicationRecord: that already calls has_paper_trail, which PaperTrail
|
|
9
|
-
# allows only once per hierarchy. StProject likewise declares it per model, so
|
|
10
|
-
# this repeats the rest of the ApplicationRecord host contract inline.
|
|
11
|
-
class Dossier < ActiveRecord::Base
|
|
12
|
-
include InlineForms::Searchable
|
|
13
|
-
|
|
14
|
-
has_paper_trail on: [ :create, :update, :destroy ], skip: [ :data ]
|
|
15
|
-
|
|
16
|
-
attr_writer :inline_forms_attribute_list
|
|
17
|
-
|
|
18
|
-
self.per_page = 7
|
|
19
|
-
|
|
20
|
-
scope :inline_forms_list, -> { order(:name, :id) }
|
|
21
|
-
|
|
22
|
-
validates :name, presence: true
|
|
23
|
-
|
|
24
|
-
def self.not_accessible_through_html?
|
|
25
|
-
false
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def _presentation
|
|
29
|
-
"#{name}"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def inline_forms_attribute_list
|
|
33
|
-
@inline_forms_attribute_list ||= [
|
|
34
|
-
[ :name, :text_field ],
|
|
35
|
-
[ :data_filename, :info ]
|
|
36
|
-
]
|
|
37
|
-
end
|
|
38
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Models the `inline_forms_addto` pre-migrate window: the attribute_list has a
|
|
4
|
-
# row (`:pending_note`) whose column does NOT exist on the gizmos table yet, so
|
|
5
|
-
# it exercises InlineForms.attribute_pending_migration? end to end. `:name` and
|
|
6
|
-
# `:created_at` are real columns; `:section` is a header. See
|
|
7
|
-
# test/integration/pending_migration_gate_test.rb.
|
|
8
|
-
class Gizmo < ApplicationRecord
|
|
9
|
-
validates :name, presence: true
|
|
10
|
-
|
|
11
|
-
scope :inline_forms_list, -> { order(:name, :id) }
|
|
12
|
-
|
|
13
|
-
def _presentation
|
|
14
|
-
"#{name}"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def inline_forms_attribute_list
|
|
18
|
-
@inline_forms_attribute_list ||= [
|
|
19
|
-
[ :name, :text_field ],
|
|
20
|
-
[ :section, :header ],
|
|
21
|
-
[ :pending_note, :text_field ],
|
|
22
|
-
[ :created_at, :info ]
|
|
23
|
-
]
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Parent with an :associated (has_many) panel, shaped like the example app's
|
|
4
|
-
# Apartment (photos:has_many photos:associated). Exercises the
|
|
5
|
-
# open-after-create flow (InlineFormsController#render_created_row_open_streams).
|
|
6
|
-
class Machine < ApplicationRecord
|
|
7
|
-
has_many :parts
|
|
8
|
-
has_many :daily_reports
|
|
9
|
-
|
|
10
|
-
validates :name, presence: true
|
|
11
|
-
|
|
12
|
-
scope :inline_forms_list, -> { order(:name, :id) }
|
|
13
|
-
|
|
14
|
-
def _presentation
|
|
15
|
-
"#{name}"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def inline_forms_attribute_list
|
|
19
|
-
@inline_forms_attribute_list ||= [
|
|
20
|
-
[ :name, :text_field ],
|
|
21
|
-
[ :parts, :associated ]
|
|
22
|
-
]
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Child of Machine (see machine.rb); shaped like the example app's Photo.
|
|
4
|
-
class Part < ApplicationRecord
|
|
5
|
-
belongs_to :machine, optional: true
|
|
6
|
-
belongs_to :phase, optional: true
|
|
7
|
-
|
|
8
|
-
def _presentation
|
|
9
|
-
"#{name}"
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def inline_forms_attribute_list
|
|
13
|
-
@inline_forms_attribute_list ||= [
|
|
14
|
-
[ :name, :text_field ]
|
|
15
|
-
]
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Exercises one representative of each form-element family the integration
|
|
4
|
-
# tests cover; shaped exactly like a `rails g inline_forms` model.
|
|
5
|
-
class Widget < ApplicationRecord
|
|
6
|
-
belongs_to :kind, optional: true
|
|
7
|
-
|
|
8
|
-
validates :name, presence: true
|
|
9
|
-
validates :notes, length: { minimum: 10 }, allow_blank: true
|
|
10
|
-
|
|
11
|
-
scope :inline_forms_list, -> { order(:name, :id) }
|
|
12
|
-
inline_forms_search_on :name
|
|
13
|
-
|
|
14
|
-
def _presentation
|
|
15
|
-
"#{name}"
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def inline_forms_attribute_list
|
|
19
|
-
@inline_forms_attribute_list ||= [
|
|
20
|
-
[ :name, :text_field ],
|
|
21
|
-
[ :notes, :plain_text_area ],
|
|
22
|
-
[ :released_on, :date_select ],
|
|
23
|
-
[ :meeting_at, :time_select ],
|
|
24
|
-
[ :start_month, :month_year_picker ],
|
|
25
|
-
[ :priority, :dropdown_with_values, { 1 => "low", 2 => "mid", 3 => "high" } ],
|
|
26
|
-
[ :active, :check_box, { 0 => "no", 1 => "yes" } ],
|
|
27
|
-
[ :kind, :dropdown_with_other ],
|
|
28
|
-
[ :rating, :slider_with_values, { 1 => "one", 2 => "two", 3 => "three", 4 => "four", 5 => "five" } ],
|
|
29
|
-
# simple_file_field's values entry names the host download route method
|
|
30
|
-
# (attribute_values(...)[0][1]); only used when a file is present.
|
|
31
|
-
[ :manual, :simple_file_field, { 0 => "download" } ],
|
|
32
|
-
[ :accent, :color_field ],
|
|
33
|
-
[ :report, :pdf_link ]
|
|
34
|
-
]
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def <=>(other)
|
|
38
|
-
name <=> other.name
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<p id="stats_report">Stats report</p>
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Minimal host app for the engine's integration tests (test/integration/).
|
|
4
|
-
# Boots the inline_forms engine against an in-memory SQLite database with the
|
|
5
|
-
# host-side gems the engine expects (will_paginate, paper_trail, turbo-rails,
|
|
6
|
-
# cancancan) but without Devise, Sprockets or ActionText. CanCanCan is on so
|
|
7
|
-
# load_and_authorize_resource and the attribute-level checks run; the dummy
|
|
8
|
-
# Ability grants everything unless a test narrows it. Tests drive the
|
|
9
|
-
# UI through Turbo-Frame requests (the frame layout never renders the
|
|
10
|
-
# current_user header), and the asset-precompile initializer skips hosts
|
|
11
|
-
# without a pipeline.
|
|
12
|
-
require "rails"
|
|
13
|
-
require "active_record/railtie"
|
|
14
|
-
require "action_controller/railtie"
|
|
15
|
-
require "action_view/railtie"
|
|
16
|
-
|
|
17
|
-
Bundler.require(*Rails.groups)
|
|
18
|
-
|
|
19
|
-
require "inline_forms"
|
|
20
|
-
# Host apps list rails-i18n in their Gemfile (the installer writes it): the
|
|
21
|
-
# Rails strings for nl (time/date formats, ...) the gem's views localize with.
|
|
22
|
-
require "rails-i18n"
|
|
23
|
-
# The schema-GUI engine (separate gem, same repo; on the load path via the
|
|
24
|
-
# Gemfile's test group). Its integration tests live in test/integration/.
|
|
25
|
-
require "inline_forms_schema_edit"
|
|
26
|
-
|
|
27
|
-
module Dummy
|
|
28
|
-
class Application < Rails::Application
|
|
29
|
-
config.load_defaults 8.1
|
|
30
|
-
config.root = File.expand_path("..", __dir__)
|
|
31
|
-
config.eager_load = false
|
|
32
|
-
config.secret_key_base = "inline_forms_dummy_test_secret"
|
|
33
|
-
config.logger = ActiveSupport::Logger.new(File::NULL)
|
|
34
|
-
config.active_support.deprecation = :stderr
|
|
35
|
-
config.action_controller.allow_forgery_protection = false
|
|
36
|
-
# Schema is defined by test/integration_test_helper.rb on the in-memory DB.
|
|
37
|
-
config.active_record.maintain_test_schema = false
|
|
38
|
-
# Raise in-place so integration failures carry the real backtrace.
|
|
39
|
-
config.action_dispatch.show_exceptions = :none
|
|
40
|
-
# A nonce-based CSP like StProject's (report-only): the layouts' inline
|
|
41
|
-
# script must carry the per-request nonce (test/integration/csp_nonce_test.rb).
|
|
42
|
-
config.content_security_policy do |policy|
|
|
43
|
-
policy.script_src :self
|
|
44
|
-
end
|
|
45
|
-
config.content_security_policy_nonce_generator = ->(_request) { SecureRandom.base64(16) }
|
|
46
|
-
config.content_security_policy_nonce_directives = %w[script-src]
|
|
47
|
-
config.content_security_policy_report_only = true
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Mirrors the initializer the installer seeds in host apps; the header
|
|
4
|
-
# (`inline_forms/_header`) iterates MODEL_TABS for admin users. Kept empty so
|
|
5
|
-
# the dummy needs no CanCan (`can?` is only called per entry).
|
|
6
|
-
MODEL_TABS = %w[].freeze
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Mirrors the initializer the installer writes into generated apps
|
|
4
|
-
# (installer_core.rb): PaperTrail serializes object/object_changes as YAML,
|
|
5
|
-
# and Psych safe-loading needs these classes permitted or version.changeset /
|
|
6
|
-
# version.reify silently degrade (empty changeset) or raise.
|
|
7
|
-
permitted = [
|
|
8
|
-
Symbol,
|
|
9
|
-
Date,
|
|
10
|
-
Time,
|
|
11
|
-
BigDecimal,
|
|
12
|
-
ActiveSupport::TimeWithZone,
|
|
13
|
-
ActiveSupport::TimeZone,
|
|
14
|
-
ActiveSupport::HashWithIndifferentAccess
|
|
15
|
-
]
|
|
16
|
-
|
|
17
|
-
%w[
|
|
18
|
-
ActiveRecord::Type::Time::Value
|
|
19
|
-
ActiveRecord::Type::Date::Value
|
|
20
|
-
ActiveRecord::Type::DateTime::Value
|
|
21
|
-
].each do |const_name|
|
|
22
|
-
klass = const_name.safe_constantize
|
|
23
|
-
permitted << klass if klass
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
Rails.application.config.active_record.yaml_column_permitted_classes ||= []
|
|
27
|
-
Rails.application.config.active_record.yaml_column_permitted_classes |= permitted
|
|
28
|
-
ActiveRecord.yaml_column_permitted_classes |= Rails.application.config.active_record.yaml_column_permitted_classes
|