Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge

  • Loading branch information...
commit 2a9295379f65ce58f66bed0ed198875de4811720 2 parents 5a78335 + 3120ed4
@mjs2600 mjs2600 authored
View
29 Gemfile
@@ -33,11 +33,32 @@ end
group :development, :test do
gem 'debugger'
+ gem 'guard'
+ gem 'rb-fsevent'
+ gem 'guard-rspec'
+ gem 'guard-cucumber'
+ gem 'guard-coffeescript'
+ gem 'guard-livereload'
+ gem 'guard-spork'
+ gem 'spork'
+ gem 'faker'
+ gem "mailcatcher"
+ gem "rspec-rails", "~> 2.0"
+end
+
+group :development do
+ gem "rails-erd"
+ gem 'letters'
+ gem 'pry-rails'
+end
+
+
+group :test do
+ gem "cucumber-rails"
end
gem "jquery-rails"
-gem "rspec-rails", ">= 2.0.1", :group => [:development, :test]
gem 'devise'
-gem 'whenever'
-gem 'letters'
-gem 'pry-rails'
+gem 'whenever', :require => false
+gem 'will_paginate', '~> 3.0'
+
View
115 Gemfile.lock
@@ -28,10 +28,21 @@ GEM
activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
+ addressable (2.3.2)
arel (3.0.2)
awesome_print (1.1.0)
bcrypt-ruby (3.0.1)
builder (3.0.4)
+ capybara (2.0.0)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 1.0.0)
+ childprocess (0.3.6)
+ ffi (~> 1.0, >= 1.0.6)
+ choice (0.1.6)
chronic (0.6.7)
coderay (1.0.8)
coffee-rails (3.2.2)
@@ -43,6 +54,16 @@ GEM
coffee-script-source (1.3.3)
colorize (0.5.8)
columnize (0.3.6)
+ cucumber (1.2.1)
+ builder (>= 2.1.2)
+ diff-lcs (>= 1.1.3)
+ gherkin (~> 2.11.0)
+ json (>= 1.4.6)
+ cucumber-rails (1.3.0)
+ capybara (>= 1.1.2)
+ cucumber (>= 1.1.8)
+ nokogiri (>= 1.5.0)
+ daemons (1.1.9)
debugger (1.2.1)
columnize (>= 0.3.1)
debugger-linecache (~> 1.1.1)
@@ -56,9 +77,42 @@ GEM
railties (~> 3.1)
warden (~> 1.2.1)
diff-lcs (1.1.3)
+ em-websocket (0.3.8)
+ addressable (>= 2.1.1)
+ eventmachine (>= 0.12.9)
erubis (2.7.0)
+ eventmachine (1.0.0)
execjs (1.4.0)
multi_json (~> 1.0)
+ faker (1.1.2)
+ i18n (~> 0.5)
+ ffi (1.1.5)
+ gherkin (2.11.5)
+ json (>= 1.4.6)
+ guard (1.5.4)
+ listen (>= 0.4.2)
+ lumberjack (>= 1.0.2)
+ pry (>= 0.9.10)
+ thor (>= 0.14.6)
+ guard-coffeescript (1.2.1)
+ coffee-script (>= 2.2.0)
+ guard (>= 1.1.0)
+ guard-cucumber (1.2.2)
+ cucumber (>= 1.2.0)
+ guard (>= 1.1.0)
+ guard-livereload (1.1.0)
+ em-websocket (>= 0.2.0)
+ guard (>= 1.5.0)
+ multi_json (~> 1.0)
+ guard-rspec (2.1.1)
+ guard (>= 1.1)
+ rspec (~> 2.11)
+ guard-spork (1.2.3)
+ childprocess (>= 0.2.3)
+ guard (>= 1.1)
+ spork (>= 0.8.4)
+ sys-proctable
+ haml (3.1.7)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
@@ -72,14 +126,28 @@ GEM
colorize
debugger
xml-simple
+ libwebsocket (0.1.5)
+ addressable
+ listen (0.5.3)
+ lumberjack (1.0.2)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
+ mailcatcher (0.5.10)
+ activesupport (~> 3.0)
+ eventmachine (~> 1.0.0)
+ haml (~> 3.1)
+ mail (~> 2.3)
+ sinatra (~> 1.2)
+ skinny (~> 0.2.3)
+ sqlite3 (~> 1.3)
+ thin (~> 1.5.0)
method_source (0.8.1)
mime-types (1.19)
multi_json (1.3.6)
mysql2 (0.3.11)
+ nokogiri (1.5.5)
orm_adapter (0.4.0)
polyglot (0.3.3)
pry (0.9.10)
@@ -91,6 +159,8 @@ GEM
rack (1.4.1)
rack-cache (1.2)
rack (>= 0.4)
+ rack-protection (1.2.0)
+ rack
rack-ssl (1.3.2)
rack
rack-test (0.6.2)
@@ -103,6 +173,11 @@ GEM
activesupport (= 3.2.8)
bundler (~> 1.0)
railties (= 3.2.8)
+ rails-erd (1.0.0)
+ activerecord (>= 3.0)
+ activesupport (>= 3.0)
+ choice (~> 0.1.6)
+ ruby-graphviz (~> 1.0.4)
railties (3.2.8)
actionpack (= 3.2.8)
activesupport (= 3.2.8)
@@ -111,6 +186,7 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
+ rb-fsevent (0.9.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.11.0)
@@ -126,16 +202,37 @@ GEM
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.11.0)
+ ruby-graphviz (1.0.8)
+ rubyzip (0.9.9)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
+ selenium-webdriver (2.26.0)
+ childprocess (>= 0.2.5)
+ libwebsocket (~> 0.1.3)
+ multi_json (~> 1.0)
+ rubyzip
+ sinatra (1.3.3)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ skinny (0.2.3)
+ eventmachine (~> 1.0.0)
+ thin (~> 1.5.0)
slop (3.3.3)
+ spork (0.9.2)
sprockets (2.1.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.6)
+ sys-proctable (0.9.2)
+ thin (1.5.0)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.11)
@@ -150,21 +247,37 @@ GEM
whenever (0.7.3)
activesupport (>= 2.3.4)
chronic (~> 0.6.3)
+ will_paginate (3.0.3)
xml-simple (1.1.2)
+ xpath (1.0.0)
+ nokogiri (~> 1.3)
PLATFORMS
ruby
DEPENDENCIES
coffee-rails (~> 3.2.1)
+ cucumber-rails
debugger
devise
+ faker
+ guard
+ guard-coffeescript
+ guard-cucumber
+ guard-livereload
+ guard-rspec
+ guard-spork
jquery-rails
letters
+ mailcatcher
mysql2
pry-rails
rails (= 3.2.8)
- rspec-rails (>= 2.0.1)
+ rails-erd
+ rb-fsevent
+ rspec-rails (~> 2.0)
sass-rails (~> 3.2.3)
+ spork
uglifier (>= 1.0.3)
whenever
+ will_paginate (~> 3.0)
View
20 README.md
@@ -1,4 +1,22 @@
temptd
======
-An automated event scheduler.
+An automated event scheduler.
+
+**TODO**
+assume UI is there
+
+voting: ui just captures the data, kind of done from the back-end POV
+
+
+cron job weds night
+ creates new sports (for now) event
+ this should implicitly have time slots for all of the days
+ sends out email letting ALL (for now until we incorporate groups) users know about next week's event poll.
+
+
+
+cron job tallies votes for each of the current events.
+
+
+
View
29 app/models/event.rb
@@ -19,6 +19,33 @@ def calculate_event_details
end
def calculate_event_time
- timeslots.all(order: timeslots.votes.length).first
+ timeslot = votes.select("votes.*, count(*) AS count").
+ group(:timeslot_id).
+ order("count DESC").
+ limit(1).try(:timeslot)
+
+ timeslot ? [timeslot.starts_at, timeslot.end_at] : nil
end
+
+
+
+ # 5.times do |day_index|
+ # day = monday + day_index.days
+ # 2.times do |i|
+ # start_time = day + (17 + i * 2).hours
+ # end_time = day + (19 + i * 2).hours
+ #
+ # Timeslot.create(event_id: test_event.id, starts_at: start_time, ends_at: end_time)
+ # end
+ # end
+
+
+ def self.start_new_sports_event
+ # Event.
+ end
+
+ def self.finish_current_sports_event
+
+ end
+
end
View
2  app/models/event_preferences.rb → app/models/event_preference.rb
@@ -1,3 +1,3 @@
-class EventPreferences < ActiveRecord::Base
+class EventPreference < ActiveRecord::Base
attr_accessible :category, :event_type_id
end
View
2  app/models/timeslot.rb
@@ -1,5 +1,5 @@
class Timeslot < ActiveRecord::Base
- attr_accessible :ends_at, :event_id, :starts_at
+ attr_accessible :event_id, :ends_at, :starts_at
belongs_to :event
has_many :votes
View
2  app/models/user.rb
@@ -9,5 +9,5 @@ class User < ActiveRecord::Base
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
- attr_accessible :email, :password, :password_confirmation, :remember_me
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :nickname
end
View
2  app/models/user_event_preferences.rb → app/models/user_event_preference.rb
@@ -1,3 +1,3 @@
-class UserEventPreferences < ActiveRecord::Base
+class UserEventPreference < ActiveRecord::Base
attr_accessible :event_preference_id, :user_id, :value
end
View
2  app/views/events/show.html.erb
@@ -1,6 +1,6 @@
<p id="notice"><%= notice %></p>
<h1><%= @event %></h1>
-<h2><%= @event.starts_at.strftime() %></h2>
+<h2><%= @event.starts_at %></h2>
<% if @event.timeslots.empty? %>
No timeslots!
View
8 config/schedule.rb
@@ -18,3 +18,11 @@
# end
# Learn more: http://github.com/javan/whenever
+
+every :wednesday, :at => '10pm' do
+ runner "Event.start_new_sports_event"
+end
+
+every :saturday, :at => '12pm' do
+ runner "Event.finish_current_sports_event"
+end
View
27 db/seeds.rb
@@ -13,6 +13,33 @@
sports_event.timeslots.create!(starts_at: starts_at)
end
+
+EventType.destroy_all
+Event.destroy_all
+User.destroy_all
+Timeslot.destroy_all
+Vote.destroy_all
+
+sport = EventType.find_or_create_by_name("Sports")
+test_event = Event.find_or_create_by_event_type_id(sport.id)
+test_user = User.create(email: "user@name.com", password: 'password', password_confirmation: 'password', nickname: "The Hammer")
+
+monday = Time.now.beginning_of_week
+
+5.times do |day_index|
+ day = monday + day_index.days
+ 2.times do |i|
+ start_time = day + (17 + i * 2).hours
+ end_time = day + (19 + i * 2).hours
+
+ Timeslot.create(event_id: test_event.id, starts_at: start_time, ends_at: end_time)
+ end
+end
+
+Vote.create(user_id: test_user.id, event_id: test_event.id, timeslot_id: Timeslot.last.id)
+Vote.create(user_id: 2, event_id: test_event.id, timeslot_id: Timeslot.first.id)
+Vote.create(user_id: 3, event_id: test_event.id, timeslot_id: Timeslot.last.id)
+
user = User.find_or_initialize_by_email("sports@scimedsolutions.com")
user.nickname = "Sporty"
user.password = "sporty"
View
19 spec/models/event_spec.rb
@@ -1,5 +1,22 @@
require 'spec_helper'
describe Event do
- pending "add some examples to (or delete) #{__FILE__}"
+
+ it "should calculate_event_time" do
+
+ end
+
+ describe "#start_new_sports_event" do
+
+ describe "should create new event"
+ expect { Event.start_new_sports_event }.to
+ change { Event.count }.by(1)
+ end
+
+
+ end
+
+
end
+
+
View
73 spec/spec_helper.rb
@@ -1,38 +1,37 @@
-# This file is copied to spec/ when you run 'rails generate rspec:install'
-ENV["RAILS_ENV"] ||= 'test'
-require File.expand_path("../../config/environment", __FILE__)
-require 'rspec/rails'
-require 'rspec/autorun'
-
-# Requires supporting ruby files with custom matchers and macros, etc,
-# in spec/support/ and its subdirectories.
-Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
-
-RSpec.configure do |config|
- # ## Mock Framework
- #
- # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
- #
- # config.mock_with :mocha
- # config.mock_with :flexmock
- # config.mock_with :rr
-
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
- config.fixture_path = "#{::Rails.root}/spec/fixtures"
-
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
- # examples within a transaction, remove the following line or assign false
- # instead of true.
- config.use_transactional_fixtures = true
-
- # If true, the base class of anonymous controllers will be inferred
- # automatically. This will be the default behavior in future versions of
- # rspec-rails.
- config.infer_base_class_for_anonymous_controllers = false
-
- # Run specs in random order to surface order dependencies. If you find an
- # order dependency and want to debug it, you can fix the order by providing
- # the seed, which is printed after each run.
- # --seed 1234
- config.order = "random"
+require 'rubygems'
+require 'spork'
+#uncomment the following line to use spork with the debugger
+#require 'spork/ext/ruby-debug'
+
+
+Spork.prefork do
+ ENV["RAILS_ENV"] ||= 'test'
+ require File.expand_path("../../config/environment", __FILE__)
+ require 'rspec/rails'
+ # require 'factories'
+ require File.expand_path("../../features/support/ldms_env", __FILE__)
+
+ # Requires supporting ruby files with custom matchers and macros, etc,
+ # in spec/support/ and its subdirectories.
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
+
+ RSpec.configure do |config|
+
+ config.mock_with :rspec
+
+ # now you can just call 'create', or 'build', etc w/out having to preface these calls w/ "FactoryGirl"
+ config.include FactoryGirl::Syntax::Methods
+
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
+
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
+ # examples within a transaction, remove the following line or assign false
+ # instead of true.
+ config.use_transactional_fixtures = true
+ end
+end
+
+Spork.each_run do
+ # This code will be run each time you run your specs.
end
Please sign in to comment.
Something went wrong with that request. Please try again.