Compare commits

...

3 Commits

Author SHA1 Message Date
7962b97e3e Merge branch 'main' into arrangement-names
All checks were successful
Add copyright notice / copyright_notice (pull_request) Successful in 23m59s
Run unit tests / unit_tests (pull_request) Successful in 8m48s
2024-11-03 09:16:53 +00:00
3b0702bbec Add copyright notice
Some checks failed
Add copyright notice / copyright_notice (pull_request) Successful in 4m53s
Run unit tests / unit_tests (pull_request) Successful in 5m57s
Build Nginx-based docker image / build-static-assets (pull_request) Failing after 1h7m33s
2024-11-03 07:47:40 +00:00
066fdea504 Assign a name to every tables arrangement
Some checks failed
Add copyright notice / copyright_notice (pull_request) Successful in 3m52s
Run unit tests / unit_tests (pull_request) Successful in 7m40s
Build Nginx-based docker image / build-static-assets (pull_request) Failing after 1h10m25s
2024-11-03 08:44:31 +01:00
6 changed files with 24 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,7 @@
# Copyright (C) 2024 Manuel Bustillo
class AddNameToTablesArrangements < ActiveRecord::Migration[7.2]
def change
add_column :tables_arrangements, :name, :string, null: false
end
end

3
db/schema.rb generated
View File

@ -12,7 +12,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_072808) 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"
@ -65,6 +65,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"

View File

@ -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