Skip to content

Commit

Permalink
Upgrade Rails to 3.2.17 and work around some cool weird issues
Browse files Browse the repository at this point in the history
* Change tests and seeds to do less "event_sessions << create(:event_session)", which now seems to work less well
* Add a couple reloads to tests
* Add a reload to update_event_times, which was failing to compute the min/max session times during initial event creation
  • Loading branch information
tjgrathwell committed Feb 19, 2014
1 parent b180da8 commit 8a62f32
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'

ruby '2.0.0'
gem 'rails', '3.2.14'
gem 'rails', '~> 3.2.17'
gem 'devise', '~> 3.0.0'
gem 'thin'
gem 'jquery-rails'
Expand Down
50 changes: 25 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.14)
actionpack (= 3.2.14)
actionmailer (3.2.17)
actionpack (= 3.2.17)
mail (~> 2.5.4)
actionpack (3.2.14)
activemodel (= 3.2.14)
activesupport (= 3.2.14)
actionpack (3.2.17)
activemodel (= 3.2.17)
activesupport (= 3.2.17)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
Expand All @@ -16,18 +16,18 @@ GEM
sprockets (~> 2.2.1)
active_hash (1.3.0)
activesupport (>= 2.2.2)
activemodel (3.2.14)
activesupport (= 3.2.14)
activemodel (3.2.17)
activesupport (= 3.2.17)
builder (~> 3.0.0)
activerecord (3.2.14)
activemodel (= 3.2.14)
activesupport (= 3.2.14)
activerecord (3.2.17)
activemodel (= 3.2.17)
activesupport (= 3.2.17)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.14)
activemodel (= 3.2.14)
activesupport (= 3.2.14)
activesupport (3.2.14)
activeresource (3.2.17)
activemodel (= 3.2.17)
activesupport (= 3.2.17)
activesupport (3.2.17)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
addressable (2.3.5)
Expand Down Expand Up @@ -221,22 +221,22 @@ GEM
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.14)
actionmailer (= 3.2.14)
actionpack (= 3.2.14)
activerecord (= 3.2.14)
activeresource (= 3.2.14)
activesupport (= 3.2.14)
rails (3.2.17)
actionmailer (= 3.2.17)
actionpack (= 3.2.17)
activerecord (= 3.2.17)
activeresource (= 3.2.17)
activesupport (= 3.2.17)
bundler (~> 1.0)
railties (= 3.2.14)
railties (= 3.2.17)
rails_12factor (0.0.2)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.2)
rails_stdout_logging (0.0.3)
railties (3.2.14)
actionpack (= 3.2.14)
activesupport (= 3.2.14)
railties (3.2.17)
actionpack (= 3.2.17)
activesupport (= 3.2.17)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
Expand Down Expand Up @@ -357,7 +357,7 @@ DEPENDENCIES
poltergeist
quiet_assets
rack-canonical-host
rails (= 3.2.14)
rails (~> 3.2.17)
rails_12factor
rb-fsevent
rspec-rails
Expand Down
4 changes: 4 additions & 0 deletions app/models/event_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class EventSession < ActiveRecord::Base
def update_event_times
return unless event

