inline_forms_installer 8.1.57 → 8.1.59

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: 8d1734105bfa07ffb1a5a27e0c52fcc41ea5cbd8aac7db548ef6601493c3b492
4
- data.tar.gz: d22858fa2313b583b881fc7f7ec69b224566be4412311f9ec5f458c912b171db
3
+ metadata.gz: 9a8fb98ca32062518006ec1a4f24690cc6e4f8a55c313ca47634e378ee689e0b
4
+ data.tar.gz: 63b4e47b930c8e49f99bef7973f92198508cb51d127d792902d3d63e5559ccce
5
5
  SHA512:
6
- metadata.gz: 759e2f5a92aa54b3fcf125b311a55b80ba00bcc0f3247564510d04753ed091be6f5d15603fa816232dd0d8ff63df1dda501f3f8118edf86de9d7f89276a94473
7
- data.tar.gz: 937571d49fb60a4fc83db7e789bab6a971287e5f1a4e50112f25b7c793a69273c69349c22dced242d1972344b5142b5faa718da1d5731ce0c6b7e711360b3053
6
+ metadata.gz: e57494b801e1a3f13b78be90ba7d76d5346fefe4ac14d01a2bd1b4a4e1cd62b745f7486fd34d5a5df3563b24ec5a389eb1149b4366b08f968754c1476cd28381
7
+ data.tar.gz: bf33012b7318a8f7aceea64dad2c203634295826410f964144b066eba0eab815f605671e84c03c952699934cefe98b524965f0f077e86ed9d1f1d9e2761f94e2
@@ -1095,11 +1095,40 @@ if ENV['install_example'] == 'true'
1095
1095
  end
1096
1096
  OWNERS_CTRL
1097
1097
 
1098
+ # Phase -- a lookup whose dropdown follows its dropdown_order column
1099
+ # (inline_forms 8.1.59, InlineForms::DropdownOrder): '---' first, then the
1100
+ # process phases in process order. Its list (/phases) is alphabetical
1101
+ # (_list_order:name) and the seed creates the rows in yet another order,
1102
+ # so the dropdown order is visibly neither id nor name order.
1103
+ say "- Generating Phase lookup (dropdown ordered by dropdown_order)..."
1104
+ sleep 1
1105
+ run %q{bundle exec rails g inline_forms Phase name:string dropdown_order:integer_field _enabled:yes _list_order:name _presentation:'#{name}'}
1106
+
1107
+ say "- Adding phase_id to apartments + belongs_to :phase..."
1108
+ sleep 1
1109
+ add_phase_ts = Time.now.utc.strftime("%Y%m%d%H%M%S")
1110
+ create_file "db/migrate/#{add_phase_ts}_add_phase_to_apartments.rb", <<-ADD_PHASE.strip_heredoc
1111
+ class AddPhaseToApartments < ActiveRecord::Migration[8.1]
1112
+ def change
1113
+ add_reference :apartments, :phase, null: true, foreign_key: true
1114
+ end
1115
+ end
1116
+ ADD_PHASE
1117
+
1118
+ inject_into_file "app/models/apartment.rb",
1119
+ " belongs_to :phase, optional: true\n",
1120
+ after: "class Apartment < ApplicationRecord\n"
1121
+
1122
+ # The :phase dropdown row goes right below :owner.
1123
+ gsub_file "app/models/apartment.rb",
1124
+ / \[ :owner, :dropdown \], \n/,
1125
+ " [ :owner, :dropdown ], \n [ :phase, :dropdown ], \n"
1126
+
1098
1127
  # Seed the example app with 3 apartments + 3 owners and assign photos
1099
1128
  # from db/seed_images. Runs as a regular migration so `bundle exec rake
1100
1129
  # db:migrate` (and `rails db:setup` on a fresh checkout) populates the
1101
1130
  # demo gallery in one shot. Idempotent via find_or_create_by!.
1102
- say "- Generating seed migration (3 apartments + 3 owners + photo gallery)..."
1131
+ say "- Generating seed migration (3 apartments + 3 owners + 4 phases + photo gallery)..."
1103
1132
  sleep 1
1104
1133
  seed_ts = Time.now.utc.strftime("%Y%m%d%H%M%S")
1105
1134
  create_file "db/migrate/#{seed_ts}_seed_example_apartments_and_owners.rb", <<-SEED_MIGRATION.strip_heredoc
@@ -1147,6 +1176,17 @@ if ENV['install_example'] == 'true'
1147
1176
  apartments: [] },
1148
1177
  ].freeze
1149
1178
 
