diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index e2169cf35..138c038e9 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -11,10 +11,7 @@ # PRs - After completing work, create a pull request using `gh pr create` - Once the PR is created, prepend the PR number to the branch name (e.g., rename `maebeale/fix-login` to `maebeale/1234-fix-login`) using `git branch -m` and `git push origin -u` with the new name, then delete the old remote branch - -# PRs -- After completing work, create a pull request using `gh pr create` -- Once the PR is created, prepend the PR number to the branch name (e.g., rename `maebeale/fix-login` to `maebeale/1234-fix-login`) using `git branch -m` and `git push origin -u` with the new name, then delete the old remote branch +- On every push, update the PR title and description to reflect the current diff # Code style requirements: - Use modern Ruby syntax @@ -67,8 +64,22 @@ This project uses rubocop-rails-omakase. All code MUST follow these rules: - No parentheses around conditions: `if foo` not `if (foo)` - No semicolons to separate statements -# PRs -- On every push, update the PR title and description to reflect the current diff - # Git - When rebasing onto main, review incoming changes for their intent and flag any oversights — missing tests, incomplete migrations, broken assumptions, or conflicts between the two branches. Check both directions: schema/model changes on either branch that affect views, partials, or layouts on the other (e.g., main redesigned a table's CSS but your branch adds new columns to it, or vice versa) + +# HTML/ERB Formatting + +## Tag attributes +- When a tag has long attributes, place the closing `>` on the same line as the last attribute +- Do NOT put the closing `>` on its own line +- Example (GOOD): + ```erb + @@ -104,10 +110,10 @@ Contact us <% end %> - <%= link_to tutorials_path, class: "flex items-center px-4 py-2 text-sm text-white + <%= link_to video_recordings_path(video_type: "instructional"), class: "flex items-center px-4 py-2 text-sm text-white hover:text-gray-700 hover:bg-gray-100 w-full space-x-2" do %> - <%= Tutorial.model_name.human(count: 2) %> + Instructional videos <% end %> <%= link_to "https://www.awbw.org", target: "_blank", class: "flex items-center px-4 py-2 text-sm text-white diff --git a/app/views/tutorials/_video_card.html.erb b/app/views/tutorials/_video_card.html.erb deleted file mode 100644 index e949196e8..000000000 --- a/app/views/tutorials/_video_card.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -
- <% if tutorial.youtube_url.present? %> -
- -
- <% end %> - -
- <%= link_to title_with_badges(tutorial), tutorial_path(tutorial), - class: "hover:text-primary", - data: { turbo_frame: "_top" } %> - <%= render "bookmarks/editable_bookmark_icon", resource: tutorial %> -
-
diff --git a/app/views/tutorials/index.html.erb b/app/views/tutorials/index.html.erb deleted file mode 100644 index 184871bcb..000000000 --- a/app/views/tutorials/index.html.erb +++ /dev/null @@ -1,44 +0,0 @@ -<% content_for(:page_bg_class, "public") %> -<%= render "shared/public_welcome_banner" %> - -
-
-
-
-

- <%= Tutorial.model_name.human(count: 2) %> -

- -

- <% if user_signed_in? %> - Our library of step-by-step tutorials and informational videos designed to support your journey - <% else %> - A library of videos designed to introduce you to our work and the real-world impact shared by the community we serve - <% end %> -

