Skip to content

Commit ca29d8a

Browse files
committed
implement upcoming event
1 parent 6d7bd01 commit ca29d8a

16 files changed

Lines changed: 379 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
/log/*
1616
!/log/.keep
1717
/tmp
18+
coverage

.rspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--color
2+
--require spec_helper

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ gem 'font-kit-rails', '~> 1.2.0'
4242
group :development, :test do
4343
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
4444
gem 'byebug'
45+
gem 'rspec-rails', '~> 3.5'
46+
gem 'simplecov', :require => false, :group => :test
47+
gem 'guard-rspec', require: false
48+
gem 'factory_girl_rails'
4549
end
4650

4751
group :development do

Gemfile.lock

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,37 @@ GEM
6060
coffee-script-source (1.10.0)
6161
concurrent-ruby (1.0.2)
6262
debug_inspector (0.0.2)
63+
diff-lcs (1.2.5)
64+
docile (1.1.5)
6365
erubis (2.7.0)
6466
execjs (2.7.0)
65-
font-awesome-rails (4.6.3.1)
67+
factory_girl (4.7.0)
68+
activesupport (>= 3.0.0)
69+
factory_girl_rails (4.7.0)
70+
factory_girl (~> 4.7.0)
71+
railties (>= 3.0.0)
72+
ffi (1.9.14)
73+
font-awesome-rails (4.7.0.0)
6674
railties (>= 3.2, < 5.1)
6775
font-kit-rails (1.2.0)
6876
rails
77+
formatador (0.2.5)
6978
globalid (0.3.7)
7079
activesupport (>= 4.1.0)
80+
guard (2.14.0)
81+
formatador (>= 0.2.4)
82+
listen (>= 2.7, < 4.0)
83+
lumberjack (~> 1.0)
84+
nenv (~> 0.1)
85+
notiffany (~> 0.0)
86+
pry (>= 0.9.12)
87+
shellany (~> 0.0)
88+
thor (>= 0.18.1)
89+
guard-compat (1.2.1)
90+
guard-rspec (4.7.3)
91+
guard (~> 2.1)
92+
guard-compat (~> 1.1)
93+
rspec (>= 2.99.0, < 4.0)
7194
i18n (0.7.0)
7295
jbuilder (2.6.0)
7396
activesupport (>= 3.0.0, < 5.1)
@@ -77,19 +100,33 @@ GEM
77100
railties (>= 4.2.0)
78101
thor (>= 0.14, < 2.0)
79102
json (1.8.3)
103+
listen (3.1.5)
104+
rb-fsevent (~> 0.9, >= 0.9.4)
105+
rb-inotify (~> 0.9, >= 0.9.7)
106+
ruby_dep (~> 1.2)
80107
loofah (2.0.3)
81108
nokogiri (>= 1.5.9)
109+
lumberjack (1.0.10)
82110
mail (2.6.4)
83111
mime-types (>= 1.16, < 4)
112+
method_source (0.8.2)
84113
mime-types (3.1)
85114
mime-types-data (~> 3.2015)
86115
mime-types-data (3.2016.0521)
87116
mini_portile2 (2.1.0)
88117
minitest (5.9.1)
89118
multi_json (1.12.1)
119+
nenv (0.3.0)
90120
nokogiri (1.6.8.1)
91121
mini_portile2 (~> 2.1.0)
122+
notiffany (0.1.1)
123+
nenv (~> 0.1)
124+
shellany (~> 0.0)
92125
pg (0.19.0)
126+
pry (0.10.4)
127+
coderay (~> 1.1.0)
128+
method_source (~> 0.8.1)
129+
slop (~> 3.4)
93130
quiet_assets (1.1.0)
94131
railties (>= 3.1, < 5.0)
95132
rack (1.6.4)
@@ -120,8 +157,33 @@ GEM
120157
rake (>= 0.8.7)
121158
thor (>= 0.18.1, < 2.0)
122159
rake (11.3.0)
160+
rb-fsevent (0.9.8)
161+
rb-inotify (0.9.7)
162+
ffi (>= 0.5.0)
123163
rdoc (4.2.2)
124164
json (~> 1.4)
165+
rspec (3.5.0)
166+
rspec-core (~> 3.5.0)
167+
rspec-expectations (~> 3.5.0)
168+
rspec-mocks (~> 3.5.0)
169+
rspec-core (3.5.4)
170+
rspec-support (~> 3.5.0)
171+
rspec-expectations (3.5.0)
172+
diff-lcs (>= 1.2.0, < 2.0)
173+
rspec-support (~> 3.5.0)
174+
rspec-mocks (3.5.0)
175+
diff-lcs (>= 1.2.0, < 2.0)
176+
rspec-support (~> 3.5.0)
177+
rspec-rails (3.5.2)
178+
actionpack (>= 3.0)
179+
activesupport (>= 3.0)
180+
railties (>= 3.0)
181+
rspec-core (~> 3.5.0)
182+
rspec-expectations (~> 3.5.0)
183+
rspec-mocks (~> 3.5.0)
184+
rspec-support (~> 3.5.0)
185+
rspec-support (3.5.0)
186+
ruby_dep (1.5.0)
125187
sass (3.4.22)
126188
sass-rails (5.0.6)
127189
railties (>= 4.0.0, < 6)
@@ -132,9 +194,16 @@ GEM
132194
sdoc (0.4.2)
133195
json (~> 1.7, >= 1.7.7)
134196
rdoc (~> 4.0)
197+
shellany (0.0.1)
135198
simple_form (3.3.1)
136199
actionpack (> 4, < 5.1)
137200
activemodel (> 4, < 5.1)
201+
simplecov (0.12.0)
202+
docile (~> 1.1.0)
203+
json (>= 1.8, < 3)
204+
simplecov-html (~> 0.10.0)
205+
simplecov-html (0.10.0)
206+
slop (3.6.0)
138207
spring (2.0.0)
139208
activesupport (>= 4.2)
140209
sprockets (3.7.0)
@@ -152,7 +221,7 @@ GEM
152221
turbolinks-source (5.0.0)
153222
tzinfo (1.2.2)
154223
thread_safe (~> 0.1)
155-
uglifier (3.0.2)
224+
uglifier (3.0.3)
156225
execjs (>= 0.3.0, < 3)
157226
web-console (2.3.0)
158227
activemodel (>= 4.0)
@@ -168,20 +237,24 @@ DEPENDENCIES
168237
bootstrap (~> 4.0.0.alpha1)
169238
byebug
170239
coffee-rails (~> 4.1.0)
240+
factory_girl_rails
171241
font-awesome-rails
172242
font-kit-rails (~> 1.2.0)
243+
guard-rspec
173244
jbuilder (~> 2.0)
174245
jquery-rails
175246
pg
176247
quiet_assets
177248
rails (= 4.2.5)
249+
rspec-rails (~> 3.5)
178250
sass-rails (~> 5.0)
179251
sdoc (~> 0.4.0)
180252
simple_form
253+
simplecov
181254
spring
182255
turbolinks
183256
uglifier (>= 1.3.0)
184257
web-console (~> 2.0)
185258

186259
BUNDLED WITH
187-
1.13.4
260+
1.13.6

Guardfile

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# A sample Guardfile
2+
# More info at https://github.com/guard/guard#readme
3+
4+
## Uncomment and set this to only include directories you want to watch
5+
# directories %w(app lib config test spec features) \
6+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7+
8+
## Note: if you are using the `directories` clause above and you are not
9+
## watching the project directory ('.'), then you will want to move
10+
## the Guardfile to a watched dir and symlink it back, e.g.
11+
#
12+
# $ mkdir config
13+
# $ mv Guardfile config/
14+
# $ ln -s config/Guardfile .
15+
#
16+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17+
18+
# Note: The cmd option is now required due to the increasing number of ways
19+
# rspec may be run, below are examples of the most common uses.
20+
# * bundler: 'bundle exec rspec'
21+
# * bundler binstubs: 'bin/rspec'
22+
# * spring: 'bin/rspec' (This will use spring if running and you have
23+
# installed the spring binstubs per the docs)
24+
# * zeus: 'zeus rspec' (requires the server to be started separately)
25+
# * 'just' rspec: 'rspec'
26+
27+
guard :rspec, cmd: "bundle exec rspec" do
28+
require "guard/rspec/dsl"
29+
dsl = Guard::RSpec::Dsl.new(self)
30+
31+
# Feel free to open issues for suggestions and improvements
32+
33+
# RSpec files
34+
rspec = dsl.rspec
35+
watch(rspec.spec_helper) { rspec.spec_dir }
36+
watch(rspec.spec_support) { rspec.spec_dir }
37+
watch(rspec.spec_files)
38+
39+
# Ruby files
40+
ruby = dsl.ruby
41+
dsl.watch_spec_files_for(ruby.lib_files)
42+
43+
# Rails files
44+
rails = dsl.rails(view_extensions: %w(erb haml slim))
45+
dsl.watch_spec_files_for(rails.app_files)
46+
dsl.watch_spec_files_for(rails.views)
47+
48+
watch(rails.controllers) do |m|
49+
[
50+
rspec.spec.call("routing/#{m[1]}_routing"),
51+
rspec.spec.call("controllers/#{m[1]}_controller"),
52+
rspec.spec.call("acceptance/#{m[1]}")
53+
]
54+
end
55+
56+
# Rails config changes
57+
watch(rails.spec_helper) { rspec.spec_dir }
58+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60+
61+
# Capybara features specs
62+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64+
65+
# Turnip features and steps
66+
watch(%r{^spec/acceptance/(.+)\.feature$})
67+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69+
end
70+
end

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The following **required** functionality is complete:
1818

1919
#### Events
2020

21-
* [ ] Users can see a list of upcoming events. Past events should not be shown. **HINT**: Good candidate for a test.
21+
* [x] Users can see a list of upcoming events. Past events should not be shown. **HINT**: Good candidate for a test.
2222
* [ ] Users can search for events from the homepage.
2323
* [ ] Users can click on an event to see details about the event.
2424
* [ ] Users can click on "Book Now" to go to a page to purchase tickets.

app/controllers/events_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class EventsController < ApplicationController
22
def index
3-
@events = Event.all
3+
@events = Event.upcoming
44
end
55

66
def show

app/models/event.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@ class Event < ActiveRecord::Base
55

66
validates_presence_of :extended_html_description, :venue, :category, :starts_at
77
validates_uniqueness_of :name, uniqueness: {scope: [:venue, :starts_at]}
8+
9+
def self.upcoming
10+
Event.where('ends_at > ?', Time.now)
11+
end
812
end

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Rails.application.routes.draw do
22
root 'events#index'
33

4+
get 'upcoming' => 'events#index'
5+
46
resources :events do
57
resources :tickets
68
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
require 'rails_helper'
2+
3+
RSpec.describe EventsController, type: :controller do
4+
5+
end

0 commit comments

Comments
 (0)