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
7 changes: 7 additions & 0 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class EventsController < ApplicationController
respond_to :json

def show
render json: Event.all
end
end
21 changes: 21 additions & 0 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,25 @@ def finish_before_start
errors.add(:finish, 'time must be after start time')
end
end

def description=(value)
if value.blank?
value = nil
end
super value
end

def location=(value)
if value.blank?
value = nil
end
super value
end

def category=(value)
if value.blank?
value = nil
end
super value
end
end
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
patch :boarded_bus, on: :collection
end

resource :events, only: :show, constraints: ->(req) { req.format == :json }

namespace :manage do
authenticate :user, ->(u) { u.director? } do
root to: "dashboard#index"
Expand Down
7 changes: 7 additions & 0 deletions test/controllers/events_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class EventsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end