diff --git a/Gemfile b/Gemfile index 9e27caa8c..e9bf41f79 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index e624b0754..c77ab48ce 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -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) @@ -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 diff --git a/app/models/event_session.rb b/app/models/event_session.rb index 1963fe3af..d04ff9d98 100644 --- a/app/models/event_session.rb +++ b/app/models/event_session.rb @@ -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") diff --git a/db/seeds/seed_event.rb b/db/seeds/seed_event.rb index 5c1d78170..d1330947f 100644 --- a/db/seeds/seed_event.rb +++ b/db/seeds/seed_event.rb @@ -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: <
Workshop Description + location: location, + details: <<-DETAILS.strip_heredoc +

Workshop Description

-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. -

Location and Sponsors

+

Location and Sponsors

-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. -

Transportation and Parking

+

Transportation and Parking

-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. -

Food and Drinks

+

Food and Drinks

-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. -

Childcare

+

Childcare

-Childcare will not be provided. + Childcare will not be provided. -

Afterparty

+

Afterparty

-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! diff --git a/spec/features/event_listing_request_spec.rb b/spec/features/event_listing_request_spec.rb index bbd59d778..fcddf167d 100644 --- a/spec/features/event_listing_request_spec.rb +++ b/spec/features/event_listing_request_spec.rb @@ -22,6 +22,7 @@ ) event.save! + event.reload visit events_path page.should have_content("January 31, #{next_year}") @@ -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 diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 725061941..28c23e083 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -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) }