From 7356dc31dc14c3a23620a6c5db2117608ec38f7a Mon Sep 17 00:00:00 2001 From: Krunal Date: Sun, 14 Sep 2025 10:02:21 -0400 Subject: [PATCH] Adding all the experimentaion code for actiontext, I tried but the notes field still looks frozen but we are close --- Gemfile | 1 + Gemfile.lock | 1 + app/assets/stylesheets/actiontext.css | 440 +++++++++++++ app/models/workshop.rb | 1 + app/views/active_storage/blobs/_blob.html.erb | 14 + .../action_text/contents/_content.html.erb | 3 + app/views/workshops/_form.html.erb | 2 +- bin/yarn | 17 + config/initializers/assets.rb | 2 +- ...te_active_storage_tables.active_storage.rb | 57 ++ ...6_create_action_text_tables.action_text.rb | 26 + db/schema.rb | 607 ++++++++++-------- docker-compose.yml | 1 + spec/rails_helper.rb | 59 +- spec/spec_helper.rb | 49 +- 15 files changed, 925 insertions(+), 355 deletions(-) create mode 100644 app/assets/stylesheets/actiontext.css create mode 100644 app/views/active_storage/blobs/_blob.html.erb create mode 100644 app/views/layouts/action_text/contents/_content.html.erb create mode 100755 bin/yarn create mode 100644 db/migrate/20250913203205_create_active_storage_tables.active_storage.rb create mode 100644 db/migrate/20250913203206_create_action_text_tables.action_text.rb diff --git a/Gemfile b/Gemfile index 1233e6f59..4b8afbdb9 100644 --- a/Gemfile +++ b/Gemfile @@ -47,6 +47,7 @@ gem "bcrypt", '3.1.16' gem "json", ">= 2.6", "< 3" # or simply: gem "json", "~> 2.7" gem 'simple_form' gem 'country_select' +gem 'actiontext' group :development, :test do gem 'better_errors' diff --git a/Gemfile.lock b/Gemfile.lock index e95ecdc2d..b6bf1589c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -460,6 +460,7 @@ PLATFORMS ruby DEPENDENCIES + actiontext apipie-rails (~> 1.5.0) aws-sdk-s3 bcrypt (= 3.1.16) diff --git a/app/assets/stylesheets/actiontext.css b/app/assets/stylesheets/actiontext.css new file mode 100644 index 000000000..9b6bcb064 --- /dev/null +++ b/app/assets/stylesheets/actiontext.css @@ -0,0 +1,440 @@ +/* + * Default Trix editor styles. See Action Text overwrites below. +*/ + +trix-editor { + border: 1px solid #bbb; + border-radius: 3px; + margin: 0; + padding: 0.4em 0.6em; + min-height: 5em; + outline: none; } + +trix-toolbar * { + box-sizing: border-box; } + +trix-toolbar .trix-button-row { + display: flex; + flex-wrap: nowrap; + justify-content: space-between; + overflow-x: auto; } + +trix-toolbar .trix-button-group { + display: flex; + margin-bottom: 10px; + border: 1px solid #bbb; + border-top-color: #ccc; + border-bottom-color: #888; + border-radius: 3px; } + trix-toolbar .trix-button-group:not(:first-child) { + margin-left: 1.5vw; } + @media (max-width: 768px) { + trix-toolbar .trix-button-group:not(:first-child) { + margin-left: 0; } } + +trix-toolbar .trix-button-group-spacer { + flex-grow: 1; } + @media (max-width: 768px) { + trix-toolbar .trix-button-group-spacer { + display: none; } } + +trix-toolbar .trix-button { + position: relative; + float: left; + color: rgba(0, 0, 0, 0.6); + font-size: 0.75em; + font-weight: 600; + white-space: nowrap; + padding: 0 0.5em; + margin: 0; + outline: none; + border: none; + border-bottom: 1px solid #ddd; + border-radius: 0; + background: transparent; } + trix-toolbar .trix-button:not(:first-child) { + border-left: 1px solid #ccc; } + trix-toolbar .trix-button.trix-active { + background: #cbeefa; + color: black; } + trix-toolbar .trix-button:not(:disabled) { + cursor: pointer; } + trix-toolbar .trix-button:disabled { + color: rgba(0, 0, 0, 0.125); } + @media (max-width: 768px) { + trix-toolbar .trix-button { + letter-spacing: -0.01em; + padding: 0 0.3em; } } + +trix-toolbar .trix-button--icon { + font-size: inherit; + width: 2.6em; + height: 1.6em; + max-width: calc(0.8em + 4vw); + text-indent: -9999px; } + @media (max-width: 768px) { + trix-toolbar .trix-button--icon { + height: 2em; + max-width: calc(0.8em + 3.5vw); } } + trix-toolbar .trix-button--icon::before { + display: inline-block; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + opacity: 0.6; + content: ""; + background-position: center; + background-repeat: no-repeat; + background-size: contain; } + @media (max-width: 768px) { + trix-toolbar .trix-button--icon::before { + right: 6%; + left: 6%; } } + trix-toolbar .trix-button--icon.trix-active::before { + opacity: 1; } + trix-toolbar .trix-button--icon:disabled::before { + opacity: 0.125; } + +trix-toolbar .trix-button--icon-attach::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M10.5%2018V7.5c0-2.25%203-2.25%203%200V18c0%204.125-6%204.125-6%200V7.5c0-6.375%209-6.375%209%200V18%22%20stroke%3D%22%23000%22%20stroke-width%3D%222%22%20stroke-miterlimit%3D%2210%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E"); + top: 8%; + bottom: 4%; } + +trix-toolbar .trix-button--icon-bold::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M6.522%2019.242a.5.5%200%200%201-.5-.5V5.35a.5.5%200%200%201%20.5-.5h5.783c1.347%200%202.46.345%203.24.982.783.64%201.216%201.562%201.216%202.683%200%201.13-.587%202.129-1.476%202.71a.35.35%200%200%200%20.049.613c1.259.56%202.101%201.742%202.101%203.22%200%201.282-.483%202.334-1.363%203.063-.876.726-2.132%201.12-3.66%201.12h-5.89ZM9.27%207.347v3.362h1.97c.766%200%201.347-.17%201.733-.464.38-.291.587-.716.587-1.27%200-.53-.183-.928-.513-1.198-.334-.273-.838-.43-1.505-.43H9.27Zm0%205.606v3.791h2.389c.832%200%201.448-.177%201.853-.497.399-.315.614-.786.614-1.423%200-.62-.22-1.077-.63-1.385-.418-.313-1.053-.486-1.905-.486H9.27Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-italic::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M9%205h6.5v2h-2.23l-2.31%2010H13v2H6v-2h2.461l2.306-10H9V5Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-link::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M18.948%205.258a4.337%204.337%200%200%200-6.108%200L11.217%206.87a.993.993%200%200%200%200%201.41c.392.39%201.027.39%201.418%200l1.623-1.613a2.323%202.323%200%200%201%203.271%200%202.29%202.29%200%200%201%200%203.251l-2.393%202.38a3.021%203.021%200%200%201-4.255%200l-.05-.049a1.007%201.007%200%200%200-1.418%200%20.993.993%200%200%200%200%201.41l.05.049a5.036%205.036%200%200%200%207.091%200l2.394-2.38a4.275%204.275%200%200%200%200-6.072Zm-13.683%2013.6a4.337%204.337%200%200%200%206.108%200l1.262-1.255a.993.993%200%200%200%200-1.41%201.007%201.007%200%200%200-1.418%200L9.954%2017.45a2.323%202.323%200%200%201-3.27%200%202.29%202.29%200%200%201%200-3.251l2.344-2.331a2.579%202.579%200%200%201%203.631%200c.392.39%201.027.39%201.419%200a.993.993%200%200%200%200-1.41%204.593%204.593%200%200%200-6.468%200l-2.345%202.33a4.275%204.275%200%200%200%200%206.072Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-strike::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M6%2014.986c.088%202.647%202.246%204.258%205.635%204.258%203.496%200%205.713-1.728%205.713-4.463%200-.275-.02-.536-.062-.781h-3.461c.398.293.573.654.573%201.123%200%201.035-1.074%201.787-2.646%201.787-1.563%200-2.773-.762-2.91-1.924H6ZM6.432%2010h3.763c-.632-.314-.914-.715-.914-1.273%200-1.045.977-1.739%202.432-1.739%201.475%200%202.52.723%202.617%201.914h2.764c-.05-2.548-2.11-4.238-5.39-4.238-3.145%200-5.392%201.719-5.392%204.316%200%20.363.04.703.12%201.02ZM4%2011a1%201%200%201%200%200%202h15a1%201%200%201%200%200-2H4Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-quote::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M4.581%208.471c.44-.5%201.056-.834%201.758-.995C8.074%207.17%209.201%207.822%2010%208.752c1.354%201.578%201.33%203.555.394%205.277-.941%201.731-2.788%203.163-4.988%203.56a.622.622%200%200%201-.653-.317c-.113-.205-.121-.49.16-.764.294-.286.567-.566.791-.835.222-.266.413-.54.524-.815.113-.28.156-.597.026-.908-.128-.303-.39-.524-.72-.69a3.02%203.02%200%200%201-1.674-2.7c0-.905.283-1.59.72-2.088Zm9.419%200c.44-.5%201.055-.834%201.758-.995%201.734-.306%202.862.346%203.66%201.276%201.355%201.578%201.33%203.555.395%205.277-.941%201.731-2.789%203.163-4.988%203.56a.622.622%200%200%201-.653-.317c-.113-.205-.122-.49.16-.764.294-.286.567-.566.791-.835.222-.266.412-.54.523-.815.114-.28.157-.597.026-.908-.127-.303-.39-.524-.72-.69a3.02%203.02%200%200%201-1.672-2.701c0-.905.283-1.59.72-2.088Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-heading-1::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M21.5%207.5v-3h-12v3H14v13h3v-13h4.5ZM9%2013.5h3.5v-3h-10v3H6v7h3v-7Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-code::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M3.293%2011.293a1%201%200%200%200%200%201.414l4%204a1%201%200%201%200%201.414-1.414L5.414%2012l3.293-3.293a1%201%200%200%200-1.414-1.414l-4%204Zm13.414%205.414%204-4a1%201%200%200%200%200-1.414l-4-4a1%201%200%201%200-1.414%201.414L18.586%2012l-3.293%203.293a1%201%200%200%200%201.414%201.414Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-bullet-list::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M5%207.5a1.5%201.5%200%201%200%200-3%201.5%201.5%200%200%200%200%203ZM8%206a1%201%200%200%201%201-1h11a1%201%200%201%201%200%202H9a1%201%200%200%201-1-1Zm1%205a1%201%200%201%200%200%202h11a1%201%200%201%200%200-2H9Zm0%206a1%201%200%201%200%200%202h11a1%201%200%201%200%200-2H9Zm-2.5-5a1.5%201.5%200%201%201-3%200%201.5%201.5%200%200%201%203%200ZM5%2019.5a1.5%201.5%200%201%200%200-3%201.5%201.5%200%200%200%200%203Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-number-list::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M3%204h2v4H4V5H3V4Zm5%202a1%201%200%200%201%201-1h11a1%201%200%201%201%200%202H9a1%201%200%200%201-1-1Zm1%205a1%201%200%201%200%200%202h11a1%201%200%201%200%200-2H9Zm0%206a1%201%200%201%200%200%202h11a1%201%200%201%200%200-2H9Zm-3.5-7H6v1l-1.5%202H6v1H3v-1l1.667-2H3v-1h2.5ZM3%2017v-1h3v4H3v-1h2v-.5H4v-1h1V17H3Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-undo::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M3%2014a1%201%200%200%200%201%201h6a1%201%200%201%200%200-2H6.257c2.247-2.764%205.151-3.668%207.579-3.264%202.589.432%204.739%202.356%205.174%205.405a1%201%200%200%200%201.98-.283c-.564-3.95-3.415-6.526-6.825-7.095C11.084%207.25%207.63%208.377%205%2011.39V8a1%201%200%200%200-2%200v6Zm2-1Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-redo::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M21%2014a1%201%200%200%201-1%201h-6a1%201%200%201%201%200-2h3.743c-2.247-2.764-5.151-3.668-7.579-3.264-2.589.432-4.739%202.356-5.174%205.405a1%201%200%200%201-1.98-.283c.564-3.95%203.415-6.526%206.826-7.095%203.08-.513%206.534.614%209.164%203.626V8a1%201%200%201%201%202%200v6Zm-2-1Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-decrease-nesting-level::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M5%206a1%201%200%200%201%201-1h12a1%201%200%201%201%200%202H6a1%201%200%200%201-1-1Zm4%205a1%201%200%201%200%200%202h9a1%201%200%201%200%200-2H9Zm-3%206a1%201%200%201%200%200%202h12a1%201%200%201%200%200-2H6Zm-3.707-5.707a1%201%200%200%200%200%201.414l2%202a1%201%200%201%200%201.414-1.414L4.414%2012l1.293-1.293a1%201%200%200%200-1.414-1.414l-2%202Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-button--icon-increase-nesting-level::before { + background-image: url("data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2224%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M5%206a1%201%200%200%201%201-1h12a1%201%200%201%201%200%202H6a1%201%200%200%201-1-1Zm4%205a1%201%200%201%200%200%202h9a1%201%200%201%200%200-2H9Zm-3%206a1%201%200%201%200%200%202h12a1%201%200%201%200%200-2H6Zm-2.293-2.293%202-2a1%201%200%200%200%200-1.414l-2-2a1%201%200%201%200-1.414%201.414L3.586%2012l-1.293%201.293a1%201%200%201%200%201.414%201.414Z%22%20fill%3D%22%23000%22%2F%3E%3C%2Fsvg%3E"); } + +trix-toolbar .trix-dialogs { + position: relative; } + +trix-toolbar .trix-dialog { + position: absolute; + top: 0; + left: 0; + right: 0; + font-size: 0.75em; + padding: 15px 10px; + background: #fff; + box-shadow: 0 0.3em 1em #ccc; + border-top: 2px solid #888; + border-radius: 5px; + z-index: 5; } + +trix-toolbar .trix-input--dialog { + font-size: inherit; + font-weight: normal; + padding: 0.5em 0.8em; + margin: 0 10px 0 0; + border-radius: 3px; + border: 1px solid #bbb; + background-color: #fff; + box-shadow: none; + outline: none; + -webkit-appearance: none; + -moz-appearance: none; } + trix-toolbar .trix-input--dialog.validate:invalid { + box-shadow: #F00 0px 0px 1.5px 1px; } + +trix-toolbar .trix-button--dialog { + font-size: inherit; + padding: 0.5em; + border-bottom: none; } + +trix-toolbar .trix-dialog--link { + max-width: 600px; } + +trix-toolbar .trix-dialog__link-fields { + display: flex; + align-items: baseline; } + trix-toolbar .trix-dialog__link-fields .trix-input { + flex: 1; } + trix-toolbar .trix-dialog__link-fields .trix-button-group { + flex: 0 0 content; + margin: 0; } + +trix-editor [data-trix-mutable]:not(.attachment__caption-editor) { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } + +trix-editor [data-trix-mutable]::-moz-selection, +trix-editor [data-trix-cursor-target]::-moz-selection, trix-editor [data-trix-mutable] ::-moz-selection { + background: none; } + +trix-editor [data-trix-mutable]::selection, +trix-editor [data-trix-cursor-target]::selection, trix-editor [data-trix-mutable] ::selection { + background: none; } + +trix-editor .attachment__caption-editor:focus[data-trix-mutable]::-moz-selection { + background: highlight; } + +trix-editor .attachment__caption-editor:focus[data-trix-mutable]::selection { + background: highlight; } + +trix-editor [data-trix-mutable].attachment.attachment--file { + box-shadow: 0 0 0 2px highlight; + border-color: transparent; } + +trix-editor [data-trix-mutable].attachment img { + box-shadow: 0 0 0 2px highlight; } + +trix-editor .attachment { + position: relative; } + trix-editor .attachment:hover { + cursor: default; } + +trix-editor .attachment--preview .attachment__caption:hover { + cursor: text; } + +trix-editor .attachment__progress { + position: absolute; + z-index: 1; + height: 20px; + top: calc(50% - 10px); + left: 5%; + width: 90%; + opacity: 0.9; + transition: opacity 200ms ease-in; } + trix-editor .attachment__progress[value="100"] { + opacity: 0; } + +trix-editor .attachment__caption-editor { + display: inline-block; + width: 100%; + margin: 0; + padding: 0; + font-size: inherit; + font-family: inherit; + line-height: inherit; + color: inherit; + text-align: center; + vertical-align: top; + border: none; + outline: none; + -webkit-appearance: none; + -moz-appearance: none; } + +trix-editor .attachment__toolbar { + position: absolute; + z-index: 1; + top: -0.9em; + left: 0; + width: 100%; + text-align: center; } + +trix-editor .trix-button-group { + display: inline-flex; } + +trix-editor .trix-button { + position: relative; + float: left; + color: #666; + white-space: nowrap; + font-size: 80%; + padding: 0 0.8em; + margin: 0; + outline: none; + border: none; + border-radius: 0; + background: transparent; } + trix-editor .trix-button:not(:first-child) { + border-left: 1px solid #ccc; } + trix-editor .trix-button.trix-active { + background: #cbeefa; } + trix-editor .trix-button:not(:disabled) { + cursor: pointer; } + +trix-editor .trix-button--remove { + text-indent: -9999px; + display: inline-block; + padding: 0; + outline: none; + width: 1.8em; + height: 1.8em; + line-height: 1.8em; + border-radius: 50%; + background-color: #fff; + border: 2px solid highlight; + box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.25); } + trix-editor .trix-button--remove::before { + display: inline-block; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + opacity: 0.7; + content: ""; + background-image: url("data:image/svg+xml,%3Csvg%20height%3D%2224%22%20width%3D%2224%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M19%206.41%2017.59%205%2012%2010.59%206.41%205%205%206.41%2010.59%2012%205%2017.59%206.41%2019%2012%2013.41%2017.59%2019%2019%2017.59%2013.41%2012z%22%2F%3E%3Cpath%20d%3D%22M0%200h24v24H0z%22%20fill%3D%22none%22%2F%3E%3C%2Fsvg%3E"); + background-position: center; + background-repeat: no-repeat; + background-size: 90%; } + trix-editor .trix-button--remove:hover { + border-color: #333; } + trix-editor .trix-button--remove:hover::before { + opacity: 1; } + +trix-editor .attachment__metadata-container { + position: relative; } + +trix-editor .attachment__metadata { + position: absolute; + left: 50%; + top: 2em; + transform: translate(-50%, 0); + max-width: 90%; + padding: 0.1em 0.6em; + font-size: 0.8em; + color: #fff; + background-color: rgba(0, 0, 0, 0.7); + border-radius: 3px; } + trix-editor .attachment__metadata .attachment__name { + display: inline-block; + max-width: 100%; + vertical-align: bottom; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } + trix-editor .attachment__metadata .attachment__size { + margin-left: 0.2em; + white-space: nowrap; } + +.trix-content { + line-height: 1.5; + overflow-wrap: break-word; + word-break: break-word; } + .trix-content * { + box-sizing: border-box; + margin: 0; + padding: 0; } + .trix-content h1 { + font-size: 1.2em; + line-height: 1.2; } + .trix-content blockquote { + border: 0 solid #ccc; + border-left-width: 0.3em; + margin-left: 0.3em; + padding-left: 0.6em; } + .trix-content [dir=rtl] blockquote, + .trix-content blockquote[dir=rtl] { + border-width: 0; + border-right-width: 0.3em; + margin-right: 0.3em; + padding-right: 0.6em; } + .trix-content li { + margin-left: 1em; } + .trix-content [dir=rtl] li { + margin-right: 1em; } + .trix-content pre { + display: inline-block; + width: 100%; + vertical-align: top; + font-family: monospace; + font-size: 0.9em; + padding: 0.5em; + white-space: pre; + background-color: #eee; + overflow-x: auto; } + .trix-content img { + max-width: 100%; + height: auto; } + .trix-content .attachment { + display: inline-block; + position: relative; + max-width: 100%; } + .trix-content .attachment a { + color: inherit; + text-decoration: none; } + .trix-content .attachment a:hover, .trix-content .attachment a:visited:hover { + color: inherit; } + .trix-content .attachment__caption { + text-align: center; } + .trix-content .attachment__caption .attachment__name + .attachment__size::before { + content: ' \2022 '; } + .trix-content .attachment--preview { + width: 100%; + text-align: center; } + .trix-content .attachment--preview .attachment__caption { + color: #666; + font-size: 0.9em; + line-height: 1.2; } + .trix-content .attachment--file { + color: #333; + line-height: 1; + margin: 0 2px 2px 2px; + padding: 0.4em 1em; + border: 1px solid #bbb; + border-radius: 5px; } + .trix-content .attachment-gallery { + display: flex; + flex-wrap: wrap; + position: relative; } + .trix-content .attachment-gallery .attachment { + flex: 1 0 33%; + padding: 0 0.5em; + max-width: 33%; } + .trix-content .attachment-gallery.attachment-gallery--2 .attachment, .trix-content .attachment-gallery.attachment-gallery--4 .attachment { + flex-basis: 50%; + max-width: 50%; } + +/* + * We need to override trix.css’s image gallery styles to accommodate the + * element we wrap around attachments. Otherwise, + * images in galleries will be squished by the max-width: 33%; rule. +*/ +.trix-content .attachment-gallery > action-text-attachment, +.trix-content .attachment-gallery > .attachment { + flex: 1 0 33%; + padding: 0 0.5em; + max-width: 33%; +} + +.trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment, +.trix-content .attachment-gallery.attachment-gallery--2 > .attachment, .trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment, +.trix-content .attachment-gallery.attachment-gallery--4 > .attachment { + flex-basis: 50%; + max-width: 50%; +} + +.trix-content action-text-attachment .attachment { + padding: 0 !important; + max-width: 100% !important; +} diff --git a/app/models/workshop.rb b/app/models/workshop.rb index 9cad06782..60ec65d94 100644 --- a/app/models/workshop.rb +++ b/app/models/workshop.rb @@ -5,6 +5,7 @@ class Workshop < ApplicationRecord # Associations belongs_to :user, optional: true before_save :set_time_frame + has_rich_text :notes has_many :sectorable_items, dependent: :destroy, inverse_of: :sectorable, as: :sectorable diff --git a/app/views/active_storage/blobs/_blob.html.erb b/app/views/active_storage/blobs/_blob.html.erb new file mode 100644 index 000000000..49ba357dd --- /dev/null +++ b/app/views/active_storage/blobs/_blob.html.erb @@ -0,0 +1,14 @@ +
attachment--<%= blob.filename.extension %>"> + <% if blob.representable? %> + <%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %> + <% end %> + +
+ <% if caption = blob.try(:caption) %> + <%= caption %> + <% else %> + <%= blob.filename %> + <%= number_to_human_size blob.byte_size %> + <% end %> +
+
diff --git a/app/views/layouts/action_text/contents/_content.html.erb b/app/views/layouts/action_text/contents/_content.html.erb new file mode 100644 index 000000000..9e3c0d0df --- /dev/null +++ b/app/views/layouts/action_text/contents/_content.html.erb @@ -0,0 +1,3 @@ +
+ <%= yield -%> +
diff --git a/app/views/workshops/_form.html.erb b/app/views/workshops/_form.html.erb index a776e3760..b1d1ac040 100644 --- a/app/views/workshops/_form.html.erb +++ b/app/views/workshops/_form.html.erb @@ -69,7 +69,7 @@
<%= f.label 'Notes' %> - <%= f.text_area :notes, placeholder: 'Anything else you\'d like us to know.' , class: "form-control form-control-workshop" %> + <%= f.rich_textarea :notes, placeholder: 'Any additional notes for the workshop.', class: "form-control form-control-workshop" %>
<%= f.label 'Tips' %> diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 000000000..9fab2c350 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,17 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + yarn = ENV["PATH"].split(File::PATH_SEPARATOR). + select { |dir| File.expand_path(dir) != __dir__ }. + product(["yarn", "yarn.cmd", "yarn.ps1"]). + map { |dir, file| File.expand_path(file, dir) }. + find { |file| File.executable?(file) } + + if yarn + exec yarn, *ARGV + else + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 636fadf52..927c9ca00 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -11,4 +11,4 @@ # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. -Rails.application.config.assets.precompile += %w( admin.js admin.css foundation_emails.css ) +Rails.application.config.assets.precompile += %w( admin.js admin.css foundation_emails.css actiontext.css ) diff --git a/db/migrate/20250913203205_create_active_storage_tables.active_storage.rb b/db/migrate/20250913203205_create_active_storage_tables.active_storage.rb new file mode 100644 index 000000000..6bd8bd082 --- /dev/null +++ b/db/migrate/20250913203205_create_active_storage_tables.active_storage.rb @@ -0,0 +1,57 @@ +# This migration comes from active_storage (originally 20170806125915) +class CreateActiveStorageTables < ActiveRecord::Migration[7.0] + def change + # Use Active Record's configured type for primary and foreign keys + primary_key_type, foreign_key_type = primary_and_foreign_key_types + + create_table :active_storage_blobs, id: primary_key_type do |t| + t.string :key, null: false + t.string :filename, null: false + t.string :content_type + t.text :metadata + t.string :service_name, null: false + t.bigint :byte_size, null: false + t.string :checksum + + if connection.supports_datetime_with_precision? + t.datetime :created_at, precision: 6, null: false + else + t.datetime :created_at, null: false + end + + t.index [ :key ], unique: true + end + + create_table :active_storage_attachments, id: primary_key_type do |t| + t.string :name, null: false + t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type + t.references :blob, null: false, type: foreign_key_type + + if connection.supports_datetime_with_precision? + t.datetime :created_at, precision: 6, null: false + else + t.datetime :created_at, null: false + end + + t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + + create_table :active_storage_variant_records, id: primary_key_type do |t| + t.belongs_to :blob, null: false, index: false, type: foreign_key_type + t.string :variation_digest, null: false + + t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_and_foreign_key_types + config = Rails.configuration.generators + setting = config.options[config.orm][:primary_key_type] + primary_key_type = setting || :primary_key + foreign_key_type = setting || :bigint + [ primary_key_type, foreign_key_type ] + end +end diff --git a/db/migrate/20250913203206_create_action_text_tables.action_text.rb b/db/migrate/20250913203206_create_action_text_tables.action_text.rb new file mode 100644 index 000000000..c1c0a9d8c --- /dev/null +++ b/db/migrate/20250913203206_create_action_text_tables.action_text.rb @@ -0,0 +1,26 @@ +# This migration comes from action_text (originally 20180528164100) +class CreateActionTextTables < ActiveRecord::Migration[6.0] + def change + # Use Active Record's configured type for primary and foreign keys + primary_key_type, foreign_key_type = primary_and_foreign_key_types + + create_table :action_text_rich_texts, id: primary_key_type do |t| + t.string :name, null: false + t.text :body, size: :long + t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type + + t.timestamps + + t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true + end + end + + private + def primary_and_foreign_key_types + config = Rails.configuration.generators + setting = config.options[config.orm][:primary_key_type] + primary_key_type = setting || :primary_key + foreign_key_type = setting || :bigint + [ primary_key_type, foreign_key_type ] + end +end diff --git a/db/schema.rb b/db/schema.rb index 4ac423fad..9040509ff 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,84 +10,121 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2025_09_13_171135) do +ActiveRecord::Schema[8.1].define(version: 2025_09_13_203206) do + create_table "action_text_rich_texts", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.text "body", size: :long + t.datetime "created_at", null: false + t.string "name", null: false + t.bigint "record_id", null: false + t.string "record_type", null: false + t.datetime "updated_at", null: false + t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true + end + + create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "blob_id", null: false + t.datetime "created_at", null: false + t.string "name", null: false + t.bigint "record_id", null: false + t.string "record_type", null: false + t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" + t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true + end + + create_table "active_storage_blobs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "byte_size", null: false + t.string "checksum" + t.string "content_type" + t.datetime "created_at", null: false + t.string "filename", null: false + t.string "key", null: false + t.text "metadata" + t.string "service_name", null: false + t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true + end + + create_table "active_storage_variant_records", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "blob_id", null: false + t.string "variation_digest", null: false + t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true + end create_table "admins", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", precision: nil + t.datetime "current_sign_in_at", precision: nil + t.string "current_sign_in_ip" t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "first_name", default: "", null: false t.string "last_name", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at", precision: nil - t.datetime "remember_created_at", precision: nil - t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at", precision: nil t.datetime "last_sign_in_at", precision: nil - t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.datetime "created_at", precision: nil + t.datetime "remember_created_at", precision: nil + t.datetime "reset_password_sent_at", precision: nil + t.string "reset_password_token" + t.integer "sign_in_count", default: 0, null: false t.datetime "updated_at", precision: nil t.index ["email"], name: "index_admins_on_email", unique: true t.index ["reset_password_token"], name: "index_admins_on_reset_password_token", unique: true end create_table "age_ranges", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "name" t.datetime "created_at", precision: nil, null: false + t.string "name" t.datetime "updated_at", precision: nil, null: false t.integer "windows_type_id" t.index ["windows_type_id"], name: "index_age_ranges_on_windows_type_id" end create_table "answer_options", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", precision: nil, null: false t.string "name" t.integer "order" - t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false end create_table "attachments", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "owner_id" - t.string "owner_type" t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false - t.string "file_file_name" t.string "file_content_type" + t.string "file_file_name" t.integer "file_file_size" t.datetime "file_updated_at", precision: nil + t.integer "owner_id" + t.string "owner_type" + t.datetime "updated_at", precision: nil, null: false end create_table "banners", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.text "content" - t.boolean "show" t.datetime "created_at", precision: nil, null: false + t.boolean "show" t.datetime "updated_at", precision: nil, null: false end create_table "bookmark_annotations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "bookmark_id" t.text "annotation", size: :medium - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "bookmark_id" + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false t.index ["bookmark_id"], name: "index_bookmark_annotations_on_bookmark_id" end create_table "bookmarks", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "user_id" - t.string "bookmarkable_type" t.integer "bookmarkable_id" + t.string "bookmarkable_type" t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false + t.integer "user_id" t.index ["user_id"], name: "index_bookmarks_on_user_id" end create_table "categories", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", precision: nil, null: false + t.integer "legacy_id" t.integer "metadatum_id" t.string "name" - t.integer "legacy_id" - t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false t.boolean "published", default: false + t.datetime "updated_at", precision: nil, null: false t.index ["metadatum_id"], name: "index_categories_on_metadatum_id" end @@ -95,152 +132,152 @@ t.integer "categorizable_id" t.string "categorizable_type" t.integer "category_id" - t.integer "legacy_id" t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false t.boolean "inactive", default: true + t.integer "legacy_id" + t.datetime "updated_at", precision: nil, null: false t.index ["category_id"], name: "index_categorizable_items_on_category_id" end create_table "ckeditor_assets", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "data_file_name", null: false - t.string "data_content_type" - t.integer "data_file_size" + t.string "actual_url" t.integer "assetable_id" t.string "assetable_type", limit: 30 - t.string "type", limit: 30 - t.integer "width" - t.integer "height" t.datetime "created_at", precision: nil, null: false + t.string "data_content_type" + t.string "data_file_name", null: false + t.integer "data_file_size" + t.integer "height" + t.string "type", limit: 30 t.datetime "updated_at", precision: nil, null: false - t.string "actual_url" + t.integer "width" t.index ["assetable_type", "assetable_id"], name: "idx_ckeditor_assetable" t.index ["assetable_type", "type", "assetable_id"], name: "idx_ckeditor_assetable_type" end create_table "event_registrations", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "first_name" - t.string "last_name" + t.datetime "created_at", null: false t.string "email" t.bigint "event_id" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.string "first_name" + t.string "last_name" + t.datetime "updated_at", null: false t.index ["event_id"], name: "index_event_registrations_on_event_id" end create_table "events", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "title" + t.datetime "created_at", null: false t.text "description" - t.datetime "start_date" - t.datetime "end_date" - t.datetime "registration_close_date" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "end_date", precision: nil t.boolean "publicly_visible", default: false, null: false + t.datetime "registration_close_date", precision: nil + t.datetime "start_date", precision: nil + t.string "title" + t.datetime "updated_at", null: false end create_table "facilitators", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "city", null: false + t.string "country", null: false + t.datetime "created_at", null: false t.string "first_name", null: false t.string "last_name", null: false - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.string "mailing_address_type", null: false + t.string "phone_number", null: false + t.string "phone_number_type", null: false t.string "primary_email_address", null: false t.string "primary_email_address_type", null: false - t.string "street_address", null: false - t.string "city", null: false t.string "state", null: false + t.string "street_address", null: false + t.datetime "updated_at", null: false t.string "zip", null: false - t.string "country", null: false - t.string "mailing_address_type", null: false - t.string "phone_number", null: false - t.string "phone_number_type", null: false end create_table "faqs", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "question" t.text "answer", size: :medium - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false t.boolean "inactive" t.integer "ordering" + t.string "question" + t.datetime "updated_at", precision: nil, null: false end create_table "footers", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "phone" - t.string "children_program" t.string "adult_program" - t.string "general_questions" + t.string "children_program" t.datetime "created_at", precision: nil, null: false + t.string "general_questions" + t.string "phone" t.datetime "updated_at", precision: nil, null: false end create_table "form_builders", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", precision: nil, null: false + t.text "description", size: :medium t.string "name" t.integer "owner_type" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.text "description", size: :medium + t.datetime "updated_at", precision: nil, null: false t.integer "windows_type_id" t.index ["windows_type_id"], name: "index_form_builders_on_windows_type_id" end create_table "form_field_answer_options", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "form_field_id" t.integer "answer_option_id" t.datetime "created_at", precision: nil, null: false + t.integer "form_field_id" t.datetime "updated_at", precision: nil, null: false t.index ["answer_option_id"], name: "index_form_field_answer_options_on_answer_option_id" t.index ["form_field_id"], name: "index_form_field_answer_options_on_form_field_id" end create_table "form_fields", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "form_id" + t.integer "answer_datatype" + t.integer "answer_type" t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false - t.string "question" + t.integer "form_id" t.string "instructional_hint" - t.integer "answer_type" - t.integer "answer_datatype" - t.integer "ordering" t.boolean "is_required", default: true - t.integer "status", default: 1 + t.integer "ordering" t.integer "parent_id" + t.string "question" + t.integer "status", default: 1 + t.datetime "updated_at", precision: nil, null: false t.index ["form_id"], name: "index_form_fields_on_form_id" end create_table "forms", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "owner_type" - t.integer "owner_id" t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false t.integer "form_builder_id" + t.integer "owner_id" + t.string "owner_type" + t.datetime "updated_at", precision: nil, null: false t.index ["form_builder_id"], name: "index_forms_on_form_builder_id" end create_table "images", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "owner_id" - t.string "owner_type" t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false - t.string "file_file_name" t.string "file_content_type" + t.string "file_file_name" t.integer "file_file_size" t.datetime "file_updated_at", precision: nil + t.integer "owner_id" + t.string "owner_type" t.integer "report_id" + t.datetime "updated_at", precision: nil, null: false t.index ["owner_id"], name: "index_images_on_owner_id" end create_table "locations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "city" - t.string "state" t.string "country" t.datetime "created_at", precision: nil, null: false + t.string "state" t.datetime "updated_at", precision: nil, null: false end create_table "media_files", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "file_file_name" t.string "file_content_type" + t.string "file_file_name" t.integer "file_file_size" t.datetime "file_updated_at", precision: nil t.integer "report_id" @@ -248,277 +285,277 @@ end create_table "metadata", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "name" - t.string "legacy_id" t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false + t.string "legacy_id" + t.string "name" t.boolean "published", default: false + t.datetime "updated_at", precision: nil, null: false end create_table "monthly_reports", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "best_call_time" + t.boolean "call_requested" + t.text "comments", size: :medium + t.datetime "created_at", precision: nil, null: false + t.text "goals", size: :medium + t.text "goals_reached", size: :medium + t.boolean "mail_evaluations" t.string "month" - t.integer "project_id" - t.integer "project_user_id" + t.text "most_challenging", size: :medium + t.text "most_effective", size: :medium t.string "name" - t.string "position" - t.boolean "mail_evaluations" - t.string "num_ongoing_participants" t.string "num_new_participants" - t.text "most_effective", size: :medium - t.text "most_challenging", size: :medium - t.text "goals_reached", size: :medium - t.text "goals", size: :medium - t.text "comments", size: :medium - t.boolean "call_requested" - t.string "best_call_time" + t.string "num_ongoing_participants" t.string "phone" - t.datetime "created_at", precision: nil, null: false + t.string "position" + t.integer "project_id" + t.integer "project_user_id" t.datetime "updated_at", precision: nil, null: false t.index ["project_id"], name: "index_monthly_reports_on_project_id" t.index ["project_user_id"], name: "index_monthly_reports_on_project_user_id" end create_table "notifications", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "notification_type" - t.string "noticeable_type" + t.datetime "created_at", precision: nil, null: false t.integer "noticeable_id" + t.string "noticeable_type" + t.integer "notification_type" + t.datetime "updated_at", precision: nil, null: false end create_table "permissions", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "security_cat" t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false t.integer "legacy_id" + t.string "security_cat" + t.datetime "updated_at", precision: nil, null: false end create_table "project_obligations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "name" t.datetime "created_at", precision: nil, null: false + t.string "name" t.datetime "updated_at", precision: nil, null: false end create_table "project_statuses", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "name" t.datetime "created_at", precision: nil, null: false + t.string "name" t.datetime "updated_at", precision: nil, null: false end create_table "project_users", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.integer "agency_id" - t.integer "user_id" - t.integer "position" t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false - t.integer "project_id" t.string "filemaker_code" + t.integer "position" + t.integer "project_id" + t.datetime "updated_at", precision: nil, null: false + t.integer "user_id" t.index ["agency_id"], name: "index_project_users_on_agency_id" t.index ["project_id"], name: "index_project_users_on_project_id" t.index ["user_id"], name: "index_project_users_on_user_id" end create_table "projects", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "name" - t.integer "location_id" t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false - t.integer "windows_type_id" + t.text "description", size: :medium t.string "district" - t.date "start_date" t.date "end_date" - t.string "locality" - t.text "description", size: :medium - t.text "notes", size: :medium t.string "filemaker_code" t.boolean "inactive", default: false - t.integer "legacy_id" t.boolean "legacy", default: false + t.integer "legacy_id" + t.string "locality" + t.integer "location_id" + t.string "name" + t.text "notes", size: :medium t.integer "project_status_id" + t.date "start_date" + t.datetime "updated_at", precision: nil, null: false + t.integer "windows_type_id" t.index ["location_id"], name: "index_projects_on_location_id" t.index ["project_status_id"], name: "index_projects_on_project_status_id" t.index ["windows_type_id"], name: "index_projects_on_windows_type_id" end create_table "quotable_item_quotes", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "quotable_type" - t.integer "quotable_id" + t.datetime "created_at", precision: nil, null: false t.integer "legacy_id" + t.integer "quotable_id" + t.string "quotable_type" t.integer "quote_id" - t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false t.index ["quote_id"], name: "index_quotable_item_quotes_on_quote_id" end create_table "quotes", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.text "quote", size: :medium + t.string "age" + t.datetime "created_at", precision: nil, null: false + t.string "gender", limit: 1 t.boolean "inactive", default: true - t.integer "legacy_id" t.boolean "legacy", default: false - t.datetime "created_at", precision: nil, null: false + t.integer "legacy_id" + t.text "quote", size: :medium + t.string "speaker_name" t.datetime "updated_at", precision: nil, null: false t.integer "workshop_id" - t.string "age" - t.string "gender", limit: 1 - t.string "speaker_name" t.index ["workshop_id"], name: "index_quotes_on_workshop_id" end create_table "report_form_field_answers", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "report_id" - t.integer "form_field_id" t.text "answer", size: :medium - t.datetime "created_at" - t.datetime "updated_at" t.integer "answer_option_id" + t.datetime "created_at", precision: nil + t.integer "form_field_id" + t.integer "report_id" + t.datetime "updated_at", precision: nil t.index ["answer_option_id"], name: "index_report_form_field_answers_on_answer_option_id" t.index ["form_field_id"], name: "index_report_form_field_answers_on_form_field_id" t.index ["report_id"], name: "index_report_form_field_answers_on_report_id" end create_table "reports", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "type" - t.integer "owner_id" - t.string "owner_type" + t.integer "adults_first_time", default: 0 + t.integer "adults_ongoing", default: 0 + t.integer "children_first_time", default: 0 + t.integer "children_ongoing", default: 0 t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false - t.integer "user_id" - t.integer "project_id" t.date "date" - t.integer "rating", default: 0 - t.integer "windows_type_id" - t.string "form_file_file_name" t.string "form_file_content_type" + t.string "form_file_file_name" t.integer "form_file_file_size" t.datetime "form_file_updated_at", precision: nil - t.integer "workshop_id" - t.string "workshop_name" - t.string "other_description" t.boolean "has_attachment", default: false - t.integer "children_first_time", default: 0 - t.integer "children_ongoing", default: 0 + t.string "other_description" + t.integer "owner_id" + t.string "owner_type" + t.integer "project_id" + t.integer "rating", default: 0 t.integer "teens_first_time", default: 0 t.integer "teens_ongoing", default: 0 - t.integer "adults_first_time", default: 0 - t.integer "adults_ongoing", default: 0 + t.string "type" + t.datetime "updated_at", precision: nil, null: false + t.integer "user_id" + t.integer "windows_type_id" + t.integer "workshop_id" + t.string "workshop_name" t.index ["project_id"], name: "index_reports_on_project_id" t.index ["user_id"], name: "index_reports_on_user_id" t.index ["windows_type_id"], name: "index_reports_on_windows_type_id" end create_table "resources", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "title" + t.string "agency" t.string "author" - t.integer "user_id" - t.text "text", size: :medium - t.boolean "featured", default: false t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false - t.string "kind" - t.integer "workshop_id" - t.boolean "male", default: false + t.boolean "featured", default: false t.boolean "female", default: false - t.string "url" + t.string "filemaker_code" t.boolean "inactive", default: true - t.string "agency" + t.string "kind" t.boolean "legacy" - t.integer "windows_type_id" - t.string "filemaker_code" - t.integer "ordering" t.integer "legacy_id" + t.boolean "male", default: false + t.integer "ordering" + t.text "text", size: :medium + t.string "title" + t.datetime "updated_at", precision: nil, null: false + t.string "url" + t.integer "user_id" + t.integer "windows_type_id" + t.integer "workshop_id" t.index ["user_id"], name: "index_resources_on_user_id" t.index ["windows_type_id"], name: "index_resources_on_windows_type_id" t.index ["workshop_id"], name: "index_resources_on_workshop_id" end create_table "sectorable_items", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", precision: nil, null: false + t.boolean "inactive", default: true + t.integer "sector_id" t.integer "sectorable_id" t.string "sectorable_type" - t.integer "sector_id" - t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false - t.boolean "inactive", default: true t.index ["sector_id"], name: "index_sectorable_items_on_sector_id" end create_table "sectors", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "name" t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false + t.string "name" t.boolean "published", default: false + t.datetime "updated_at", precision: nil, null: false end create_table "user_form_form_fields", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", precision: nil, null: false t.integer "form_field_id" - t.integer "user_form_id" t.text "text", size: :medium - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "updated_at", precision: nil, null: false + t.integer "user_form_id" t.index ["form_field_id"], name: "index_user_form_form_fields_on_form_field_id" t.index ["user_form_id"], name: "index_user_form_form_fields_on_user_form_id" end create_table "user_forms", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "user_id" - t.integer "form_id" t.datetime "created_at", precision: nil, null: false + t.integer "form_id" t.datetime "updated_at", precision: nil, null: false + t.integer "user_id" t.index ["form_id"], name: "index_user_forms_on_form_id" t.index ["user_id"], name: "index_user_forms_on_user_id" end create_table "user_permissions", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "user_id" - t.integer "permission_id" t.datetime "created_at", precision: nil, null: false + t.integer "permission_id" t.datetime "updated_at", precision: nil, null: false + t.integer "user_id" t.index ["permission_id"], name: "index_user_permissions_on_permission_id" t.index ["user_id"], name: "index_user_permissions_on_user_id" end create_table "users", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "address" + t.string "address2" + t.integer "agency_id" + t.string "avatar_content_type" + t.string "avatar_file_name" + t.integer "avatar_file_size" + t.datetime "avatar_updated_at", precision: nil + t.string "best_time_to_call" + t.date "birthday" + t.string "city" + t.string "city2" + t.text "comment", size: :medium + t.boolean "confirmed", default: true + t.datetime "created_at", precision: nil + t.datetime "current_sign_in_at", precision: nil + t.string "current_sign_in_ip" t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false + t.bigint "facilitator_id" t.string "first_name", default: "" + t.boolean "inactive", default: false t.string "last_name", default: "" - t.string "reset_password_token" - t.datetime "reset_password_sent_at", precision: nil - t.datetime "remember_created_at", precision: nil - t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at", precision: nil t.datetime "last_sign_in_at", precision: nil - t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.datetime "created_at", precision: nil - t.datetime "updated_at", precision: nil - t.integer "agency_id" - t.string "phone" - t.string "address" - t.string "city" - t.string "state" - t.string "zip" - t.date "birthday" - t.string "subscribecode" - t.text "comment", size: :medium - t.text "notes", size: :medium t.boolean "legacy", default: false - t.boolean "inactive", default: false - t.boolean "confirmed", default: true t.integer "legacy_id" + t.text "notes", size: :medium + t.string "phone" t.string "phone2" t.string "phone3" - t.string "best_time_to_call" - t.string "address2" - t.string "city2" - t.string "state2" - t.string "zip2" t.integer "primary_address" - t.string "avatar_file_name" - t.string "avatar_content_type" - t.integer "avatar_file_size" - t.datetime "avatar_updated_at", precision: nil + t.datetime "remember_created_at", precision: nil + t.datetime "reset_password_sent_at", precision: nil + t.string "reset_password_token" + t.integer "sign_in_count", default: 0, null: false + t.string "state" + t.string "state2" + t.string "subscribecode" t.boolean "super_user", default: false - t.bigint "facilitator_id" + t.datetime "updated_at", precision: nil + t.string "zip" + t.string "zip2" t.index ["agency_id"], name: "index_users_on_agency_id" t.index ["email"], name: "index_users_on_email", unique: true t.index ["facilitator_id"], name: "index_users_on_facilitator_id" @@ -526,153 +563,155 @@ end create_table "windows_types", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "name" t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false t.integer "legacy_id" + t.string "name" t.string "short_name" + t.datetime "updated_at", precision: nil, null: false end create_table "workshop_age_ranges", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "workshop_id" t.integer "age_range_id" t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false + t.integer "workshop_id" t.index ["age_range_id"], name: "index_workshop_age_ranges_on_age_range_id" t.index ["workshop_id"], name: "index_workshop_age_ranges_on_workshop_id" end create_table "workshop_logs", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "workshop_id" - t.integer "user_id" + t.text "challenges", size: :medium + t.text "comments", size: :medium + t.datetime "created_at", precision: nil, null: false t.date "date" + t.text "differences", size: :medium + t.boolean "is_embodied_art_workshop", default: false + t.boolean "lead_similar" + t.integer "num_participants_first_time", default: 0 + t.integer "num_participants_on_going", default: 0 + t.integer "project_id" + t.text "questions", size: :medium t.integer "rating", default: 0 t.text "reaction", size: :medium + t.text "similarities", size: :medium t.text "successes", size: :medium - t.text "challenges", size: :medium t.text "suggestions", size: :medium - t.text "questions", size: :medium - t.boolean "lead_similar" - t.text "similarities", size: :medium - t.text "differences", size: :medium - t.text "comments", size: :medium - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "project_id" - t.boolean "is_embodied_art_workshop", default: false - t.integer "num_participants_on_going", default: 0 - t.integer "num_participants_first_time", default: 0 + t.datetime "updated_at", precision: nil, null: false + t.integer "user_id" + t.integer "workshop_id" t.index ["project_id"], name: "index_workshop_logs_on_project_id" t.index ["user_id"], name: "index_workshop_logs_on_user_id" t.index ["workshop_id"], name: "index_workshop_logs_on_workshop_id" end create_table "workshop_resources", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "workshop_id" - t.integer "resource_id" t.datetime "created_at", precision: nil, null: false + t.integer "resource_id" t.datetime "updated_at", precision: nil, null: false + t.integer "workshop_id" t.index ["resource_id"], name: "index_workshop_resources_on_resource_id" t.index ["workshop_id"], name: "index_workshop_resources_on_workshop_id" end create_table "workshop_variations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.integer "workshop_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false t.text "code", size: :medium + t.datetime "created_at", precision: nil, null: false t.boolean "inactive", default: true - t.integer "ordering" - t.string "name" t.boolean "legacy", default: false + t.string "name" + t.integer "ordering" + t.datetime "updated_at", precision: nil, null: false t.integer "variation_id" + t.integer "workshop_id" t.index ["workshop_id"], name: "index_workshop_variations_on_workshop_id" end create_table "workshops", id: :integer, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "title" - t.string "full_name" - t.string "author_location" - t.integer "month" - t.integer "year" - t.text "objective", size: :medium - t.text "materials", size: :medium - t.text "timeframe", size: :medium t.text "age_range", size: :medium - t.text "setup", size: :medium - t.text "instructions", size: :medium - t.text "warm_up", size: :medium - t.text "creation", size: :medium + t.text "age_range_spanish", size: :medium + t.string "author_location" t.text "closing", size: :medium - t.text "misc_instructions", size: :medium - t.text "project", size: :medium + t.text "closing_spanish", size: :medium + t.datetime "created_at", precision: nil, null: false + t.text "creation", size: :medium + t.text "creation_spanish", size: :medium + t.text "demonstration", size: :medium + t.text "demonstration_spanish", size: :medium t.text "description", size: :medium - t.text "notes", size: :medium - t.text "timestamps", size: :medium - t.text "tips", size: :medium - t.string "pub_issue" - t.string "misc1" - t.string "misc2" - t.boolean "inactive", default: true - t.boolean "searchable", default: false + t.text "description_spanish", size: :medium + t.text "extra_field" + t.text "extra_field_spanish" t.boolean "featured", default: false - t.string "photo_caption" t.string "filemaker_code" - t.datetime "created_at", precision: nil, null: false - t.datetime "updated_at", precision: nil, null: false + t.string "full_name" + t.string "header_content_type" + t.string "header_file_name" + t.integer "header_file_size" + t.datetime "header_updated_at", precision: nil + t.boolean "inactive", default: true + t.text "instructions", size: :medium + t.text "instructions_spanish", size: :medium + t.text "introduction", size: :medium + t.text "introduction_spanish", size: :medium + t.integer "led_count", default: 0 t.boolean "legacy", default: false t.integer "legacy_id" - t.integer "windows_type_id" - t.integer "user_id" - t.integer "led_count", default: 0 - t.text "objective_spanish", size: :medium + t.text "materials", size: :medium t.text "materials_spanish", size: :medium - t.text "timeframe_spanish", size: :medium - t.text "age_range_spanish", size: :medium - t.text "setup_spanish", size: :medium - t.text "instructions_spanish", size: :medium - t.text "project_spanish", size: :medium - t.text "warm_up_spanish", size: :medium - t.text "creation_spanish", size: :medium - t.text "closing_spanish", size: :medium + t.string "misc1" + t.text "misc1_spanish", size: :medium + t.string "misc2" + t.text "misc2_spanish", size: :medium + t.text "misc_instructions", size: :medium t.text "misc_instructions_spanish", size: :medium - t.text "description_spanish", size: :medium + t.integer "month" + t.text "notes", size: :medium t.text "notes_spanish", size: :medium - t.text "tips_spanish", size: :medium - t.string "thumbnail_file_name" - t.string "thumbnail_content_type" - t.integer "thumbnail_file_size" - t.datetime "thumbnail_updated_at" - t.text "optional_materials", size: :medium - t.text "optional_materials_spanish", size: :medium - t.text "introduction", size: :medium - t.text "introduction_spanish", size: :medium - t.text "demonstration", size: :medium - t.text "demonstration_spanish", size: :medium + t.text "objective", size: :medium + t.text "objective_spanish", size: :medium t.text "opening_circle", size: :medium t.text "opening_circle_spanish", size: :medium - t.text "visualization", size: :medium - t.text "visualization_spanish", size: :medium - t.text "misc1_spanish", size: :medium - t.text "misc2_spanish", size: :medium - t.integer "time_intro" - t.integer "time_demonstration" - t.integer "time_warm_up" - t.integer "time_creation" + t.text "optional_materials", size: :medium + t.text "optional_materials_spanish", size: :medium + t.string "photo_caption" + t.text "project", size: :medium + t.text "project_spanish", size: :medium + t.string "pub_issue" + t.boolean "searchable", default: false + t.text "setup", size: :medium + t.text "setup_spanish", size: :medium + t.string "thumbnail_content_type" + t.string "thumbnail_file_name" + t.integer "thumbnail_file_size" + t.datetime "thumbnail_updated_at", precision: nil t.integer "time_closing" + t.integer "time_creation" + t.integer "time_demonstration" + t.integer "time_intro" t.integer "time_opening" - t.string "header_file_name" - t.string "header_content_type" - t.integer "header_file_size" - t.datetime "header_updated_at", precision: nil - t.text "extra_field" - t.text "extra_field_spanish" + t.integer "time_warm_up" + t.text "timeframe", size: :medium + t.text "timeframe_spanish", size: :medium + t.text "timestamps", size: :medium + t.text "tips", size: :medium + t.text "tips_spanish", size: :medium + t.string "title" + t.datetime "updated_at", precision: nil, null: false + t.integer "user_id" + t.text "visualization", size: :medium + t.text "visualization_spanish", size: :medium + t.text "warm_up", size: :medium + t.text "warm_up_spanish", size: :medium + t.integer "windows_type_id" + t.integer "year" t.index ["title", "full_name", "objective", "materials", "introduction", "demonstration", "opening_circle", "warm_up", "creation", "closing", "notes", "tips", "misc1", "misc2"], name: "workshop_fullsearch", type: :fulltext t.index ["title"], name: "workshop_fullsearch_title", type: :fulltext t.index ["user_id"], name: "index_workshops_on_user_id" t.index ["windows_type_id"], name: "index_workshops_on_windows_type_id" end + add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" + add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "age_ranges", "windows_types" add_foreign_key "bookmark_annotations", "bookmarks" add_foreign_key "bookmarks", "users" diff --git a/docker-compose.yml b/docker-compose.yml index 1cd917a11..482cf258a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -38,6 +38,7 @@ services: volumes: - ./:/app:cached - /app/tmp + - ./tmp/capybara:/app/tmp/capybara working_dir: /app command: bash -lc "bin/rails s -b 0.0.0.0 -p 3000" diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 50b8fa0d9..79811b8f6 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,21 +1,15 @@ -require 'shoulda/matchers' +# This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' -require File.expand_path('../config/environment', __dir__) +require_relative '../config/environment' # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? +# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file +# that will avoid rails generators crashing because migrations haven't been run yet +# return unless Rails.env.test? require 'rspec/rails' -require 'factory_bot_rails' # Add additional requires below this line. Rails is not loaded until this point! -# Setup Shoulda Matchers -Shoulda::Matchers.configure do |config| - config.integrate do |with| - with.test_framework :rspec - with.library :rails - end -end - # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # run as spec files by default. This means that files in spec/support that end @@ -28,52 +22,51 @@ # of increasing the boot-up time by auto-requiring all files in the support # directory. Alternatively, in the individual `*_spec.rb` files, manually # require only the support files necessary. -Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } +# +# Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f } -# Checks for pending migrations and applies them before tests are run. +# Ensures that the test database schema matches the current schema file. +# If there are pending migrations it will invoke `db:test:prepare` to +# recreate the test database by loading the schema. # If you are not using ActiveRecord, you can remove these lines. begin ActiveRecord::Migration.maintain_test_schema! rescue ActiveRecord::PendingMigrationError => e - puts e.to_s.strip - exit 1 + abort e.to_s.strip end RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_paths = ["#{::Rails.root}/spec/fixtures"] + config.fixture_paths = [ + Rails.root.join('spec/fixtures') + ] # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. config.use_transactional_fixtures = true - config.include Devise::Test::IntegrationHelpers, type: :request + # You can uncomment this line to turn off ActiveRecord support entirely. # config.use_active_record = false - # RSpec Rails can automatically mix in different behaviours to your tests - # based on their file location, for example enabling you to call `get` and - # `post` in specs under `spec/controllers`. + # RSpec Rails uses metadata to mix in different behaviours to your tests, + # for example enabling you to call `get` and `post` in request specs. e.g.: # - # You can disable this behaviour by removing the line below, and instead - # explicitly tag your specs with their type, e.g.: - # - # RSpec.describe UsersController, type: :controller do + # RSpec.describe UsersController, type: :request do # # ... # end # # The different available types are documented in the features, such as in - # https://relishapp.com/rspec/rspec-rails/docs - config.infer_spec_type_from_file_location! + # https://rspec.info/features/8-0/rspec-rails + # + # You can also this infer these behaviours automatically by location, e.g. + # /spec/models would pull in the same behaviour as `type: :model` but this + # behaviour is considered legacy and will be removed in a future version. + # + # To enable this behaviour uncomment the line below. + # config.infer_spec_type_from_file_location! # Filter lines from Rails gems in backtraces. config.filter_rails_from_backtrace! # arbitrary gems may also be filtered via: # config.filter_gems_from_backtrace("gem name") - - # ==> Mailer Prevention (add this block) - config.before(:each) do - ActionMailer::Base.delivery_method = :test - ActionMailer::Base.deliveries.clear - end - # <== End Mailer Prevention end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7b4460273..327b58ea1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,30 +13,6 @@ # it. # # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration -if ENV["CI"] - require "simplecov" - require "simplecov_json_formatter" - SimpleCov.formatter = - if ENV["GITHUB_ACTIONS"] == "true" - SimpleCov::Formatter::JSONFormatter - else - SimpleCov::Formatter::MultiFormatter.new([ - SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::JSONFormatter - ]) - end - SimpleCov.at_exit do - SimpleCov.result.format! - File.write("coverage/summary.json", JSON.dump({ covered_percent: SimpleCov.result.covered_percent })) - end - SimpleCov.start "rails" do - enable_coverage :branch - add_filter %w[/spec/ /vendor/ /config/ /bin/] - track_files "{app,lib}/**/*.rb" - minimum_coverage 20 # tune as you like - end -end - RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest @@ -68,35 +44,35 @@ # triggering implicit auto-inclusion in groups with matching metadata. config.shared_context_metadata_behavior = :apply_to_host_groups - # The settings below are suggested to provide a good initial experience - # with RSpec, but feel free to customize to your heart's content. - +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin # This allows you to limit a spec run to individual examples or groups # you care about by tagging them with `:focus` metadata. When nothing # is tagged with `:focus`, all examples get run. RSpec also provides # aliases for `it`, `describe`, and `context` that include `:focus` # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - # config.filter_run_when_matching :focus + config.filter_run_when_matching :focus # Allows RSpec to persist some state between runs in order to support # the `--only-failures` and `--next-failure` CLI options. We recommend # you configure your source control system to ignore this file. - # config.example_status_persistence_file_path = "spec/examples.txt" + config.example_status_persistence_file_path = "spec/examples.txt" # Limits the available syntax to the non-monkey patched syntax that is # recommended. For more details, see: # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ - # config.disable_monkey_patching! + config.disable_monkey_patching! # Many RSpec users commonly either run the entire suite or an individual # file, and it's useful to allow more verbose output when running an # individual spec file. - # if config.files_to_run.one? - # # Use the documentation formatter for detailed output, - # # unless a formatter has already been configured - # # (e.g. via a command-line flag). - # config.default_formatter = "doc" - # end + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end # Print the 10 slowest examples and example groups at the # end of the spec run, to help surface which specs are running @@ -114,4 +90,5 @@ # test failures related to randomization by passing the same `--seed` value # as the one that triggered the failure. Kernel.srand config.seed +=end end