Skip to content

Commit

Permalink
hw4
Browse files Browse the repository at this point in the history
  • Loading branch information
saasbook committed Feb 23, 2012
1 parent 80d310f commit b4c3ac2
Show file tree
Hide file tree
Showing 85 changed files with 4,067 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_WITHOUT: production
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--colour
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ group :development, :test do
gem 'simplecov'
end
group :production do
# gem 'pg'
gem 'pg'
end

# Gems used only for assets and not required
Expand Down
202 changes: 202 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
GEM
remote: http://rubygems.org/
specs:
actionmailer (3.1.0)
actionpack (= 3.1.0)
mail (~> 2.3.0)
actionpack (3.1.0)
activemodel (= 3.1.0)
activesupport (= 3.1.0)
builder (~> 3.0.0)
erubis (~> 2.7.0)
i18n (~> 0.6)
rack (~> 1.3.2)
rack-cache (~> 1.0.3)
rack-mount (~> 0.8.2)
rack-test (~> 0.6.1)
sprockets (~> 2.0.0)
activemodel (3.1.0)
activesupport (= 3.1.0)
bcrypt-ruby (~> 3.0.0)
builder (~> 3.0.0)
i18n (~> 0.6)
activerecord (3.1.0)
activemodel (= 3.1.0)
activesupport (= 3.1.0)
arel (~> 2.2.1)
tzinfo (~> 0.3.29)
activeresource (3.1.0)
activemodel (= 3.1.0)
activesupport (= 3.1.0)
activesupport (3.1.0)
multi_json (~> 1.0)
addressable (2.2.7)
archive-tar-minitar (0.5.2)
arel (2.2.1)
bcrypt-ruby (3.0.1)
builder (3.0.0)
capybara (1.1.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
childprocess (0.3.1)
ffi (~> 1.0.6)
coffee-rails (3.1.1)
coffee-script (>= 2.2.0)
railties (~> 3.1.0)
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.2.0)
columnize (0.3.6)
cucumber (1.1.4)
builder (>= 2.1.2)
diff-lcs (>= 1.1.2)
gherkin (~> 2.7.1)
json (>= 1.4.6)
term-ansicolor (>= 1.0.6)
cucumber-rails (1.2.1)
capybara (>= 1.1.2)
cucumber (>= 1.1.3)
nokogiri (>= 1.5.0)
cucumber-rails-training-wheels (1.0.0)
cucumber-rails (>= 1.1.1)
database_cleaner (0.7.1)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
ffi (1.0.11)
gherkin (2.7.7)
json (>= 1.4.6)
haml (3.1.4)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.19)
railties (~> 3.0)
thor (~> 0.14)
json (1.6.5)
launchy (2.0.5)
addressable (~> 2.2.6)
libv8 (3.3.10.4)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
mail (2.3.0)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.4)
nokogiri (1.5.0)
pg (0.12.2)
polyglot (0.3.3)
rack (1.3.6)
rack-cache (1.0.3)
rack (>= 0.4)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.2)
rack
rack-test (0.6.1)
rack (>= 1.0)
rails (3.1.0)
actionmailer (= 3.1.0)
actionpack (= 3.1.0)
activerecord (= 3.1.0)
activeresource (= 3.1.0)
activesupport (= 3.1.0)
bundler (~> 1.0)
railties (= 3.1.0)
railties (3.1.0)
actionpack (= 3.1.0)
activesupport (= 3.1.0)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.6)
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.8.0)
rspec-core (~> 2.8.0)
rspec-expectations (~> 2.8.0)
rspec-mocks (~> 2.8.0)
rspec-core (2.8.0)
rspec-expectations (2.8.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.8.0)
rspec-rails (2.8.1)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.8.0)
ruby-debug-base19 (0.11.25)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby_core_source (>= 0.1.4)
ruby-debug19 (0.11.6)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
rubyzip (0.9.6.1)
sass (3.1.15)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (~> 3.1.10)
tilt (~> 1.3.2)
selenium-webdriver (2.19.0)
childprocess (>= 0.2.5)
ffi (~> 1.0.9)
multi_json (~> 1.0.4)
rubyzip
simplecov (0.5.4)
multi_json (~> 1.0.3)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
term-ansicolor (1.0.7)
therubyracer (0.9.9)
libv8 (~> 3.3.10)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.31)
uglifier (1.2.3)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
xpath (0.1.4)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
capybara
coffee-rails (~> 3.1.0)
cucumber-rails
cucumber-rails-training-wheels
database_cleaner
haml
jquery-rails
launchy
pg
rails (= 3.1.0)
rspec-rails
ruby-debug19
sass-rails (~> 3.1.0)
simplecov
sqlite3
therubyracer
uglifier
17 changes: 15 additions & 2 deletions app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
class MoviesController < ApplicationController

