From f0e9079635df23f6a8a64bfc0cf0be9ee1be9d5a Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Tue, 27 Jan 2026 11:54:52 -0500 Subject: [PATCH 01/20] Update gemspec --- michel.gemspec | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/michel.gemspec b/michel.gemspec index ee8225e..679d8e4 100644 --- a/michel.gemspec +++ b/michel.gemspec @@ -8,15 +8,11 @@ Gem::Specification.new do |spec| spec.authors = ["Sally Hall", "Aji Slater"] spec.email = ["sally@thoughtbot.com", "aji.slater@gmail.com"] - spec.summary = "This is the summary" - spec.description = "Write a longer description or delete this line." + spec.summary = "Generator to help with appointment scheduling" spec.homepage = "https://github.com/thoughtbot/michel/" spec.required_ruby_version = ">= 3.0.0" - spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'" - spec.metadata["homepage_uri"] = spec.homepage - spec.metadata["source_code_uri"] = "https://github.com/thoughtbot/michel/" # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." # Specify which files should be added to the gem when it is released. From 806e2d5886ac160aa2137cd3d0513acc235c1a9c Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Tue, 27 Jan 2026 16:35:19 -0500 Subject: [PATCH 02/20] Add documentation --- .github/workflows/dynamic-security.yml | 19 ++++ CODE_OF_CONDUCT.md | 134 +------------------------ CONTRIBUTING.md | 37 +++++++ LICENSE | 4 +- NEWS.md | 51 ++++++++++ README.md | 74 +++++++++----- RELEASING.md | 43 ++++++++ SECURITY.md | 2 + spec/example-app/README.md | 24 ----- 9 files changed, 204 insertions(+), 184 deletions(-) create mode 100644 .github/workflows/dynamic-security.yml create mode 100644 CONTRIBUTING.md create mode 100644 NEWS.md create mode 100644 RELEASING.md create mode 100644 SECURITY.md delete mode 100644 spec/example-app/README.md diff --git a/.github/workflows/dynamic-security.yml b/.github/workflows/dynamic-security.yml new file mode 100644 index 0000000..26a424d --- /dev/null +++ b/.github/workflows/dynamic-security.yml @@ -0,0 +1,19 @@ +name: update-security + +on: + push: + paths: + - SECURITY.md + branches: + - main + workflow_dispatch: + +jobs: + update-security: + permissions: + contents: write + pull-requests: write + pages: write + uses: thoughtbot/templates/.github/workflows/dynamic-security.yaml@main + secrets: + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 67fe8ce..848a59a 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,132 +1,6 @@ -# Contributor Covenant Code of Conduct +# Code of conduct -## Our Pledge +By participating in this project, you agree to abide by the +[thoughtbot code of conduct][1]. -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, caste, color, religion, or sexual -identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall - community - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or advances of - any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email address, - without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official email address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -[INSERT CONTACT METHOD]. -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of -actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or permanent -ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the -community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.1, available at -[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. - -Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. - -For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at -[https://www.contributor-covenant.org/translations][translations]. - -[homepage]: https://www.contributor-covenant.org -[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html -[Mozilla CoC]: https://github.com/mozilla/diversity -[FAQ]: https://www.contributor-covenant.org/faq -[translations]: https://www.contributor-covenant.org/translations +[1]: https://thoughtbot.com/open-source-code-of-conduct diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..c623aba --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,37 @@ +# Contributing + +We love contributions from everyone. +By participating in this project, +you agree to abide by the thoughtbot [code of conduct]. + + [code of conduct]: https://thoughtbot.com/open-source-code-of-conduct + +We expect everyone to follow the code of conduct +anywhere in thoughtbot's project codebases, +issue trackers, chatrooms, and mailing lists. + +## Contributing Code + +$(INSTALL_DEPENDENCIES) + +Fork the repo. + +Make sure the tests pass: + + $(TEST_RUNNER) + +Make your change, with new passing tests. Follow the [style guide][style]. + + [style]: https://github.com/thoughtbot/guides/tree/master/style + +Mention how your changes affect the project to other developers and users in the +`NEWS.md` file. + +Push to your fork. Write a [good commit message][commit]. Submit a pull request. + + [commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html + +Others will give constructive feedback. +This is a time for discussion and improvements, +and making the necessary changes will be required before we can +merge the contribution. diff --git a/LICENSE b/LICENSE index 55ac165..951cca8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,4 @@ -The MIT License - -Copyright (c) thoughtbot, inc. +Copyright (c) Sally Hall and thoughtbot, inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..532aa3b --- /dev/null +++ b/NEWS.md @@ -0,0 +1,51 @@ +# News + +All notable changes to this project will be documented in this file. + +The format is loosely based on [Keep a Changelog] and this project adheres to +[Semantic Versioning]. + + [Keep a Changelog]: http://keepachangelog.com/ + [Semantic Versioning]: http://semver.org/ + +## [Unreleased] + +### Added + +- This is for new features. + +### Changed + +- This is for changes in existing functionality. + +### Deprecated + +- This is for once-stable features removed in upcoming releases. + +### Removed + +- This is for deprecated features removed in this release. + +### Fixed + +- This is for any bug fixes. + +### Security + +- This is to invite users to upgrade in case of vulnerabilities. + + [Unreleased]: https://github.com/thoughtbot/michel/compare/v0.2.0...HEAD + +## [0.0.2] - 2016-02-01 + +### Added + +- This version to show how each version title is linked (`## [0.0.2]`). + + [0.2.0]: https://github.com/thoughtbot/michel/compare/v0.1.0...v0.2.0 + +## 0.0.1 - 2016-01-01 + +### Added + +- This `NEWS.md` file. diff --git a/README.md b/README.md index e335443..111cb15 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,59 @@ # Michel -TODO: Delete this and the text below, and describe your gem - -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/michel`. To experiment with that code, run `bin/console` for an interactive prompt. - -## Installation - -TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org. - -Install the gem and add to the application's Gemfile by executing: - -```bash -bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG -``` - -If bundler is not being used to manage dependencies, install the gem by executing: - -```bash -gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG -``` +Find available time slots quickly with a materialized view. ## Usage -TODO: Write usage instructions here +### Install Michel + `gem michel` + `rails generate michel:install` + TODO: Still need to create this generator + +### Configure + Michel needs three existing classes to function: + * Resource Class - The resource that is occupied by a booking, ex: Physician, Room, Instructor. This resource is assumed to be available for only one booking at a time. A resource has many bookings and many availabilities. + * Booking Class - The event that is scheduled for a resource, ex: Appointment. The resource is unavailable for the duration of the booking. It is required to have the following attributes: + * `start_time` - a DateTime indicating the start time of the booking. + * `duration` - an integer representing the number of minutes the booking lasts. + * a reference to the id of the resource class + The booking class is also used to block off unavailable times. It is recommended that you have a booking type to distinguish between appointments and other events. + * Availability Class - The weekly schedule during which a resource is available for a booking, which is required to have the following attributes: + * `timezone` - a string representing the time zone in which the availability is configured, ex: 'UTC' + * `weekday` - an integer representing the weekday, starting with Monday = 1 + * `start_time` - a string representing the beginning time of the availability in the configured timezone in 24-hour format, ex: '09:00' + * `end_time` - a string representing the end time of the availability in the configured timezone in 24-hour format, ex: '017:00' + * a reference to the id of the resource class + There should be one availability record for each continuous block of available time during a week. For example, if a resource is available from 9-5, M-Th, with a 1 hour break from 12-1, that is represented by eight availabilities: one for each day from 9-12 and another for each day from 1-5. + +### Run generator + To generate the database view and necessary supporting code, run `rails generate michel:view`. This will: + 1. Generate a migration to add an index to the booking class table on the resource id and start_time. + 2. Generate a Scenic model for available time slots. + 3. Generate a sql file with the view to back the scenic model. + 4. Insert associations between the existing classes and the generated `AvailableTimeSlot` class. + + Once the generator is finished, run `rails db:migrate` to run the generated migrations. + +### Start Scheduling. + To find available time slots, search for matching `AvailableTimeSlots`. Each slot has a `start_time` and an `end_time` and belongs to an `availability` and a `resource`. + + To refresh the materialized view, run `AvailableTimeSlot.refresh`. The view should be refreshed when a booking is created, updated, or deleted, or when availability changes. -## Development +## Contributing -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. +See the [CONTRIBUTING] document. +Thank you, [contributors]! -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). +[CONTRIBUTING]: CONTRIBUTING.md +[contributors]: https://github.com/thoughtbot/michel/graphs/contributors -## Contributing +## License -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/michel. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/michel/blob/main/CODE_OF_CONDUCT.md). +Michel is Copyright (c) thoughtbot, inc. +It is free software, and may be redistributed +under the terms specified in the [LICENSE] file. -## Code of Conduct +[LICENSE]: /LICENSE -Everyone interacting in the Michel project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/michel/blob/main/CODE_OF_CONDUCT.md). + + diff --git a/RELEASING.md b/RELEASING.md new file mode 100644 index 0000000..637a458 --- /dev/null +++ b/RELEASING.md @@ -0,0 +1,43 @@ +# Releasing + +## 1. Update version file accordingly + +Include an RC (release candidate) number if appropriate, e.g. 2.0.0.rc. + +## 2. Update `NEWS.md` or `CHANGELOG.md` to reflect the changes since last release + +You can copy [GitHub automatically generated release notes] for this step. + +## 3. Commit changes + +There shouldn't be code changes, and thus CI doesn't need to run. Add "[ci skip]" to the commit message. + +## 4. Tag the release: `git tag -s vVERSION` + +We recommend the [_quick guide on how to sign a release_] from git ready. + +## 5. Push changes + +Push the changes with `git push --tags` + +## 6. Build and publish + +```bash +gem build project-name.gemspec +gem push project-name-*.gem +``` + +If the project is hosted on RubyGems, consider using [RubyGems Trusted Publication] to automatically +push the release using a GitHub action. + +## 7. Add a new GitHub release using the recent `NEWS.md` or `CHANGELOG.md` as the content + +Sample URL: https://github.com/thoughtbot/project-name/releases/new?tag=vVERSION + +## 8. Announce the new release + +Make sure to say "thank you" to the contributors who helped shape this version! + +[RubyGems Trusted Publication]: https://github.com/rubygems/release-gem +[_quick guide on how to sign a release_]: https://gitready.com/advanced/2014/11/02/gpg-sign-releases.html +[GitHub automatically generated release notes]: https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#about-automatically-generated-release-notes diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..9b63758 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,2 @@ + + diff --git a/spec/example-app/README.md b/spec/example-app/README.md deleted file mode 100644 index 7db80e4..0000000 --- a/spec/example-app/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# README - -This README would normally document whatever steps are necessary to get the -application up and running. - -Things you may want to cover: - -* Ruby version - -* System dependencies - -* Configuration - -* Database creation - -* Database initialization - -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... From 449fafabf93ec837f25e6407423ba18365bfd7fa Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 10:41:49 -0500 Subject: [PATCH 03/20] add debug gem --- Gemfile | 1 + Gemfile.lock | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index 5fb87b2..a696592 100644 --- a/Gemfile +++ b/Gemfile @@ -13,3 +13,4 @@ gem "pg", "~> 1.1" gem "bundler-audit", ">= 0.7.0", require: false gem "database_cleaner" gem "ammeter" +gem "debug" diff --git a/Gemfile.lock b/Gemfile.lock index d27381a..8631382 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -102,6 +102,9 @@ GEM database_cleaner-core (~> 2.0) database_cleaner-core (2.0.1) date (3.5.1) + debug (1.11.1) + irb (~> 1.10) + reline (>= 0.3.8) diff-lcs (1.6.2) drb (2.2.3) erb (6.0.1) @@ -310,6 +313,7 @@ DEPENDENCIES ammeter bundler-audit (>= 0.7.0) database_cleaner + debug michel! pg (~> 1.1) rails (~> 8.0.2, >= 8.0.2.1) From 934469bafad45c7c8e904f43fd5ddb4a0f2428b9 Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 10:42:52 -0500 Subject: [PATCH 04/20] Add install generator --- lib/generators/michel/install/install_generator.rb | 13 +++++++++++++ lib/generators/michel/install/templates/michel.rb | 5 +++++ .../view}/templates/belongs_to_associations.erb | 0 .../view}/templates/has_many_associations.erb | 0 .../{ => michel/view}/templates/index_migration.erb | 0 lib/generators/{ => michel/view}/templates/view.erb | 0 .../view/view_generator.rb} | 2 +- ...hel_generator_spec.rb => view_generator_spec.rb} | 6 +++--- 8 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 lib/generators/michel/install/install_generator.rb create mode 100644 lib/generators/michel/install/templates/michel.rb rename lib/generators/{ => michel/view}/templates/belongs_to_associations.erb (100%) rename lib/generators/{ => michel/view}/templates/has_many_associations.erb (100%) rename lib/generators/{ => michel/view}/templates/index_migration.erb (100%) rename lib/generators/{ => michel/view}/templates/view.erb (100%) rename lib/generators/{michel_generator.rb => michel/view/view_generator.rb} (97%) rename spec/generators/{michel_generator_spec.rb => view_generator_spec.rb} (94%) diff --git a/lib/generators/michel/install/install_generator.rb b/lib/generators/michel/install/install_generator.rb new file mode 100644 index 0000000..5e6148c --- /dev/null +++ b/lib/generators/michel/install/install_generator.rb @@ -0,0 +1,13 @@ +require "rails/generators/base" +require "scenic" +module Michel + module Generators + class InstallGenerator < Rails::Generators::Base + source_root File.expand_path("/templates", __FILE__) + + def create_initializer + copy_file "michel.rb", "config/initializers/michel.rb" + end + end + end +end diff --git a/lib/generators/michel/install/templates/michel.rb b/lib/generators/michel/install/templates/michel.rb new file mode 100644 index 0000000..b9afe67 --- /dev/null +++ b/lib/generators/michel/install/templates/michel.rb @@ -0,0 +1,5 @@ +Michel.setup do |config| + config.resource_class_name = "Resource" + config.booking_class_name = "Booking" + config.availability_class_name = "Availability" +end diff --git a/lib/generators/templates/belongs_to_associations.erb b/lib/generators/michel/view/templates/belongs_to_associations.erb similarity index 100% rename from lib/generators/templates/belongs_to_associations.erb rename to lib/generators/michel/view/templates/belongs_to_associations.erb diff --git a/lib/generators/templates/has_many_associations.erb b/lib/generators/michel/view/templates/has_many_associations.erb similarity index 100% rename from lib/generators/templates/has_many_associations.erb rename to lib/generators/michel/view/templates/has_many_associations.erb diff --git a/lib/generators/templates/index_migration.erb b/lib/generators/michel/view/templates/index_migration.erb similarity index 100% rename from lib/generators/templates/index_migration.erb rename to lib/generators/michel/view/templates/index_migration.erb diff --git a/lib/generators/templates/view.erb b/lib/generators/michel/view/templates/view.erb similarity index 100% rename from lib/generators/templates/view.erb rename to lib/generators/michel/view/templates/view.erb diff --git a/lib/generators/michel_generator.rb b/lib/generators/michel/view/view_generator.rb similarity index 97% rename from lib/generators/michel_generator.rb rename to lib/generators/michel/view/view_generator.rb index 4253cc6..e0f9da7 100644 --- a/lib/generators/michel_generator.rb +++ b/lib/generators/michel/view/view_generator.rb @@ -2,7 +2,7 @@ require "scenic" module Michel module Generators - class MichelGenerator < Rails::Generators::Base + class ViewGenerator < Rails::Generators::Base source_root File.expand_path("templates", __dir__) include Scenic diff --git a/spec/generators/michel_generator_spec.rb b/spec/generators/view_generator_spec.rb similarity index 94% rename from spec/generators/michel_generator_spec.rb rename to spec/generators/view_generator_spec.rb index f2c7271..e0ff3a4 100644 --- a/spec/generators/michel_generator_spec.rb +++ b/spec/generators/view_generator_spec.rb @@ -7,7 +7,7 @@ config.availability_class_name = "PhysicianAvailability" end - Rails::Generators.invoke("michel") + Rails::Generators.invoke("michel:view") Scenic.load ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).migrate @@ -16,7 +16,7 @@ after(:all) do ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).rollback(2) - Rails::Generators.invoke("michel", [], behavior: :revoke) + Rails::Generators.invoke("michel:view", [], behavior: :revoke) end it "generates available time slots" do @@ -31,8 +31,8 @@ ) Scenic.database.refresh_materialized_view("available_time_slots", concurrently: false) - slots = AvailableTimeSlot.all + expect(slots).not_to be_empty expect(slots.first.start_time.hour).to eq(9) end From 642c29af081bc1c07045d931b113f3736e14a693 Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 11:09:19 -0500 Subject: [PATCH 05/20] Install generator spec --- .../michel/install/install_generator.rb | 2 +- michel.gemspec | 9 ++------- .../michel/install/install_generator_spec.rb | 18 ++++++++++++++++++ .../{ => michel/view}/view_generator_spec.rb | 8 +++++--- 4 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 spec/generators/michel/install/install_generator_spec.rb rename spec/generators/{ => michel/view}/view_generator_spec.rb (91%) diff --git a/lib/generators/michel/install/install_generator.rb b/lib/generators/michel/install/install_generator.rb index 5e6148c..70ef1f2 100644 --- a/lib/generators/michel/install/install_generator.rb +++ b/lib/generators/michel/install/install_generator.rb @@ -3,7 +3,7 @@ module Michel module Generators class InstallGenerator < Rails::Generators::Base - source_root File.expand_path("/templates", __FILE__) + source_root File.expand_path("../templates", __FILE__) def create_initializer copy_file "michel.rb", "config/initializers/michel.rb" diff --git a/michel.gemspec b/michel.gemspec index 679d8e4..37b4b31 100644 --- a/michel.gemspec +++ b/michel.gemspec @@ -17,13 +17,8 @@ Gem::Specification.new do |spec| # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - gemspec = File.basename(__FILE__) - spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls| - ls.readlines("\x0", chomp: true).reject do |f| - (f == gemspec) || - f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile]) - end - end + + spec.files = `git ls-files`.split("\n") spec.bindir = "exe" spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] diff --git a/spec/generators/michel/install/install_generator_spec.rb b/spec/generators/michel/install/install_generator_spec.rb new file mode 100644 index 0000000..27e3f77 --- /dev/null +++ b/spec/generators/michel/install/install_generator_spec.rb @@ -0,0 +1,18 @@ +require "spec_helper" +require "generators/michel/install/install_generator" + +RSpec.describe Michel::Generators::InstallGenerator, :generator do + it "generates initializer file" do + destination File.expand_path("../../../../../tmp", __FILE__) + prepare_destination + + run_generator + initializer = file("config/initializers/michel.rb") + + # is_expected_to contain - verifies the file's contents + expect(initializer).to contain(/Michel.setup do |config|/) + expect(initializer).to contain(/config.resource_class_name = "Resource"/) + expect(initializer).to contain(/config.booking_class_name = "Booking"/) + expect(initializer).to contain(/config.availability_class_name = "Availability"/) + end +end diff --git a/spec/generators/view_generator_spec.rb b/spec/generators/michel/view/view_generator_spec.rb similarity index 91% rename from spec/generators/view_generator_spec.rb rename to spec/generators/michel/view/view_generator_spec.rb index e0ff3a4..750d670 100644 --- a/spec/generators/view_generator_spec.rb +++ b/spec/generators/michel/view/view_generator_spec.rb @@ -1,5 +1,7 @@ require "spec_helper" -RSpec.describe "Michel materialized view", type: :generator do +require "generators/michel/view/view_generator" + +RSpec.describe Michel::Generators::ViewGenerator, :generator do before(:all) do Michel.setup do |config| config.resource_class_name = "Physician" @@ -7,7 +9,7 @@ config.availability_class_name = "PhysicianAvailability" end - Rails::Generators.invoke("michel:view") + run_generator Scenic.load ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).migrate @@ -16,7 +18,7 @@ after(:all) do ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).rollback(2) - Rails::Generators.invoke("michel:view", [], behavior: :revoke) + run_generator [], behavior: :revoke end it "generates available time slots" do From 6f324ceee5ba5cc5b0f4a69fc0c9724f7470db9c Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 11:57:14 -0500 Subject: [PATCH 06/20] railtie? --- README.md | 4 +++- .../michel/view/templates/index_migration.erb | 2 +- lib/michel.rb | 1 + lib/michel/railtie.rb | 13 +++++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 lib/michel/railtie.rb diff --git a/README.md b/README.md index 111cb15..7eb41b1 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Find available time slots quickly with a materialized view. ### Install Michel `gem michel` `rails generate michel:install` - TODO: Still need to create this generator + ### Configure Michel needs three existing classes to function: @@ -25,6 +25,8 @@ Find available time slots quickly with a materialized view. * a reference to the id of the resource class There should be one availability record for each continuous block of available time during a week. For example, if a resource is available from 9-5, M-Th, with a 1 hour break from 12-1, that is represented by eight availabilities: one for each day from 9-12 and another for each day from 1-5. + Configure the class names in `config/initializers/michel.rb` + ### Run generator To generate the database view and necessary supporting code, run `rails generate michel:view`. This will: 1. Generate a migration to add an index to the booking class table on the resource id and start_time. diff --git a/lib/generators/michel/view/templates/index_migration.erb b/lib/generators/michel/view/templates/index_migration.erb index fe97821..2e19d6b 100644 --- a/lib/generators/michel/view/templates/index_migration.erb +++ b/lib/generators/michel/view/templates/index_migration.erb @@ -2,7 +2,7 @@ reversible do |direction| direction.up do execute <<-SQL - CREATE EXTENSION btree_gist; + CREATE EXTENSION IF NOT EXISTS btree_gist; CREATE INDEX on <%=Michel.booking_class_table_name%> using gist (<%=Michel.resource_class_foreign_id%>, tsrange(start_time, start_time + interval '1 minute' * duration, '()')); SQL end diff --git a/lib/michel.rb b/lib/michel.rb index f33858e..174a885 100644 --- a/lib/michel.rb +++ b/lib/michel.rb @@ -1,4 +1,5 @@ require "zeitwerk" +require "michel/railtie" if defined?(Rails) loader = Zeitwerk::Loader.for_gem loader.ignore("#{__dir__}/generators") diff --git a/lib/michel/railtie.rb b/lib/michel/railtie.rb new file mode 100644 index 0000000..67b0336 --- /dev/null +++ b/lib/michel/railtie.rb @@ -0,0 +1,13 @@ +# lib/michel/railtie.rb +module Michel + class Railtie < Rails::Railtie + initializer "michel.load_scenic" do + require "scenic" + require "scenic/statements" + + ActiveSupport.on_load(:active_record) do + ActiveRecord::Migration.include Scenic::Statements + end + end + end +end From a76d0cba2ddc6fa38fb2eb2ce5275f8627b4a619 Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 12:39:18 -0500 Subject: [PATCH 07/20] make view migration reversible --- lib/generators/michel/view/templates/view_migration.rb | 3 +++ lib/generators/michel/view/view_generator.rb | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 lib/generators/michel/view/templates/view_migration.rb diff --git a/lib/generators/michel/view/templates/view_migration.rb b/lib/generators/michel/view/templates/view_migration.rb new file mode 100644 index 0000000..be6527b --- /dev/null +++ b/lib/generators/michel/view/templates/view_migration.rb @@ -0,0 +1,3 @@ +def down + drop_view :available_time_slots, materialized: true +end diff --git a/lib/generators/michel/view/view_generator.rb b/lib/generators/michel/view/view_generator.rb index e0f9da7..3562324 100644 --- a/lib/generators/michel/view/view_generator.rb +++ b/lib/generators/michel/view/view_generator.rb @@ -22,6 +22,11 @@ def create_scenic_model puts "Creating scenic model available_time_slot" invoke "scenic:model", ["available_time_slot"], {"materialized" => true, "test_framework" => false} + + Dir.glob(Rails.root.join("db/migrate/*create_available_time_slots.rb")).each do |file| + gsub_file file, /change/, "up" + inject_into_class file, "CreateAvailableTimeSlots", template_content("view_migration.rb") + end end def create_sql_file From 19dffc49dd226c8ed574365334010709f076fc7f Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 13:23:51 -0500 Subject: [PATCH 08/20] Just make them install scenic --- README.md | 2 ++ .../view/templates/belongs_to_associations.erb | 4 ++++ .../michel/view/templates/view_migration.rb | 11 ++++++++--- lib/generators/michel/view/view_generator.rb | 2 +- lib/michel.rb | 1 - lib/michel/railtie.rb | 13 ------------- 6 files changed, 15 insertions(+), 18 deletions(-) delete mode 100644 lib/michel/railtie.rb diff --git a/README.md b/README.md index 7eb41b1..5d689f3 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,8 @@ Find available time slots quickly with a materialized view. ## Usage ### Install Michel + In order to run the migrations, you must also install Scenic + `gem scenic` `gem michel` `rails generate michel:install` diff --git a/lib/generators/michel/view/templates/belongs_to_associations.erb b/lib/generators/michel/view/templates/belongs_to_associations.erb index c0f6660..801fc9f 100644 --- a/lib/generators/michel/view/templates/belongs_to_associations.erb +++ b/lib/generators/michel/view/templates/belongs_to_associations.erb @@ -1,2 +1,6 @@ belongs_to :<%=Michel.availability_class_symbol%> belongs_to :<%=Michel.resource_class_symbol%> + + def self.refresh + Scenic.database.refresh_materialized_view(table_name, concurrently: false, cascade: false) + end diff --git a/lib/generators/michel/view/templates/view_migration.rb b/lib/generators/michel/view/templates/view_migration.rb index be6527b..8fed4ae 100644 --- a/lib/generators/michel/view/templates/view_migration.rb +++ b/lib/generators/michel/view/templates/view_migration.rb @@ -1,3 +1,8 @@ -def down - drop_view :available_time_slots, materialized: true -end + unless defined?(Scenic) + raise "Scenic gem must be included in the Gemfile to run this migration" + end + def down + drop_view :available_time_slots, materialized: true + end + + \ No newline at end of file diff --git a/lib/generators/michel/view/view_generator.rb b/lib/generators/michel/view/view_generator.rb index 3562324..b4aa92d 100644 --- a/lib/generators/michel/view/view_generator.rb +++ b/lib/generators/michel/view/view_generator.rb @@ -21,7 +21,7 @@ def create_scenic_model self.destination_root = Rails.root puts "Creating scenic model available_time_slot" - invoke "scenic:model", ["available_time_slot"], {"materialized" => true, "test_framework" => false} + invoke "scenic:model", ["available_time_slots"], {"materialized" => true, "test_framework" => false} Dir.glob(Rails.root.join("db/migrate/*create_available_time_slots.rb")).each do |file| gsub_file file, /change/, "up" diff --git a/lib/michel.rb b/lib/michel.rb index 174a885..f33858e 100644 --- a/lib/michel.rb +++ b/lib/michel.rb @@ -1,5 +1,4 @@ require "zeitwerk" -require "michel/railtie" if defined?(Rails) loader = Zeitwerk::Loader.for_gem loader.ignore("#{__dir__}/generators") diff --git a/lib/michel/railtie.rb b/lib/michel/railtie.rb deleted file mode 100644 index 67b0336..0000000 --- a/lib/michel/railtie.rb +++ /dev/null @@ -1,13 +0,0 @@ -# lib/michel/railtie.rb -module Michel - class Railtie < Rails::Railtie - initializer "michel.load_scenic" do - require "scenic" - require "scenic/statements" - - ActiveSupport.on_load(:active_record) do - ActiveRecord::Migration.include Scenic::Statements - end - end - end -end From bc6f8ca782c1d7aad5461ac1ee5b7f79817bf649 Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 13:35:40 -0500 Subject: [PATCH 09/20] readme formatting --- README.md | 61 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 5d689f3..197933e 100644 --- a/README.md +++ b/README.md @@ -5,36 +5,49 @@ Find available time slots quickly with a materialized view. ## Usage ### Install Michel - In order to run the migrations, you must also install Scenic - `gem scenic` - `gem michel` - `rails generate michel:install` + In order to run the migrations, you must also install Scenic. Add to your gemfile: + ``` + gem "michel" + gem "scenic" + ``` -### Configure - Michel needs three existing classes to function: - * Resource Class - The resource that is occupied by a booking, ex: Physician, Room, Instructor. This resource is assumed to be available for only one booking at a time. A resource has many bookings and many availabilities. - * Booking Class - The event that is scheduled for a resource, ex: Appointment. The resource is unavailable for the duration of the booking. It is required to have the following attributes: - * `start_time` - a DateTime indicating the start time of the booking. - * `duration` - an integer representing the number of minutes the booking lasts. - * a reference to the id of the resource class - The booking class is also used to block off unavailable times. It is recommended that you have a booking type to distinguish between appointments and other events. - * Availability Class - The weekly schedule during which a resource is available for a booking, which is required to have the following attributes: - * `timezone` - a string representing the time zone in which the availability is configured, ex: 'UTC' - * `weekday` - an integer representing the weekday, starting with Monday = 1 - * `start_time` - a string representing the beginning time of the availability in the configured timezone in 24-hour format, ex: '09:00' - * `end_time` - a string representing the end time of the availability in the configured timezone in 24-hour format, ex: '017:00' - * a reference to the id of the resource class - There should be one availability record for each continuous block of available time during a week. For example, if a resource is available from 9-5, M-Th, with a 1 hour break from 12-1, that is represented by eight availabilities: one for each day from 9-12 and another for each day from 1-5. + Run `bundle install`, then `rails generate michel:install` +### Configure Configure the class names in `config/initializers/michel.rb` -### Run generator + Michel expects three classes to exist in the application: + * Resource Class + * The resource that is occupied by a booking, ex: Physician, Room, Instructor. + * This resource is assumed to be available for only one booking at a time. A resource has many bookings and many availabilities. + + * Booking Class + * The event that is scheduled for a resource, ex: Appointment. + * The resource is unavailable for the duration of the booking. + * It is required to have the following attributes: + * `start_time` - a DateTime indicating the start time of the booking. + * `duration` - an integer representing the number of minutes the booking lasts. + * a reference to the id of the resource class + * The booking class is also used to block off unavailable times. It is recommended that you have a booking type to distinguish between appointments and other events. + * Availability Class + * The weekly schedule during which a resource is available for a booking + * It is required to have the following attributes: + * `timezone` - a string representing the time zone in which the availability is configured, ex: 'UTC' + * `weekday` - an integer representing the weekday, starting with Monday = 1 + * `start_time` - a string representing the beginning time of the availability in the configured timezone in 24-hour format, ex: '09:00' + * `end_time` - a string representing the end time of the availability in the configured timezone in 24-hour format, ex: '017:00' + * a reference to the id of the resource class + * There should be one availability record for each continuous block of available time during a week. For example, if a resource is available from 9-5, M-Th, with a 1 hour break from 12-1, that is represented by eight availabilities: one for each day from 9-12 and another for each day from 1-5. + + +### Run the generator To generate the database view and necessary supporting code, run `rails generate michel:view`. This will: - 1. Generate a migration to add an index to the booking class table on the resource id and start_time. - 2. Generate a Scenic model for available time slots. - 3. Generate a sql file with the view to back the scenic model. - 4. Insert associations between the existing classes and the generated `AvailableTimeSlot` class. + + 1. Generate a migration to add an index to the booking class table on the resource id and start_time. + 2. Generate a Scenic model for available time slots. + 3. Generate a sql file with the view to back the scenic model. + 4. Insert associations between the existing classes and the generated `AvailableTimeSlot` class. Once the generator is finished, run `rails db:migrate` to run the generated migrations. From 9cd3774bc965a01b1ef5a5351068cc7715e4812b Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 14:50:37 -0500 Subject: [PATCH 10/20] Add standard ignores --- .standard.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .standard.yml diff --git a/.standard.yml b/.standard.yml new file mode 100644 index 0000000..2edd79d --- /dev/null +++ b/.standard.yml @@ -0,0 +1,5 @@ +ignore: + - 'lib/generators/michel/view/templates/view_migration.rb': + - Layout/InitialIndentation + - Layout/TrailingEmptyLines + - Layout/TrailingWhitespace From 2aeb0b30bf14c8840b04c850618072a89c5ccc47 Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 14:51:31 -0500 Subject: [PATCH 11/20] Add scenic to gemfile --- Gemfile | 1 + Gemfile.lock | 1 + 2 files changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index a696592..c10df18 100644 --- a/Gemfile +++ b/Gemfile @@ -14,3 +14,4 @@ gem "bundler-audit", ">= 0.7.0", require: false gem "database_cleaner" gem "ammeter" gem "debug" +gem "scenic" diff --git a/Gemfile.lock b/Gemfile.lock index 8631382..90c76c4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -318,6 +318,7 @@ DEPENDENCIES pg (~> 1.1) rails (~> 8.0.2, >= 8.0.2.1) rake (~> 13.0) + scenic standardrb BUNDLED WITH From c03fb61155dbece7cf0ad3493dea4eabed0c0b19 Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 14:55:38 -0500 Subject: [PATCH 12/20] keep views folder --- spec/example-app/db/views/.keep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 spec/example-app/db/views/.keep diff --git a/spec/example-app/db/views/.keep b/spec/example-app/db/views/.keep new file mode 100644 index 0000000..e69de29 From e58adea235c1de61ae3dc7acc5fa13bc3a0bfd6a Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 14:57:58 -0500 Subject: [PATCH 13/20] call class refresh method --- spec/generators/michel/view/view_generator_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/generators/michel/view/view_generator_spec.rb b/spec/generators/michel/view/view_generator_spec.rb index 750d670..5f46ffb 100644 --- a/spec/generators/michel/view/view_generator_spec.rb +++ b/spec/generators/michel/view/view_generator_spec.rb @@ -32,7 +32,7 @@ timezone: "UTC" ) - Scenic.database.refresh_materialized_view("available_time_slots", concurrently: false) + AvailableTimeSlot.refresh slots = AvailableTimeSlot.all expect(slots).not_to be_empty @@ -56,7 +56,7 @@ duration: 30 ) - Scenic.database.refresh_materialized_view("available_time_slots", concurrently: false) + AvailableTimeSlot.refresh # Now the 9:00 slot should not be available slot_times = AvailableTimeSlot.pluck(:start_time) From f2956672fe42bec190602c46c5950f2d4d5100db Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 15:04:44 -0500 Subject: [PATCH 14/20] don't cache classes --- spec/example-app/config/environments/test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/example-app/config/environments/test.rb b/spec/example-app/config/environments/test.rb index 24695cb..3337bd3 100644 --- a/spec/example-app/config/environments/test.rb +++ b/spec/example-app/config/environments/test.rb @@ -8,7 +8,7 @@ # While tests run files are not watched, reloading is not necessary. config.enable_reloading = true - + config.cache_classes = false # Eager loading loads your entire application. When running a single test locally, # this is usually not necessary, and can slow down your test suite. However, it's # recommended that you enable it in continuous integration systems to ensure eager From ae9239d8d02ca93fa6917c93cf7e6d7c724aa46c Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 15:09:56 -0500 Subject: [PATCH 15/20] reload available time slot --- spec/example-app/db/views/.keep | 0 spec/generators/michel/view/view_generator_spec.rb | 1 + 2 files changed, 1 insertion(+) delete mode 100644 spec/example-app/db/views/.keep diff --git a/spec/example-app/db/views/.keep b/spec/example-app/db/views/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/spec/generators/michel/view/view_generator_spec.rb b/spec/generators/michel/view/view_generator_spec.rb index 5f46ffb..efde0ee 100644 --- a/spec/generators/michel/view/view_generator_spec.rb +++ b/spec/generators/michel/view/view_generator_spec.rb @@ -14,6 +14,7 @@ ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).migrate Rails.autoloaders.main.reload + load Rails.root.join('app/models/available_time_slot.rb') end after(:all) do From 29c10ac73397487afed0d55d82e92389b7f8ade9 Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 15:14:16 -0500 Subject: [PATCH 16/20] logging --- spec/generators/michel/view/view_generator_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/generators/michel/view/view_generator_spec.rb b/spec/generators/michel/view/view_generator_spec.rb index efde0ee..5ee4e29 100644 --- a/spec/generators/michel/view/view_generator_spec.rb +++ b/spec/generators/michel/view/view_generator_spec.rb @@ -10,8 +10,8 @@ end run_generator - Scenic.load - + # Scenic.load +puts "RUNNING THE BEFORE BLOCK ***************" ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).migrate Rails.autoloaders.main.reload load Rails.root.join('app/models/available_time_slot.rb') From 9c0470d767bbc89f302a8c3591096f2315c5f246 Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 15:15:26 -0500 Subject: [PATCH 17/20] linting --- spec/generators/michel/view/view_generator_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/generators/michel/view/view_generator_spec.rb b/spec/generators/michel/view/view_generator_spec.rb index 5ee4e29..a60e360 100644 --- a/spec/generators/michel/view/view_generator_spec.rb +++ b/spec/generators/michel/view/view_generator_spec.rb @@ -11,10 +11,10 @@ run_generator # Scenic.load -puts "RUNNING THE BEFORE BLOCK ***************" + puts "RUNNING THE BEFORE BLOCK ***************" ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).migrate Rails.autoloaders.main.reload - load Rails.root.join('app/models/available_time_slot.rb') + load Rails.root.join("app/models/available_time_slot.rb") end after(:all) do From a1bcdf78103a17ed634cdccdcc4636cd27fed873 Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 15:16:50 -0500 Subject: [PATCH 18/20] more logging --- spec/generators/michel/view/view_generator_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/generators/michel/view/view_generator_spec.rb b/spec/generators/michel/view/view_generator_spec.rb index a60e360..6970f00 100644 --- a/spec/generators/michel/view/view_generator_spec.rb +++ b/spec/generators/michel/view/view_generator_spec.rb @@ -12,6 +12,7 @@ run_generator # Scenic.load puts "RUNNING THE BEFORE BLOCK ***************" + puts `ls spec/example-app/app/models` ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).migrate Rails.autoloaders.main.reload load Rails.root.join("app/models/available_time_slot.rb") From 459d74ad79540c5c571e5dd3bf8ec05509d261f4 Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 15:19:59 -0500 Subject: [PATCH 19/20] invoke generator different way --- spec/generators/michel/view/view_generator_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/generators/michel/view/view_generator_spec.rb b/spec/generators/michel/view/view_generator_spec.rb index 6970f00..0eecf95 100644 --- a/spec/generators/michel/view/view_generator_spec.rb +++ b/spec/generators/michel/view/view_generator_spec.rb @@ -8,8 +8,9 @@ config.booking_class_name = "Appointment" config.availability_class_name = "PhysicianAvailability" end + Rails::Generators.invoke("michel:view") - run_generator + # run_generator # Scenic.load puts "RUNNING THE BEFORE BLOCK ***************" puts `ls spec/example-app/app/models` From 17a669ce73050876f0444c07a08796cfe0deb332 Mon Sep 17 00:00:00 2001 From: Sally Hall Date: Wed, 28 Jan 2026 15:23:10 -0500 Subject: [PATCH 20/20] cleanup things that didn't work --- spec/example-app/config/environments/test.rb | 2 +- spec/generators/michel/view/view_generator_spec.rb | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/spec/example-app/config/environments/test.rb b/spec/example-app/config/environments/test.rb index 3337bd3..24695cb 100644 --- a/spec/example-app/config/environments/test.rb +++ b/spec/example-app/config/environments/test.rb @@ -8,7 +8,7 @@ # While tests run files are not watched, reloading is not necessary. config.enable_reloading = true - config.cache_classes = false + # Eager loading loads your entire application. When running a single test locally, # this is usually not necessary, and can slow down your test suite. However, it's # recommended that you enable it in continuous integration systems to ensure eager diff --git a/spec/generators/michel/view/view_generator_spec.rb b/spec/generators/michel/view/view_generator_spec.rb index 0eecf95..26a52c9 100644 --- a/spec/generators/michel/view/view_generator_spec.rb +++ b/spec/generators/michel/view/view_generator_spec.rb @@ -10,18 +10,13 @@ end Rails::Generators.invoke("michel:view") - # run_generator - # Scenic.load - puts "RUNNING THE BEFORE BLOCK ***************" - puts `ls spec/example-app/app/models` ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).migrate Rails.autoloaders.main.reload - load Rails.root.join("app/models/available_time_slot.rb") end after(:all) do ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).rollback(2) - run_generator [], behavior: :revoke + Rails::Generators.invoke("michel:view", [], behavior: :revoke) end it "generates available time slots" do