# TODO: This 'reload' shouldn't be needed, but without it, the
# following minimum/maximum statements return 'nil' when
# initially creating an event and its session. Booo!
event.reload
event.update_attributes(
starts_at: event.event_sessions.minimum("event_sessions.starts_at"),
ends_at: event.event_sessions.maximum("event_sessions.ends_at")
Expand Down
35 changes: 17 additions & 18 deletions db/seeds/seed_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,37 +78,36 @@ def self.seed_event(options={})
student_rsvp_limit: 5,
time_zone: 'Pacific Time (US & Canada)',
course_id: Course::RAILS.id,
details: <<DETAILS
<h2>Workshop Description</h2>
location: location,
details: <<-DETAILS.strip_heredoc
<h2>Workshop Description</h2>
This workshop is created by seeds.rb. It is to help you see what it looks like to have an event with multiple people RSVPed.
This workshop is created by seeds.rb. It is to help you see what it looks like to have an event with multiple people RSVPed.
<h2>Location and Sponsors</h2>
<h2>Location and Sponsors</h2>
The location of this workshop is located in the Cloud. That is where it is located.
The location of this workshop is located in the Cloud. That is where it is located.
<h2>Transportation and Parking</h2>
<h2>Transportation and Parking</h2>
You can park in this workshop if you are able to fly an airship into the cloud. Otherwise, parking is restricted.
You can park in this workshop if you are able to fly an airship into the cloud. Otherwise, parking is restricted.
<h2>Food and Drinks</h2>
<h2>Food and Drinks</h2>
Food will be provided by you, if you bring it in a knapsack.
Food will be provided by you, if you bring it in a knapsack.
<h2>Childcare</h2>
<h2>Childcare</h2>
Childcare will not be provided.
Childcare will not be provided.
<h2>Afterparty</h2>
<h2>Afterparty</h2>
The afterparty will be at the Fancy Goat at 7:09 PM.
The afterparty will be at the Fancy Goat at 7:09 PM.
DETAILS
DETAILS
)
event.event_sessions << EventSession.create(name: 'First Session', starts_at: 60.days.from_now, ends_at: 61.days.from_now)
event.event_sessions << EventSession.create(name: 'Second Session', starts_at: 65.days.from_now, ends_at: 66.days.from_now)

event.location = location
event.event_sessions << EventSession.new(name: 'First Session', starts_at: 60.days.from_now, ends_at: 61.days.from_now)
event.event_sessions << EventSession.new(name: 'Second Session', starts_at: 65.days.from_now, ends_at: 66.days.from_now)

event.save!

Expand Down
6 changes: 3 additions & 3 deletions spec/features/event_listing_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
)

event.save!
event.reload

visit events_path
page.should have_content("January 31, #{next_year}")
Expand Down Expand Up @@ -139,9 +140,8 @@
@event = create(:event)
@session1 = @event.event_sessions.first
@session1.update_attributes!(name: 'Installfest', starts_at: 10.days.from_now, ends_at: 11.days.from_now)
@event.event_sessions << create(:event_session)
@session2 = @event.event_sessions.last
@session2.update_attributes!(name: 'Curriculum', starts_at: 12.days.from_now, ends_at: 13.days.from_now)
@session2 = create(:event_session, event: @event, name: 'Curriculum', starts_at: 12.days.from_now, ends_at: 13.days.from_now)
@event.reload
end

it "allows user to volunteer for an event" do
Expand Down
33 changes: 33 additions & 0 deletions spec/models/event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,39 @@
end
end

describe '#starts_at, #ends_at' do
it 'populates from the event_session when creating an event+session together' do
event = Event.create(
title: "Amazingly Sessioned Event",
details: "This is note in the details attribute.",
time_zone: "Hawaii",
published: true,
student_rsvp_limit: 100,
course_id: Course::RAILS.id,
volunteer_details: "I am some details for volunteers.",
student_details: "I am some details for students.",
event_sessions_attributes: {
"0" => {
name: "My Amazing Session",
required_for_students: "1",
"starts_at(1i)" => "2015",
"starts_at(2i)" => "01",
"starts_at(3i)" => "12",
"starts_at(4i)" => "15",
"starts_at(5i)" => "15",
"ends_at(1i)" => "2015",
"ends_at(2i)" => "01",
"ends_at(3i)" => "12",
"ends_at(4i)" => "17",
"ends_at(5i)" => "45"
}
}
)
event.starts_at.should == event.event_sessions.first.starts_at
event.ends_at.should == event.event_sessions.first.ends_at
end
end

describe "#volunteer?" do
let(:event) { create(:event) }

Expand Down

0 comments on commit 8a62f32

Please sign in to comment.