inline_forms 8.1.70 → 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 +81 -0
- data/README.rdoc +3 -3
- 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/templates/add_columns_migration.erb +0 -2
- data/lib/generators/inline_forms_addto_generator.rb +40 -121
- 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 +34 -41
- data/lib/generators/templates/migration.erb +0 -2
- data/lib/generators/templates/test.erb +1 -1
- 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 -518
- data/test/inline_forms_generator_test.rb +0 -261
- 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
|
@@ -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
|
data/test/dummy/config/routes.rb
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Mirrors the routes `rails g inline_forms` injects for each resource.
|
|
4
|
-
Rails.application.routes.draw do
|
|
5
|
-
# Devise stand-in: the inline_forms header links destroy_user_session_path.
|
|
6
|
-
delete "logout", to: proc { [ 204, {}, [] ] }, as: :destroy_user_session
|
|
7
|
-
|
|
8
|
-
resources :widgets do
|
|
9
|
-
post "revert", on: :member
|
|
10
|
-
get "list_versions", on: :member
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
resources :machines do
|
|
14
|
-
post "revert", on: :member
|
|
15
|
-
get "list_versions", on: :member
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
resources :parts do
|
|
19
|
-
post "revert", on: :member
|
|
20
|
-
get "list_versions", on: :member
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
resources :daily_reports do
|
|
24
|
-
post "revert", on: :member
|
|
25
|
-
get "list_versions", on: :member
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
resources :gizmos do
|
|
29
|
-
post "revert", on: :member
|
|
30
|
-
get "list_versions", on: :member
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
resources :dossiers do
|
|
34
|
-
post "revert", on: :member
|
|
35
|
-
get "list_versions", on: :member
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
resources :documents do
|
|
39
|
-
post "revert", on: :member
|
|
40
|
-
get "list_versions", on: :member
|
|
41
|
-
InlineForms.file_routes(self)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
InlineForms.draw_file_trash_routes(self)
|
|
45
|
-
|
|
46
|
-
get "stats", to: "stats#show"
|
|
47
|
-
|
|
48
|
-
# Schema-change GUI (opt-in in real installs; routed here for the engine's
|
|
49
|
-
# fast test suite). One line, so gem upgrades can add routes freely.
|
|
50
|
-
InlineFormsSchemaEdit.draw_routes(self)
|
|
51
|
-
end
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "test_helper"
|
|
4
|
-
|
|
5
|
-
# Documents the contract between *_show helpers, +__callee__+, and
|
|
6
|
-
# +params[:form_element]+ (used by InlineFormsController#update as +"#{form_element}_update"+).
|
|
7
|
-
class FormElementFromCalleeTest < Minitest::Test
|
|
8
|
-
def test_symbol_callee_typical_show_method_maps_to_controller_suffix
|
|
9
|
-
got = InlineForms.form_element_string_from_callee(:text_field_show)
|
|
10
|
-
assert_equal(
|
|
11
|
-
"text_field",
|
|
12
|
-
got,
|
|
13
|
-
":text_field_show must become the string \"text_field\" so the edit URL's " \
|
|
14
|
-
"form_element matches text_field_update / text_field_edit."
|
|
15
|
-
)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def test_string_callee_same_as_symbol
|
|
19
|
-
got = InlineForms.form_element_string_from_callee("dropdown_with_values_show")
|
|
20
|
-
assert_equal(
|
|
21
|
-
"dropdown_with_values",
|
|
22
|
-
got,
|
|
23
|
-
"String callee from backtrace-style names must match Symbol behavior."
|
|
24
|
-
)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def test_block_in_prefix_from_nested_call_still_maps_correctly
|
|
28
|
-
got = InlineForms.form_element_string_from_callee("block in text_field_show")
|
|
29
|
-
assert_equal(
|
|
30
|
-
"text_field",
|
|
31
|
-
got,
|
|
32
|
-
"When *_show runs inside a block, Ruby may prefix the callee label with " \
|
|
33
|
-
"\"block in \"; that prefix must be stripped before removing _show."
|
|
34
|
-
)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def test_only_one_trailing_show_suffix_removed
|
|
38
|
-
got = InlineForms.form_element_string_from_callee(:foo_show)
|
|
39
|
-
assert_equal(
|
|
40
|
-
"foo",
|
|
41
|
-
got,
|
|
42
|
-
"delete_suffix('_show') must remove only the trailing _show once " \
|
|
43
|
-
"(not leave \"foo\" with a spurious strip)."
|
|
44
|
-
)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def test_multi_word_element_name_underscores_preserved
|
|
48
|
-
got = InlineForms.form_element_string_from_callee(:dropdown_with_values_show)
|
|
49
|
-
assert_equal(
|
|
50
|
-
"dropdown_with_values",
|
|
51
|
-
got,
|
|
52
|
-
"Form element names with underscores must survive unchanged except for _show."
|
|
53
|
-
)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def test_callee_without_show_suffix_is_unchanged_modulo_block_prefix
|
|
57
|
-
got = InlineForms.form_element_string_from_callee(:already_plain)
|
|
58
|
-
assert_equal(
|
|
59
|
-
"already_plain",
|
|
60
|
-
got,
|
|
61
|
-
"If someone passes a callee without _show, output is unchanged (minus block prefix)."
|
|
62
|
-
)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def test_nil_callee_yields_empty_string
|
|
66
|
-
got = InlineForms.form_element_string_from_callee(nil)
|
|
67
|
-
assert_equal(
|
|
68
|
-
"",
|
|
69
|
-
got,
|
|
70
|
-
"nil.to_s is empty; callers must pass __callee__ from a *_show method."
|
|
71
|
-
)
|
|
72
|
-
end
|
|
73
|
-
end
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
|
|
4
|
-
|
|
5
|
-
require "minitest/autorun"
|
|
6
|
-
require "tmpdir"
|
|
7
|
-
require "zlib"
|
|
8
|
-
require "inline_forms/gem_files"
|
|
9
|
-
|
|
10
|
-
# 8.1.53 shipped every file as 0660 (the checkout's group-only modes), so an
|
|
11
|
-
# installed gem was unreadable for anyone outside the installing user and
|
|
12
|
-
# group. Gem builds now package 0644 / 0755 whatever the on-disk modes.
|
|
13
|
-
class GemPackageModesTest < Minitest::Test
|
|
14
|
-
REPO_ROOT = File.expand_path("..", __dir__)
|
|
15
|
-
|
|
16
|
-
def packaged_modes(gem_path)
|
|
17
|
-
modes = {}
|
|
18
|
-
File.open(gem_path, "rb") do |io|
|
|
19
|
-
Gem::Package::TarReader.new(io).each do |entry|
|
|
20
|
-
next unless entry.full_name == "data.tar.gz"
|
|
21
|
-
|
|
22
|
-
Gem::Package::TarReader.new(Zlib::GzipReader.new(entry)).each do |file|
|
|
23
|
-
modes[file.full_name] = file.header.mode & 0o777
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
modes
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def build(spec, dir, gem_dir)
|
|
31
|
-
gem_path = File.join(gem_dir, "#{spec.full_name}.gem")
|
|
32
|
-
Dir.chdir(dir) do
|
|
33
|
-
package = Gem::Package.new(gem_path)
|
|
34
|
-
package.spec = spec
|
|
35
|
-
Gem::DefaultUserInteraction.use_ui(Gem::SilentUI.new) { package.build(true) }
|
|
36
|
-
end
|
|
37
|
-
gem_path
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def test_packaged_mode_keeps_only_the_owner_execute_bit
|
|
41
|
-
assert_equal 0o644, InlineFormsGemFiles.packaged_mode(0o100660)
|
|
42
|
-
assert_equal 0o644, InlineFormsGemFiles.packaged_mode(0o100600)
|
|
43
|
-
assert_equal 0o755, InlineFormsGemFiles.packaged_mode(0o100770)
|
|
44
|
-
assert_equal 0o755, InlineFormsGemFiles.packaged_mode(0o100700)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def test_group_only_files_are_packaged_world_readable
|
|
48
|
-
Dir.mktmpdir do |src|
|
|
49
|
-
Dir.mktmpdir do |out|
|
|
50
|
-
File.write(File.join(src, "plain.rb"), "# plain\n")
|
|
51
|
-
File.write(File.join(src, "tool"), "#!/bin/sh\n")
|
|
52
|
-
File.chmod(0o660, File.join(src, "plain.rb"))
|
|
53
|
-
File.chmod(0o700, File.join(src, "tool"))
|
|
54
|
-
|
|
55
|
-
spec = Gem::Specification.new do |s|
|
|
56
|
-
s.name = "modes_probe"
|
|
57
|
-
s.version = "0.0.1"
|
|
58
|
-
s.summary = "probe"
|
|
59
|
-
s.authors = [ "probe" ]
|
|
60
|
-
s.files = %w[plain.rb tool]
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
modes = packaged_modes(build(spec, src, out))
|
|
64
|
-
|
|
65
|
-
assert_equal({ "plain.rb" => 0o644, "tool" => 0o755 }, modes)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def test_every_gemspec_in_the_repo_packages_world_readable_files
|
|
71
|
-
%w[inline_forms.gemspec inline_forms_installer.gemspec
|
|
72
|
-
inline_forms_schema_edit/inline_forms_schema_edit.gemspec].each do |gemspec|
|
|
73
|
-
path = File.join(REPO_ROOT, gemspec)
|
|
74
|
-
spec = Gem::Specification.load(path)
|
|
75
|
-
refute_nil spec, gemspec
|
|
76
|
-
|
|
77
|
-
Dir.mktmpdir do |out|
|
|
78
|
-
modes = packaged_modes(build(spec, File.dirname(path), out))
|
|
79
|
-
|
|
80
|
-
refute_empty modes, gemspec
|
|
81
|
-
unreadable = modes.reject { |_, mode| (mode & 0o444) == 0o444 }
|
|
82
|
-
assert_empty unreadable, "#{gemspec}: not world-readable in the .gem"
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "test_helper"
|
|
4
|
-
require "logger"
|
|
5
|
-
require "active_model"
|
|
6
|
-
require "action_dispatch"
|
|
7
|
-
|
|
8
|
-
# Record double with the same +model_name+ routing key as +resources :articles+
|
|
9
|
-
# (a class nested under Minitest::Test would get +inline_edit_…_article+, not +article+).
|
|
10
|
-
class InlineFormsArticlesRouteDouble
|
|
11
|
-
include ActiveModel::Model
|
|
12
|
-
include ActiveModel::Conversion
|
|
13
|
-
|
|
14
|
-
attr_accessor :id
|
|
15
|
-
|
|
16
|
-
def self.model_name
|
|
17
|
-
ActiveModel::Name.new(self, nil, "Article")
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def initialize(id = 1)
|
|
21
|
-
@id = id
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def persisted?
|
|
25
|
-
true
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def to_param
|
|
29
|
-
id.to_s
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# Class-only double for +polymorphic_path(Model)+ (collection +articles+).
|
|
34
|
-
class InlineFormsArticleClassRouteDouble
|
|
35
|
-
def self.model_name
|
|
36
|
-
ActiveModel::Name.new(self, nil, "Article")
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
# Parity between polymorphic URL helpers and named +edit_article_path+,
|
|
41
|
-
# +article_path+, and +articles_path+ for a standard +resources :articles+
|
|
42
|
-
# route (no full Rails app boot).
|
|
43
|
-
class InlineEditPolymorphicPathTest < Minitest::Test
|
|
44
|
-
def setup
|
|
45
|
-
@routes = ActionDispatch::Routing::RouteSet.new
|
|
46
|
-
@routes.draw { resources :articles }
|
|
47
|
-
routes = @routes
|
|
48
|
-
holder_class = Class.new do
|
|
49
|
-
include routes.url_helpers
|
|
50
|
-
end
|
|
51
|
-
holder_class.default_url_options = { only_path: true }
|
|
52
|
-
@holder = holder_class.new
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def test_edit_polymorphic_path_matches_named_edit_helper
|
|
56
|
-
article = InlineFormsArticlesRouteDouble.new(42)
|
|
57
|
-
options = {
|
|
58
|
-
attribute: "title",
|
|
59
|
-
form_element: "text_field",
|
|
60
|
-
update: "field_article_42_title"
|
|
61
|
-
}
|
|
62
|
-
poly = @holder.edit_polymorphic_path(article, **options)
|
|
63
|
-
named = @holder.edit_article_path(article, **options)
|
|
64
|
-
assert_equal named, poly
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def test_member_polymorphic_path_matches_article_path
|
|
68
|
-
article = InlineFormsArticlesRouteDouble.new(7)
|
|
69
|
-
options = { update: "span", close: true }
|
|
70
|
-
poly = @holder.polymorphic_path(article, **options)
|
|
71
|
-
named = @holder.article_path(article, **options)
|
|
72
|
-
assert_equal named, poly
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def test_collection_polymorphic_path_matches_articles_path
|
|
76
|
-
options = { update: "list", parent_class: "Parent", parent_id: "3" }
|
|
77
|
-
poly = @holder.polymorphic_path(InlineFormsArticleClassRouteDouble, **options)
|
|
78
|
-
named = @holder.articles_path(**options)
|
|
79
|
-
assert_equal named, poly
|
|
80
|
-
end
|
|
81
|
-
end
|