def show
id = params[:id] # retrieve movie ID from URI route
@movie = Movie.find(id) # look up movie by unique ID
@id = params[:id] # retrieve movie ID from URI route
@movie = Movie.find(@id) # look up movie by unique ID
@director = @movie.director
# will render app/views/movies/show.<extension> by default
end

Expand Down Expand Up @@ -57,5 +58,17 @@ def destroy
flash[:notice] = "Movie '#{@movie.title}' deleted."
redirect_to movies_path
end

def similar
@id = params[:movie_id]
@movie = Movie.find(@id)
@director = @movie.director
if not @director.blank?
@movies = Movie.similar_directors(@director)
else
flash[:notice] = "'#{@movie.title}' has no director info"
redirect_to movies_path
end
end

end
4 changes: 4 additions & 0 deletions app/models/movie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ class Movie < ActiveRecord::Base
def self.all_ratings
%w(G PG PG-13 NC-17 R)
end

def self.similar_directors(director)
Movie.where(:director => director)
end
end
3 changes: 3 additions & 0 deletions app/views/movies/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@

= label :movie, :release_date, 'Released On'
= date_select :movie, :release_date

= label :movie, :director, 'Director'
= text_field :movie, 'director'

= submit_tag 'Update Movie Info'
2 changes: 2 additions & 0 deletions app/views/movies/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
%th{:class => @title_header}= link_to 'Movie Title', movies_path(:sort => 'title', :ratings => @selected_ratings), :id => 'title_header'
%th Rating
%th{:class => @date_header}= link_to 'Release Date', movies_path(:sort => 'release_date', :ratings => @selected_ratings), :id => 'release_date_header'
%th Director
%th More Info
%tbody
- @movies.each do |movie|
%tr
%td= movie.title
%td= movie.rating
%td= movie.release_date
%td= movie.director
%td= link_to "More about #{movie.title}", movie_path(movie)

= link_to 'Add new movie', new_movie_path
4 changes: 4 additions & 0 deletions app/views/movies/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
%li
Released on:
= @movie.release_date.strftime("%B %d, %Y")
%li
Director:
= @movie.director

%h3 Description:

%p#description= @movie.description

= link_to 'Edit', edit_movie_path(@movie)
= button_to 'Delete', movie_path(@movie), :method => :delete, :confirm => 'Are you sure?'
= link_to 'Find Movies With Same Director', movie_similar_path(@id)
= link_to 'Back to movie list', movies_path
23 changes: 23 additions & 0 deletions app/views/movies/similar.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-# in app/views/movies/similar.html.haml
%h2 Movies with Same Director as #{@movie.title}

%table#movies
%thead
%tr
%th Movie Title
%th Rating
%th Release Date
%th Director
%th More Info
%tbody
- @movies.each do |movie|
%tr
%td= movie.title
%td= movie.rating
%td= movie.release_date
%td= movie.director
%td= link_to "More about #{movie.title}", movie_path(movie)

= link_to 'Back', movie_path(@movie)

8 changes: 8 additions & 0 deletions config/cucumber.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%>
default: <%= std_opts %> features
wip: --tags @wip:3 --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
resources :movies
resources :movies do
match "similar" => "movies#similar"
end

# Sample resource route with options:
# resources :products do
Expand Down
Loading

0 comments on commit b4c3ac2

Please sign in to comment.