diff --git a/.gitea/workflows/tests.yml b/.gitea/workflows/tests.yml index c83664b..380d3ca 100644 --- a/.gitea/workflows/tests.yml +++ b/.gitea/workflows/tests.yml @@ -23,7 +23,7 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} ref: ${{ github.head_ref }} # Checkout the actual branch, not the result if merged into the base - - uses: ruby/setup-ruby@v1.220.0 + - uses: ruby/setup-ruby@v1 - run: bundle install - &postgres_wait name: Wait until Postgres is ready to accept connections @@ -65,26 +65,29 @@ jobs: if: failure() run: docker ps --filter network=$JOB_CONTAINER_NAME-$GITHUB_JOB-network --filter name=$JOB_CONTAINER_NAME-* --format "{{.ID}}" | xargs docker rm -f rubocop: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - - uses: ruby/setup-ruby@v1.220.0 + - uses: ruby/setup-ruby@v1 - run: bundle install - run: bundle exec rubocop --force-exclusion --parallel check-licenses: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - - uses: ruby/setup-ruby@v1.220.0 + - uses: ruby/setup-ruby@v1 - name: Install project dependencies run: bundle install --jobs `getconf _NPROCESSORS_ONLN` - name: Run license finder run: license_finder copyright_notice: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index 13e3051..945067b 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ # Ignore swagger generated documentation swagger/v1/swagger.yaml +wedding-planner.code-workspace diff --git a/Gemfile b/Gemfile index 9c3bbb6..e0e1d14 100644 --- a/Gemfile +++ b/Gemfile @@ -33,7 +33,7 @@ group :development, :test do gem 'factory_bot_rails' gem 'license_finder' gem 'pry' - gem 'rspec-rails', '~> 7.1.0' + gem 'rspec-rails', '~> 8.0.0' gem 'shoulda-matchers', '~> 6.0' end diff --git a/Gemfile.lock b/Gemfile.lock index 338698c..685eac4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -82,10 +82,10 @@ GEM babel-transpiler (0.7.0) babel-source (>= 4.0, < 6) execjs (~> 2.0) - base64 (0.2.0) + base64 (0.3.0) bcrypt (3.1.20) - benchmark (0.4.0) - bigdecimal (3.1.9) + benchmark (0.4.1) + bigdecimal (3.2.1) bindex (0.8.1) bootsnap (1.18.6) msgpack (~> 1.2) @@ -97,7 +97,7 @@ GEM concurrent-ruby (1.3.5) connection_pool (2.5.3) crass (1.0.6) - csv (3.3.4) + csv (3.3.5) date (3.4.1) debug (1.10.0) irb (~> 1.10) @@ -108,8 +108,9 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) - diff-lcs (1.5.1) - drb (2.2.1) + diff-lcs (1.6.2) + drb (2.2.3) + erb (5.0.1) erubi (1.13.1) et-orbi (1.2.11) tzinfo @@ -137,7 +138,8 @@ GEM activesupport (>= 6.0.0) railties (>= 6.0.0) io-console (0.8.0) - irb (1.14.3) + irb (1.15.2) + pp (>= 0.6.0) rdoc (>= 4.0.0) reline (>= 0.4.2) jbuilder (2.13.0) @@ -178,7 +180,7 @@ GEM xml-simple (~> 1.1.9) lint_roller (1.1.0) logger (1.7.0) - loofah (2.23.1) + loofah (2.24.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -189,7 +191,7 @@ GEM marcel (1.0.4) method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.8) + mini_portile2 (2.8.9) minitest (5.25.5) money (6.19.0) i18n (>= 0.6.4, <= 2) @@ -206,18 +208,18 @@ GEM net-smtp (0.5.1) net-protocol nio4r (2.7.4) - nokogiri (1.18.7) + nokogiri (1.18.8) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.18.7-aarch64-linux-gnu) + nokogiri (1.18.8-aarch64-linux-gnu) racc (~> 1.4) - nokogiri (1.18.7-arm-linux-gnu) + nokogiri (1.18.8-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.18.7-arm64-darwin) + nokogiri (1.18.8-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.7-x86_64-darwin) + nokogiri (1.18.8-x86_64-darwin) racc (~> 1.4) - nokogiri (1.18.7-x86_64-linux-gnu) + nokogiri (1.18.8-x86_64-linux-gnu) racc (~> 1.4) orm_adapter (0.5.0) parallel (1.27.0) @@ -228,11 +230,14 @@ GEM pluck_to_hash (1.0.2) activerecord (>= 4.0.2) activesupport (>= 4.0.2) + pp (0.6.2) + prettyprint + prettyprint (0.2.0) prism (1.4.0) pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) - psych (5.2.3) + psych (5.2.6) date stringio public_suffix (6.0.1) @@ -240,12 +245,14 @@ GEM nio4r (~> 2.0) raabro (1.4.0) racc (1.8.1) - rack (3.1.14) - rack-cors (2.0.2) - rack (>= 2.0.0) - rack-session (2.0.0) + rack (3.1.15) + rack-cors (3.0.0) + logger + rack (>= 3.0.14) + rack-session (2.1.1) + base64 (>= 0.1.0) rack (>= 3.0.0) - rack-test (2.1.0) + rack-test (2.2.0) rack (>= 1.3) rackup (2.2.1) rack (>= 3) @@ -263,7 +270,7 @@ GEM activesupport (= 8.0.2) bundler (>= 1.15.0) railties (= 8.0.2) - rails-dom-testing (2.2.0) + rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) @@ -279,8 +286,9 @@ GEM thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.2.1) - rdoc (6.10.0) + rake (13.3.0) + rdoc (6.14.0) + erb psych (>= 4.0.0) react-rails (3.2.1) babel-transpiler (>= 0.7.0) @@ -299,23 +307,23 @@ GEM actionpack (>= 5.2) railties (>= 5.2) rexml (3.3.9) - rspec-core (3.13.3) + rspec-core (3.13.4) rspec-support (~> 3.13.0) - rspec-expectations (3.13.3) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.2) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (7.1.1) - actionpack (>= 7.0) - activesupport (>= 7.0) - railties (>= 7.0) + rspec-rails (8.0.0) + actionpack (>= 7.2) + activesupport (>= 7.2) + railties (>= 7.2) rspec-core (~> 3.13) rspec-expectations (~> 3.13) rspec-mocks (~> 3.13) rspec-support (~> 3.13) - rspec-support (3.13.2) + rspec-support (3.13.4) rswag (2.16.0) rswag-api (= 2.16.0) rswag-specs (= 2.16.0) @@ -331,7 +339,7 @@ GEM rswag-ui (2.16.0) actionpack (>= 5.2, < 8.1) railties (>= 5.2, < 8.1) - rubocop (1.75.8) + rubocop (1.76.1) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -339,10 +347,10 @@ GEM parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.9.3, < 3.0) - rubocop-ast (>= 1.44.0, < 2.0) + rubocop-ast (>= 1.45.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.44.1) + rubocop-ast (1.45.1) parser (>= 3.3.7.2) prism (~> 1.4) rubocop-factory_bot (2.27.1) @@ -384,12 +392,12 @@ GEM sprockets (>= 3.0.0) stimulus-rails (1.3.4) railties (>= 6.0.0) - stringio (3.1.6) + stringio (3.1.7) thor (1.3.2) tilt (2.4.0) timeout (0.4.3) tomlrb (2.0.3) - turbo-rails (2.0.13) + turbo-rails (2.0.16) actionpack (>= 7.1.0) railties (>= 7.1.0) tzinfo (2.0.6) @@ -411,7 +419,7 @@ GEM with_env (1.1.0) xml-simple (1.1.9) rexml - zeitwerk (2.7.2) + zeitwerk (2.7.3) PLATFORMS aarch64-linux @@ -446,7 +454,7 @@ DEPENDENCIES rails (~> 8.0.0, >= 8.0.0) react-rails redis (>= 4.0.1) - rspec-rails (~> 7.1.0) + rspec-rails (~> 8.0.0) rswag rubocop rubocop-factory_bot @@ -480,10 +488,10 @@ CHECKSUMS ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383 babel-source (5.8.35) sha256=79ef222a9dcb867ac2efa3b0da35b4bcb15a4bfa67b6b2dcbf1e9a29104498d9 babel-transpiler (0.7.0) sha256=4c06f4ad9e8e1cabe94f99e11df2f140bb72aca9ba067dbb49dc14d9b98d1570 - base64 (0.2.0) sha256=0f25e9b21a02a0cc0cea8ef92b2041035d39350946e8789c562b2d1a3da01507 + base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b bcrypt (3.1.20) sha256=8410f8c7b3ed54a3c00cd2456bf13917d695117f033218e2483b2e40b0784099 - benchmark (0.4.0) sha256=0f12f8c495545e3710c3e4f0480f63f06b4c842cc94cec7f33a956f5180e874a - bigdecimal (3.1.9) sha256=2ffc742031521ad69c2dfc815a98e426a230a3d22aeac1995826a75dabfad8cc + benchmark (0.4.1) sha256=d4ef40037bba27f03b28013e219b950b82bace296549ec15a78016552f8d2cce + bigdecimal (3.2.1) sha256=1f68631e876c6aba8fe9b84b36983c55ad3293ff2d1ad4c6f115bde1e9d802e3 bindex (0.8.1) sha256=7b1ecc9dc539ed8bccfc8cb4d2732046227b09d6f37582ff12e50a5047ceb17e bootsnap (1.18.6) sha256=0ae2393c1e911e38be0f24e9173e7be570c3650128251bf06240046f84a07d00 builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f @@ -493,12 +501,13 @@ CHECKSUMS concurrent-ruby (1.3.5) sha256=813b3e37aca6df2a21a3b9f1d497f8cbab24a2b94cab325bffe65ee0f6cbebc6 connection_pool (2.5.3) sha256=cfd74a82b9b094d1ce30c4f1a346da23ee19dc8a062a16a85f58eab1ced4305b crass (1.0.6) sha256=dc516022a56e7b3b156099abc81b6d2b08ea1ed12676ac7a5657617f012bd45d - csv (3.3.4) sha256=e96ecd5a8c3494aa5b596282249daba5c6033203c199248e6146e36d2a78d8cd + csv (3.3.5) sha256=6e5134ac3383ef728b7f02725d9872934f523cb40b961479f69cf3afa6c8e73f date (3.4.1) sha256=bf268e14ef7158009bfeaec40b5fa3c7271906e88b196d958a89d4b408abe64f debug (1.10.0) sha256=11e28ca74875979e612444104f3972bd5ffb9e79179907d7ad46dba44bd2e7a4 devise (4.9.4) sha256=920042fe5e704c548aa4eb65ebdd65980b83ffae67feb32c697206bfd975a7f8 - diff-lcs (1.5.1) sha256=273223dfb40685548436d32b4733aa67351769c7dea621da7d9dd4813e63ddfe - drb (2.2.1) sha256=e9d472bf785f558b96b25358bae115646da0dbfd45107ad858b0bc0d935cb340 + diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962 + drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373 + erb (5.0.1) sha256=760439803b36cc93eca8a266aab614614e588024a89bc30a62e78d98ff452c23 erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9 et-orbi (1.2.11) sha256=d26e868cc21db88280a9ec1a50aa3da5d267eb9b2037ba7b831d6c2731f5df64 execjs (2.9.1) sha256=e8fd066f6df60c8e8fbebc32c6fb356b5212c77374e8416a9019ca4bb154dcfb @@ -511,7 +520,7 @@ CHECKSUMS i18n (1.14.7) sha256=ceba573f8138ff2c0915427f1fc5bdf4aa3ab8ae88c8ce255eb3ecf0a11a5d0f importmap-rails (2.1.0) sha256=9f10c67d60651a547579f448100d033df311c5d5db578301374aeb774faae741 io-console (0.8.0) sha256=cd6a9facbc69871d69b2cb8b926fc6ea7ef06f06e505e81a64f14a470fddefa2 - irb (1.14.3) sha256=c457f1f2f1438ae9ce5c5be3981ae2138dec7fb894c7d73777eeeb0a6c0d0752 + irb (1.15.2) sha256=222f32952e278da34b58ffe45e8634bf4afc2dc7aa9da23fed67e581aa50fdba jbuilder (2.13.0) sha256=7200a38a1c0081aa81b7a9757e7a299db75bc58cf1fd45ca7919a91627d227d6 json (2.12.2) sha256=ba94a48ad265605c8fa9a50a5892f3ba6a02661aa010f638211f3cb36f44abf4 json-schema (5.0.1) sha256=bef71a82c600a42594911553522e143f7634affc198ed507ef3ded2f920a74a9 @@ -528,12 +537,12 @@ CHECKSUMS license_finder (7.2.1) sha256=179ead19b64b170638b72fd16024233813673ac9d20d5ba75ae0b4444887ef14 lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87 logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203 - loofah (2.23.1) sha256=d0a07422cb3b69272e124afa914ef6d517e30d5496b7f1c1fc5b95481f13f75e + loofah (2.24.1) sha256=655a30842b70ec476410b347ab1cd2a5b92da46a19044357bbd9f401b009a337 mail (2.8.1) sha256=ec3b9fadcf2b3755c78785cb17bc9a0ca9ee9857108a64b6f5cfc9c0b5bfc9ad marcel (1.0.4) sha256=0d5649feb64b8f19f3d3468b96c680bae9746335d02194270287868a661516a4 method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5 mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef - mini_portile2 (2.8.8) sha256=8e47136cdac04ce81750bb6c09733b37895bf06962554e4b4056d78168d70a75 + mini_portile2 (2.8.9) sha256=0cd7c7f824e010c072e33f68bc02d85a00aeb6fce05bb4819c03dfd3c140c289 minitest (5.25.5) sha256=391b6c6cb43a4802bfb7c93af1ebe2ac66a210293f4a3fb7db36f2fc7dc2c756 money (6.19.0) sha256=ec936fa1e42f2783719241ed9fd52725d0efa628f928feea1eb5c37d5de7daf3 msgpack (1.7.5) sha256=ffb04979f51e6406823c03abe50e1da2c825c55a37dee138518cdd09d9d3aea8 @@ -543,36 +552,38 @@ CHECKSUMS net-protocol (0.2.2) sha256=aa73e0cba6a125369de9837b8d8ef82a61849360eba0521900e2c3713aa162a8 net-smtp (0.5.1) sha256=ed96a0af63c524fceb4b29b0d352195c30d82dd916a42f03c62a3a70e5b70736 nio4r (2.7.4) sha256=d95dee68e0bb251b8ff90ac3423a511e3b784124e5db7ff5f4813a220ae73ca9 - nokogiri (1.18.7) sha256=6b63ff5defe48f30d1d3b3122f65255ca91df2caf5378c6e0482ce73ff46fb31 - nokogiri (1.18.7-aarch64-linux-gnu) sha256=57a064ab5440814a69a0e040817bd8154adea68a30d2ff2b3aa515a6a06dbb5f - nokogiri (1.18.7-arm-linux-gnu) sha256=337d9149deb5ae01022dff7c90f97bed81715fd586aacab0c5809ef933994c5e - nokogiri (1.18.7-arm64-darwin) sha256=083abb2e9ed2646860f6b481a981485a658c6064caafaa81bf1cda1bada2e9d5 - nokogiri (1.18.7-x86_64-darwin) sha256=081d1aa517454ba3415304e2ea51fe411d6a3a809490d0c4aa42799cada417b7 - nokogiri (1.18.7-x86_64-linux-gnu) sha256=3a0bf946eb2defde13d760f869b61bc8b0c18875afdd3cffa96543cfa3a18005 + nokogiri (1.18.8) sha256=8c7464875d9ca7f71080c24c0db7bcaa3940e8be3c6fc4bcebccf8b9a0016365 + nokogiri (1.18.8-aarch64-linux-gnu) sha256=36badd2eb281fca6214a5188e24a34399b15d89730639a068d12931e2adc210e + nokogiri (1.18.8-arm-linux-gnu) sha256=17de01ca3adf9f8e187883ed73c672344d3dbb3c260f88ffa1008e8dc255a28e + nokogiri (1.18.8-arm64-darwin) sha256=483b5b9fb33653f6f05cbe00d09ea315f268f0e707cfc809aa39b62993008212 + nokogiri (1.18.8-x86_64-darwin) sha256=024cdfe7d9ae3466bba6c06f348fb2a8395d9426b66a3c82f1961b907945cc0c + nokogiri (1.18.8-x86_64-linux-gnu) sha256=4a747875db873d18a2985ee2c320a6070c4a414ad629da625fbc58d1a20e5ecc orm_adapter (0.5.0) sha256=aa5d0be5d540cbb46d3a93e88061f4ece6a25f6e97d6a47122beb84fe595e9b9 parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130 parser (3.3.8.0) sha256=2476364142b307fa5a1b1ece44f260728be23858a9c71078e956131a75453c45 pg (1.5.9) sha256=761efbdf73b66516f0c26fcbe6515dc7500c3f0aa1a1b853feae245433c64fdc pluck_to_hash (1.0.2) sha256=1599906239716f98262a41493dd7d4cb72e8d83ad3d76d666deacfc5de50a47e + pp (0.6.2) sha256=947ec3120c6f92195f8ee8aa25a7b2c5297bb106d83b41baa02983686577b6ff + prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193 prism (1.4.0) sha256=dc0e3e00e93160213dc2a65519d9002a4a1e7b962db57d444cf1a71565bb703e pry (0.15.2) sha256=12d54b8640d3fa29c9211dd4ffb08f3fd8bf7a4fd9b5a73ce5b59c8709385b6b - psych (5.2.3) sha256=84a54bb952d14604fea22d99938348814678782f58b12648fcdfa4d2fce859ee + psych (5.2.6) sha256=814328aa5dcb6d604d32126a20bc1cbcf05521a5b49dbb1a8b30a07e580f316e public_suffix (6.0.1) sha256=61d44e1cab5cbbbe5b31068481cf16976dd0dc1b6b07bd95617ef8c5e3e00c6f puma (6.6.0) sha256=f25c06873eb3d5de5f0a4ebc783acc81a4ccfe580c760cfe323497798018ad87 raabro (1.4.0) sha256=d4fa9ff5172391edb92b242eed8be802d1934b1464061ae5e70d80962c5da882 racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f - rack (3.1.14) sha256=84613c2a8df193bb6711d9c14ecc6d5a65a7cb4312379a65e793562608944b44 - rack-cors (2.0.2) sha256=415d4e1599891760c5dc9ef0349c7fecdf94f7c6a03e75b2e7c2b54b82adda1b - rack-session (2.0.0) sha256=db04b2063e180369192a9046b4559af311990af38c6a93d4c600cee4eb6d4e81 - rack-test (2.1.0) sha256=0c61fc61904049d691922ea4bb99e28004ed3f43aa5cfd495024cc345f125dfb + rack (3.1.15) sha256=d12b3e9960d18a26ded961250f2c0e3b375b49ff40dbe6786e9c3b160cbffca4 + rack-cors (3.0.0) sha256=7b95be61db39606906b61b83bd7203fa802b0ceaaad8fcb2fef39e097bf53f68 + rack-session (2.1.1) sha256=0b6dc07dea7e4b583f58a48e8b806d4c9f1c6c9214ebc202ec94562cbea2e4e9 + rack-test (2.2.0) sha256=005a36692c306ac0b4a9350355ee080fd09ddef1148a5f8b2ac636c720f5c463 rackup (2.2.1) sha256=f737191fd5c5b348b7f0a4412a3b86383f88c43e13b8217b63d4c8d90b9e798d rails (8.0.2) sha256=fdfaa5a83ec0388e02864e88d515959caedc88053b5f701c4deb1652d8f164c6 - rails-dom-testing (2.2.0) sha256=e515712e48df1f687a1d7c380fd7b07b8558faa26464474da64183a7426fa93b + rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d rails-html-sanitizer (1.6.2) sha256=35fce2ca8242da8775c83b6ba9c1bcaad6751d9eb73c1abaa8403475ab89a560 railties (8.0.2) sha256=0d7c3f40c49ba74980f1bac1d4bb153a9331c5ee8a9631d89c7bf79db82e5cf9 rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a - rake (13.2.1) sha256=46cb38dae65d7d74b6020a4ac9d48afed8eb8149c040eccf0523bec91907059d - rdoc (6.10.0) sha256=db665021883ac9df3ba29cdf71aece960749888db1bf9615b4a584cfa3fa3eda + rake (13.3.0) sha256=96f5092d786ff412c62fde76f793cc0541bd84d2eb579caa529aa8a059934493 + rdoc (6.14.0) sha256=2c46de58d7129b8743fcf6d76e3db971bdc914150e15ac06b386549bd82ed7db react-rails (3.2.1) sha256=2235db0b240517596b1cb3e26177ab5bc64d3a56579b0415ee242b1691f81f64 redis (5.4.0) sha256=798900d869418a9fc3977f916578375b45c38247a556b61d58cba6bb02f7d06b redis-client (0.23.2) sha256=e33bab6682c8155cfef95e6dd296936bb9c2981a89fb578ace27a076fa2836fa @@ -580,17 +591,17 @@ CHECKSUMS reline (0.6.1) sha256=1afcc9d7cb1029cdbe780d72f2f09251ce46d3780050f3ec39c3ccc6b60675fb responders (3.1.1) sha256=92f2a87e09028347368639cfb468f5fefa745cb0dc2377ef060db1cdd79a341a rexml (3.3.9) sha256=d71875b85299f341edf47d44df0212e7658cbdf35aeb69cefdb63f57af3137c9 - rspec-core (3.13.3) sha256=25136507f4f9cf2e8977a2851e64e438b4331646054e345998714108745cdfe4 - rspec-expectations (3.13.3) sha256=0e6b5af59b900147698ea0ff80456c4f2e69cac4394fbd392fbd1ca561f66c58 - rspec-mocks (3.13.2) sha256=2327335def0e1665325a9b617e3af9ae20272741d80ac550336309a7c59abdef - rspec-rails (7.1.1) sha256=e15dccabed211e2fd92f21330c819adcbeb1591c1d66c580d8f2d8288557e331 - rspec-support (3.13.2) sha256=cea3a2463fd9b84b9dcc9685efd80ea701aa8f7b3decb3b3ce795ed67737dbec + rspec-core (3.13.4) sha256=f9da156b7b775c82610a7b580624df51a55102f8c8e4a103b98f5d7a9fa23958 + rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836 + rspec-mocks (3.13.5) sha256=e4338a6f285ada9fe56f5893f5457783af8194f5d08884d17a87321d5195ea81 + rspec-rails (8.0.0) sha256=977a508cd94d152db2068c6585470db5d0cd47eef56d5410b9531034fb9d97bf + rspec-support (3.13.4) sha256=184b1814f6a968102b57df631892c7f1990a91c9a3b9e80ef892a0fc2a71a3f7 rswag (2.16.0) sha256=f07ce41548b9bb51464c38bc7b95af22fee84b90f2d1197a515a623906353086 rswag-api (2.16.0) sha256=b653f7bd92e98be18b01ab4525d88950d7b0960e293a99f856b9efcee3ae6074 rswag-specs (2.16.0) sha256=8ba26085c408b0bd2ed21dc8015c80f417c7d34c63720ab7133c2549b5bd2a91 rswag-ui (2.16.0) sha256=a1f49e927dceda92e6e6e7c1000f1e217ee66c565f69e28131dc98b33cd3a04f - rubocop (1.75.8) sha256=c80ab4286c5dcfc49d7ad1787cdba5569b63b58c96ee7afde4ec47a9c8a85be9 - rubocop-ast (1.44.1) sha256=e3cc04203b2ef04f6d6cf5f85fe6d643f442b18cc3b23e3ada0ce5b6521b8e92 + rubocop (1.76.1) sha256=e15a2d750794cf2157d2de8b1b403dfa71b8dc3957a22ae6043b1bdf21e7e0e7 + rubocop-ast (1.45.1) sha256=94042e49adc17f187ba037b33f941ba7398fede77cdf4bffafba95190a473a3e rubocop-factory_bot (2.27.1) sha256=9d744b5916778c1848e5fe6777cc69855bd96548853554ec239ba9961b8573fe rubocop-rails (2.32.0) sha256=9fcc623c8722fe71e835e99c4a18b740b5b0d3fb69915d7f0777f00794b30490 rubocop-rspec (3.6.0) sha256=c0e4205871776727e54dee9cc91af5fd74578001551ba40e1fe1a1ab4b404479 @@ -604,12 +615,12 @@ CHECKSUMS sprockets (4.2.1) sha256=951b13dd2f2fcae840a7184722689a803e0ff9d2702d902bd844b196da773f97 sprockets-rails (3.5.2) sha256=a9e88e6ce9f8c912d349aa5401509165ec42326baf9e942a85de4b76dbc4119e stimulus-rails (1.3.4) sha256=765676ffa1f33af64ce026d26b48e8ffb2e0b94e0f50e9119e11d6107d67cb06 - stringio (3.1.6) sha256=292c495d1657adfcdf0a32eecf12a60e6691317a500c3112ad3b2e31068274f5 + stringio (3.1.7) sha256=5b78b7cb242a315fb4fca61a8255d62ec438f58da2b90be66048546ade4507fa thor (1.3.2) sha256=eef0293b9e24158ccad7ab383ae83534b7ad4ed99c09f96f1a6b036550abbeda tilt (2.4.0) sha256=df74f29a451daed26591a85e8e0cebb198892cb75b6573394303acda273fba4d timeout (0.4.3) sha256=9509f079b2b55fe4236d79633bd75e34c1c1e7e3fb4b56cb5fda61f80a0fe30e tomlrb (2.0.3) sha256=c2736acf24919f793334023a4ff396c0647d93fce702a73c9d348deaa815d4f7 - turbo-rails (2.0.13) sha256=c40ac0a3ccd57c129925c8ac524a5dfd1e17fad080906e2d32135721a8bba22f + turbo-rails (2.0.16) sha256=d24e1b60f0c575b3549ecda967e5391027143f8220d837ed792c8d48ea0ea38d tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b unicode-display_width (2.6.0) sha256=12279874bba6d5e4d2728cef814b19197dbb10d7a7837a869bab65da943b7f5a uri (1.0.3) sha256=e9f2244608eea2f7bc357d954c65c910ce0399ca5e18a7a29207ac22d8767011 @@ -620,7 +631,7 @@ CHECKSUMS websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241 with_env (1.1.0) sha256=50b3e4f0a6cda8f90d8a6bd87a6261f6c381429abafb161c4c69ad4a0cd0b6e4 xml-simple (1.1.9) sha256=d21131e519c86f1a5bc2b6d2d57d46e6998e47f18ed249b25cad86433dbd695d - zeitwerk (2.7.2) sha256=842e067cb11eb923d747249badfb5fcdc9652d6f20a1f06453317920fdcd4673 + zeitwerk (2.7.3) sha256=b2e86b4a9b57d26ba68a15230dcc7fe6f040f06831ce64417b0621ad96ba3e85 RUBY VERSION ruby 3.4.3p32 diff --git a/README.md b/README.md index e1cc204..22e4142 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,12 @@ The backend service will seed the database with fake data. It's worth noting tha The backend, frontend and workers have hot-reloading enabled, so changes made to the codebase should be reflected in the application on the next request. +Please, include this in your `/etc/hosts` file: + +``` +127.0.0.1 libre-wedding-planner.app.localhost +``` + Once all containers have started, visit http://libre-wedding-planner.app.localhost/default/dashboard to load the application. ## Multitenancy diff --git a/app/controllers/guests_controller.rb b/app/controllers/guests_controller.rb index 1d872fa..1b215eb 100644 --- a/app/controllers/guests_controller.rb +++ b/app/controllers/guests_controller.rb @@ -5,21 +5,22 @@ require 'csv' class GuestsController < ApplicationController + GUEST_PARAMS = { only: %i[id name status], include: { group: { only: %i[id name] } } }.freeze def index render json: Guest.includes(:group) .left_joins(:group) .order('groups.name' => :asc, name: :asc) - .as_json(only: %i[id name status], include: { group: { only: %i[id name] } }) + .as_json(GUEST_PARAMS) end def create - Guest.create!(guest_params) - render json: {}, status: :created + guest = Guest.create!(guest_params) + render json: guest.as_json(GUEST_PARAMS), status: :created end def update - Guest.find(params[:id]).update!(guest_params) - render json: {}, status: :ok + guest = Guest.find(params[:id]).update!(guest_params) + render json: guest.as_json(GUEST_PARAMS), status: :ok end def destroy diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb new file mode 100644 index 0000000..69888ea --- /dev/null +++ b/app/controllers/invitations_controller.rb @@ -0,0 +1,48 @@ +# Copyright (C) 2024-2025 LibreWeddingPlanner contributors + +# frozen_string_literal: true + +# Copyright (C) 2024-2025 LibreWeddingPlanner contributors + +class InvitationsController < ApplicationController + def index + render json: Invitation.includes(:guests).as_json( + only: :id, + include: { + guests: { + only: %i[id name] + } + } + ) + end + + def create + invitation = Invitation.create + + if invitation.persisted? + render json: invitation, only: :id, status: :created + else + render json: { errors: invitation.errors.full_messages }, status: :unprocessable_entity + end + end + + def update + invitation = Invitation.find(params[:id]) + + if invitation.update(guest_ids: params[:invitation][:guest_ids]) + render json: invitation, only: :id, include: { guests: { only: %i[id name] } }, status: :ok + else + render json: { errors: invitation.errors.full_messages }, status: :unprocessable_entity + end + end + + def destroy + invitation = Invitation.find(params[:id]) + + if invitation.destroy + head :no_content + else + render json: { errors: invitation.errors.full_messages }, status: :unprocessable_entity + end + end +end diff --git a/app/controllers/websites_controller.rb b/app/controllers/websites_controller.rb new file mode 100644 index 0000000..44b1fb1 --- /dev/null +++ b/app/controllers/websites_controller.rb @@ -0,0 +1,25 @@ +# Copyright (C) 2024-2025 LibreWeddingPlanner contributors + +# frozen_string_literal: true + +class WebsitesController < ApplicationController + skip_before_action :authenticate_user!, only: :show + + def show + render json: current_tenant.website.as_json(only: %i[content]) || {}, status: :ok + end + + def update + ActiveRecord::Base.transaction do + website = current_tenant.website || current_tenant.create_website + website.update!(website_params) + render json: website.as_json(only: %i[content]), status: :ok + end + end + + private + + def website_params + params.expect(website: [:content]) + end +end diff --git a/app/models/expense.rb b/app/models/expense.rb index 66b32f3..a04a5c1 100644 --- a/app/models/expense.rb +++ b/app/models/expense.rb @@ -20,7 +20,7 @@ # # Foreign Keys # -# fk_rails_... (wedding_id => weddings.id) +# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade # class Expense < ApplicationRecord acts_as_tenant :wedding diff --git a/app/models/group.rb b/app/models/group.rb index 2db28ed..e0db499 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -25,7 +25,7 @@ # Foreign Keys # # fk_rails_... (parent_id => groups.id) -# fk_rails_... (wedding_id => weddings.id) +# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade # class Group < ApplicationRecord acts_as_tenant :wedding diff --git a/app/models/guest.rb b/app/models/guest.rb index d080679..54142ee 100644 --- a/app/models/guest.rb +++ b/app/models/guest.rb @@ -6,28 +6,32 @@ # # Table name: guests # -# id :uuid not null, primary key -# name :string -# phone :string -# status :integer default("considered") -# created_at :datetime not null -# updated_at :datetime not null -# group_id :uuid -# wedding_id :uuid not null +# id :uuid not null, primary key +# name :string +# phone :string +# status :integer default("considered") +# created_at :datetime not null +# updated_at :datetime not null +# group_id :uuid +# invitation_id :uuid +# wedding_id :uuid not null # # Indexes # -# index_guests_on_group_id (group_id) -# index_guests_on_wedding_id (wedding_id) +# index_guests_on_group_id (group_id) +# index_guests_on_invitation_id (invitation_id) +# index_guests_on_wedding_id (wedding_id) # # Foreign Keys # # fk_rails_... (group_id => groups.id) -# fk_rails_... (wedding_id => weddings.id) +# fk_rails_... (invitation_id => invitations.id) +# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade # class Guest < ApplicationRecord acts_as_tenant :wedding belongs_to :group, optional: true + belongs_to :invitation, optional: true enum :status, { considered: 0, diff --git a/app/models/invitation.rb b/app/models/invitation.rb new file mode 100644 index 0000000..020242e --- /dev/null +++ b/app/models/invitation.rb @@ -0,0 +1,25 @@ +# Copyright (C) 2024-2025 LibreWeddingPlanner contributors + +# frozen_string_literal: true + +# == Schema Information +# +# Table name: invitations +# +# id :uuid not null, primary key +# created_at :datetime not null +# updated_at :datetime not null +# wedding_id :uuid not null +# +# Indexes +# +# index_invitations_on_wedding_id (wedding_id) +# +# Foreign Keys +# +# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade +# +class Invitation < ApplicationRecord + acts_as_tenant :wedding + has_many :guests, dependent: :nullify +end diff --git a/app/models/seat.rb b/app/models/seat.rb index 9c31c42..f4f7b97 100644 --- a/app/models/seat.rb +++ b/app/models/seat.rb @@ -24,7 +24,7 @@ # # fk_rails_... (guest_id => guests.id) # fk_rails_... (tables_arrangement_id => tables_arrangements.id) ON DELETE => cascade -# fk_rails_... (wedding_id => weddings.id) +# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade # class Seat < ApplicationRecord acts_as_tenant :wedding diff --git a/app/models/tables_arrangement.rb b/app/models/tables_arrangement.rb index a461555..b5fccb0 100644 --- a/app/models/tables_arrangement.rb +++ b/app/models/tables_arrangement.rb @@ -20,7 +20,7 @@ # # Foreign Keys # -# fk_rails_... (wedding_id => weddings.id) +# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade # class TablesArrangement < ApplicationRecord acts_as_tenant :wedding diff --git a/app/models/user.rb b/app/models/user.rb index ff46fff..6c7d79c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -32,7 +32,7 @@ # # Foreign Keys # -# fk_rails_... (wedding_id => weddings.id) +# fk_rails_... (wedding_id => weddings.id) ON DELETE => cascade # class User < ApplicationRecord acts_as_tenant :wedding diff --git a/app/models/website.rb b/app/models/website.rb new file mode 100644 index 0000000..401b101 --- /dev/null +++ b/app/models/website.rb @@ -0,0 +1,25 @@ +# Copyright (C) 2024-2025 LibreWeddingPlanner contributors + +# frozen_string_literal: true + +# == Schema Information +# +# Table name: websites +# +# id :bigint not null, primary key +# content :text +# created_at :datetime not null +# updated_at :datetime not null +# wedding_id :uuid not null +# +# Indexes +# +# index_websites_on_wedding_id (wedding_id) +# +# Foreign Keys +# +# fk_rails_... (wedding_id => weddings.id) +# +class Website < ApplicationRecord + belongs_to :wedding +end diff --git a/app/models/wedding.rb b/app/models/wedding.rb index 5f0dabf..36e3ca8 100644 --- a/app/models/wedding.rb +++ b/app/models/wedding.rb @@ -21,4 +21,7 @@ class Wedding < ApplicationRecord validates :slug, presence: true, uniqueness: true, format: { with: /\A#{SLUG_REGEX}\z/ } has_many :guests, dependent: :delete_all + has_many :groups, dependent: :delete_all + has_many :invitations, dependent: :delete_all + has_one :website, dependent: :destroy end diff --git a/app/serializers/serializable_guest.rb b/app/serializers/serializable_guest.rb index ee4bac1..9b062bf 100644 --- a/app/serializers/serializable_guest.rb +++ b/app/serializers/serializable_guest.rb @@ -5,16 +5,12 @@ class SerializableGuest < JSONAPI::Serializable::Resource type 'guest' - attributes :id, :group_id, :status + attributes :id, :status attribute :name do @object.name end - attribute :group_name do - @object.group.name - end - attribute :status do @object.status.capitalize end diff --git a/config/initializers/acts_as_tenant.rb b/config/initializers/acts_as_tenant.rb index fd8890d..25855eb 100644 --- a/config/initializers/acts_as_tenant.rb +++ b/config/initializers/acts_as_tenant.rb @@ -2,4 +2,8 @@ ActsAsTenant.configure do |config| config.require_tenant = !Rails.env.test? -end \ No newline at end of file +end + +Rails.application.console do + ActsAsTenant.current_tenant = Wedding.first +end diff --git a/config/routes.rb b/config/routes.rb index 39d0460..e908b04 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -37,8 +37,12 @@ Rails.application.routes.draw do resources :expenses, only: %i[index create update destroy] do get :summary, on: :collection end + + resource :website, only: [:show, :update] + resources :tables_arrangements, only: %i[index show create] resources :summary, only: :index + resources :invitations, only: %i[index create update destroy] root to: redirect("/%{slug}") end diff --git a/db/migrate/20250127183547_create_invitations.rb b/db/migrate/20250127183547_create_invitations.rb new file mode 100644 index 0000000..ed2e8a3 --- /dev/null +++ b/db/migrate/20250127183547_create_invitations.rb @@ -0,0 +1,10 @@ +class CreateInvitations < ActiveRecord::Migration[8.0] + def change + create_table :invitations, id: :uuid do |t| + t.references :wedding, null: false, foreign_key: { on_delete: :cascade }, type: :uuid + t.timestamps + end + + add_reference :guests, :invitation, foreign_key: true, type: :uuid + end +end diff --git a/db/migrate/20250127190131_fix_cascading_wedding_deletion.rb b/db/migrate/20250127190131_fix_cascading_wedding_deletion.rb new file mode 100644 index 0000000..a371d8e --- /dev/null +++ b/db/migrate/20250127190131_fix_cascading_wedding_deletion.rb @@ -0,0 +1,8 @@ +class FixCascadingWeddingDeletion < ActiveRecord::Migration[8.0] + def change + [:expenses, :groups, :guests, :seats, :tables_arrangements, :users].each do |table| + remove_foreign_key table, :weddings, column: :wedding_id + add_foreign_key table, :weddings, on_delete: :cascade + end + end +end diff --git a/db/migrate/20250608181054_create_websites.rb b/db/migrate/20250608181054_create_websites.rb new file mode 100644 index 0000000..63715b7 --- /dev/null +++ b/db/migrate/20250608181054_create_websites.rb @@ -0,0 +1,10 @@ +class CreateWebsites < ActiveRecord::Migration[8.0] + def change + create_table :websites do |t| + t.text :content + t.references :wedding, null: false, foreign_key: true, type: :uuid + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 5b61f3f..2576583 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_01_26_091823) do +ActiveRecord::Schema[8.0].define(version: 2025_06_08_181054) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -63,10 +63,19 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_26_091823) do t.integer "status", default: 0 t.string "name" t.uuid "wedding_id", null: false + t.uuid "invitation_id" t.index ["group_id"], name: "index_guests_on_group_id" + t.index ["invitation_id"], name: "index_guests_on_invitation_id" t.index ["wedding_id"], name: "index_guests_on_wedding_id" end + create_table "invitations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "wedding_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["wedding_id"], name: "index_invitations_on_wedding_id" + end + create_table "seats", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "guest_id", null: false t.uuid "tables_arrangement_id", null: false @@ -232,6 +241,14 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_26_091823) do t.index ["wedding_id"], name: "index_users_on_wedding_id" end + create_table "websites", force: :cascade do |t| + t.text "content" + t.uuid "wedding_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["wedding_id"], name: "index_websites_on_wedding_id" + end + create_table "weddings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.string "slug", null: false t.datetime "created_at", null: false @@ -239,22 +256,25 @@ ActiveRecord::Schema[8.0].define(version: 2025_01_26_091823) do t.index ["slug"], name: "index_weddings_on_slug", unique: true end - add_foreign_key "expenses", "weddings" + add_foreign_key "expenses", "weddings", on_delete: :cascade add_foreign_key "group_affinities", "groups", column: "group_a_id" add_foreign_key "group_affinities", "groups", column: "group_b_id" add_foreign_key "groups", "groups", column: "parent_id" - add_foreign_key "groups", "weddings" + add_foreign_key "groups", "weddings", on_delete: :cascade add_foreign_key "guests", "groups" - add_foreign_key "guests", "weddings" + add_foreign_key "guests", "invitations" + add_foreign_key "guests", "weddings", on_delete: :cascade + add_foreign_key "invitations", "weddings", on_delete: :cascade add_foreign_key "seats", "guests" add_foreign_key "seats", "tables_arrangements", on_delete: :cascade - add_foreign_key "seats", "weddings" + add_foreign_key "seats", "weddings", on_delete: :cascade add_foreign_key "solid_queue_blocked_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade add_foreign_key "solid_queue_claimed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade add_foreign_key "solid_queue_failed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade add_foreign_key "solid_queue_ready_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade add_foreign_key "solid_queue_recurring_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade - add_foreign_key "tables_arrangements", "weddings" - add_foreign_key "users", "weddings" + add_foreign_key "tables_arrangements", "weddings", on_delete: :cascade + add_foreign_key "users", "weddings", on_delete: :cascade + add_foreign_key "websites", "weddings" end diff --git a/db/seeds.rb b/db/seeds.rb index fcf5ec3..f69b6e9 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,33 +1,33 @@ +# frozen_string_literal: true + # Copyright (C) 2024-2025 LibreWeddingPlanner contributors -NUMBER_OF_GUESTS = 50 +NUMBER_OF_GUESTS = 200 ActsAsTenant.without_tenant do - TablesArrangement.delete_all - Expense.delete_all - Guest.delete_all - Group.delete_all - + GroupAffinity.delete_all Wedding.delete_all end wedding = Wedding.create!(slug: :default) ActsAsTenant.with_tenant(wedding) do - Expense.create!(name: 'Photographer', amount: 3000, pricing_type: 'fixed') - Expense.create!(name: 'Country house', amount: 6000, pricing_type: 'fixed') - Expense.create!(name: 'Catering', amount: 200, pricing_type: 'per_person') - Expense.create!(name: 'Flowers', amount: 500, pricing_type: 'fixed') - Expense.create!(name: 'Band', amount: 1000, pricing_type: 'fixed') - Expense.create!(name: 'Wedding planner', amount: 2000, pricing_type: 'fixed') - Expense.create!(name: 'Dress', amount: 1000, pricing_type: 'fixed') - Expense.create!(name: 'Suit', amount: 500, pricing_type: 'fixed') - Expense.create!(name: 'Rings', amount: 1000, pricing_type: 'fixed') - Expense.create!(name: 'Makeup', amount: 200, pricing_type: 'fixed') - Expense.create!(name: 'Hair', amount: 200, pricing_type: 'fixed') - Expense.create!(name: 'Transportation', amount: 3000, pricing_type: 'fixed') - Expense.create!(name: 'Invitations', amount: 200, pricing_type: 'fixed') - Expense.create!(name: 'Cake', amount: 500, pricing_type: 'fixed') + [ + { name: 'Photographer', amount: 3000, pricing_type: 'fixed' }, + { name: 'Country house', amount: 6000, pricing_type: 'fixed' }, + { name: 'Catering', amount: 200, pricing_type: 'per_person' }, + { name: 'Flowers', amount: 500, pricing_type: 'fixed' }, + { name: 'Band', amount: 1000, pricing_type: 'fixed' }, + { name: 'Wedding planner', amount: 2000, pricing_type: 'fixed' }, + { name: 'Dress', amount: 1000, pricing_type: 'fixed' }, + { name: 'Suit', amount: 500, pricing_type: 'fixed' }, + { name: 'Rings', amount: 1000, pricing_type: 'fixed' }, + { name: 'Makeup', amount: 200, pricing_type: 'fixed' }, + { name: 'Hair', amount: 200, pricing_type: 'fixed' }, + { name: 'Transportation', amount: 3000, pricing_type: 'fixed' }, + { name: 'Invitations', amount: 200, pricing_type: 'fixed' }, + { name: 'Cake', amount: 500, pricing_type: 'fixed' } + ].then { Expense.insert_all!(it) } Group.create!(name: "Jim's guests", icon: 'pi pi-heart').tap do |parent| parent.children.create!(name: "Jim's family", icon: 'pi pi-users').tap do |family| @@ -61,18 +61,34 @@ ActsAsTenant.with_tenant(wedding) do groups = Group.all - NUMBER_OF_GUESTS.times do - Guest.create!( + NUMBER_OF_GUESTS.times.map do |i| + { name: Faker::Name.name, phone: Faker::PhoneNumber.cell_phone, - group: groups.sample, - status: Guest.statuses.keys.sample - ) + group_id: groups.sample.id, + status: Guest.statuses.keys.sample, + } + end.then { Guest.insert_all!(it) } + + Group.includes(:guests).each do |group| + guests = group.guests.potential.to_a + + while guests.any? + invitation = Invitation.create! + + guests.shift(rand(1..3)).each do |guest| + guest.update!(invitation:) + end + guests.shift(1) if rand < 0.3 # Leave a percentage of guests without an invitation + + end end + # TODO: Clean up invitations with no guests + ActiveJob.perform_all_later(3.times.map { TableSimulatorJob.new(wedding.id) }) - 'red'.paint.palette.triad(as: :hex).zip(Group.roots).each { |(color, group)| group.update!(color: color.paint.desaturate(40)) } + "red".dup.paint.palette.triad(as: :hex).zip(Group.roots).each { |(color, group)| group.update!(color: color.paint.desaturate(40)) } Group.roots.each(&:colorize_children) @@ -80,6 +96,6 @@ ActsAsTenant.with_tenant(wedding) do email: 'development@example.com', confirmed_at: Time.zone.now, password: 'supersecretpassword', - password_confirmation: 'supersecretpassword', + password_confirmation: 'supersecretpassword' ) end diff --git a/spec/factories/invitations.rb b/spec/factories/invitations.rb new file mode 100644 index 0000000..a1dab61 --- /dev/null +++ b/spec/factories/invitations.rb @@ -0,0 +1,9 @@ +# Copyright (C) 2024-2025 LibreWeddingPlanner contributors + +# frozen_string_literal: true + +FactoryBot.define do + factory :invitation do + wedding + end +end diff --git a/spec/factories/websites.rb b/spec/factories/websites.rb new file mode 100644 index 0000000..b8c4048 --- /dev/null +++ b/spec/factories/websites.rb @@ -0,0 +1,10 @@ +# Copyright (C) 2024-2025 LibreWeddingPlanner contributors + +# frozen_string_literal: true + +FactoryBot.define do + factory :website do + content { 'MyText' } + wedding { nil } + end +end diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb new file mode 100644 index 0000000..f4cc2c3 --- /dev/null +++ b/spec/models/invitation_spec.rb @@ -0,0 +1,9 @@ +# Copyright (C) 2024-2025 LibreWeddingPlanner contributors + +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Invitation do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/website_spec.rb b/spec/models/website_spec.rb new file mode 100644 index 0000000..a9533cd --- /dev/null +++ b/spec/models/website_spec.rb @@ -0,0 +1,9 @@ +# Copyright (C) 2024-2025 LibreWeddingPlanner contributors + +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Website do + it { is_expected.to belong_to(:wedding) } +end