1179
+ # Phases, created in neither name nor dropdown order: the apartment
1180
+ # dropdown shows ---, helprequest, decision, admittance (dropdown_order);
1181
+ # /phases lists them by name.
1182
+ PHASES = [
1183
+ { name: "decision", dropdown_order: 20 },
1184
+ { name: "admittance", dropdown_order: 30 },
1185
+ { name: "---", dropdown_order: 0 },
1186
+ { name: "helprequest", dropdown_order: 10 },
1187
+ ].freeze
1188
+ APARTMENT_PHASES = { "Apt 1" => "helprequest", "Apt 2" => "decision", "Apt 3" => "---" }.freeze
1189
+
1150
1190
  # Comments seeded on each apartment's first photo (Apartment ->
1151
1191
  # Photo -> Comment: the second nesting level).
1152
1192
  COMMENTS = [
@@ -1160,6 +1200,10 @@ if ENV['install_example'] == 'true'
1160
1200
  Dir.glob(seed_dir.join("*.{png,jpg,jpeg,gif}"), File::FNM_CASEFOLD).sort :
1161
1201
  []
1162
1202
 
1203
+ PHASES.each do |spec|
1204
+ Phase.find_or_create_by!(name: spec[:name]) { |ph| ph.dropdown_order = spec[:dropdown_order] }
1205
+ end
1206
+
1163
1207
  apt_records = {}
1164
1208
  APARTMENTS.each_with_index do |spec, idx|
1165
1209
  apt = Apartment.find_or_create_by!(name: spec[:name]) do |a|
@@ -1193,6 +1237,9 @@ if ENV['install_example'] == 'true'
1193
1237
  end
1194
1238
  end
1195
1239
 
1240
+ phase = Phase.find_by(name: APARTMENT_PHASES[spec[:name]])
1241
+ apt.update!(phase: phase) if phase && apt.phase_id != phase.id
1242
+
1196
1243
  apt_records[spec[:name]] = apt
1197
1244
  end
1198
1245
 
@@ -1223,6 +1270,7 @@ if ENV['install_example'] == 'true'
1223
1270
  apt.photos.destroy_all
1224
1271
  apt.destroy
1225
1272
  end
1273
+ PHASES.each { |spec| Phase.find_by(name: spec[:name])&.destroy }
1226
1274
  end
1227
1275
  end
1228
1276
  SEED_MIGRATION
@@ -1,7 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  module InlineFormsInstaller
4
- VERSION = "8.1.57"
4
+ VERSION = "8.1.59"
5
5
 
6
6
  # Canonical bare Ruby version (must match gemspec `required_ruby_version`).
7
7
  # Written verbatim into generated apps' `.ruby-version` for rbenv/chruby/asdf/
@@ -12,3 +12,19 @@ Rails.application.config.dartsass.builds = {
12
12
  "inline_forms_install/inline_forms_main.scss" => "inline_forms/inline_forms.css",
13
13
  "inline_forms_install/devise_main.scss" => "inline_forms/devise.css"
14
14
  }
15
+
16
+ # SELF-IMPORT GUARD: put the inline_forms gem's stylesheet dir FIRST on the
17
+ # Sass load path. Dartsass::Runner assembles
18
+ # dartsass <build_options> --load-path app/assets/stylesheets
19
+ # --load-path <each config.assets.paths entry> <in:out ...>
20
+ # and Dart Sass takes the first load path that has a match. app/assets/builds
21
+ # is on config.assets.paths BEFORE the gem, and a plain .css file is importable
22
+ # by Sass, so `@use "inline_forms/inline_forms"` (and ".../devise") in the
23
+ # inline_forms_install/*_main.scss entries would resolve to the PREVIOUS OUTPUT
24
+ # app/assets/builds/inline_forms/{inline_forms,devise}.css instead of the gem's
25
+ # .scss: from the second build on, each build re-imports its own stale result
26
+ # and gem stylesheet changes never reach the app. build_options precede the
27
+ # load paths in the command, so this --load-path wins. Single token on
28
+ # purpose: the runner splits every build_options entry on whitespace.
29
+ Rails.application.config.dartsass.build_options <<
30
+ "--load-path=#{InlineForms::Engine.root.join('app/assets/stylesheets')}"
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+ require "dartsass/runner"
5
+ require "sass-embedded"
6
+
7
+ # config/initializers/inline_forms_dartsass_builds.rb puts the gem's
8
+ # stylesheet dir first on the Sass load path. Without it,
9
+ # app/assets/builds (ahead of the gem in config.assets.paths) shadows the
10
+ # gem's .scss: `@use "inline_forms/inline_forms"` in the
11
+ # inline_forms_install/*_main.scss entries re-imports the app's previous
12
+ # compiled CSS, and gem stylesheet changes never reach the app after its
13
+ # first build. test_helper runs dartsass:build, so by now builds/ already held
14
+ # a previous build when this run's one ran.
15
+ class ExampleAppDartsassBuildTest < ActiveSupport::TestCase
16
+ test "the gem stylesheet dir is the first Sass load path" do
17
+ command = Dartsass::Runner.dartsass_compile_command
18
+ first_load_path = command.index { |arg| arg == "--load-path" || arg.start_with?("--load-path=") }
19
+
20
+ assert_equal "--load-path=#{gem_stylesheets}", command[first_load_path]
21
+ end
22
+
23
+ %w[inline_forms devise].each do |entry|
24
+ test "builds/inline_forms/#{entry}.css is compiled from the gem's #{entry}.scss" do
25
+ built = Rails.root.join("app/assets/builds/inline_forms/#{entry}.css")
26
+ assert built.file?, "#{built} missing; dartsass:build did not run"
27
+
28
+ expected = Sass.compile(File.join(gem_stylesheets, "inline_forms", "#{entry}.scss"),
29
+ load_paths: load_paths, style: :compressed,
30
+ logger: Sass::Logger.silent).css
31
+ assert_equal expected.strip, built.read.strip,
32
+ "#{entry}.css differs from a direct compile of the gem's #{entry}.scss " \
33
+ "(re-imported a stale app/assets/builds/inline_forms/#{entry}.css?)"
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def gem_stylesheets
40
+ InlineForms::Engine.root.join("app/assets/stylesheets").to_s
41
+ end
42
+
43
+ # The gem's stylesheets, then the app's asset paths without app/assets/builds.
44
+ def load_paths
45
+ [ gem_stylesheets ] + Rails.application.config.assets.paths.map(&:to_s)
46
+ .reject { |path| path.end_with?("app/assets/builds") }
47
+ end
48
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../example_app/example_integration_test_case"
4
+
5
+ # Phase (inline_forms 8.1.59): a lookup with a dropdown_order column. The
6
+ # apartment's phase dropdown follows dropdown_order ('---' first, then the
7
+ # phases in process order), not id order and not the alphabetical list order
8
+ # of /phases. See InlineForms::DropdownOrder.
9
+ class ExampleAppPhaseDropdownTest < ExampleAppIntegrationTestCase
10
+ PHASES = { "decision" => 20, "admittance" => 30, "---" => 0, "helprequest" => 10 }.freeze
11
+
12
+ setup do
13
+ PHASES.each do |name, position|
14
+ Phase.find_or_create_by!(name: name) { |phase| phase.dropdown_order = position }
15
+ end
16
+ @apartment = Apartment.find_or_create_by!(name: "Phase Apt") { |a| a.title = "Phase Title" }
17
+ end
18
+
19
+ test "the apartment phase dropdown follows dropdown_order" do
20
+ frame = "apartment_#{@apartment.id}_phase"
21
+ get edit_apartment_path(@apartment, attribute: "phase", form_element: "dropdown", update: frame),
22
+ headers: { "Turbo-Frame" => frame }
23
+
24
+ assert_response :success
25
+ options = @response.body.scan(%r{<option(?: [^>]*)?>([^<]*)</option>}).flatten
26
+ assert_equal [ "---", "helprequest", "decision", "admittance" ], options
27
+ end
28
+
29
+ test "choosing a phase in the dropdown saves it" do
30
+ frame = "apartment_#{@apartment.id}_phase"
31
+ decision = Phase.find_by!(name: "decision")
32
+
33
+ put apartment_path(@apartment, attribute: "phase", form_element: "dropdown", update: frame),
34
+ params: { _apartment: { phase_id: decision.id } }, headers: { "Turbo-Frame" => frame }
35
+
36
+ assert_response :success
37
+ assert_equal decision, @apartment.reload.phase
38
+ end
39
+
40
+ test "the phases list stays in its own (alphabetical) list order" do
41
+ get phases_path
42
+
43
+ assert_response :success
44
+ positions = %w[admittance decision helprequest].map { |name| @response.body.index(">#{name}<") }
45
+ assert positions.all?, "every phase is listed"
46
+ assert_equal positions.sort, positions
47
+ end
48
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+ require "sass-embedded"
5
+
6
+ # Sass @import is removed in Dart Sass 3. Since 8.1.58 the gem's entry points
7
+ # load foundation_and_overrides with @use; the only gem @imports left are the
8
+ # three in foundation_and_overrides.scss that wait for the Foundation decision
9
+ # (see the module-system note in inline_forms/inline_forms.scss). Compiles
10
+ # both entry points from the installed gem, with every deprecation reported
11
+ # (verbose), and fails if the gem gains an @import or an entry point compiles
12
+ # with more [import] warnings than 8.1.58 had.
13
+ class ExampleAppSassDeprecationsTest < ActiveSupport::TestCase
14
+ GEM_IMPORTS_LEFT = [
15
+ "foundation_and_overrides.scss 'settings/settings'",
16
+ "foundation_and_overrides.scss 'foundation'",
17
+ "foundation_and_overrides.scss 'theme'"
18
+ ].freeze
19
+ # 8.1.58 with foundation-rails 6.9.0.0: the three above + 114 inside Foundation.
20
+ MAX_IMPORT_WARNINGS = 117
21
+
22
+ %w[inline_forms devise].each do |entry|
23
+ test "#{entry}.scss compiles without new @import deprecations" do
24
+ imports = import_deprecations(entry)
25
+
26
+ gem_imports = imports.select { |span| span.url.start_with?(gem_stylesheets_url) }
27
+ .map { |span| "#{File.basename(span.url)} #{span.text}" }
28
+ assert_empty gem_imports - GEM_IMPORTS_LEFT,
29
+ "#{entry}.scss: new @import in the gem; load it with @use"
30
+ assert_operator imports.size, :<=, MAX_IMPORT_WARNINGS,
31
+ "#{entry}.scss: more [import] deprecations than 8.1.58"
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def gem_stylesheets
38
+ InlineForms::Engine.root.join("app/assets/stylesheets").to_s
39
+ end
40
+
41
+ def gem_stylesheets_url
42
+ "file://#{gem_stylesheets}/"
43
+ end
44
+
45
+ # The gem's stylesheets first, then the app's asset paths without
46
+ # app/assets/builds (its compiled inline_forms/*.css would shadow the .scss).
47
+ def load_paths
48
+ [ gem_stylesheets ] + Rails.application.config.assets.paths.map(&:to_s)
49
+ .reject { |path| path.end_with?("app/assets/builds") }
50
+ end
51
+
52
+ def import_deprecations(entry)
53
+ spans = []
54
+ logger = {
55
+ warn: lambda do |_message, context|
56
+ spans << context.span if context.deprecation && context.deprecation_type == "import"
57
+ end
58
+ }
59
+ Sass.compile(File.join(gem_stylesheets, "inline_forms", "#{entry}.scss"),
60
+ load_paths: load_paths, style: :compressed, verbose: true, logger: logger)
61
+ spans
62
+ end
63
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms_installer
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.57
4
+ version: 8.1.59
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -97,16 +97,19 @@ files:
97
97
  - lib/installer_templates/example_app_tests/test/integration/example_app_apartment_top_level_new_test.rb
98
98
  - lib/installer_templates/example_app_tests/test/integration/example_app_apartment_top_level_pagination_test.rb
99
99
  - lib/installer_templates/example_app_tests/test/integration/example_app_apartment_versions_turbo_test.rb
100
+ - lib/installer_templates/example_app_tests/test/integration/example_app_dartsass_build_test.rb
100
101
  - lib/installer_templates/example_app_tests/test/integration/example_app_devise_passwords_test.rb
101
102
  - lib/installer_templates/example_app_tests/test/integration/example_app_devise_sign_in_test.rb
102
103
  - lib/installer_templates/example_app_tests/test/integration/example_app_guest_access_test.rb
103
104
  - lib/installer_templates/example_app_tests/test/integration/example_app_layout_title_test.rb
104
105
  - lib/installer_templates/example_app_tests/test/integration/example_app_owner_tabs_test.rb
106
+ - lib/installer_templates/example_app_tests/test/integration/example_app_phase_dropdown_test.rb
105
107
  - lib/installer_templates/example_app_tests/test/integration/example_app_photo_comments_test.rb
106
108
  - lib/installer_templates/example_app_tests/test/integration/example_app_photo_revert_test.rb
107
109
  - lib/installer_templates/example_app_tests/test/integration/example_app_photos_test.rb
108
110
  - lib/installer_templates/example_app_tests/test/integration/example_app_production_ssl_test.rb
109
111
  - lib/installer_templates/example_app_tests/test/integration/example_app_routing_test.rb
112
+ - lib/installer_templates/example_app_tests/test/integration/example_app_sass_deprecations_test.rb
110
113
  - lib/installer_templates/example_app_tests/test/integration/example_app_schema_edit_test.rb
111
114
  - lib/installer_templates/example_app_tests/test/integration/example_app_showcase_choice_scale_fields_test.rb
112
115
  - lib/installer_templates/example_app_tests/test/integration/example_app_showcase_date_time_fields_test.rb