-
- -
- <% if allowed_to?(:new?, Tutorial) %> - <%= link_to "New #{Tutorial.model_name.human.downcase}", - new_tutorial_path, - class: "admin-only bg-blue-100 btn btn-primary-outline" %> - <% end %> -
-
- - <%= render "search_boxes" %> - - <% result_src = tutorials_path + "?" + request.query_string %> - - <%= turbo_frame_tag "tutorials_results", src: result_src do %> -
-
- <% 3.times do %> -
- <% end %> -
-
- <% end %> -
-
diff --git a/app/views/tutorials/index_lazy.html.erb b/app/views/tutorials/index_lazy.html.erb deleted file mode 100644 index b0da51f69..000000000 --- a/app/views/tutorials/index_lazy.html.erb +++ /dev/null @@ -1,24 +0,0 @@ -<%= turbo_frame_tag "tutorials_results" do %> -
-
- <% if @tutorials.any? %> - <%= tag.div class: "grid grid-cols-1 lg:grid-cols-2 gap-4" do %> - <% @tutorials.each_with_index do |tutorial, idx| %> - <%= tag.div class: "bg-white shadow-md rounded-md pt-6 px-2 pb-2" do %> - <%= render "tutorial", tutorial: tutorial %> - <% end %> - <% end %> - <% end %> - - - - <% else %> -
- No <%= Tutorial.model_name.human(count: 2).downcase %> found matching your filters. -
- <% end %> -
-
-<% end %> diff --git a/app/views/tutorials/show.html.erb b/app/views/tutorials/show.html.erb deleted file mode 100644 index 4b51de37b..000000000 --- a/app/views/tutorials/show.html.erb +++ /dev/null @@ -1,46 +0,0 @@ -<% content_for(:page_bg_class, "admin-or-public-or-authpublished") %> -
- -
- <%= link_to "Home", root_path, class: "text-sm text-gray-500 hover:text-gray-700 px-2 py-1" %> - <%= link_to Tutorial.model_name.human(count: 2), tutorials_path, class: "text-sm text-gray-500 hover:text-gray-700 px-2 py-1" %> - <% if allowed_to?(:edit?, @tutorial) %> - <%= link_to "Edit", edit_tutorial_path(@tutorial), - class: "admin-only bg-blue-100 text-sm text-gray-500 hover:text-gray-700 px-2 py-1" %> - <% end %> - - <%= render "bookmarks/editable_bookmark_button", resource: @tutorial.object %> - -
- - -
- - -
- <%= title_with_badges(@tutorial, font_size: "text-3xl") %> -
- - - <% if @tutorial.youtube_url.present? %> -
-
- -
-
- <% end %> - - <%= render "assets/display_assets", resource: @tutorial, link: true %> - - - - <%= @tutorial.rhino_body %> - -
-
diff --git a/app/views/tutorials/_form.html.erb b/app/views/video_recordings/_form.html.erb similarity index 75% rename from app/views/tutorials/_form.html.erb rename to app/views/video_recordings/_form.html.erb index 4714e96da..23978b9c0 100644 --- a/app/views/tutorials/_form.html.erb +++ b/app/views/video_recordings/_form.html.erb @@ -1,5 +1,5 @@ -<%= simple_form_for(@tutorial, html: { multipart: true }) do |f| %> - <%= render 'shared/errors', resource: @tutorial if @tutorial.errors.any? %> +<%= simple_form_for(@video_recording, html: { multipart: true }) do |f| %> + <%= render 'shared/errors', resource: @video_recording if @video_recording.errors.any? %>
@@ -8,11 +8,17 @@ input_html: { rows: 2, value: f.object.title } %>
-
- <%= f.input :published, as: :boolean %> - <%= f.input :featured, as: :boolean %> - <%= f.input :publicly_visible, as: :boolean %> - <%= f.input :publicly_featured, as: :boolean %> +
+
+ <%= f.input :published, as: :boolean %> + <%= f.input :featured, as: :boolean %> + <%= f.input :publicly_visible, as: :boolean %> + <%= f.input :publicly_featured, as: :boolean %> +
+
+ <%= f.input :is_instructional, as: :boolean, label: "Instructional" %> + <%= f.input :is_podcast, as: :boolean, label: "Podcast" %> +
@@ -75,17 +81,17 @@
<% @sectors.each do |sector| %> - <% id = "tutorial_sector_ids_#{sector.id}" %> + <% id = "video_recording_sector_ids_#{sector.id}" %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 4c5b68b82..1ff330f4f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -38,9 +38,9 @@ en: workshop_variation_idea: rhino_body: "Details" models: - tutorial: + video_recording: one: "Video" - other: "Video Gallery" + other: "Videos" helpers: submit: create: "Submit" diff --git a/config/routes.rb b/config/routes.rb index fab3611f8..317d82d4f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -159,7 +159,7 @@ resources :story_ideas resources :stories resources :story_shares, only: [ :index, :show ] - resources :tutorials + resources :video_recordings resources :user_forms resources :windows_types resources :workshop_ideas @@ -182,7 +182,7 @@ resources :stories, only: :index resources :community_news, only: :index resources :events, only: :index - resources :video_gallery, only: :index + resources :video_recordings, only: :index end root to: "home#index" diff --git a/db/migrate/20260125175620_add_position_index_to_category.rb b/db/migrate/20260125175620_add_position_index_to_category.rb index de2e7a7cf..697c14f13 100644 --- a/db/migrate/20260125175620_add_position_index_to_category.rb +++ b/db/migrate/20260125175620_add_position_index_to_category.rb @@ -1,6 +1,5 @@ class AddPositionIndexToCategory < ActiveRecord::Migration[8.1] def change - Category.heal_position_column!(name: :desc) add_index :categories, [ :metadatum_id, :position ], unique: true end end diff --git a/db/migrate/20260308140252_rename_video_recordings.rb b/db/migrate/20260308140252_rename_video_recordings.rb new file mode 100644 index 000000000..bb5201697 --- /dev/null +++ b/db/migrate/20260308140252_rename_video_recordings.rb @@ -0,0 +1,10 @@ +class RenameVideoRecordings < ActiveRecord::Migration[8.0] + def change + rename_table :tutorials, :video_recordings + + add_column :video_recordings, :is_instructional, :boolean, default: true, null: false + add_column :video_recordings, :is_podcast, :boolean, default: false, null: false + add_index :video_recordings, :is_instructional + add_index :video_recordings, :is_podcast + end +end diff --git a/db/schema.rb b/db/schema.rb index 77439b4b6..d56d0e43d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -18,6 +18,7 @@ t.string "mentionable_type", null: false t.datetime "updated_at", null: false t.index ["action_text_rich_text_id", "mentionable_type", "mentionable_id"], name: "index_at_mentions_on_rich_text_and_mentionable", unique: true + t.index ["action_text_rich_text_id"], name: "index_action_text_mentions_on_action_text_rich_text_id" t.index ["mentionable_type", "mentionable_id"], name: "index_action_text_mentions_on_mentionable" end @@ -50,7 +51,7 @@ t.datetime "created_at", precision: nil, null: false t.string "filename", null: false t.string "key", null: false - t.text "metadata", size: :medium + t.text "metadata" t.string "service_name", null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end @@ -63,8 +64,8 @@ create_table "addresses", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "address_type" - t.bigint "addressable_id", null: false - t.string "addressable_type", null: false + t.bigint "addressable_id" + t.string "addressable_type" t.string "city", null: false t.string "country" t.string "county" @@ -74,7 +75,7 @@ t.integer "la_city_council_district" t.integer "la_service_planning_area" t.integer "la_supervisorial_district" - t.string "locality", null: false + t.string "locality" t.string "phone" t.boolean "primary", default: false, null: false t.string "state", null: false @@ -138,7 +139,7 @@ t.string "resource_type" t.datetime "time" t.bigint "user_id" - t.bigint "visit_id", null: false + t.bigint "visit_id" t.index ["name", "time"], name: "index_ahoy_events_on_name_and_time" t.index ["resource_id"], name: "index_ahoy_events_on_resource_id" t.index ["resource_type", "resource_id", "time"], name: "index_ahoy_events_on_resource_type_and_resource_id_and_time" @@ -192,7 +193,8 @@ t.string "title" t.string "type", default: "PrimaryAsset", null: false t.datetime "updated_at", null: false - t.index ["owner_type", "owner_id"], name: "index_assets_on_owner_type_and_owner_id" + t.index ["owner_id"], name: "index_assets_on_owner_id" + t.index ["owner_type"], name: "index_assets_on_owner_type" t.index ["type"], name: "index_assets_on_type" end @@ -202,19 +204,19 @@ t.string "file_file_name" t.integer "file_file_size" t.datetime "file_updated_at", precision: nil - t.integer "owner_id", null: false - t.string "owner_type", null: false + 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_unicode_ci", force: :cascade do |t| - t.text "content", size: :medium, null: false + t.text "content" t.datetime "created_at", precision: nil, null: false - t.integer "created_by_id", null: false + t.integer "created_by_id" t.boolean "published", default: false, null: false - t.boolean "show", default: false, null: false + t.boolean "show" t.datetime "updated_at", precision: nil, null: false - t.integer "updated_by_id", null: false + t.integer "updated_by_id" t.index ["created_by_id"], name: "index_banners_on_created_by_id" t.index ["published"], name: "index_banners_on_published" t.index ["updated_by_id"], name: "index_banners_on_updated_by_id" @@ -277,7 +279,7 @@ end create_table "bookmark_annotations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.text "annotation", size: :long + t.text "annotation", size: :medium t.integer "bookmark_id" t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false @@ -285,48 +287,48 @@ end create_table "bookmarks", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.integer "bookmarkable_id", null: false - t.string "bookmarkable_type", null: false + 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", null: false + t.integer "user_id" t.index ["bookmarkable_type", "bookmarkable_id"], name: "index_bookmarks_on_bookmarkable" t.index ["user_id"], name: "index_bookmarks_on_user_id" end create_table "categories", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.integer "category_type_id", null: false + t.integer "category_type_id" t.datetime "created_at", precision: nil, null: false t.integer "legacy_id" - t.string "name", null: false + t.string "name" t.integer "position", null: false - t.boolean "published", default: false, null: false + t.boolean "published", default: false t.datetime "updated_at", precision: nil, null: false t.index ["category_type_id", "position"], name: "index_categories_on_category_type_id_and_position", unique: true - t.index ["name"], name: "index_categories_on_name", unique: true + t.index ["category_type_id"], name: "index_categories_on_category_type_id" end create_table "categorizable_items", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.integer "categorizable_id", null: false + t.integer "categorizable_id" t.string "categorizable_type" - t.integer "category_id", null: false + t.integer "category_id" t.datetime "created_at", precision: nil, null: false t.integer "legacy_id" t.datetime "updated_at", precision: nil, null: false t.index ["categorizable_type", "categorizable_id"], name: "idx_on_categorizable_type_categorizable_id_ccce65d80c" t.index ["category_id", "categorizable_type", "categorizable_id"], name: "index_categorizable_items_uniqueness", unique: true + t.index ["category_id"], name: "index_categorizable_items_on_category_id" end create_table "category_types", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.string "display_text" t.string "legacy_id" - t.string "name", null: false + t.string "name" t.boolean "profile_specific", default: false, null: false - t.boolean "published", default: false, null: false - t.boolean "story_specific", default: false, null: false + t.boolean "published", default: false + t.boolean "story_specific", default: false t.datetime "updated_at", precision: nil, null: false - t.index ["name"], name: "index_category_types_on_name", unique: true end create_table "ckeditor_assets", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| @@ -354,22 +356,23 @@ t.datetime "updated_at", null: false t.integer "updated_by_id" t.index ["commentable_type", "commentable_id", "created_at"], name: "idx_on_commentable_type_commentable_id_created_at_89c6e27600" + t.index ["commentable_type", "commentable_id"], name: "index_comments_on_commentable" t.index ["created_by_id"], name: "index_comments_on_created_by_id" t.index ["updated_by_id"], name: "index_comments_on_updated_by_id" end create_table "community_news", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.integer "author_id", null: false - t.text "body", size: :medium + t.text "body" t.datetime "created_at", null: false t.integer "created_by_id", null: false - t.boolean "featured", default: false, null: false + t.boolean "featured" t.integer "organization_id" t.boolean "publicly_featured", default: false, null: false t.boolean "publicly_visible", default: false, null: false - t.boolean "published", default: false, null: false + t.boolean "published" t.string "reference_url" - t.string "title", null: false + t.string "title" t.datetime "updated_at", null: false t.integer "updated_by_id", null: false t.integer "windows_type_id" @@ -448,8 +451,8 @@ t.integer "cost_cents" t.datetime "created_at", null: false t.integer "created_by_id" - t.text "description", size: :medium - t.datetime "end_date", precision: nil, null: false + t.text "description" + t.datetime "end_date", precision: nil t.boolean "featured", default: false, null: false t.boolean "inactive", default: true, null: false t.integer "location_id" @@ -460,8 +463,8 @@ t.boolean "publicly_visible", default: false, null: false t.boolean "published", default: false, null: false t.datetime "registration_close_date", precision: nil - t.datetime "start_date", precision: nil, null: false - t.string "title", null: false + t.datetime "start_date", precision: nil + t.string "title" t.datetime "updated_at", null: false t.string "videoconference_label", default: "Virtual event" t.string "videoconference_url" @@ -471,13 +474,13 @@ end create_table "faqs", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.text "answer", size: :long, null: false + t.text "answer", size: :medium t.datetime "created_at", precision: nil, null: false - t.boolean "inactive", default: false, null: false + t.boolean "inactive" t.integer "position", null: false t.boolean "publicly_visible", default: false, null: false t.boolean "published", default: false, null: false - t.string "question", null: false + t.string "question" t.datetime "updated_at", precision: nil, null: false t.index ["published"], name: "index_faqs_on_published" end @@ -493,18 +496,18 @@ create_table "form_builders", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false - t.text "description", size: :long - t.string "name", null: false + t.text "description", size: :medium + t.string "name" t.integer "owner_type" t.datetime "updated_at", precision: nil, null: false - t.integer "windows_type_id", 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_unicode_ci", force: :cascade do |t| - t.integer "answer_option_id", null: false + t.integer "answer_option_id" t.datetime "created_at", precision: nil, null: false - t.integer "form_field_id", 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" @@ -516,18 +519,17 @@ t.datetime "created_at", precision: nil, null: false t.string "field_group" t.string "field_key" - t.integer "form_id", null: false + t.integer "form_id" t.text "instructional_hint" t.boolean "is_required", default: true t.integer "parent_id" t.integer "position" - t.string "question", null: false + t.string "question" t.integer "status", default: 1 t.datetime "updated_at", precision: nil, null: false t.index ["field_group"], name: "index_form_fields_on_field_group" t.index ["field_key"], name: "index_form_fields_on_field_key" t.index ["form_id"], name: "index_form_fields_on_form_id" - t.index ["parent_id"], name: "index_form_fields_on_parent_id" end create_table "forms", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| @@ -539,7 +541,6 @@ t.boolean "scholarship_application", default: false, null: false t.datetime "updated_at", precision: nil, null: false t.index ["form_builder_id"], name: "index_forms_on_form_builder_id" - t.index ["owner_type", "owner_id"], name: "index_forms_on_owner_type_and_owner_id" end create_table "images", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| @@ -558,8 +559,8 @@ end create_table "locations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.string "city", null: false - t.string "country", null: false + t.string "city" + t.string "country" t.datetime "created_at", precision: nil, null: false t.string "state" t.datetime "updated_at", precision: nil, null: false @@ -572,20 +573,19 @@ t.datetime "file_updated_at", precision: nil t.integer "report_id" t.integer "workshop_log_id" - t.index ["report_id"], name: "index_media_files_on_report_id" end create_table "monthly_reports", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "best_call_time" t.boolean "call_requested" - t.text "comments", size: :long + t.text "comments", size: :medium t.datetime "created_at", precision: nil, null: false - t.text "goals", size: :long - t.text "goals_reached", size: :long + t.text "goals", size: :medium + t.text "goals_reached", size: :medium t.boolean "mail_evaluations" t.string "month" - t.text "most_challenging", size: :long - t.text "most_effective", size: :long + t.text "most_challenging", size: :medium + t.text "most_effective", size: :medium t.string "name" t.string "num_new_participants" t.string "num_ongoing_participants" @@ -610,7 +610,7 @@ t.string "kind", null: false t.integer "noticeable_id" t.string "noticeable_type" - t.integer "notification_type", null: false + t.integer "notification_type" t.integer "parent_notification_id" t.string "recipient_email", null: false t.string "recipient_role", null: false @@ -632,10 +632,9 @@ create_table "organization_statuses", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false - t.string "name", null: false + t.string "name" t.boolean "published", default: false, null: false t.datetime "updated_at", precision: nil, null: false - t.index ["name"], name: "index_organization_statuses_on_name", unique: true t.index ["published"], name: "index_organization_statuses_on_published" end @@ -643,17 +642,17 @@ t.string "agency_type" t.string "agency_type_other" t.datetime "created_at", precision: nil, null: false - t.text "description", size: :long + t.text "description", size: :medium t.string "email" t.date "end_date" t.string "filemaker_code" t.string "internal_id" - t.boolean "legacy", default: false, null: false + t.boolean "legacy", default: false t.integer "legacy_id" t.integer "location_id" t.string "mission_vision_values" - t.string "name", null: false - t.text "notes", size: :long + t.string "name" + t.text "notes", size: :medium t.integer "organization_status_id" t.boolean "profile_show_description", default: true, null: false t.boolean "profile_show_email", default: true, null: false @@ -693,14 +692,16 @@ t.index ["event_id"], name: "index_payments_on_event_id" t.index ["payable_type", "payable_id", "status"], name: "index_payments_on_payable_type_and_payable_id_and_status" t.index ["payable_type", "payable_id"], name: "index_payments_on_payable" + t.index ["payable_type", "payable_id"], name: "index_payments_on_payable_type_and_payable_id" t.index ["payer_type", "payer_id"], name: "index_payments_on_payer" - t.index ["stripe_charge_id"], name: "index_payments_on_stripe_charge_id", unique: true + t.index ["payer_type", "payer_id"], name: "index_payments_on_payer_type_and_payer_id" + t.index ["stripe_charge_id"], name: "index_payments_on_stripe_charge_id" t.index ["stripe_payment_intent_id"], name: "index_payments_on_stripe_payment_intent_id", unique: true end create_table "people", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "best_time_to_call" - t.text "bio", size: :medium + t.text "bio" t.boolean "blog_contributor", default: false, null: false t.datetime "created_at", null: false t.integer "created_by_id" @@ -773,11 +774,10 @@ create_table "quotable_item_quotes", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "legacy_id" - t.integer "quotable_id", null: false - t.string "quotable_type", null: false - t.integer "quote_id", null: false + t.integer "quotable_id" + t.string "quotable_type" + t.integer "quote_id" t.datetime "updated_at", precision: nil, null: false - t.index ["quotable_type", "quotable_id"], name: "index_quotable_item_quotes_on_quotable_type_and_quotable_id" t.index ["quote_id"], name: "index_quotable_item_quotes_on_quote_id" end @@ -785,11 +785,11 @@ t.string "age" t.datetime "created_at", precision: nil, null: false t.string "gender", limit: 1 - t.boolean "inactive", default: true, null: false + t.boolean "inactive", default: true t.boolean "legacy", default: false t.integer "legacy_id" t.boolean "published", default: false, null: false - t.text "quote", size: :long + t.text "quote", size: :medium t.string "speaker_name" t.datetime "updated_at", precision: nil, null: false t.integer "workshop_id" @@ -798,11 +798,11 @@ end create_table "report_form_field_answers", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.text "answer", size: :long + t.text "answer", size: :medium t.integer "answer_option_id" t.datetime "created_at", precision: nil - t.integer "form_field_id", null: false - t.integer "report_id", null: false + 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" @@ -815,15 +815,15 @@ t.integer "children_first_time", default: 0 t.integer "children_ongoing", default: 0 t.datetime "created_at", precision: nil, null: false - t.integer "created_by_id", null: false + t.integer "created_by_id" t.date "date" t.string "external_workshop_title" 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.boolean "has_attachment", default: false, null: false - t.integer "organization_id", null: false + t.boolean "has_attachment", default: false + t.integer "organization_id" t.string "other_description" t.integer "owner_id" t.string "owner_type" @@ -832,12 +832,11 @@ t.integer "teens_ongoing", default: 0 t.string "type" t.datetime "updated_at", precision: nil, null: false - t.integer "windows_type_id", null: false + t.integer "windows_type_id" t.integer "workshop_id" t.string "workshop_name" t.index ["created_by_id"], name: "index_reports_on_created_by_id" t.index ["organization_id"], name: "index_reports_on_organization_id" - t.index ["owner_type", "owner_id"], name: "index_reports_on_owner_type_and_owner_id" t.index ["type", "date"], name: "index_reports_on_type_and_date" t.index ["type", "organization_id"], name: "index_reports_on_type_and_organization_id" t.index ["windows_type_id"], name: "index_reports_on_windows_type_id" @@ -847,30 +846,28 @@ create_table "resources", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "agency" t.string "author" - t.text "body", size: :long + t.text "body", size: :medium t.datetime "created_at", precision: nil, null: false - t.integer "created_by_id", null: false + t.integer "created_by_id" t.boolean "featured", default: false t.boolean "female", default: false t.string "filemaker_code" t.boolean "inactive", default: true - t.string "kind", null: false + t.string "kind" t.boolean "legacy" t.integer "legacy_id" t.boolean "male", default: false - t.boolean "pdf_from_body", default: false, null: false t.integer "position" t.boolean "publicly_featured", default: false, null: false t.boolean "publicly_visible", default: false, null: false t.boolean "published", default: false, null: false - t.string "title", null: false + t.string "title" t.datetime "updated_at", precision: nil, null: false t.string "url" t.integer "windows_type_id" t.integer "workshop_id" t.index ["created_by_id"], name: "index_resources_on_created_by_id" t.index ["published"], name: "index_resources_on_published" - t.index ["title"], name: "index_resources_on_title", unique: true t.index ["windows_type_id"], name: "index_resources_on_windows_type_id" t.index ["workshop_id"], name: "index_resources_on_workshop_id" end @@ -879,24 +876,24 @@ t.datetime "created_at", precision: nil, null: false t.boolean "is_leader", default: false, null: false t.integer "sector_id" - t.integer "sectorable_id", null: false - t.string "sectorable_type", null: false + t.integer "sectorable_id" + t.string "sectorable_type" t.datetime "updated_at", precision: nil, null: false t.index ["sector_id", "sectorable_type", "sectorable_id"], name: "index_sectorable_items_uniqueness", unique: true + t.index ["sector_id"], name: "index_sectorable_items_on_sector_id" t.index ["sectorable_type", "sectorable_id"], name: "index_sectorable_items_on_sectorable_type_and_sectorable_id" end create_table "sectors", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false - t.string "name", null: false - t.boolean "published", default: false, null: false + t.string "name" + t.boolean "published", default: false t.datetime "updated_at", precision: nil, null: false - t.index ["name"], name: "index_sectors_on_name", unique: true end create_table "stories", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "author_credit_preference" - t.text "body", size: :medium + t.text "body" t.datetime "created_at", null: false t.integer "created_by_id", null: false t.string "external_workshop_title" @@ -908,7 +905,7 @@ t.boolean "published", default: false, null: false t.bigint "spotlighted_facilitator_id" t.bigint "story_idea_id" - t.string "title", null: false + t.string "title" t.datetime "updated_at", null: false t.integer "updated_by_id", null: false t.string "website_url" @@ -920,15 +917,14 @@ t.index ["published"], name: "index_stories_on_published" t.index ["spotlighted_facilitator_id"], name: "index_stories_on_spotlighted_facilitator_id" t.index ["story_idea_id"], name: "index_stories_on_story_idea_id" - t.index ["title"], name: "index_stories_on_title", unique: true t.index ["updated_by_id"], name: "index_stories_on_updated_by_id" t.index ["windows_type_id"], name: "index_stories_on_windows_type_id" t.index ["workshop_id"], name: "index_stories_on_workshop_id" end create_table "story_ideas", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.string "author_credit_preference", null: false - t.text "body", size: :medium + t.string "author_credit_preference" + t.text "body" t.datetime "created_at", null: false t.integer "created_by_id", null: false t.string "external_workshop_title" @@ -947,37 +943,21 @@ t.index ["workshop_id"], name: "index_story_ideas_on_workshop_id" end - create_table "tutorials", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.text "body" - t.datetime "created_at", null: false - t.boolean "featured", default: false, null: false - t.integer "position", default: 10, null: false - t.boolean "publicly_featured", default: false, null: false - t.boolean "publicly_visible", default: false, null: false - t.boolean "published", default: false, null: false - t.string "title", null: false - t.datetime "updated_at", null: false - t.string "youtube_url" - t.index ["featured"], name: "index_tutorials_on_featured" - t.index ["published"], name: "index_tutorials_on_published" - t.index ["title"], name: "index_tutorials_on_title", unique: true - end - create_table "user_form_form_fields", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false - t.integer "form_field_id", null: false - t.text "text", size: :long + t.integer "form_field_id" + t.text "text", size: :medium t.datetime "updated_at", precision: nil, null: false - t.integer "user_form_id", 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_unicode_ci", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false - t.integer "form_id", null: false + t.integer "form_id" t.datetime "updated_at", precision: nil, null: false - t.integer "user_id", 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 @@ -1003,7 +983,7 @@ t.date "birthday" t.string "city" t.string "city2" - t.text "comment", size: :long + t.text "comment", size: :medium t.datetime "confirmation_sent_at" t.string "confirmation_token" t.datetime "confirmed_at" @@ -1023,7 +1003,7 @@ t.boolean "legacy", default: false t.integer "legacy_id" t.datetime "locked_at" - t.text "notes", size: :long + t.text "notes", size: :medium t.bigint "person_id" t.string "phone" t.string "phone2" @@ -1051,18 +1031,38 @@ t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true t.index ["created_by_id"], name: "index_users_on_created_by_id" t.index ["email"], name: "index_users_on_email", unique: true - t.index ["person_id"], name: "index_users_on_person_id_unique", unique: true + t.index ["person_id"], name: "index_users_on_person_id" t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true t.index ["updated_by_id"], name: "index_users_on_updated_by_id" t.index ["welcome_instructions_token"], name: "index_users_on_welcome_instructions_token", unique: true end + create_table "video_recordings", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| + t.text "body" + t.datetime "created_at", null: false + t.boolean "featured", default: false, null: false + t.boolean "is_instructional", default: true, null: false + t.boolean "is_podcast", default: false, null: false + t.integer "position", default: 10, null: false + t.boolean "publicly_featured", default: false, null: false + t.boolean "publicly_visible", default: false, null: false + t.boolean "published", default: false, null: false + t.string "title" + t.datetime "updated_at", null: false + t.string "youtube_url" + t.index ["featured"], name: "index_video_recordings_on_featured" + t.index ["is_instructional"], name: "index_video_recordings_on_is_instructional" + t.index ["is_podcast"], name: "index_video_recordings_on_is_podcast" + t.index ["published"], name: "index_video_recordings_on_published" + t.index ["title"], name: "index_video_recordings_on_title" + end + create_table "windows_types", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false t.integer "legacy_id" - t.string "name", null: false - t.string "short_name", null: false + t.string "name" + t.string "short_name" t.datetime "updated_at", precision: nil, null: false end @@ -1076,37 +1076,37 @@ end create_table "workshop_ideas", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.text "age_range", size: :medium - t.text "age_range_spanish", size: :medium + t.text "age_range" + t.text "age_range_spanish" t.string "author_credit_preference" - t.text "closing", size: :medium - t.text "closing_spanish", size: :medium + t.text "closing" + t.text "closing_spanish" t.datetime "created_at", null: false t.integer "created_by_id", 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 "description_spanish", size: :medium - t.text "instructions", size: :medium - t.text "instructions_spanish", size: :medium - t.text "introduction", size: :medium - t.text "introduction_spanish", size: :medium - t.text "materials", size: :medium - t.text "materials_spanish", size: :medium - t.text "misc_instructions_spanish", size: :medium - t.text "notes", size: :medium - t.text "notes_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 "optional_materials", size: :medium - t.text "optional_materials_spanish", size: :medium - t.text "setup", size: :medium - t.text "setup_spanish", size: :medium - t.text "staff_notes", size: :medium + t.text "creation" + t.text "creation_spanish" + t.text "demonstration" + t.text "demonstration_spanish" + t.text "description" + t.text "description_spanish" + t.text "instructions" + t.text "instructions_spanish" + t.text "introduction" + t.text "introduction_spanish" + t.text "materials" + t.text "materials_spanish" + t.text "misc_instructions_spanish" + t.text "notes" + t.text "notes_spanish" + t.text "objective" + t.text "objective_spanish" + t.text "opening_circle" + t.text "opening_circle_spanish" + t.text "optional_materials" + t.text "optional_materials_spanish" + t.text "setup" + t.text "setup_spanish" + t.text "staff_notes" t.integer "time_closing" t.integer "time_creation" t.integer "time_demonstration" @@ -1116,41 +1116,40 @@ t.integer "time_opening" t.integer "time_opening_circle" t.integer "time_warm_up" - t.text "timeframe", size: :medium - t.text "timeframe_spanish", size: :medium - t.text "tips", size: :medium - t.text "tips_spanish", size: :medium - t.string "title", null: false + t.text "timeframe" + t.text "timeframe_spanish" + t.text "tips" + t.text "tips_spanish" + t.string "title" t.datetime "updated_at", null: false t.integer "updated_by_id", null: false - 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.text "visualization" + t.text "visualization_spanish" + t.text "warm_up" + t.text "warm_up_spanish" t.integer "windows_type_id", null: false t.index ["created_by_id"], name: "index_workshop_ideas_on_created_by_id" - t.index ["title"], name: "index_workshop_ideas_on_title", unique: true t.index ["updated_by_id"], name: "index_workshop_ideas_on_updated_by_id" t.index ["windows_type_id"], name: "index_workshop_ideas_on_windows_type_id" end create_table "workshop_logs", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.text "challenges", size: :long - t.text "comments", size: :long + 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: :long + 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 "organization_id" - t.text "questions", size: :long + t.text "questions", size: :medium t.integer "rating", default: 0 - t.text "reaction", size: :long - t.text "similarities", size: :long - t.text "successes", size: :long - t.text "suggestions", size: :long + t.text "reaction", size: :medium + t.text "similarities", size: :medium + t.text "successes", size: :medium + t.text "suggestions", size: :medium t.datetime "updated_at", precision: nil, null: false t.integer "user_id" t.integer "workshop_id" @@ -1161,9 +1160,9 @@ create_table "workshop_resources", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.datetime "created_at", precision: nil, null: false - t.integer "resource_id", null: false + t.integer "resource_id" t.datetime "updated_at", precision: nil, null: false - t.integer "workshop_id", 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 @@ -1182,7 +1181,7 @@ end create_table "workshop_variation_ideas", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.string "author_credit_preference", null: false + t.string "author_credit_preference" t.text "body", size: :long t.datetime "created_at", null: false t.integer "created_by_id", null: false @@ -1196,21 +1195,21 @@ t.string "youtube_url" t.index ["body"], name: "index_workshop_variation_ideas_on_body", type: :fulltext t.index ["created_by_id"], name: "index_workshop_variation_ideas_on_created_by_id" + t.index ["name"], name: "index_workshop_variation_ideas_on_name" t.index ["organization_id"], name: "index_workshop_variation_ideas_on_organization_id" t.index ["updated_by_id"], name: "index_workshop_variation_ideas_on_updated_by_id" t.index ["windows_type_id"], name: "index_workshop_variation_ideas_on_windows_type_id" - t.index ["workshop_id", "name"], name: "index_workshop_variation_ideas_on_workshop_id_and_name", unique: true t.index ["workshop_id"], name: "index_workshop_variation_ideas_on_workshop_id" end create_table "workshop_variations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| t.string "author_credit_preference" - t.text "body", size: :long + t.text "body", size: :medium t.datetime "created_at", precision: nil, null: false t.integer "created_by_id" t.boolean "inactive", default: true t.boolean "legacy", default: false - t.string "name", null: false + t.string "name" t.integer "organization_id" t.integer "position" t.boolean "publicly_visible", default: false, null: false @@ -1218,35 +1217,34 @@ t.datetime "updated_at", precision: nil, null: false t.integer "variation_id" t.integer "windows_type_id" - t.integer "workshop_id", null: false + t.integer "workshop_id" t.bigint "workshop_variation_idea_id" t.string "youtube_url" t.index ["created_by_id"], name: "index_workshop_variations_on_created_by_id" t.index ["organization_id"], name: "index_workshop_variations_on_organization_id" t.index ["published"], name: "index_workshop_variations_on_published" t.index ["windows_type_id"], name: "index_workshop_variations_on_windows_type_id" - t.index ["workshop_id", "name"], name: "index_workshop_variations_on_workshop_id_and_name", unique: true t.index ["workshop_id"], name: "index_workshop_variations_on_workshop_id" t.index ["workshop_variation_idea_id"], name: "index_workshop_variations_on_workshop_variation_idea_id" end create_table "workshops", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t| - t.text "age_range", size: :long - t.text "age_range_spanish", size: :long + t.text "age_range", size: :medium + t.text "age_range_spanish", size: :medium t.string "author_credit_preference" t.string "author_location" - t.text "closing", size: :long - t.text "closing_spanish", size: :long + t.text "closing", size: :medium + t.text "closing_spanish", size: :medium t.datetime "created_at", precision: nil, null: false t.integer "created_by_id" - t.text "creation", size: :long - t.text "creation_spanish", size: :long - t.text "demonstration", size: :long - t.text "demonstration_spanish", size: :long - t.text "description", size: :long - t.text "description_spanish", size: :long - t.text "extra_field", size: :medium - t.text "extra_field_spanish", size: :medium + 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 "description_spanish", size: :medium + t.text "extra_field" + t.text "extra_field_spanish" t.boolean "featured", default: false t.string "filemaker_code" t.string "full_name" @@ -1255,40 +1253,40 @@ t.integer "header_file_size" t.datetime "header_updated_at", precision: nil t.boolean "inactive", default: true - t.text "instructions", size: :long - t.text "instructions_spanish", size: :long - t.text "introduction", size: :long - t.text "introduction_spanish", size: :long + 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.text "materials", size: :long - t.text "materials_spanish", size: :long + t.text "materials", size: :medium + t.text "materials_spanish", size: :medium t.string "misc1" - t.text "misc1_spanish", size: :long + t.text "misc1_spanish", size: :medium t.string "misc2" - t.text "misc2_spanish", size: :long - t.text "misc_instructions", size: :long - t.text "misc_instructions_spanish", size: :long + t.text "misc2_spanish", size: :medium + t.text "misc_instructions", size: :medium + t.text "misc_instructions_spanish", size: :medium t.integer "month" - t.text "notes", size: :long - t.text "notes_spanish", size: :long - t.text "objective", size: :long - t.text "objective_spanish", size: :long - t.text "opening_circle", size: :long - t.text "opening_circle_spanish", size: :long - t.text "optional_materials", size: :long - t.text "optional_materials_spanish", size: :long + t.text "notes", size: :medium + t.text "notes_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 "optional_materials", size: :medium + t.text "optional_materials_spanish", size: :medium t.string "photo_caption" - t.text "project", size: :long - t.text "project_spanish", size: :long + t.text "project", size: :medium + t.text "project_spanish", size: :medium t.string "pub_issue" t.boolean "publicly_featured", default: false, null: false t.boolean "publicly_visible", default: false, null: false t.boolean "published", default: false, null: false t.boolean "searchable", default: false - t.text "setup", size: :long - t.text "setup_spanish", size: :long + 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" @@ -1300,17 +1298,17 @@ t.integer "time_opening" t.integer "time_opening_circle" t.integer "time_warm_up" - t.text "timeframe", size: :long - t.text "timeframe_spanish", size: :long - t.text "timestamps", size: :long - t.text "tips", size: :long - t.text "tips_spanish", size: :long - t.string "title", null: false + 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.text "visualization", size: :long - t.text "visualization_spanish", size: :long - t.text "warm_up", size: :long - t.text "warm_up_spanish", size: :long + 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.bigint "workshop_idea_id" t.integer "year" @@ -1328,6 +1326,7 @@ end add_foreign_key "action_text_mentions", "action_text_rich_texts" + 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 "affiliations", "organizations" add_foreign_key "affiliations", "organizations", column: "organization_agency_id" diff --git a/db/seeds.rb b/db/seeds.rb index 8cf7e225d..eeb12772e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,3 +1,6 @@ +# Disable email delivery during seeding +ActionMailer::Base.perform_deliveries = false + puts "Creating Users…" # Helper: case-insensitive find-or-create by name @@ -82,6 +85,7 @@ def find_or_create_by_name!(klass, name, **attrs, &block) invited = User.find_or_create_by!(email: "invited.pending@example.com") do |user| user.password = "password" user.super_user = false + user.confirmed_at = Time.current end unless invited.confirmed_at.present? invited.update_columns( @@ -107,6 +111,7 @@ def find_or_create_by_name!(klass, name, **attrs, &block) confirmed_no_pw = User.find_or_create_by!(email: "confirmed.nopassword@example.com") do |user| user.password = "password" user.super_user = false + user.confirmed_at = Time.current end unless confirmed_no_pw.welcome_instructions_token.present? token = Devise.friendly_token @@ -157,6 +162,7 @@ def find_or_create_by_name!(klass, name, **attrs, &block) never_invited = User.find_or_create_by!(email: "never.invited@example.com") do |user| user.password = "password" user.super_user = false + user.confirmed_at = Time.current end unless never_invited.welcome_instructions_sent_at.present? never_invited.update_columns(confirmed_at: nil) @@ -177,6 +183,7 @@ def find_or_create_by_name!(klass, name, **attrs, &block) stale_invited = User.find_or_create_by!(email: "stale.invite@example.com") do |user| user.password = "password" user.super_user = false + user.confirmed_at = Time.current end unless stale_invited.confirmed_at.present? stale_invited.update_columns( @@ -202,6 +209,7 @@ def find_or_create_by_name!(klass, name, **attrs, &block) recent_invited = User.find_or_create_by!(email: "recent.invite@example.com") do |user| user.password = "password" user.super_user = false + user.confirmed_at = Time.current end unless recent_invited.confirmed_at.present? recent_invited.update_columns( @@ -227,6 +235,7 @@ def find_or_create_by_name!(klass, name, **attrs, &block) User.find_or_create_by!(email: "orphan.uninvited@example.com") do |user| user.password = "password" user.super_user = false + user.confirmed_at = Time.current end.tap do |u| u.update_columns(confirmed_at: nil) unless u.welcome_instructions_sent_at.present? end @@ -235,6 +244,7 @@ def find_or_create_by_name!(klass, name, **attrs, &block) invited_no_person = User.find_or_create_by!(email: "invited.noperson@example.com") do |user| user.password = "password" user.super_user = false + user.confirmed_at = Time.current end unless invited_no_person.confirmed_at.present? invited_no_person.update_columns( diff --git a/db/seeds/dummy_dev_seeds.rb b/db/seeds/dummy_dev_seeds.rb index 8d46cc8f5..ab88126c7 100644 --- a/db/seeds/dummy_dev_seeds.rb +++ b/db/seeds/dummy_dev_seeds.rb @@ -555,16 +555,21 @@ ] # rubocop:enable Style/PercentLiteralDelimiters -variations.each_with_index do |var_data, i| +variations.each do |var_data| workshop = Workshop.find_by(title: var_data[:workshop_title]) next unless workshop - workshop.workshop_variations.where(name: var_data[:name]).first_or_create!( + windows_type_id = [ adult_wt.id, children_wt.id, combined_wt.id ].sample + variation = workshop.workshop_variations.find_or_initialize_by(name: var_data[:name]) + variation.assign_attributes( body: var_data[:rhino_body], rhino_body: var_data[:rhino_body], position: var_data[:position], - published: i != variations.length - 1 + published: [ true, true, false ].sample, + windows_type_id: windows_type_id, + author_credit_preference: "anonymous" ) + variation.save! end puts "Creating Persons and Affiliations for seed users…" @@ -834,11 +839,11 @@ end puts "Linking some WorkshopVariations to WorkshopVariationIdeas…" -WorkshopVariationIdea.all.sample(2).each do |idea| +WorkshopVariationIdea.all.sample(2).each_with_index do |idea, i| variation = WorkshopVariation.where(workshop_variation_idea_id: nil).sample next unless variation - variation.update!(workshop_variation_idea_id: idea.id) + variation.update!(workshop_variation_idea_id: idea.id, published: i > 0) end puts "Creating WorkshopLogs…" @@ -1364,7 +1369,9 @@ featured: true, publicly_visible: true, publicly_featured: true, - position: 1 + position: 1, + is_instructional: true, + is_podcast: false }, { title: "Trauma-Informed Facilitation Basics", @@ -1374,7 +1381,9 @@ featured: true, publicly_visible: true, publicly_featured: true, - position: 2 + position: 2, + is_instructional: true, + is_podcast: false }, { title: "Creating Safe Spaces for Art Expression", @@ -1384,7 +1393,9 @@ featured: true, publicly_visible: true, publicly_featured: true, - position: 3 + position: 3, + is_instructional: false, + is_podcast: false }, { title: "Working with Children and Youth", @@ -1392,7 +1403,9 @@ youtube_url: "https://www.youtube.com/watch?v=kJQP7kiw5Fk", published: true, featured: true, - position: 4 + position: 4, + is_instructional: false, + is_podcast: false }, { title: "Art Materials and Supply Management", @@ -1400,7 +1413,9 @@ youtube_url: "https://www.youtube.com/watch?v=RgKAFK5djSk", published: true, featured: true, - position: 5 + position: 5, + is_instructional: false, + is_podcast: false }, { title: "Monthly Reporting Walkthrough", @@ -1408,10 +1423,12 @@ youtube_url: "https://www.youtube.com/watch?v=JGwWNGJdvx8", published: true, featured: true, - position: 6 + position: 6, + is_instructional: false, + is_podcast: false } -].each do |tutorial_data| - Tutorial.where(title: tutorial_data[:title]).first_or_create!(tutorial_data) +].each do |video_data| + VideoRecording.where(title: video_data[:title]).first_or_create!(video_data) end puts "Creating Bookmarks for seed users…" diff --git a/lib/domain_theme.rb b/lib/domain_theme.rb index d188127fb..123da503a 100644 --- a/lib/domain_theme.rb +++ b/lib/domain_theme.rb @@ -19,7 +19,7 @@ module DomainTheme category_types: :lime, faqs: :pink, - tutorials: :cyan, + video_recordings: :cyan, workshop_ideas: :indigo, workshop_variation_ideas: :purple, diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake index 4b946898e..ed649734d 100644 --- a/lib/tasks/dev.rake +++ b/lib/tasks/dev.rake @@ -1,7 +1,7 @@ namespace :db do namespace :dev do desc "Generate dev seed data" - task seed: :environment do + task seed: [ :environment, "db:seed" ] do load Rails.root.join("db/seeds/dummy_dev_seeds.rb") end end diff --git a/spec/decorators/tutorial_decorator_spec.rb b/spec/decorators/tutorial_decorator_spec.rb deleted file mode 100644 index 1deb3ced6..000000000 --- a/spec/decorators/tutorial_decorator_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'rails_helper' - -RSpec.describe TutorialDecorator do -end diff --git a/spec/decorators/video_recording_decorator_spec.rb b/spec/decorators/video_recording_decorator_spec.rb new file mode 100644 index 000000000..ff1303e25 --- /dev/null +++ b/spec/decorators/video_recording_decorator_spec.rb @@ -0,0 +1,4 @@ +require 'rails_helper' + +RSpec.describe VideoRecordingDecorator do +end diff --git a/spec/factories/tutorials.rb b/spec/factories/video_recordings.rb similarity index 60% rename from spec/factories/tutorials.rb rename to spec/factories/video_recordings.rb index 87c630367..3186b554c 100644 --- a/spec/factories/tutorials.rb +++ b/spec/factories/video_recordings.rb @@ -1,11 +1,13 @@ FactoryBot.define do - factory :tutorial do + factory :video_recording do title { "MyString" } body { "MyText" } featured { false } published { false } position { 1 } youtube_url { "MyString" } + is_instructional { true } + is_podcast { false } trait :featured do featured { true } @@ -26,5 +28,19 @@ trait :publicly_featured do publicly_featured { true } end + + trait :instructional do + is_instructional { true } + end + + trait :podcast do + is_instructional { false } + is_podcast { true } + end + + trait :both do + is_instructional { true } + is_podcast { true } + end end end diff --git a/spec/models/bookmark_spec.rb b/spec/models/bookmark_spec.rb index 08cec428d..cb4122d5c 100644 --- a/spec/models/bookmark_spec.rb +++ b/spec/models/bookmark_spec.rb @@ -12,7 +12,7 @@ it "includes all expected model names" do expect(Bookmark::BOOKMARKABLE_MODELS).to include( "CommunityNews", "Event", "Organization", "Person", "Report", - "Resource", "Story", "StoryIdea", "Tutorial", "Workshop", + "Resource", "Story", "StoryIdea", "VideoRecording", "Workshop", "WorkshopIdea", "WorkshopLog", "WorkshopVariation", "WorkshopVariationIdea" ) end @@ -52,8 +52,8 @@ it "uses model_name.human for labels" do options = Bookmark.bookmarkable_type_options - tutorial_option = options.find { |_, value| value == "Tutorial" } - expect(tutorial_option.first).to eq(Tutorial.model_name.human) + video_recording_option = options.find { |_, value| value == "VideoRecording" } + expect(video_recording_option.first).to eq(VideoRecording.model_name.human) end it "returns [label, value] pairs" do @@ -116,24 +116,24 @@ end end - describe "tutorial bookmarks" do + describe "video_recording bookmarks" do let(:user) { create(:user) } - let!(:tutorial) { create(:tutorial, :published, title: "Getting Started") } - let!(:tutorial_bookmark) { create(:bookmark, user: user, bookmarkable: tutorial) } + let!(:video_recording) { create(:video_recording, :published, title: "Getting Started") } + let!(:video_recording_bookmark) { create(:bookmark, user: user, bookmarkable: video_recording) } - it "filters by title matching tutorial" do + it "filters by title matching video_recording" do result = Bookmark.filter_by_params(title: "Getting") - expect(result).to include(tutorial_bookmark) + expect(result).to include(video_recording_bookmark) end - it "excludes non-matching tutorials in title filter" do + it "excludes non-matching video_recordings in title filter" do result = Bookmark.filter_by_params(title: "Nonexistent") - expect(result).not_to include(tutorial_bookmark) + expect(result).not_to include(video_recording_bookmark) end - it "includes tutorial bookmarks when sorting by title" do + it "includes video_recording bookmarks when sorting by title" do result = Bookmark.sorted("title") - expect(result).to include(tutorial_bookmark) + expect(result).to include(video_recording_bookmark) end end diff --git a/spec/models/tutorial_spec.rb b/spec/models/tutorial_spec.rb deleted file mode 100644 index 3b444536c..000000000 --- a/spec/models/tutorial_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'rails_helper' - -RSpec.describe Tutorial, type: :model do - describe '.search_by_params' do - let!(:published_tutorial) { create(:tutorial, :published, title: 'Getting Started Guide', rhino_body: 'Welcome to AWBW') } - let!(:draft_tutorial) { create(:tutorial, title: 'Advanced Workshop Tips', rhino_body: 'For experienced facilitators') } - - it 'returns all when no params' do - results = Tutorial.search_by_params({}) - expect(results).to include(published_tutorial, draft_tutorial) - end - - it 'filters by search (title or body)' do - results = Tutorial.search_by_params(search: 'Getting Started') - expect(results).to include(published_tutorial) - expect(results).not_to include(draft_tutorial) - end - - it 'filters by search matching body content' do - results = Tutorial.search_by_params(search: 'facilitators') - expect(results).to include(draft_tutorial) - expect(results).not_to include(published_tutorial) - end - - it 'filters by title only' do - results = Tutorial.search_by_params(title: 'Advanced') - expect(results).to include(draft_tutorial) - expect(results).not_to include(published_tutorial) - end - - it 'filters by published param' do - results = Tutorial.search_by_params(published: 'true') - expect(results).to include(published_tutorial) - expect(results).not_to include(draft_tutorial) - end - - it 'chains search and published filters' do - results = Tutorial.search_by_params(search: 'Guide', published: 'true') - expect(results).to include(published_tutorial) - expect(results).not_to include(draft_tutorial) - end - end -end diff --git a/spec/models/video_recording_spec.rb b/spec/models/video_recording_spec.rb new file mode 100644 index 000000000..59a5dd678 --- /dev/null +++ b/spec/models/video_recording_spec.rb @@ -0,0 +1,43 @@ +require "rails_helper" + +RSpec.describe VideoRecording, type: :model do + describe ".search_by_params" do + let!(:published_video_recording) { create(:video_recording, :published, title: "Getting Started Guide", rhino_body: "Welcome to AWBW") } + let!(:draft_video_recording) { create(:video_recording, title: "Advanced Workshop Tips", rhino_body: "For experienced facilitators") } + + it "returns all when no params" do + results = VideoRecording.search_by_params({}) + expect(results).to include(published_video_recording, draft_video_recording) + end + + it "filters by search (title or body)" do + results = VideoRecording.search_by_params(search: "Getting Started") + expect(results).to include(published_video_recording) + expect(results).not_to include(draft_video_recording) + end + + it "filters by search matching body content" do + results = VideoRecording.search_by_params(search: "facilitators") + expect(results).to include(draft_video_recording) + expect(results).not_to include(published_video_recording) + end + + it "filters by title only" do + results = VideoRecording.search_by_params(title: "Advanced") + expect(results).to include(draft_video_recording) + expect(results).not_to include(published_video_recording) + end + + it "filters by published param" do + results = VideoRecording.search_by_params(published: "true") + expect(results).to include(published_video_recording) + expect(results).not_to include(draft_video_recording) + end + + it "chains search and published filters" do + results = VideoRecording.search_by_params(search: "Guide", published: "true") + expect(results).to include(published_video_recording) + expect(results).not_to include(draft_video_recording) + end + end +end diff --git a/spec/requests/bookmarks_spec.rb b/spec/requests/bookmarks_spec.rb index 1eb421b42..f30becd22 100644 --- a/spec/requests/bookmarks_spec.rb +++ b/spec/requests/bookmarks_spec.rb @@ -49,23 +49,23 @@ expect(response).to redirect_to(root_path) end - context "with tutorials" do - let(:tutorial) { create(:tutorial, :published) } + context "with video_recordings" do + let(:video_recording) { create(:video_recording, :published) } - it "cannot create a tutorial bookmark" do + it "cannot create a video_recording bookmark" do expect { post bookmarks_path, - params: { bookmark: { bookmarkable_id: tutorial.id, - bookmarkable_type: "Tutorial" } } + params: { bookmark: { bookmarkable_id: video_recording.id, + bookmarkable_type: "VideoRecording" } } }.not_to change(Bookmark, :count) expect(response).to redirect_to(root_path) end - it "cannot destroy a tutorial bookmark" do - tutorial_bookmark = create(:bookmark, user: regular_user, bookmarkable: tutorial) + it "cannot destroy a video_recording bookmark" do + video_recording_bookmark = create(:bookmark, user: regular_user, bookmarkable: video_recording) expect { - delete bookmark_path(tutorial_bookmark) + delete bookmark_path(video_recording_bookmark) }.not_to change(Bookmark, :count) expect(response).to redirect_to(root_path) @@ -100,9 +100,9 @@ expect(response.body).not_to include("value=\"Report\"") end - it "includes Video (Tutorial) in bookmark type dropdown" do + it "includes Video in bookmark type dropdown" do get personal_bookmarks_path - expect(response.body).to include(Tutorial.model_name.human) + expect(response.body).to include(VideoRecording.model_name.human) end it "can access personal bookmarks sorted by title" do @@ -150,22 +150,22 @@ expect(response).to redirect_to(root_path) end - context "with tutorials" do - let(:tutorial) { create(:tutorial, :published) } + context "with video_recordings" do + let(:video_recording) { create(:video_recording, :published) } - it "can create a tutorial bookmark" do + it "can create a video_recording bookmark" do expect { post bookmarks_path, - params: { bookmark: { bookmarkable_id: tutorial.id, - bookmarkable_type: "Tutorial" } }, + params: { bookmark: { bookmarkable_id: video_recording.id, + bookmarkable_type: "VideoRecording" } }, headers: turbo_headers }.to change(Bookmark, :count).by(1) end - it "can destroy their own tutorial bookmark" do - tutorial_bookmark = create(:bookmark, user: regular_user, bookmarkable: tutorial) + it "can destroy their own video_recording bookmark" do + video_recording_bookmark = create(:bookmark, user: regular_user, bookmarkable: video_recording) expect { - delete bookmark_path(tutorial_bookmark), headers: turbo_headers + delete bookmark_path(video_recording_bookmark), headers: turbo_headers }.to change(Bookmark, :count).by(-1) end end @@ -227,22 +227,22 @@ }.to change(Bookmark, :count).by(-1) end - context "with tutorials" do - let(:tutorial) { create(:tutorial, :published) } + context "with video_recordings" do + let(:video_recording) { create(:video_recording, :published) } - it "can create a tutorial bookmark" do + it "can create a video_recording bookmark" do expect { post bookmarks_path, - params: { bookmark: { bookmarkable_id: tutorial.id, - bookmarkable_type: "Tutorial" } }, + params: { bookmark: { bookmarkable_id: video_recording.id, + bookmarkable_type: "VideoRecording" } }, headers: turbo_headers }.to change(Bookmark, :count).by(1) end - it "can destroy any tutorial bookmark" do - tutorial_bookmark = create(:bookmark, user: other_user, bookmarkable: tutorial) + it "can destroy any video_recording bookmark" do + video_recording_bookmark = create(:bookmark, user: other_user, bookmarkable: video_recording) expect { - delete bookmark_path(tutorial_bookmark) + delete bookmark_path(video_recording_bookmark) }.to change(Bookmark, :count).by(-1) end end diff --git a/spec/requests/tutorials_spec.rb b/spec/requests/video_recordings_spec.rb similarity index 52% rename from spec/requests/tutorials_spec.rb rename to spec/requests/video_recordings_spec.rb index 17391497e..c38cde33e 100644 --- a/spec/requests/tutorials_spec.rb +++ b/spec/requests/video_recordings_spec.rb @@ -12,14 +12,14 @@ # of tools you can use to make these specs even more expressive, but we're # sticking to rails and rspec-rails APIs to keep things simple and stable. -RSpec.describe "/tutorials", type: :request do +RSpec.describe "/video_recordings", type: :request do # This should return the minimal set of attributes required to create a valid - # Tutorial. As you add validations to Tutorial, be sure to + # VideoRecording. As you add validations to VideoRecording, be sure to # adjust the attributes here as well. let(:valid_attributes) do { title: "How to Use the Home Page", - body: "

