Skip to content

Commit

Permalink
Remove events.available_live column; update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
moveson committed Feb 21, 2018
1 parent e7c0a53 commit be590c3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
6 changes: 0 additions & 6 deletions app/models/event_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ class EventGroup < ApplicationRecord

scope :standard_includes, -> { includes(events: :splits) }

after_commit :align_available_live # Needed only so long as Event model retains duplicate available_live attribute

def self.search(search_param)
return all if search_param.blank?
joins(:events).where('event_groups.name ILIKE ? OR events.name ILIKE ?', "%#{search_param}%", "%#{search_param}%")
Expand All @@ -40,8 +38,4 @@ def ordered_events
def first_event
ordered_events.first
end

def align_available_live
events.each { |event| event.update(available_live: available_live) }
end
end
5 changes: 5 additions & 0 deletions db/migrate/20180221005830_remove_events_available_live.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveEventsAvailableLive < ActiveRecord::Migration[5.1]
def change
remove_column :events, :available_live, :boolean
end
end
3 changes: 1 addition & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20180208175849) do
ActiveRecord::Schema.define(version: 20180221005830) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -116,7 +116,6 @@
t.integer "event_group_id"
t.string "short_name"
t.string "podium_template"
t.boolean "available_live"
t.boolean "monitor_pacers", default: false
t.index ["course_id"], name: "index_events_on_course_id"
t.index ["event_group_id"], name: "index_events_on_event_group_id"
Expand Down
Binary file modified erd.pdf
Binary file not shown.
8 changes: 4 additions & 4 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
require 'rails_helper'

# t.integer "course_id", null: false
# t.integer "organization_id"
# t.string "name", limit: 64, null: false
# t.datetime "start_time"
# t.boolean "concealed", default: false
# t.boolean "available_live", default: false
# t.string "beacon_url"
# t.integer "laps_required"
# t.string "slug", null: false
# t.boolean "auto_live_times", default: false
# t.string "home_time_zone", null: false
# t.integer "event_group_id"
# t.string "short_name"
# t.string "podium_template"
# t.boolean "monitor_pacers", default: false

RSpec.describe Event, type: :model do
it_behaves_like 'auditable'
Expand Down
3 changes: 2 additions & 1 deletion spec/view_models/event_spread_display_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@

context 'when display_style is provided in the params' do
let(:prepared_params) { ActionController::Parameters.new(display_style: 'ampm') }
let(:event) { instance_double('Event', simple?: true, available_live: true) }
let(:event) { instance_double('Event', simple?: true, event_group: event_group) }
let(:event_group) { instance_double('EventGroup', available_live: true) }

it 'returns the provided display_style' do
expect(subject.display_style).to eq('ampm')
Expand Down

0 comments on commit be590c3

Please sign in to comment.