1
0
Fork 0
mirror of https://github.com/chobbledotcom/play-test.git synced 2026-05-13 03:56:26 +01:00
The website for play-test.co.uk - a system for logging play equipment inspections (BS EN 19460) https://play-test.co.uk
  • Ruby 71.8%
  • C# 11.2%
  • JavaScript 5.7%
  • HTML 5.6%
  • CSS 2.7%
  • Other 3%
Find a file
stefan burke 388ee27de3
Introduce AssessmentSchema for form metadata (#502)
* Introduce AssessmentSchema as a typed registry for form metadata

The form YAML for each assessment was previously walked ad-hoc by three
different concerns (FormConfigurable, ValidationConfigurable,
AssessmentCompletion) plus a couple of consumers, each reaching into the
raw Array[Hash] structure with its own logic. AssessmentSchema loads each
config once into immutable Field/Fieldset value objects with typed
accessors (#partial_for, #required?, #numeric?, etc.), and the concerns
delegate to it.

Behaviour and the existing form_fields contract are preserved -
including overrides like InspectorCompany.form_fields(user:) - so
consumers (PDF builder, controllers) continue to work unchanged.

* Remove form_fields shim; migrate all callers to typed schema

Removes FormConfigurable#form_fields and AssessmentSchema#to_form_config.
The Array[Hash] structure was a transitional shim - every consumer now
talks to AssessmentSchema directly via Field/Fieldset value objects.

- AssessmentSchema gains #exclude(*field_names) for permission-driven
  filtering (replaces InspectorCompany's mutate-the-array trick), plus
  Fieldset.from_raw / Fieldset#without to support it.
- ValidationConfigurable calls assessment_schema directly instead of
  going through form_fields with a rescue.
- pdf_generator_service/assessment_block_builder uses
  assessment.class.assessment_schema and asks Field for #composite_fields
  and Schema for #add_not_applicable_fields.
- user_height_assessments_controller uses schema.find_field(field) and
  reads .partial / .attributes off the typed Field.
- InspectorCompany replaces its 12-line mutating form_fields(user:)
  override with a 4-line form_schema(user:) that returns
  assessment_schema.exclude(:notes).

The chobble-forms gem's _fields.html.erb partial calls
model.class.form_fields(user:), so we override it at
app/views/chobble_forms/_fields.html.erb with a schema-based version.
The gem prepends its own view path, so an initializer re-prepends
app/views after Rails initialisation to make the override win.

Form helper methods like form_schema(user:) are now the public API for
view-level field metadata; tests that previously stubbed form_fields
on anonymous classes now stub assessment_schema instead.

* Fix user_height defaulted-zero turbo stream parameter type

apply_user_height_defaults populated @fields_defaulted_to_zero from a
%w[] array of strings, then handed those strings to the chobble_forms
field partials, which expect Symbols. Previously the broken lookup in
find_field_config (Symbol-vs-String comparison) silently returned nil
and the turbo stream was skipped entirely; the new schema lookup
correctly resolves the field, exposing the partial's strict typing.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-04-25 15:57:39 +00:00
.claude Rubocop everything 2025-07-17 17:26:42 +01:00
.github Bump R-J-dev/bunny-deploy from 2.1.1 to 3.0.0 (#463) 2026-03-03 18:22:44 +00:00
.helix Rubocop everything 2025-07-17 17:26:42 +01:00
.licenses/bundler Update annotations and attributions (#479) 2026-04-06 08:04:31 +00:00
app Introduce AssessmentSchema for form metadata (#502) 2026-04-25 15:57:39 +00:00
bin Reduce jscpd duplication threshold from 50 to 45 tokens (#440) 2026-02-10 18:36:06 +00:00
config Introduce AssessmentSchema for form metadata (#502) 2026-04-25 15:57:39 +00:00
db Add Play Zone inspection type with assessment workflow (#497) 2026-03-25 17:54:16 +00:00
gems Use the turbo_response partial in chobble-forms to update the users_at_* fields 2025-08-12 19:54:25 +01:00
hooks Ignore sorbet/rbi/* 2025-08-13 01:23:08 +01:00
lib Add Play Zone inspection type with assessment workflow (#497) 2026-03-25 17:54:16 +00:00
log Loads of refactoring - turning things into factories to reduce duplicate code 2025-06-09 15:15:49 +01:00
public Remove PWA stuff 2025-08-09 23:50:19 +01:00
sorbet More Sorbet fixes 2025-08-19 08:00:41 +00:00
spec Introduce AssessmentSchema for form metadata (#502) 2026-04-25 15:57:39 +00:00
spencers_app Claude/nixos graphical app build l7 hg x (#468) 2026-03-03 18:20:57 +00:00
storage Re-add .keep 2025-10-19 11:13:03 +01:00
test Rubocop everything 2025-10-24 21:59:22 +01:00
tmp Convert trough fields to milimetres and integer fields, not decimals 2025-07-24 15:54:28 +01:00
vendor Loads of refactoring - turning things into factories to reduce duplicate code 2025-06-09 15:15:49 +01:00
.better-html.yml chore(lint): add better-html for enhanced ERB linting and safety checks (#81) 2025-08-04 02:28:16 +00:00
.dockerignore Fix test.rake 2025-08-05 19:25:12 +00:00
.env.example Add catch bed unit type (Chunk 3) (#495) 2026-03-24 21:12:46 +00:00
.erb-lint-tracking Track ERB lint violations requiring manual fixes (#386) 2026-02-18 11:47:22 +00:00
.erb_lint.yml Run erb_lint (#80) 2025-08-04 02:33:04 +00:00
.gitattributes Try and ignore coverage stuff from git 2025-06-15 21:44:39 +01:00
.gitignore Replace site_overrides with TextReplacements 2025-10-22 15:47:08 +01:00
.gitmodules SSH => HTTPS submodule 2025-08-12 15:24:46 +01:00
.licensed.yml Add licensee gem check for AGPLv3 and extensive license data (#148) 2025-08-05 23:47:17 +00:00
.parallel_rspec Loads of refactoring - turning things into factories to reduce duplicate code 2025-06-09 15:15:49 +01:00
.rspec Update safety standards - add negative adjustments to user capacity, take roofs into equation with wall heights 2025-07-03 18:10:23 +01:00
.rspec_status Selectively pick changes 2025-08-08 22:33:53 +01:00
.rubocop.yml Rubocop everything 2025-10-24 21:59:22 +01:00
.ruby-version Loads of refactoring - turning things into factories to reduce duplicate code 2025-06-09 15:15:49 +01:00
.standard.yml Add nice error message and fix homepage search box 2025-08-06 15:17:28 +00:00
.yamllint.yml Run yamlfix over everything 2025-08-16 21:58:26 +01:00
14960.md Unify lots of safety standard stuff and tabbify the interface nicely 2025-06-20 12:40:35 +01:00
attributions.json Update annotations and attributions (#479) 2026-04-06 08:04:31 +00:00
ATTRIBUTIONS.md Update annotations and attributions (#479) 2026-04-06 08:04:31 +00:00
biome.json style: reformat JavaScript files for consistent indentation and spacing (#150) 2025-08-05 23:29:01 +00:00
BOUNCING_PILLOW_FIELDS.md Add unit type enums (defaulting to BOUNCY_CASTLE) 2025-07-21 23:57:49 +01:00
CLAUDE.md Require Sorbet types on new code 2025-08-13 01:10:41 +01:00
code_standard_violations.txt Store code standard violations 2025-10-24 22:07:19 +01:00
config.ru Rubocop everything 2025-10-24 21:59:22 +01:00
Dockerfile Add cmake to Dockerfile 2025-08-06 04:36:07 +01:00
erb_lint_output.txt Fix ERB linting issues (#362) 2025-10-28 14:46:23 +00:00
flake.lock Loads of refactoring - turning things into factories to reduce duplicate code 2025-06-09 15:15:49 +01:00
flake.nix Reduce code duplication detected by jscpd (#416) 2025-11-28 13:54:51 +00:00
Gemfile Bump openssl from 3.3.1 to 3.3.2 (#367) 2025-10-28 14:47:22 +00:00
Gemfile.lock Update bundles (#462) 2026-03-02 18:58:48 +00:00
ID_GENERATION.md Add ID_GENERATION spec 2025-10-12 14:06:45 +01:00
LICENSE Equipment => Units 2025-06-09 19:26:45 +01:00
NEW_UNIT_TYPES.md Add Play Zone inspection type with assessment workflow (#497) 2026-03-25 17:54:16 +00:00
OFFLINE.md Add offline assessments plan and architecture documentation (#451) 2026-02-12 15:36:28 +00:00
Rakefile Loads of refactoring - turning things into factories to reduce duplicate code 2025-06-09 15:15:49 +01:00
README.md Update README to describe Chobble CIC and link to principles (#461) 2026-03-02 18:45:51 +00:00
RPII_TODO_08_08.md Support a developer and an admin NTFY channel 2025-08-12 21:37:54 +01:00
standardrb_output.txt Fix StandardRB linting issues (#363) 2025-10-25 15:25:52 +00:00
terragon-setup.sh Fake a secret in the Terragon setup 2025-08-13 16:58:09 +01:00
TEST-QUALITY-CRITERIA.md Add test quality criteria doc (#444) 2026-02-10 18:57:22 +00:00
TODO.md Update TODO 2025-08-06 17:31:10 +01:00
unfixed_issues.txt Fix ERB linting issues (#362) 2025-10-28 14:46:23 +00:00

play-test - BS EN 14960 inspection-logging tool

A web app for managing safety inspections of inflatable play equipment like bouncy castles and slides. Developed by Chobble CIC, a community interest company in Manchester, UK.

License: AGPL v3 Docker Image codecov

play-test helps inspectors track and document safety checks on inflatable play equipment. It handles equipment records, inspection forms, photo management, and PDF report generation. Makes repeat inspections of the same units quick and straightforward.

A public instance is live at play-test.co.uk.

Sponsor Development

Features

🎪 Equipment Tracking

  • Store unit details, dimensions, and manufacturer info
  • Keep inspection history for each piece of equipment
  • Upload photos with automatic processing
  • Quick access to previous inspection data

📋 Inspection Management

  • Seven assessment types covering different safety aspects
  • Draft inspections you can edit before finalising
  • Generate PDF reports with QR codes
  • Built-in safety calculations (anchor points, user capacity, etc.)

👥 Company Management

  • Company accounts with branding
  • User management and access control
  • Upload your logo for PDF reports
  • Works on phones, tablets, and desktops

🛠️ Technical Features

  • Export any unit or inspection as PDF or JSON
  • Shows safety standards right where you need them
  • Dark/light theme
  • Minimal dependencies
  • Full internationalisation support
  • No JavaScript required for core functionality

Getting Started

Docker

Quickest way to try it out:

docker pull dockerstefn/play-test
docker run -p 3000:3000 dockerstefn/play-test

Development Setup

There's a Nix flake for easy environment setup:

# Clone the repo
git clone https://github.com/yourusername/play-test.git
cd play-test

# With direnv (recommended)
direnv allow

# Or manually with Nix
nix develop

# Standard Rails setup
bundle install
rails db:create db:migrate db:seed
rails server

Traditional Setup

# Requires Ruby 3.0+ and SQLite
bundle install
rails db:setup
rails server

Testing

Currently over 90% test coverage:

# Run all tests with coverage
bin/test

# Check specific file coverage
bin/coverage_check app/models/inspection.rb

# View detailed HTML report
open coverage/index.html

Test Coverage

If you want to help improve Play-Test, a great way would be to write some more rspec and Capybara tests. Check out coverage.play-test.co.uk for an up-to-date test coverage breakdown.

Tech Stack

  • Rails 8.0+ - With minimal gems
  • SQLite - No fancy databases (yet?)
  • RSpec & Capybara - 90%+ test coverage
  • Semantic HTML + MVP.css - Simple CSS
  • Turbo for progressive JS enhancement

About Chobble CIC

play-test is developed by Chobble CIC, a community interest company based in Manchester, UK. As a CIC, Chobble is regulated to operate in the public interest rather than for private shareholders — surplus profits are reinvested in community activities like open source development and reduced rates for charities and community organisations.

Chobble's principles include transparency, fair pricing, client ownership of their tools and data, and ethical boundaries. All source code is shared openly, and there's no vendor lock-in.

Contributing

Pull requests welcome! This is an open source project and we're not affiliated with any industry bodies, so improvements from anyone are appreciated.

AGPLv3 - see LICENSE file. This means you can use, modify, and distribute the code, but you must share any improvements.