Skip to content

Write specs for ApplicationDatatable (#7471) - #7491

Open
1steve78 wants to merge 1 commit into
rubyforgood:mainfrom
1steve78:test/7471-application-datatable-spec
Open

1steve78 wants to merge 1 commit into
rubyforgood:mainfrom
1steve78:test/7471-application-datatable-spec

Conversation

@1steve78

@1steve78 1steve78 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

What github issue is this PR for, if any?

Resolves #7471 (Part of #5563)

What changed, and why?

Replaced the pending stub and # TODO comment in spec/datatables/application_datatable_spec.rb with real specs exercising ApplicationDatatable's public behavior through minimal Class.new(described_class) subclasses backed by CasaOrg:

  • Initialization & serialization: verifies base_relation, params, DEFAULT_PER_PAGE, #as_json, and #to_json (data, recordsFiltered, recordsTotal).
  • HTML sanitization: verifies recursive HTML escaping across scalar, nested hash, and array values in data.
  • Pagination: verifies default DEFAULT_PER_PAGE (10) with offset 0, page/per_page slicing, partial final pages with string start/length params, and empty results past the end while preserving recordsFiltered and recordsTotal.
  • Ordering: verifies ascending/descending sort on ORDERABLE_FIELDS, case-insensitive column/direction matching, non-zero order[:column] lookup, NULLS LAST in both directions, ASC fallback when dir is nil or non-whitelisted, and ignoring nil or unallowlisted column names.
  • Search & filtering: verifies search_term filtering (including pagination within filtered results and blank searches), additional_filters defaulting to {} when omitted, and all three bool_filter branches (["true"], %w[true false], []).

No pending/skip/xit examples remain.

How is this tested? (please write rspec and jest tests!) 💖💪

  • bundle exec rspec spec/datatables/application_datatable_spec.rb — 24 examples, 0 failures
  • bundle exec rspec spec/datatables/ — 70 examples, 0 failures
  • bundle exec standardrb spec/datatables/application_datatable_spec.rb — 0 offenses
  • bundle exec standardrb --except Layout/EndOfLine --format progress — 1007 files inspected, 0 offenses
  • bundle exec rails factory_bot:lint — passed
  • bundle exec rake test_checker — passed
  • npm run lint — passed

Screenshots please :)

N/A (spec-only change; no UI changes).

@github-actions github-actions Bot added 🧪 Tests Tests ruby Touches Ruby code labels Dec 2, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Touches Ruby code 🧪 Tests Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Write real specs for ApplicationDatatable

1 participant