Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HER-53: update booking model #55

Merged

Conversation

olesiamironenko
Copy link
Collaborator

Issue HER-53: Update Booking Model to Allow for Modifications

https://raquelanaroman.atlassian.net/browse/HER-53

Description

As a teacher user, I want to be able to modify the booking times within the availability window.

Acceptance Criteria

The Booking model needs to be associated with the Availability model to get the window of availability.

Create a migration to add Availability reference to Booking.

class AddAvailabilityToBookings < ActiveRecord::Migration[7.2]
  def change
    add_reference :bookings, :availability, foreign_key: true
  end
end

Update the models:

Booking Model:

class Booking < ApplicationRecord
  belongs_to :availability
  # other associations and validations
end

Availability Model:

class Availability < ApplicationRecord
  has_many :bookings
  # other associations and validations
end

Update the controller logic:

def update
  booking = Booking.find(params[:id])
  availability = booking.availability

Everything else remains the same as HER-58

Changes

  1. Generated migration.
  2. Run migration.
  3. Updated booking model.
  4. Updated availability model.
  5. Updated booking controller.
  6. Updated booking model tests.
  7. Updated availability model tests.
  8. Updated booking controller tests.

Review Checklist

  • I have documented my code with code comments.

Copy link
Collaborator

@trca831 trca831 left a comment

Choose a reason for hiding this comment

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

LGTM!

@olesiamironenko olesiamironenko merged commit 7fabdb6 into main Jan 14, 2025
3 checks passed
@olesiamironenko olesiamironenko deleted the HER-53-update-booking-model-to-allow-for-modifications branch January 14, 2025 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants