Compare commits
	
		
			11 Commits
		
	
	
		
			7962b97e3e
			...
			eb2b111472
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| eb2b111472 | |||
| 3a8a83e60e | |||
| dacc0aa74e | |||
| f0e8c570c9 | |||
| c08f7bd37c | |||
| f21aaa3723 | |||
| b78165fb08 | |||
| 7a1a2f7107 | |||
| 4f133ac3f5 | |||
| 33434db3f2 | |||
| 066fdea504 | 
							
								
								
									
										4
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							| @ -3,9 +3,13 @@ on: | |||||||
|   push: |   push: | ||||||
|     branches: |     branches: | ||||||
|       - main |       - main | ||||||
|  | concurrency: | ||||||
|  |   group: ${{ github.ref }} | ||||||
|  |   cancel-in-progress: true | ||||||
| jobs: | jobs: | ||||||
|   build-static-assets: |   build-static-assets: | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|  |     timeout-minutes: 30 | ||||||
|     steps: |     steps: | ||||||
|       - uses: actions/checkout@v4 |       - uses: actions/checkout@v4 | ||||||
|         with: |         with: | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								.github/workflows/copyright_notice.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/copyright_notice.yml
									
									
									
									
										vendored
									
									
								
							| @ -3,6 +3,9 @@ on: | |||||||
|   pull_request: |   pull_request: | ||||||
| permissions: | permissions: | ||||||
|   contents: write |   contents: write | ||||||
|  | concurrency: | ||||||
|  |   group: ${{ github.ref }} | ||||||
|  |   cancel-in-progress: true | ||||||
| jobs: | jobs: | ||||||
|   copyright_notice: |   copyright_notice: | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|  | |||||||
							
								
								
									
										3
									
								
								.github/workflows/tests.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/tests.yml
									
									
									
									
										vendored
									
									
								
							| @ -4,6 +4,9 @@ on: | |||||||
|     branches: |     branches: | ||||||
|       - main |       - main | ||||||
|   pull_request: |   pull_request: | ||||||
|  | concurrency: | ||||||
|  |   group: ${{ github.ref }} | ||||||
|  |   cancel-in-progress: true | ||||||
| jobs: | jobs: | ||||||
|   unit_tests: |   unit_tests: | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								Gemfile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Gemfile
									
									
									
									
									
								
							| @ -15,6 +15,7 @@ gem 'stimulus-rails' | |||||||
| gem 'turbo-rails' | gem 'turbo-rails' | ||||||
| gem 'tzinfo-data', platforms: %i[windows jruby] | gem 'tzinfo-data', platforms: %i[windows jruby] | ||||||
| 
 | 
 | ||||||
|  | gem 'faker' | ||||||
| gem 'jsonapi-rails' | gem 'jsonapi-rails' | ||||||
| gem 'rack-cors' | gem 'rack-cors' | ||||||
| gem 'react-rails' | gem 'react-rails' | ||||||
| @ -23,7 +24,6 @@ gem 'rubytree' | |||||||
| group :development, :test do | group :development, :test do | ||||||
|   gem 'debug', platforms: %i[mri windows] |   gem 'debug', platforms: %i[mri windows] | ||||||
|   gem 'factory_bot_rails' |   gem 'factory_bot_rails' | ||||||
|   gem 'faker' |  | ||||||
|   gem 'pry' |   gem 'pry' | ||||||
|   gem 'rspec-rails', '~> 7.0.0' |   gem 'rspec-rails', '~> 7.0.0' | ||||||
| end | end | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
| 
 | 
 | ||||||
| class TablesArrangementsController < ApplicationController | class TablesArrangementsController < ApplicationController | ||||||
|   def index |   def index | ||||||
|     render json: TablesArrangement.all.order(discomfort: :asc).limit(3).as_json(only: %i[id discomfort]) |     render json: TablesArrangement.all.order(discomfort: :asc).limit(3).as_json(only: %i[id name discomfort]) | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def show |   def show | ||||||
|  | |||||||
| @ -3,4 +3,12 @@ | |||||||
| class TablesArrangement < ApplicationRecord | class TablesArrangement < ApplicationRecord | ||||||
|   has_many :seats |   has_many :seats | ||||||
|   has_many :guests, through: :seats |   has_many :guests, through: :seats | ||||||
|  | 
 | ||||||
|  |   before_create :assign_name | ||||||
|  | 
 | ||||||
|  |   private | ||||||
|  | 
 | ||||||
|  |   def assign_name | ||||||
|  |     self.name = "#{Faker::Adjective.positive} #{Faker::Creature::Animal.name}".capitalize | ||||||
|  |   end | ||||||
| end | end | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ | |||||||
| class SerializableGuest < JSONAPI::Serializable::Resource | class SerializableGuest < JSONAPI::Serializable::Resource | ||||||
|   type 'guest' |   type 'guest' | ||||||
| 
 | 
 | ||||||
|   attributes :id, :email, :group_id, :status |   attributes :id, :group_id, :status | ||||||
| 
 | 
 | ||||||
