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

#74 Add Handle to Events #94

Merged
merged 9 commits into from
Oct 17, 2021
2 changes: 1 addition & 1 deletion app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ def set_event

# Only allow a list of trusted parameters through.
def event_params
params.require(:event).permit(:name, :description, :start_at, :end_at)
params.require(:event).permit(:name, :handle, :description, :start_at, :end_at)
end
end
1 change: 1 addition & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Event < ApplicationRecord
has_many :attendees, through: :event_attendees, source: :profile

validates :start_at, :end_at, presence: true
validates :handle, presence: true
yagosansz marked this conversation as resolved.
Show resolved Hide resolved

scope :ongoing_or_upcoming, -> { where("end_at >= ?", Time.zone.now) }

Expand Down
8 changes: 8 additions & 0 deletions db/migrate/20211014013357_add_handle_to_events.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

# Add a handle column to events table
class AddHandleToEvents < ActiveRecord::Migration[6.1]
def change
add_column :events, :handle, :string
yagosansz marked this conversation as resolved.
Show resolved Hide resolved
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

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

3 changes: 3 additions & 0 deletions spec/factories/events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
FactoryBot.define do
factory :event do
name { "RubyConf" }
handle { "RubyConf" }
description { "[RubyConf 2020](https://rubyconf.org/) will be held in `Denver`." }
start_at { "2021-11-08 00:00:00" }
end_at { "2021-11-10 00:00:00" }

trait :one_day do
name { "HexDevs Open-Source" }
handle { "HexDevs" }
start_at { "2021-08-05 21:00:00" }
end_at { "2021-08-05 23:59:00" }
end

trait :past_event do
name { "PastConf" }
handle { "PastConf" }
description { "The conference you always miss by a few days." }
start_at { 3.days.ago }
end_at { 1.day.ago }
Expand Down