Compare commits

..

1 Commits

Author SHA1 Message Date
Renovate Bot
fc2b4b091f Update dependency faker to v3.4.1 2024-07-12 13:03:41 +00:00
4 changed files with 20 additions and 76 deletions

View File

@ -1,34 +0,0 @@
name: Run unit tests
on:
push:
branches:
- main
pull_request:
jobs:
unit_tests:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: ruby/setup-ruby@v1
- run: bundle install
- run: |
bundle exec rake db:create db:schema:load
bundle exec rspec
env:
RAILS_ENV: test
DATABASE_URL: postgres://postgres:postgres@postgres:5432/postgres

View File

@ -1,16 +1,14 @@
class GuestsController < ApplicationController class GuestsController < ApplicationController
before_action :set_guest, only: %i[show edit update destroy] before_action :set_guest, only: %i[ show edit update destroy ]
# GET /guests or /guests.json # GET /guests or /guests.json
def index def index
@guests = Guest.all @guests = Guest.all.includes(:affinity_groups)
.left_outer_joins(:affinity_groups)
.order('tags.name' => :asc)
.includes(:affinity_groups, :unbreakable_bonds)
end end
# GET /guests/1 or /guests/1.json # GET /guests/1 or /guests/1.json
def show; end def show
end
# GET /guests/new # GET /guests/new
def new def new
@ -18,7 +16,8 @@ class GuestsController < ApplicationController
end end
# GET /guests/1/edit # GET /guests/1/edit
def edit; end def edit
end
# POST /guests or /guests.json # POST /guests or /guests.json
def create def create
@ -26,7 +25,7 @@ class GuestsController < ApplicationController
respond_to do |format| respond_to do |format|
if @guest.save if @guest.save
format.html { redirect_to guest_url(@guest), notice: 'Guest was successfully created.' } format.html { redirect_to guest_url(@guest), notice: "Guest was successfully created." }
format.json { render :show, status: :created, location: @guest } format.json { render :show, status: :created, location: @guest }
else else
format.html { render :new, status: :unprocessable_entity } format.html { render :new, status: :unprocessable_entity }
@ -39,7 +38,7 @@ class GuestsController < ApplicationController
def update def update
respond_to do |format| respond_to do |format|
if @guest.update(guest_params) if @guest.update(guest_params)
format.html { redirect_to guest_url(@guest), notice: 'Guest was successfully updated.' } format.html { redirect_to guest_url(@guest), notice: "Guest was successfully updated." }
format.json { render :show, status: :ok, location: @guest } format.json { render :show, status: :ok, location: @guest }
else else
format.html { render :edit, status: :unprocessable_entity } format.html { render :edit, status: :unprocessable_entity }
@ -53,20 +52,19 @@ class GuestsController < ApplicationController
@guest.destroy! @guest.destroy!
respond_to do |format| respond_to do |format|
format.html { redirect_to guests_url, notice: 'Guest was successfully destroyed.' } format.html { redirect_to guests_url, notice: "Guest was successfully destroyed." }
format.json { head :no_content } format.json { head :no_content }
end end
end end
private private
# Use callbacks to share common setup or constraints between actions.
def set_guest
@guest = Guest.find(params[:id])
end
# Use callbacks to share common setup or constraints between actions. # Only allow a list of trusted parameters through.
def set_guest def guest_params
@guest = Guest.find(params[:id]) params.require(:guest).permit(:first_name, :last_name, :email, :phone)
end end
# Only allow a list of trusted parameters through.
def guest_params
params.require(:guest).permit(:first_name, :last_name, :email, :phone)
end
end end

View File

@ -10,7 +10,6 @@
<th>Email</th> <th>Email</th>
<th>Phone</th> <th>Phone</th>
<th>Affinity groups</th> <th>Affinity groups</th>
<th>Unbreakable bonds</th>
<th colspan="2"></th> <th colspan="2"></th>
</tr> </tr>
<% @guests.each_with_index do |guest, i| %> <% @guests.each_with_index do |guest, i| %>
@ -20,7 +19,6 @@
<td><%= guest.email %></td> <td><%= guest.email %></td>
<td><%= guest.phone %></td> <td><%= guest.phone %></td>
<td><%= guest.affinity_groups.pluck(:name).join(", ") %></td> <td><%= guest.affinity_groups.pluck(:name).join(", ") %></td>
<td><%= guest.unbreakable_bonds.pluck(:name).join(", ") %></td>
<td><%= link_to "Show", guest %></td> <td><%= link_to "Show", guest %></td>
<td><%= link_to "Edit", edit_guest_path(guest) %></td> <td><%= link_to "Edit", edit_guest_path(guest) %></td>
</tr> </tr>

View File

@ -28,10 +28,7 @@ Expense.create!(name: 'Transportation', amount: 3000, pricing_type: 'fixed')
Expense.create!(name: 'Invitations', amount: 200, pricing_type: 'fixed') Expense.create!(name: 'Invitations', amount: 200, pricing_type: 'fixed')
Expense.create!(name: 'Cake', amount: 500, pricing_type: 'fixed') Expense.create!(name: 'Cake', amount: 500, pricing_type: 'fixed')
<<<<<<< HEAD
=======
>>>>>>> 8fd0b7c (Modify seeds file to make sure every guest is part of a group)
samples = { samples = {
close_family: 10, close_family: 10,
family_1_group_a: 5, family_1_group_a: 5,
@ -52,25 +49,10 @@ end
300.times do 300.times do
guest = Guest.create!(first_name: Faker::Name.first_name, guest = Guest.create!(first_name: Faker::Name.first_name,
last_name: Faker::Name.last_name, last_name: Faker::Name.last_name,
email: Faker::Internet.email, email: Faker::Internet.email,
phone: Faker::PhoneNumber.cell_phone) phone: Faker::PhoneNumber.cell_phone)
guest.affinity_group_list.add(samples.sample) guest.affinity_group_list.add(samples.sample)
guest.save! guest.save!
end end
Guest.affinity_group_counts.each do |group|
couples = (group.taggings_count / 4).floor
guests_involved = Guest.tagged_with(group.name).limit(couples * 2)
guests_involved.each_slice(2) do |a, b|
bond_name = "#{a.full_name} & #{b.full_name}"
a.unbreakable_bond_list.add(bond_name)
b.unbreakable_bond_list.add(bond_name)
a.save!
b.save!
end
end