|   attribute :name do |   attribute :name do | ||||||
|     "#{@object.first_name} #{@object.last_name}" |     "#{@object.first_name} #{@object.last_name}" | ||||||
|  | |||||||
| @ -0,0 +1,5 @@ | |||||||
|  | class AddNameToTablesArrangements < ActiveRecord::Migration[7.2] | ||||||
|  |   def change | ||||||
|  |     add_column :tables_arrangements, :name, :string, null: false | ||||||
|  |   end | ||||||
|  | end | ||||||
							
								
								
									
										7
									
								
								db/migrate/20241103093955_remove_email_from_guests.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								db/migrate/20241103093955_remove_email_from_guests.rb
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | |||||||
|  | # Copyright (C) 2024 Manuel Bustillo | ||||||
|  | 
 | ||||||
|  | class RemoveEmailFromGuests < ActiveRecord::Migration[7.2] | ||||||
|  |   def change | ||||||
|  |     remove_column :guests, :email, :string | ||||||
|  |   end | ||||||
|  | end | ||||||
							
								
								
									
										6
									
								
								db/schema.rb
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								db/schema.rb
									
									
									
										generated
									
									
									
								
							| @ -1,5 +1,3 @@ | |||||||
| # Copyright (C) 2024 Manuel Bustillo |  | ||||||
| 
 |  | ||||||
| # This file is auto-generated from the current state of the database. Instead | # This file is auto-generated from the current state of the database. Instead | ||||||
| # of editing this file, please use the migrations feature of Active Record to | # of editing this file, please use the migrations feature of Active Record to | ||||||
| # incrementally modify your database, and then regenerate this schema definition. | # incrementally modify your database, and then regenerate this schema definition. | ||||||
| @ -12,7 +10,7 @@ | |||||||
| # | # | ||||||
| # It's strongly recommended that you check this file into your version control system. | # It's strongly recommended that you check this file into your version control system. | ||||||
| 
 | 
 | ||||||
| ActiveRecord::Schema[7.2].define(version: 2024_11_01_181052) do | ActiveRecord::Schema[7.2].define(version: 2024_11_03_093955) do | ||||||
|   # These are extensions that must be enabled in order to support this database |   # These are extensions that must be enabled in order to support this database | ||||||
|   enable_extension "plpgsql" |   enable_extension "plpgsql" | ||||||
| 
 | 
 | ||||||
| @ -42,7 +40,6 @@ ActiveRecord::Schema[7.2].define(version: 2024_11_01_181052) do | |||||||
|   create_table "guests", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| |   create_table "guests", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| | ||||||
|     t.string "first_name" |     t.string "first_name" | ||||||
|     t.string "last_name" |     t.string "last_name" | ||||||
|     t.string "email" |  | ||||||
|     t.string "phone" |     t.string "phone" | ||||||
|     t.datetime "created_at", null: false |     t.datetime "created_at", null: false | ||||||
|     t.datetime "updated_at", null: false |     t.datetime "updated_at", null: false | ||||||
| @ -65,6 +62,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_11_01_181052) do | |||||||
|     t.integer "discomfort" |     t.integer "discomfort" | ||||||
|     t.datetime "created_at", null: false |     t.datetime "created_at", null: false | ||||||
|     t.datetime "updated_at", null: false |     t.datetime "updated_at", null: false | ||||||
|  |     t.string "name", null: false | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   add_foreign_key "groups", "groups", column: "parent_id" |   add_foreign_key "groups", "groups", column: "parent_id" | ||||||
|  | |||||||
| @ -58,7 +58,6 @@ NUMBER_OF_GUESTS.times do | |||||||
|   Guest.create!( |   Guest.create!( | ||||||
|     first_name: Faker::Name.first_name, |     first_name: Faker::Name.first_name, | ||||||
|     last_name: Faker::Name.last_name, |     last_name: Faker::Name.last_name, | ||||||
|     email: Faker::Internet.email, |  | ||||||
|     phone: Faker::PhoneNumber.cell_phone, |     phone: Faker::PhoneNumber.cell_phone, | ||||||
|     group: groups.sample, |     group: groups.sample, | ||||||
|     status: Guest.statuses.keys.sample |     status: Guest.statuses.keys.sample | ||||||
|  | |||||||
| @ -6,7 +6,6 @@ FactoryBot.define do | |||||||
| 
 | 
 | ||||||
|     first_name { Faker::Name.first_name } |     first_name { Faker::Name.first_name } | ||||||
|     last_name { Faker::Name.last_name } |     last_name { Faker::Name.last_name } | ||||||
|     email { Faker::Internet.email } |  | ||||||
|     phone { Faker::PhoneNumber.cell_phone } |     phone { Faker::PhoneNumber.cell_phone } | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  | |||||||
| @ -3,5 +3,9 @@ | |||||||
| require 'rails_helper' | require 'rails_helper' | ||||||
| 
 | 
 | ||||||
| RSpec.describe TablesArrangement, type: :model do | RSpec.describe TablesArrangement, type: :model do | ||||||
|   pending "add some examples to (or delete) #{__FILE__}" |   describe 'callbacks' do | ||||||
|  |     it 'assigns a name before creation' do | ||||||
|  |       expect(described_class.create!.name).to be_present | ||||||
|  |     end | ||||||
|  |   end | ||||||
| end | end | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user