michel 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/dynamic-security.yml +19 -0
- data/.github/workflows/main.yml +92 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.standard.yml +5 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +6 -0
- data/CONTRIBUTING.md +38 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +325 -0
- data/LICENSE +19 -0
- data/README.md +76 -0
- data/RELEASING.md +43 -0
- data/Rakefile +10 -0
- data/SECURITY.md +2 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/generators/michel/install/install_generator.rb +13 -0
- data/lib/generators/michel/install/templates/michel.rb +5 -0
- data/lib/generators/michel/view/templates/belongs_to_associations.erb +6 -0
- data/lib/generators/michel/view/templates/has_many_associations.erb +2 -0
- data/lib/generators/michel/view/templates/index_migration.erb +15 -0
- data/lib/generators/michel/view/templates/view.erb +95 -0
- data/lib/generators/michel/view/templates/view_migration.rb +8 -0
- data/lib/generators/michel/view/view_generator.rb +59 -0
- data/lib/michel/version.rb +5 -0
- data/lib/michel.rb +60 -0
- data/michel.gemspec +33 -0
- data/sig/michel.rbs +4 -0
- data/spec/example-app/.ruby-version +1 -0
- data/spec/example-app/Rakefile +6 -0
- data/spec/example-app/app/controllers/application_controller.rb +2 -0
- data/spec/example-app/app/controllers/concerns/.keep +0 -0
- data/spec/example-app/app/models/application_record.rb +3 -0
- data/spec/example-app/app/models/appointment.rb +3 -0
- data/spec/example-app/app/models/concerns/.keep +0 -0
- data/spec/example-app/app/models/physician.rb +4 -0
- data/spec/example-app/app/models/physician_availability.rb +3 -0
- data/spec/example-app/bin/bundle +109 -0
- data/spec/example-app/bin/dev +2 -0
- data/spec/example-app/bin/rails +4 -0
- data/spec/example-app/bin/rake +4 -0
- data/spec/example-app/bin/setup +34 -0
- data/spec/example-app/config/application.rb +44 -0
- data/spec/example-app/config/boot.rb +3 -0
- data/spec/example-app/config/credentials.yml.enc +1 -0
- data/spec/example-app/config/database.yml +85 -0
- data/spec/example-app/config/environment.rb +5 -0
- data/spec/example-app/config/environments/development.rb +49 -0
- data/spec/example-app/config/environments/production.rb +64 -0
- data/spec/example-app/config/environments/test.rb +42 -0
- data/spec/example-app/config/initializers/cors.rb +16 -0
- data/spec/example-app/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/example-app/config/initializers/inflections.rb +16 -0
- data/spec/example-app/config/locales/en.yml +31 -0
- data/spec/example-app/config/puma.rb +38 -0
- data/spec/example-app/config/routes.rb +10 -0
- data/spec/example-app/config.ru +6 -0
- data/spec/example-app/db/migrate/20250829205200_create_physicians.rb +8 -0
- data/spec/example-app/db/migrate/20250829205205_create_appointments.rb +10 -0
- data/spec/example-app/db/migrate/20250829205257_create_availabilities.rb +12 -0
- data/spec/example-app/db/schema.rb +42 -0
- data/spec/example-app/db/seeds.rb +9 -0
- data/spec/example-app/lib/tasks/.keep +0 -0
- data/spec/example-app/log/.keep +0 -0
- data/spec/example-app/public/robots.txt +1 -0
- data/spec/example-app/script/.keep +0 -0
- data/spec/example-app/tmp/.keep +0 -0
- data/spec/example-app/tmp/pids/.keep +0 -0
- data/spec/example-app/vendor/.keep +0 -0
- data/spec/generators/michel/install/install_generator_spec.rb +18 -0
- data/spec/generators/michel/view/view_generator_spec.rb +63 -0
- data/spec/lib/michel_spec.rb +60 -0
- data/spec/spec_helper.rb +27 -0
- metadata +158 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# PostgreSQL. Versions 9.3 and up are supported.
|
|
2
|
+
#
|
|
3
|
+
# Install the pg driver:
|
|
4
|
+
# gem install pg
|
|
5
|
+
# On macOS with Homebrew:
|
|
6
|
+
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
|
|
7
|
+
# On Windows:
|
|
8
|
+
# gem install pg
|
|
9
|
+
# Choose the win32 build.
|
|
10
|
+
# Install PostgreSQL and put its /bin directory on your path.
|
|
11
|
+
#
|
|
12
|
+
# Configure Using Gemfile
|
|
13
|
+
# gem "pg"
|
|
14
|
+
#
|
|
15
|
+
default: &default
|
|
16
|
+
adapter: postgresql
|
|
17
|
+
encoding: unicode
|
|
18
|
+
# For details on connection pooling, see Rails configuration guide
|
|
19
|
+
# https://guides.rubyonrails.org/configuring.html#database-pooling
|
|
20
|
+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
development:
|
|
24
|
+
<<: *default
|
|
25
|
+
database: example_app_development
|
|
26
|
+
|
|
27
|
+
# The specified database role being used to connect to PostgreSQL.
|
|
28
|
+
# To create additional roles in PostgreSQL see `$ createuser --help`.
|
|
29
|
+
# When left blank, PostgreSQL will use the default role. This is
|
|
30
|
+
# the same name as the operating system user running Rails.
|
|
31
|
+
#username: example_app
|
|
32
|
+
|
|
33
|
+
# The password associated with the PostgreSQL role (username).
|
|
34
|
+
#password:
|
|
35
|
+
|
|
36
|
+
# Connect on a TCP socket. Omitted by default since the client uses a
|
|
37
|
+
# domain socket that doesn't need configuration. Windows does not have
|
|
38
|
+
# domain sockets, so uncomment these lines.
|
|
39
|
+
#host: localhost
|
|
40
|
+
|
|
41
|
+
# The TCP port the server listens on. Defaults to 5432.
|
|
42
|
+
# If your server runs on a different port number, change accordingly.
|
|
43
|
+
#port: 5432
|
|
44
|
+
|
|
45
|
+
# Schema search path. The server defaults to $user,public
|
|
46
|
+
#schema_search_path: myapp,sharedapp,public
|
|
47
|
+
|
|
48
|
+
# Minimum log levels, in increasing order:
|
|
49
|
+
# debug5, debug4, debug3, debug2, debug1,
|
|
50
|
+
# log, notice, warning, error, fatal, and panic
|
|
51
|
+
# Defaults to warning.
|
|
52
|
+
#min_messages: notice
|
|
53
|
+
|
|
54
|
+
# Warning: The database defined as "test" will be erased and
|
|
55
|
+
# re-generated from your development database when you run "rake".
|
|
56
|
+
# Do not set this db to the same as development or production.
|
|
57
|
+
test:
|
|
58
|
+
<<: *default
|
|
59
|
+
database: example_app_test
|
|
60
|
+
|
|
61
|
+
# As with config/credentials.yml, you never want to store sensitive information,
|
|
62
|
+
# like your database password, in your source code. If your source code is
|
|
63
|
+
# ever seen by anyone, they now have access to your database.
|
|
64
|
+
#
|
|
65
|
+
# Instead, provide the password or a full connection URL as an environment
|
|
66
|
+
# variable when you boot the app. For example:
|
|
67
|
+
#
|
|
68
|
+
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
|
|
69
|
+
#
|
|
70
|
+
# If the connection URL is provided in the special DATABASE_URL environment
|
|
71
|
+
# variable, Rails will automatically merge its configuration values on top of
|
|
72
|
+
# the values provided in this file. Alternatively, you can specify a connection
|
|
73
|
+
# URL environment variable explicitly:
|
|
74
|
+
#
|
|
75
|
+
# production:
|
|
76
|
+
# url: <%= ENV["MY_APP_DATABASE_URL"] %>
|
|
77
|
+
#
|
|
78
|
+
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
|
|
79
|
+
# for a full overview on how database connection configuration can be specified.
|
|
80
|
+
#
|
|
81
|
+
production:
|
|
82
|
+
<<: *default
|
|
83
|
+
database: example_app_production
|
|
84
|
+
username: example_app
|
|
85
|
+
password: <%= ENV["EXAMPLE_APP_DATABASE_PASSWORD"] %>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
|
2
|
+
|
|
3
|
+
Rails.application.configure do
|
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
5
|
+
|
|
6
|
+
# Make code changes take effect immediately without server restart.
|
|
7
|
+
config.enable_reloading = true
|
|
8
|
+
|
|
9
|
+
# Do not eager load code on boot.
|
|
10
|
+
config.eager_load = false
|
|
11
|
+
|
|
12
|
+
# Show full error reports.
|
|
13
|
+
config.consider_all_requests_local = true
|
|
14
|
+
|
|
15
|
+
# Enable server timing.
|
|
16
|
+
config.server_timing = true
|
|
17
|
+
|
|
18
|
+
# Enable/disable Action Controller caching. By default Action Controller caching is disabled.
|
|
19
|
+
# Run rails dev:cache to toggle Action Controller caching.
|
|
20
|
+
if Rails.root.join("tmp/caching-dev.txt").exist?
|
|
21
|
+
config.public_file_server.headers = {"cache-control" => "public, max-age=#{2.days.to_i}"}
|
|
22
|
+
else
|
|
23
|
+
config.action_controller.perform_caching = false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Change to :null_store to avoid any caching.
|
|
27
|
+
config.cache_store = :memory_store
|
|
28
|
+
|
|
29
|
+
# Print deprecation notices to the Rails logger.
|
|
30
|
+
config.active_support.deprecation = :log
|
|
31
|
+
|
|
32
|
+
# Raise an error on page load if there are pending migrations.
|
|
33
|
+
config.active_record.migration_error = :page_load
|
|
34
|
+
|
|
35
|
+
# Highlight code that triggered database queries in logs.
|
|
36
|
+
config.active_record.verbose_query_logs = true
|
|
37
|
+
|
|
38
|
+
# Append comments with runtime information tags to SQL queries in logs.
|
|
39
|
+
config.active_record.query_log_tags_enabled = true
|
|
40
|
+
|
|
41
|
+
# Raises error for missing translations.
|
|
42
|
+
# config.i18n.raise_on_missing_translations = true
|
|
43
|
+
|
|
44
|
+
# Annotate rendered view with file names.
|
|
45
|
+
config.action_view.annotate_rendered_view_with_filenames = true
|
|
46
|
+
|
|
47
|
+
# Raise error when a before_action's only/except options reference missing actions.
|
|
48
|
+
config.action_controller.raise_on_missing_callback_actions = true
|
|
49
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require "active_support/core_ext/integer/time"
|
|
2
|
+
|
|
3
|
+
Rails.application.configure do
|
|
4
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
5
|
+
|
|
6
|
+
# Code is not reloaded between requests.
|
|
7
|
+
config.enable_reloading = false
|
|
8
|
+
|
|
9
|
+
# Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
|
|
10
|
+
config.eager_load = true
|
|
11
|
+
|
|
12
|
+
# Full error reports are disabled.
|
|
13
|
+
config.consider_all_requests_local = false
|
|
14
|
+
|
|
15
|
+
# Cache assets for far-future expiry since they are all digest stamped.
|
|
16
|
+
config.public_file_server.headers = {"cache-control" => "public, max-age=#{1.year.to_i}"}
|
|
17
|
+
|
|
18
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
|
19
|
+
# config.asset_host = "http://assets.example.com"
|
|
20
|
+
|
|
21
|
+
# Assume all access to the app is happening through a SSL-terminating reverse proxy.
|
|
22
|
+
config.assume_ssl = true
|
|
23
|
+
|
|
24
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
|
25
|
+
config.force_ssl = true
|
|
26
|
+
|
|
27
|
+
# Skip http-to-https redirect for the default health check endpoint.
|
|
28
|
+
# config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } }
|
|
29
|
+
|
|
30
|
+
# Log to STDOUT with the current request id as a default log tag.
|
|
31
|
+
config.log_tags = [:request_id]
|
|
32
|
+
config.logger = ActiveSupport::TaggedLogging.logger($stdout)
|
|
33
|
+
|
|
34
|
+
# Change to "debug" to log everything (including potentially personally-identifiable information!)
|
|
35
|
+
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
|
|
36
|
+
|
|
37
|
+
# Prevent health checks from clogging up the logs.
|
|
38
|
+
config.silence_healthcheck_path = "/up"
|
|
39
|
+
|
|
40
|
+
# Don't log any deprecations.
|
|
41
|
+
config.active_support.report_deprecations = false
|
|
42
|
+
|
|
43
|
+
# Replace the default in-process memory cache store with a durable alternative.
|
|
44
|
+
# config.cache_store = :mem_cache_store
|
|
45
|
+
|
|
46
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
|
47
|
+
# the I18n.default_locale when a translation cannot be found).
|
|
48
|
+
config.i18n.fallbacks = true
|
|
49
|
+
|
|
50
|
+
# Do not dump schema after migrations.
|
|
51
|
+
config.active_record.dump_schema_after_migration = false
|
|
52
|
+
|
|
53
|
+
# Only use :id for inspections in production.
|
|
54
|
+
config.active_record.attributes_for_inspect = [:id]
|
|
55
|
+
|
|
56
|
+
# Enable DNS rebinding protection and other `Host` header attacks.
|
|
57
|
+
# config.hosts = [
|
|
58
|
+
# "example.com", # Allow requests from example.com
|
|
59
|
+
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
|
|
60
|
+
# ]
|
|
61
|
+
#
|
|
62
|
+
# Skip DNS rebinding protection for the default health check endpoint.
|
|
63
|
+
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
|
|
64
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# The test environment is used exclusively to run your application's
|
|
2
|
+
# test suite. You never need to work with it otherwise. Remember that
|
|
3
|
+
# your test database is "scratch space" for the test suite and is wiped
|
|
4
|
+
# and recreated between test runs. Don't rely on the data there!
|
|
5
|
+
|
|
6
|
+
Rails.application.configure do
|
|
7
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
8
|
+
|
|
9
|
+
# While tests run files are not watched, reloading is not necessary.
|
|
10
|
+
config.enable_reloading = true
|
|
11
|
+
|
|
12
|
+
# Eager loading loads your entire application. When running a single test locally,
|
|
13
|
+
# this is usually not necessary, and can slow down your test suite. However, it's
|
|
14
|
+
# recommended that you enable it in continuous integration systems to ensure eager
|
|
15
|
+
# loading is working properly before deploying your code.
|
|
16
|
+
config.eager_load = ENV["CI"].present?
|
|
17
|
+
|
|
18
|
+
# Configure public file server for tests with cache-control for performance.
|
|
19
|
+
config.public_file_server.headers = {"cache-control" => "public, max-age=3600"}
|
|
20
|
+
|
|
21
|
+
# Show full error reports.
|
|
22
|
+
config.consider_all_requests_local = true
|
|
23
|
+
config.cache_store = :null_store
|
|
24
|
+
|
|
25
|
+
# Render exception templates for rescuable exceptions and raise for other exceptions.
|
|
26
|
+
config.action_dispatch.show_exceptions = :rescuable
|
|
27
|
+
|
|
28
|
+
# Disable request forgery protection in test environment.
|
|
29
|
+
config.action_controller.allow_forgery_protection = false
|
|
30
|
+
|
|
31
|
+
# Print deprecation notices to the stderr.
|
|
32
|
+
config.active_support.deprecation = :stderr
|
|
33
|
+
|
|
34
|
+
# Raises error for missing translations.
|
|
35
|
+
# config.i18n.raise_on_missing_translations = true
|
|
36
|
+
|
|
37
|
+
# Annotate rendered view with file names.
|
|
38
|
+
# config.action_view.annotate_rendered_view_with_filenames = true
|
|
39
|
+
|
|
40
|
+
# Raise error when a before_action's only/except options reference missing actions.
|
|
41
|
+
config.action_controller.raise_on_missing_callback_actions = true
|
|
42
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Avoid CORS issues when API is called from the frontend app.
|
|
4
|
+
# Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin Ajax requests.
|
|
5
|
+
|
|
6
|
+
# Read more: https://github.com/cyu/rack-cors
|
|
7
|
+
|
|
8
|
+
# Rails.application.config.middleware.insert_before 0, Rack::Cors do
|
|
9
|
+
# allow do
|
|
10
|
+
# origins "example.com"
|
|
11
|
+
#
|
|
12
|
+
# resource "*",
|
|
13
|
+
# headers: :any,
|
|
14
|
+
# methods: [:get, :post, :put, :patch, :delete, :options, :head]
|
|
15
|
+
# end
|
|
16
|
+
# end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
|
|
4
|
+
# Use this to limit dissemination of sensitive information.
|
|
5
|
+
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
|
|
6
|
+
Rails.application.config.filter_parameters += [
|
|
7
|
+
:passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc
|
|
8
|
+
]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
|
4
|
+
# are locale specific, and you may define rules for as many different
|
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
|
7
|
+
# inflect.plural /^(ox)$/i, "\\1en"
|
|
8
|
+
# inflect.singular /^(ox)en/i, "\\1"
|
|
9
|
+
# inflect.irregular "person", "people"
|
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
|
11
|
+
# end
|
|
12
|
+
|
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
|
15
|
+
# inflect.acronym "RESTful"
|
|
16
|
+
# end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Files in the config/locales directory are used for internationalization and
|
|
2
|
+
# are automatically loaded by Rails. If you want to use locales other than
|
|
3
|
+
# English, add the necessary files in this directory.
|
|
4
|
+
#
|
|
5
|
+
# To use the locales, use `I18n.t`:
|
|
6
|
+
#
|
|
7
|
+
# I18n.t "hello"
|
|
8
|
+
#
|
|
9
|
+
# In views, this is aliased to just `t`:
|
|
10
|
+
#
|
|
11
|
+
# <%= t("hello") %>
|
|
12
|
+
#
|
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
|
14
|
+
#
|
|
15
|
+
# I18n.locale = :es
|
|
16
|
+
#
|
|
17
|
+
# This would use the information in config/locales/es.yml.
|
|
18
|
+
#
|
|
19
|
+
# To learn more about the API, please read the Rails Internationalization guide
|
|
20
|
+
# at https://guides.rubyonrails.org/i18n.html.
|
|
21
|
+
#
|
|
22
|
+
# Be aware that YAML interprets the following case-insensitive strings as
|
|
23
|
+
# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings
|
|
24
|
+
# must be quoted to be interpreted as strings. For example:
|
|
25
|
+
#
|
|
26
|
+
# en:
|
|
27
|
+
# "yes": yup
|
|
28
|
+
# enabled: "ON"
|
|
29
|
+
|
|
30
|
+
en:
|
|
31
|
+
hello: "Hello world"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# This configuration file will be evaluated by Puma. The top-level methods that
|
|
2
|
+
# are invoked here are part of Puma's configuration DSL. For more information
|
|
3
|
+
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
|
|
4
|
+
#
|
|
5
|
+
# Puma starts a configurable number of processes (workers) and each process
|
|
6
|
+
# serves each request in a thread from an internal thread pool.
|
|
7
|
+
#
|
|
8
|
+
# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You
|
|
9
|
+
# should only set this value when you want to run 2 or more workers. The
|
|
10
|
+
# default is already 1.
|
|
11
|
+
#
|
|
12
|
+
# The ideal number of threads per worker depends both on how much time the
|
|
13
|
+
# application spends waiting for IO operations and on how much you wish to
|
|
14
|
+
# prioritize throughput over latency.
|
|
15
|
+
#
|
|
16
|
+
# As a rule of thumb, increasing the number of threads will increase how much
|
|
17
|
+
# traffic a given process can handle (throughput), but due to CRuby's
|
|
18
|
+
# Global VM Lock (GVL) it has diminishing returns and will degrade the
|
|
19
|
+
# response time (latency) of the application.
|
|
20
|
+
#
|
|
21
|
+
# The default is set to 3 threads as it's deemed a decent compromise between
|
|
22
|
+
# throughput and latency for the average Rails application.
|
|
23
|
+
#
|
|
24
|
+
# Any libraries that use a connection pool or another resource pool should
|
|
25
|
+
# be configured to provide at least as many connections as the number of
|
|
26
|
+
# threads. This includes Active Record's `pool` parameter in `database.yml`.
|
|
27
|
+
threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
|
|
28
|
+
threads threads_count, threads_count
|
|
29
|
+
|
|
30
|
+
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
|
|
31
|
+
port ENV.fetch("PORT", 3000)
|
|
32
|
+
|
|
33
|
+
# Allow puma to be restarted by `bin/rails restart` command.
|
|
34
|
+
plugin :tmp_restart
|
|
35
|
+
|
|
36
|
+
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
|
|
37
|
+
# In other environments, only set the PID file if requested.
|
|
38
|
+
pidfile ENV["PIDFILE"] if ENV["PIDFILE"]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Rails.application.routes.draw do
|
|
2
|
+
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
|
3
|
+
|
|
4
|
+
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
|
5
|
+
# Can be used by load balancers and uptime monitors to verify that the app is live.
|
|
6
|
+
get "up" => "rails/health#show", :as => :rails_health_check
|
|
7
|
+
|
|
8
|
+
# Defines the root path route ("/")
|
|
9
|
+
# root "posts#index"
|
|
10
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class CreateAvailabilities < ActiveRecord::Migration[8.0]
|
|
2
|
+
def change
|
|
3
|
+
create_table :physician_availabilities do |t|
|
|
4
|
+
t.references :physician
|
|
5
|
+
t.integer :weekday, null: false # 1 = Monday, etc
|
|
6
|
+
t.string :start_time, null: false # '09:00'
|
|
7
|
+
t.string :end_time, null: false # '17:00'
|
|
8
|
+
t.string :timezone, null: false # e.g. 'UTC'
|
|
9
|
+
t.timestamps
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
|
4
|
+
#
|
|
5
|
+
# This file is the source Rails uses to define your schema when running `bin/rails
|
|
6
|
+
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
|
9
|
+
# migrations use external dependencies or application code.
|
|
10
|
+
#
|
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
|
12
|
+
|
|
13
|
+
ActiveRecord::Schema[8.0].define(version: 2025_08_29_205257) do
|
|
14
|
+
# These are extensions that must be enabled in order to support this database
|
|
15
|
+
enable_extension "pg_catalog.plpgsql"
|
|
16
|
+
|
|
17
|
+
create_table "appointments", force: :cascade do |t|
|
|
18
|
+
t.bigint "physician_id"
|
|
19
|
+
t.datetime "start_time", null: false
|
|
20
|
+
t.integer "duration", null: false
|
|
21
|
+
t.datetime "created_at", null: false
|
|
22
|
+
t.datetime "updated_at", null: false
|
|
23
|
+
t.index ["physician_id"], name: "index_appointments_on_physician_id"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
create_table "physician_availabilities", force: :cascade do |t|
|
|
27
|
+
t.bigint "physician_id"
|
|
28
|
+
t.integer "weekday", null: false
|
|
29
|
+
t.string "start_time", null: false
|
|
30
|
+
t.string "end_time", null: false
|
|
31
|
+
t.string "timezone", null: false
|
|
32
|
+
t.datetime "created_at", null: false
|
|
33
|
+
t.datetime "updated_at", null: false
|
|
34
|
+
t.index ["physician_id"], name: "index_physician_availabilities_on_physician_id"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
create_table "physicians", force: :cascade do |t|
|
|
38
|
+
t.string "name"
|
|
39
|
+
t.datetime "created_at", null: false
|
|
40
|
+
t.datetime "updated_at", null: false
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# This file should ensure the existence of records required to run the application in every environment (production,
|
|
2
|
+
# development, test). The code here should be idempotent so that it can be executed at any point in every environment.
|
|
3
|
+
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
|
|
4
|
+
#
|
|
5
|
+
# Example:
|
|
6
|
+
#
|
|
7
|
+
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name|
|
|
8
|
+
# MovieGenre.find_or_create_by!(name: genre_name)
|
|
9
|
+
# end
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "generators/michel/install/install_generator"
|
|
3
|
+
|
|
4
|
+
RSpec.describe Michel::Generators::InstallGenerator, :generator do
|
|
5
|
+
it "generates initializer file" do
|
|
6
|
+
destination File.expand_path("../../../../../tmp", __FILE__)
|
|
7
|
+
prepare_destination
|
|
8
|
+
|
|
9
|
+
run_generator
|
|
10
|
+
initializer = file("config/initializers/michel.rb")
|
|
11
|
+
|
|
12
|
+
# is_expected_to contain - verifies the file's contents
|
|
13
|
+
expect(initializer).to contain(/Michel.setup do |config|/)
|
|
14
|
+
expect(initializer).to contain(/config.resource_class_name = "Resource"/)
|
|
15
|
+
expect(initializer).to contain(/config.booking_class_name = "Booking"/)
|
|
16
|
+
expect(initializer).to contain(/config.availability_class_name = "Availability"/)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
require "generators/michel/view/view_generator"
|
|
3
|
+
|
|
4
|
+
RSpec.describe Michel::Generators::ViewGenerator, :generator do
|
|
5
|
+
before(:all) do
|
|
6
|
+
Michel.setup do |config|
|
|
7
|
+
config.resource_class_name = "Physician"
|
|
8
|
+
config.booking_class_name = "Appointment"
|
|
9
|
+
config.availability_class_name = "PhysicianAvailability"
|
|
10
|
+
end
|
|
11
|
+
Rails::Generators.invoke("michel:view")
|
|
12
|
+
|
|
13
|
+
ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).migrate
|
|
14
|
+
Rails.autoloaders.main.reload
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
after(:all) do
|
|
18
|
+
ActiveRecord::MigrationContext.new(Rails.root.join("db/migrate")).rollback(2)
|
|
19
|
+
Rails::Generators.invoke("michel:view", [], behavior: :revoke)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "generates available time slots" do
|
|
23
|
+
doctor = Physician.create!(name: "Dr. Seuss")
|
|
24
|
+
|
|
25
|
+
PhysicianAvailability.create!(
|
|
26
|
+
physician: doctor,
|
|
27
|
+
weekday: Date.tomorrow.wday, # ensures it aligns with tomorrow
|
|
28
|
+
start_time: "09:00",
|
|
29
|
+
end_time: "10:00",
|
|
30
|
+
timezone: "UTC"
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
AvailableTimeSlot.refresh
|
|
34
|
+
slots = AvailableTimeSlot.all
|
|
35
|
+
|
|
36
|
+
expect(slots).not_to be_empty
|
|
37
|
+
expect(slots.first.start_time.hour).to eq(9)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "excludes slots that overlap with a booking" do
|
|
41
|
+
doctor = Physician.create!(name: "Dr. Seuss")
|
|
42
|
+
PhysicianAvailability.create!(
|
|
43
|
+
physician: doctor,
|
|
44
|
+
weekday: Date.tomorrow.wday, # ensures it aligns with tomorrow
|
|
45
|
+
start_time: "09:00",
|
|
46
|
+
end_time: "10:00",
|
|
47
|
+
timezone: "UTC"
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# Book a 30min slot at 9:00
|
|
51
|
+
Appointment.create!(
|
|
52
|
+
physician: doctor,
|
|
53
|
+
start_time: Date.tomorrow.beginning_of_day + 9.hours,
|
|
54
|
+
duration: 30
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
AvailableTimeSlot.refresh
|
|
58
|
+
|
|
59
|
+
# Now the 9:00 slot should not be available
|
|
60
|
+
slot_times = AvailableTimeSlot.pluck(:start_time)
|
|
61
|
+
expect(slot_times).not_to include(Date.tomorrow.beginning_of_day + 9.hours)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require "michel"
|
|
2
|
+
RSpec.describe Michel do
|
|
3
|
+
before do
|
|
4
|
+
Michel.setup do |config|
|
|
5
|
+
config.resource_class_name = "Physician"
|
|
6
|
+
config.booking_class_name = "Appointment"
|
|
7
|
+
config.availability_class_name = "PhysicianAvailability"
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe "resource helpers" do
|
|
12
|
+
it "returns correct symbol" do
|
|
13
|
+
expect(Michel.resource_class_symbol).to eq(:physician)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "returns correct foreign key" do
|
|
17
|
+
expect(Michel.resource_class_foreign_id).to eq("physician_id")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "returns correct underscored name" do
|
|
21
|
+
expect(Michel.resource_class_underscore).to eq("physician")
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe "booking helpers" do
|
|
26
|
+
it "returns correct symbol" do
|
|
27
|
+
expect(Michel.booking_class_symbol).to eq(:appointment)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "returns correct table name" do
|
|
31
|
+
expect(Michel.booking_class_table_name).to eq("appointments")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "returns correct foreign key" do
|
|
35
|
+
expect(Michel.booking_class_foreign_id).to eq("appointment_id")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "returns correct underscored name" do
|
|
39
|
+
expect(Michel.booking_class_underscore).to eq("appointment")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe "availability helpers" do
|
|
44
|
+
it "returns correct symbol" do
|
|
45
|
+
expect(Michel.availability_class_symbol).to eq(:physician_availability)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "returns correct table name" do
|
|
49
|
+
expect(Michel.availability_class_table_name).to eq("physician_availabilities")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "returns correct foreign key" do
|
|
53
|
+
expect(Michel.availability_class_foreign_id).to eq("physician_availability_id")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "returns correct underscored name" do
|
|
57
|
+
expect(Michel.availability_class_underscore).to eq("physician_availability")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Dir.glob("#{__dir__}/support/**/*.rb").each { |f| require f }
|
|
4
|
+
require File.expand_path("../../spec/example-app/config/environment", __FILE__)
|
|
5
|
+
require "michel"
|
|
6
|
+
require "scenic"
|
|
7
|
+
|
|
8
|
+
RSpec.configure do |config|
|
|
9
|
+
# Enable flags like --only-failures and --next-failure
|
|
10
|
+
config.example_status_persistence_file_path = ".rspec_status"
|
|
11
|
+
|
|
12
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
|
13
|
+
config.disable_monkey_patching!
|
|
14
|
+
|
|
15
|
+
config.expect_with :rspec do |c|
|
|
16
|
+
c.syntax = :expect
|
|
17
|
+
end
|
|
18
|
+
config.around(:each) do |example|
|
|
19
|
+
ActiveRecord::SchemaMigration
|
|
20
|
+
.new(ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool)
|
|
21
|
+
.create_table
|
|
22
|
+
|
|
23
|
+
DatabaseCleaner.start
|
|
24
|
+
example.run
|
|
25
|
+
DatabaseCleaner.clean
|
|
26
|
+
end
|
|
27
|
+
end
|