Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require:
plugins:
- rubocop-performance

AllCops:
TargetRubyVersion: 3.3.3
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class ApplicationController < ActionController::API

end
2 changes: 2 additions & 0 deletions app/controllers/attendees_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class AttendeesController < ApplicationController
end
2 changes: 2 additions & 0 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class RoomsController < ApplicationController
end
2 changes: 2 additions & 0 deletions app/controllers/venues_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class VenuesController < ApplicationController
end
3 changes: 3 additions & 0 deletions app/models/attendee.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Attendee < ApplicationRecord
belongs_to :room
end
4 changes: 4 additions & 0 deletions app/models/room.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Room < ApplicationRecord
has_and_belongs_to_many :venues
has_many :attendees
end
6 changes: 6 additions & 0 deletions app/models/room_venue.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class RoomVenue < ApplicationRecord
belongs_to :room
belongs_to :venue

has_many :votes
end
3 changes: 3 additions & 0 deletions app/models/venue.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Venue < ApplicationRecord
has_and_belongs_to_many :rooms
end
2 changes: 2 additions & 0 deletions app/models/vote.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Vote < ApplicationRecord
end
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
config.eager_load = false

# Show full error reports.
config.consider_all_requests_local = true
# config.consider_all_requests_local = true

# Enable server timing
config.server_timing = true
Expand Down
13 changes: 4 additions & 9 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
Rails.application.routes.draw do

# GET route to know that API is online.
# Limited to json requests - sends a 200 response with empty headers and empty response body
if Rails.env.development?
get '/', to: proc { [200, {}, ['']] }, constraints: { format: 'json' }
end



post '/rooms', to: 'rooms#create'
post 'rooms/:invite', to: 'rooms#join'
post '/venues', to: 'venues#create'
post '/attendees', to: 'attendees#create'
end
26 changes: 26 additions & 0 deletions db/migrate/20250410174025_create_rooms_and_venues.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class CreateRoomsAndVenues < ActiveRecord::Migration[7.1]
def change
create_table :rooms do |t|
t.string :invite_code
t.integer :host_id
t.integer :status

t.timestamps
end

create_table :venues do |t|
t.integer :cost
t.string :menu_link
t.integer :rating
t.integer :category_id

t.timestamps
end

create_table :rooms_venues do |t|
# Intentionally keeping the id column to reference at vote time
t.belongs_to :room
t.belongs_to :venue
end
end
end
9 changes: 9 additions & 0 deletions db/migrate/20250410174408_create_attendees.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateAttendees < ActiveRecord::Migration[7.1]
def change
create_table :attendees do |t|
t.references :room
t.string :name
t.timestamps
end
end
end
9 changes: 9 additions & 0 deletions db/migrate/20250410174650_create_votes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class CreateVotes < ActiveRecord::Migration[7.1]
def change
create_table :votes do |t|
t.references :rooms_venues, null: false, foreign_key: true
Copy link

Copilot AI Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reference name 'rooms_venues' is plural; Rails conventions suggest using a singular name (e.g., 'room_venue') to properly define the belongs_to association in the Vote model.

Suggested change
t.references :rooms_venues, null: false, foreign_key: true
t.references :room_venue, null: false, foreign_key: true

Copilot uses AI. Check for mistakes.
t.references :attendee, null: false, foreign_key: true
t.timestamps
end
end
end
45 changes: 44 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
# Character.create(name: "Luke", movie: movies.first)

raise 'SEEDING NOT ALLOWED IN PRODUCTION' if Rails.env.production?
# Seeds::UserSeeder.new.run


# Seeds::UserSeeder.new.run
5 changes: 5 additions & 0 deletions spec/factories/attendees.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FactoryBot.define do
factory :attendee do
name { Faker::Name.name }
end
end
6 changes: 6 additions & 0 deletions spec/factories/room_venues.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FactoryBot.define do
factory :room_venue do
association :room
association :venue
end
end
7 changes: 7 additions & 0 deletions spec/factories/rooms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FactoryBot.define do
factory :room do
invite_code { SecureRandom.hex(10) }
venue { venue }
Copy link

Copilot AI Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assignment 'venue { venue }' may lead to an unintended recursive reference. Consider using 'association :venue' or providing an explicit value to properly set up the association.

Suggested change
venue { venue }
association :venue

Copilot uses AI. Check for mistakes.
host_id { attendee }
Copy link

Copilot AI Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assigning 'host_id' with 'attendee' is ambiguous; if host_id is intended to reference an Attendee's id, use an association (e.g., 'association :attendee') or assign the proper value explicitly.

Suggested change
host_id { attendee }
association :attendee, factory: :attendee, strategy: :build
host_id { attendee.id }

Copilot uses AI. Check for mistakes.
end
end
9 changes: 9 additions & 0 deletions spec/factories/venues.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FactoryBot.define do
factory :venue do
name { 'Venue Name' }
menu_link { 'http://menu.page.com' }
cost 100
rating 5
category_id 1
end
end
6 changes: 6 additions & 0 deletions spec/factories/votes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FactoryBot.define do
factory :vote do
room_venue
category_id 1
end
end
70 changes: 0 additions & 70 deletions spec/rails_helper.rb

This file was deleted.

92 changes: 0 additions & 92 deletions spec/spec_helper.rb

This file was deleted.

6 changes: 0 additions & 6 deletions spec/support/shoulda_matchers.rb

This file was deleted.

Loading