This tutorial walks through the main home page features.

", + body: "

This instructional video walks through the main home page features.

", youtube_url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ" } end @@ -40,58 +40,58 @@ describe "GET /index" do it "renders a successful response" do - Tutorial.create! valid_attributes - get tutorials_url + VideoRecording.create! valid_attributes + get video_recordings_url expect(response).to be_successful end end describe "GET /show" do it "renders a successful response" do - tutorial = Tutorial.create! valid_attributes - get tutorial_url(tutorial) + video_recording = VideoRecording.create! valid_attributes + get video_recording_url(video_recording) expect(response).to be_successful end end describe "GET /new" do it "renders a successful response" do - get new_tutorial_url + get new_video_recording_url expect(response).to be_successful end end describe "GET /edit" do it "renders a successful response" do - tutorial = Tutorial.create! valid_attributes - get edit_tutorial_url(tutorial) + video_recording = VideoRecording.create! valid_attributes + get edit_video_recording_url(video_recording) expect(response).to be_successful end end describe "POST /create" do context "with valid parameters" do - it "creates a new Tutorial" do + it "creates a new VideoRecording" do expect { - post tutorials_url, params: { tutorial: valid_attributes } - }.to change(Tutorial, :count).by(1) + post video_recordings_url, params: { video_recording: valid_attributes } + }.to change(VideoRecording, :count).by(1) end - it "redirects to the created tutorial" do - post tutorials_url, params: { tutorial: valid_attributes } - expect(response).to redirect_to(tutorial_url(Tutorial.last)) + it "redirects to the created video_recording" do + post video_recordings_url, params: { video_recording: valid_attributes } + expect(response).to redirect_to(video_recording_url(VideoRecording.last)) end end context "with invalid parameters" do - it "does not create a new Tutorial" do + it "does not create a new VideoRecording" do expect { - post tutorials_url, params: { tutorial: invalid_attributes } - }.to change(Tutorial, :count).by(0) + post video_recordings_url, params: { video_recording: invalid_attributes } + }.to change(VideoRecording, :count).by(0) end it "renders a response with 422 status (i.e. to display the 'new' template)" do - post tutorials_url, params: { tutorial: invalid_attributes } + post video_recordings_url, params: { video_recording: invalid_attributes } expect(response).to have_http_status(:unprocessable_content) end end @@ -105,42 +105,42 @@ ) end - it "updates the requested tutorial" do - tutorial = Tutorial.create! valid_attributes - patch tutorial_url(tutorial), params: { tutorial: new_attributes } - tutorial.reload + it "updates the requested video_recording" do + video_recording = VideoRecording.create! valid_attributes + patch video_recording_url(video_recording), params: { video_recording: new_attributes } + video_recording.reload skip("Add assertions for updated state") end - it "redirects to the updated tutorial" do - tutorial = Tutorial.create! valid_attributes - patch tutorial_url(tutorial), params: { tutorial: new_attributes } - tutorial.reload - expect(response).to redirect_to(tutorial_url(tutorial)) + it "redirects to the updated video_recording" do + video_recording = VideoRecording.create! valid_attributes + patch video_recording_url(video_recording), params: { video_recording: new_attributes } + video_recording.reload + expect(response).to redirect_to(video_recording_url(video_recording)) end end context "with invalid parameters" do it "renders a response with 422 status (i.e. to display the 'edit' template)" do - tutorial = Tutorial.create! valid_attributes - patch tutorial_url(tutorial), params: { tutorial: invalid_attributes } + video_recording = VideoRecording.create! valid_attributes + patch video_recording_url(video_recording), params: { video_recording: invalid_attributes } expect(response).to have_http_status(:unprocessable_content) end end end describe "DELETE /destroy" do - it "destroys the requested tutorial" do - tutorial = Tutorial.create! valid_attributes + it "destroys the requested video_recording" do + video_recording = VideoRecording.create! valid_attributes expect { - delete tutorial_url(tutorial) - }.to change(Tutorial, :count).by(-1) + delete video_recording_url(video_recording) + }.to change(VideoRecording, :count).by(-1) end - it "redirects to the tutorials list" do - tutorial = Tutorial.create! valid_attributes - delete tutorial_url(tutorial) - expect(response).to redirect_to(tutorials_url) + it "redirects to the video_recordings list" do + video_recording = VideoRecording.create! valid_attributes + delete video_recording_url(video_recording) + expect(response).to redirect_to(video_recordings_url) end end end diff --git a/spec/routing/tutorials_routing_spec.rb b/spec/routing/tutorials_routing_spec.rb deleted file mode 100644 index 61624b99e..000000000 --- a/spec/routing/tutorials_routing_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require "rails_helper" - -RSpec.describe TutorialsController, type: :routing do - describe "routing" do - it "routes to #index" do - expect(get: "/tutorials").to route_to("tutorials#index") - end - - it "routes to #new" do - expect(get: "/tutorials/new").to route_to("tutorials#new") - end - - it "routes to #show" do - expect(get: "/tutorials/1").to route_to("tutorials#show", id: "1") - end - - it "routes to #edit" do - expect(get: "/tutorials/1/edit").to route_to("tutorials#edit", id: "1") - end - - - it "routes to #create" do - expect(post: "/tutorials").to route_to("tutorials#create") - end - - it "routes to #update via PUT" do - expect(put: "/tutorials/1").to route_to("tutorials#update", id: "1") - end - - it "routes to #update via PATCH" do - expect(patch: "/tutorials/1").to route_to("tutorials#update", id: "1") - end - - it "routes to #destroy" do - expect(delete: "/tutorials/1").to route_to("tutorials#destroy", id: "1") - end - end -end diff --git a/spec/routing/video_recordings_routing_spec.rb b/spec/routing/video_recordings_routing_spec.rb new file mode 100644 index 000000000..78289b31b --- /dev/null +++ b/spec/routing/video_recordings_routing_spec.rb @@ -0,0 +1,37 @@ +require "rails_helper" + +RSpec.describe VideoRecordingsController, type: :routing do + describe "routing" do + it "routes /video_recordings to video_recordings#index" do + expect(get: "/video_recordings").to route_to("video_recordings#index") + end + + it "routes /video_recordings/new to video_recordings#new" do + expect(get: "/video_recordings/new").to route_to("video_recordings#new") + end + + it "routes /video_recordings/1 to video_recordings#show" do + expect(get: "/video_recordings/1").to route_to("video_recordings#show", id: "1") + end + + it "routes /video_recordings/1/edit to video_recordings#edit" do + expect(get: "/video_recordings/1/edit").to route_to("video_recordings#edit", id: "1") + end + + it "routes POST /video_recordings to video_recordings#create" do + expect(post: "/video_recordings").to route_to("video_recordings#create") + end + + it "routes PUT /video_recordings/1 to video_recordings#update" do + expect(put: "/video_recordings/1").to route_to("video_recordings#update", id: "1") + end + + it "routes PATCH /video_recordings/1 to video_recordings#update" do + expect(patch: "/video_recordings/1").to route_to("video_recordings#update", id: "1") + end + + it "routes DELETE /video_recordings/1 to video_recordings#destroy" do + expect(delete: "/video_recordings/1").to route_to("video_recordings#destroy", id: "1") + end + end +end diff --git a/spec/views/page_bg_class_alignment_spec.rb b/spec/views/page_bg_class_alignment_spec.rb index da368f997..30e45495b 100644 --- a/spec/views/page_bg_class_alignment_spec.rb +++ b/spec/views/page_bg_class_alignment_spec.rb @@ -31,7 +31,7 @@ "app/views/story_shares/index.html.erb" => "public", "app/views/tags/index.html.erb" => "public", "app/views/taggings/index.html.erb" => "public", - "app/views/tutorials/index.html.erb" => "public", + "app/views/video_recordings/index.html.erb" => "public", "app/views/workshop_variations/index.html.erb" => "public", "app/views/workshops/index.html.erb" => "public", @@ -55,7 +55,7 @@ "app/views/faqs/show.html.erb" => "admin-or-public-or-authpublished", "app/views/resources/show.html.erb" => "admin-or-public-or-authpublished", "app/views/stories/show.html.erb" => "admin-or-public-or-authpublished", - "app/views/tutorials/show.html.erb" => "admin-or-public-or-authpublished", + "app/views/video_recordings/show.html.erb" => "admin-or-public-or-authpublished", "app/views/workshop_variations/show.html.erb" => "admin-or-public-or-authpublished", "app/views/workshops/show.html.erb" => "admin-or-public-or-authpublished", "app/views/story_shares/show.html.erb" => "admin-or-public-or-authpublished", @@ -135,7 +135,7 @@ "app/views/resources/new.html.erb" => "admin-only bg-blue-100", "app/views/sectors/new.html.erb" => "admin-only bg-blue-100", "app/views/stories/new.html.erb" => "admin-only bg-blue-100", - "app/views/tutorials/new.html.erb" => "admin-only bg-blue-100", + "app/views/video_recordings/new.html.erb" => "admin-only bg-blue-100", "app/views/users/new.html.erb" => "admin-only bg-blue-100", "app/views/windows_types/new.html.erb" => "admin-only bg-blue-100", "app/views/workshop_variations/new.html.erb" => "admin-only bg-blue-100", @@ -154,7 +154,7 @@ "app/views/sectors/edit.html.erb" => "admin-only bg-blue-100", "app/views/stories/edit.html.erb" => "admin-only bg-blue-100", "app/views/story_ideas/edit.html.erb" => "admin-only bg-blue-100", - "app/views/tutorials/edit.html.erb" => "admin-only bg-blue-100", + "app/views/video_recordings/edit.html.erb" => "admin-only bg-blue-100", "app/views/users/edit.html.erb" => "admin-only bg-blue-100", "app/views/windows_types/edit.html.erb" => "admin-only bg-blue-100", "app/views/workshop_ideas/edit.html.erb" => "admin-only bg-blue-100", diff --git a/spec/views/tutorials/edit.html.erb_spec.rb b/spec/views/tutorials/edit.html.erb_spec.rb deleted file mode 100644 index 33e270a23..000000000 --- a/spec/views/tutorials/edit.html.erb_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'rails_helper' - -RSpec.describe "tutorials/edit", type: :view do - let(:admin) { create(:user, :admin) } - - let(:tutorial) { - sign_in admin - - Tutorial.create!( - title: "MyString", - body: "MyText", - featured: false, - published: false, - position: 1, - youtube_url: "MyString" - ).decorate - } - - before(:each) do - assign(:tutorial, tutorial) - assign(:categories_grouped, Category.includes(:category_type).published.order(:position, :name) - .group_by(&:category_type).select { |type, _| type.nil? || type.published? } - .sort_by { |type, _| type&.name.to_s.downcase }) - assign(:sectors, Sector.published.order(:name)) - end - - it "renders the edit tutorial form" do - render - - assert_select "form[action=?][method=?]", tutorial_path(tutorial), "post" do - assert_select "textarea[name=?]", "tutorial[title]" - assert_select "input[name=?][type=?]", "tutorial[rhino_body]", "hidden" - assert_select "input[name=?][type=checkbox]", "tutorial[published]" - assert_select "input[name=?][type=checkbox]", "tutorial[featured]" - assert_select "input[name=?]", "tutorial[position]" - assert_select "textarea[name=?]", "tutorial[youtube_url]" - end - end -end diff --git a/spec/views/tutorials/new.html.erb_spec.rb b/spec/views/tutorials/new.html.erb_spec.rb deleted file mode 100644 index 3cdfeb6c3..000000000 --- a/spec/views/tutorials/new.html.erb_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'rails_helper' - -RSpec.describe "tutorials/new", type: :view do - let(:admin) { create(:user, :admin) } - - before(:each) do - sign_in admin - - assign(:tutorial, Tutorial.new( - title: "MyString", - body: "MyText", - featured: false, - published: false, - position: 1, - youtube_url: "MyString" - ).decorate) - assign(:categories_grouped, Category.includes(:category_type).published.order(:position, :name) - .group_by(&:category_type).select { |type, _| type.nil? || type.published? } - .sort_by { |type, _| type&.name.to_s.downcase }) - assign(:sectors, Sector.published.order(:name)) - end - - it "renders new tutorial form" do - render - - assert_select "form[action=?][method=?]", tutorials_path, "post" do - assert_select "textarea[name=?]", "tutorial[title]" - assert_select "input[name=?][type=?]", "tutorial[rhino_body]", "hidden" - assert_select "input[name=?][type=checkbox]", "tutorial[published]" - assert_select "input[name=?][type=checkbox]", "tutorial[featured]" - assert_select "input[name=?]", "tutorial[position]" - assert_select "textarea[name=?]", "tutorial[youtube_url]" - end - end -end diff --git a/spec/views/video_recordings/edit.html.erb_spec.rb b/spec/views/video_recordings/edit.html.erb_spec.rb new file mode 100644 index 000000000..e0d0deb53 --- /dev/null +++ b/spec/views/video_recordings/edit.html.erb_spec.rb @@ -0,0 +1,39 @@ +require "rails_helper" + +RSpec.describe "video_recordings/edit", type: :view do + let(:admin) { create(:user, :admin) } + + let(:video_recording) { + sign_in admin + + VideoRecording.create!( + title: "MyString", + youtube_url: "MyString", + featured: false, + published: false, + position: 1, + is_instructional: false + ).decorate + } + + before(:each) do + assign(:video_recording, video_recording) + assign(:categories_grouped, Category.includes(:category_type).published.order(:position, :name) + .group_by(&:category_type).select { |type, _| type.nil? || type.published? } + .sort_by { |type, _| type&.name.to_s.downcase }) + assign(:sectors, Sector.published.order(:name)) + end + + it "renders the edit video recording form" do + render + + assert_select "form[action=?][method=?]", video_recording_path(video_recording), "post" do + assert_select "textarea[name=?]", "video_recording[title]" + assert_select "input[name=?][type=?]", "video_recording[rhino_body]", "hidden" + assert_select "input[name=?][type=checkbox]", "video_recording[published]" + assert_select "input[name=?][type=checkbox]", "video_recording[featured]" + assert_select "input[name=?]", "video_recording[position]" + assert_select "textarea[name=?]", "video_recording[youtube_url]" + end + end +end diff --git a/spec/views/tutorials/index.html.erb_spec.rb b/spec/views/video_recordings/index.html.erb_spec.rb similarity index 64% rename from spec/views/tutorials/index.html.erb_spec.rb rename to spec/views/video_recordings/index.html.erb_spec.rb index a2956b965..91b663829 100644 --- a/spec/views/tutorials/index.html.erb_spec.rb +++ b/spec/views/video_recordings/index.html.erb_spec.rb @@ -1,12 +1,12 @@ require 'rails_helper' -RSpec.describe "tutorials/index", type: :view do +RSpec.describe "video_recordings/index", type: :view do let(:admin) { create(:user, :admin) } before(:each) do sign_in admin - Tutorial.create!( + VideoRecording.create!( title: "Title1", body: "MyText", featured: false, @@ -14,7 +14,7 @@ position: 2, youtube_url: "Youtube Url" ) - Tutorial.create!( + VideoRecording.create!( title: "Title2", body: "MyText", featured: false, @@ -22,25 +22,26 @@ position: 2, youtube_url: "Youtube Url" ) - assign(:tutorials, Tutorial.all.decorate) + assign(:video_recordings, VideoRecording.all.decorate) assign(:sectors, Sector.published.order(:name)) assign(:category_types, CategoryType.published.where(story_specific: false).order(:name).decorate) + assign(:video_type, "instructional") end it "renders the search filters and turbo frame" do render - assert_select "turbo-frame#tutorials_results" + assert_select "turbo-frame#video_recordings_results" assert_select "input[name=search]" end end -RSpec.describe "tutorials/index_lazy", type: :view do +RSpec.describe "video_recordings/index_lazy", type: :view do let(:admin) { create(:user, :admin) } before(:each) do sign_in admin - Tutorial.create!( + VideoRecording.create!( title: "Title1", body: "MyText", featured: false, @@ -48,7 +49,7 @@ position: 2, youtube_url: "Youtube Url" ) - Tutorial.create!( + VideoRecording.create!( title: "Title2", body: "MyText", featured: false, @@ -56,12 +57,13 @@ position: 2, youtube_url: "Youtube Url" ) - assign(:tutorials, Tutorial.all.paginate(page: 1, per_page: 25).decorate) + assign(:video_recordings, VideoRecording.all.paginate(page: 1, per_page: 25).decorate) + assign(:video_type, "instructional") end - it "renders the tutorial titles inside the turbo frame" do + it "renders the video recording titles inside the turbo frame" do render - assert_select "turbo-frame#tutorials_results" + assert_select "turbo-frame#video_recordings_results" expect(rendered).to match(/Title1/) expect(rendered).to match(/Title2/) end diff --git a/spec/views/video_recordings/new.html.erb_spec.rb b/spec/views/video_recordings/new.html.erb_spec.rb new file mode 100644 index 000000000..c755ab5f0 --- /dev/null +++ b/spec/views/video_recordings/new.html.erb_spec.rb @@ -0,0 +1,35 @@ +require "rails_helper" + +RSpec.describe "video_recordings/new", type: :view do + let(:admin) { create(:user, :admin) } + + before(:each) do + sign_in admin + + assign(:video_recording, VideoRecording.new( + title: "MyString", + youtube_url: "MyString", + featured: false, + published: false, + position: 1, + is_instructional: false + ).decorate) + assign(:categories_grouped, Category.includes(:category_type).published.order(:position, :name) + .group_by(&:category_type).select { |type, _| type.nil? || type.published? } + .sort_by { |type, _| type&.name.to_s.downcase }) + assign(:sectors, Sector.published.order(:name)) + end + + it "renders new video recording form" do + render + + assert_select "form[action=?][method=?]", video_recordings_path, "post" do + assert_select "textarea[name=?]", "video_recording[title]" + assert_select "input[name=?][type=?]", "video_recording[rhino_body]", "hidden" + assert_select "input[name=?][type=checkbox]", "video_recording[published]" + assert_select "input[name=?][type=checkbox]", "video_recording[featured]" + assert_select "input[name=?]", "video_recording[position]" + assert_select "textarea[name=?]", "video_recording[youtube_url]" + end + end +end diff --git a/spec/views/tutorials/show.html.erb_spec.rb b/spec/views/video_recordings/show.html.erb_spec.rb similarity index 55% rename from spec/views/tutorials/show.html.erb_spec.rb rename to spec/views/video_recordings/show.html.erb_spec.rb index af95e6dd2..5028f6fec 100644 --- a/spec/views/tutorials/show.html.erb_spec.rb +++ b/spec/views/video_recordings/show.html.erb_spec.rb @@ -1,25 +1,23 @@ -require 'rails_helper' +require "rails_helper" -RSpec.describe "tutorials/show", type: :view do +RSpec.describe "video_recordings/show", type: :view do let(:admin) { create(:user, :admin) } before(:each) do sign_in admin - assign(:tutorial, Tutorial.create!( + assign(:video_recording, VideoRecording.create!( title: "Title", - body: "MyText", - rhino_body: "MyText", + youtube_url: "Youtube Url", featured: false, published: false, position: 2, - youtube_url: "Youtube Url" + is_instructional: false ).decorate) end it "renders attributes in

" do render expect(rendered).to match(/Title/) - expect(rendered).to match(/MyText/) end end