Skip to content

Commit

Permalink
Merge remote branch 'hw3_public/master' into hw3_start
Browse files Browse the repository at this point in the history
Conflicts:
	.gitignore
	Gemfile
	app/assets/stylesheets/application.css
	app/controllers/movies_controller.rb
	app/models/movie.rb
	app/views/movies/index.html.haml
	config/cucumber.yml
	config/database.yml
	config/routes.rb
	lib/tasks/cucumber.rake
  • Loading branch information
Richard Xia committed Feb 8, 2012
2 parents b34151c + 609b1fc commit a25e60f
Show file tree
Hide file tree
Showing 18 changed files with 560 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
#* #*
\#*\#
*~ *~
TAGS TAGS
db/schema.rb db/schema.rb
Expand Down
24 changes: 15 additions & 9 deletions Gemfile
Expand Up @@ -5,6 +5,20 @@ gem 'rails', '3.1.0'
# Bundle edge Rails instead: # Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git' # gem 'rails', :git => 'git://github.com/rails/rails.git'


# for Heroku deployment - as described in Ap. A of ELLS book
group :development, :test do
gem 'sqlite3'
gem 'ruby-debug19', :require => 'ruby-debug'
gem 'cucumber-rails'
gem 'cucumber-rails-training-wheels'
gem 'database_cleaner'
gem 'capybara'
gem 'launchy'
end
group :production do
# gem 'pg'
end

# Gems used only for assets and not required # Gems used only for assets and not required
# in production environments by default. # in production environments by default.
group :assets do group :assets do
Expand All @@ -22,13 +36,5 @@ gem 'jquery-rails'
# Deploy with Capistrano # Deploy with Capistrano
# gem 'capistrano' # gem 'capistrano'


group :development, :test do # To use debugger
gem 'sqlite3'
gem 'ruby-debug19'
end

group :production do
gem 'pg'
end

gem 'haml' gem 'haml'
20 changes: 19 additions & 1 deletion app/controllers/movies_controller.rb
Expand Up @@ -30,9 +30,27 @@ def new
end end


def create def create
debugger
@movie = Movie.create!(params[:movie]) @movie = Movie.create!(params[:movie])
flash[:notice] = "#{@movie.title} was successfully created." flash[:notice] = "#{@movie.title} was successfully created."
redirect_to movies_path
end

def edit
@movie = Movie.find params[:id]
end

def update
@movie = Movie.find params[:id]
@movie.update_attributes!(params[:movie])
flash[:notice] = "#{@movie.title} was successfully updated."
redirect_to movie_path(@movie)
end

def destroy
@movie = Movie.find(params[:id])
@movie.destroy
flash[:notice] = "Movie '#{@movie.title}' deleted."
redirect_to movies_path
end end


end end
Empty file added app/models/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion config/cucumber.yml
@@ -1,7 +1,7 @@
<% <%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" 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}" 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'] || 'progress'} --strict --tags ~@wip" std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
%> %>
default: <%= std_opts %> features default: <%= std_opts %> features
wip: --tags @wip:3 --wip features wip: --tags @wip:3 --wip features
Expand Down
5 changes: 4 additions & 1 deletion config/database.yml
Expand Up @@ -12,7 +12,7 @@ development:
# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production. # Do not set this db to the same as development or production.
test: test: &test
adapter: sqlite3 adapter: sqlite3
database: db/test.sqlite3 database: db/test.sqlite3
pool: 5 pool: 5
Expand All @@ -23,3 +23,6 @@ production:
database: db/production.sqlite3 database: db/production.sqlite3
pool: 5 pool: 5
timeout: 5000 timeout: 5000

cucumber:
<<: *test
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -13,7 +13,7 @@
# Sample resource route (maps HTTP verbs to controller actions automatically): # Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products # resources :products
resources :movies resources :movies

# Sample resource route with options: # Sample resource route with options:
# resources :products do # resources :products do
# member do # member do
Expand Down
25 changes: 25 additions & 0 deletions db/migrate/20120130161449_add_more_movies.rb
@@ -0,0 +1,25 @@
class AddMoreMovies < ActiveRecord::Migration
MORE_MOVIES = [
{:title => 'Aladdin', :rating => 'G', :release_date => '25-Nov-1992'},
{:title => 'The Terminator', :rating => 'R', :release_date => '26-Oct-1984'},
{:title => 'When Harry Met Sally', :rating => 'R', :release_date => '21-Jul-1989'},
{:title => 'The Help', :rating => 'PG-13', :release_date => '10-Aug-2011'},
{:title => 'Chocolat', :rating => 'PG-13', :release_date => '5-Jan-2001'},
{:title => 'Amelie', :rating => 'R', :release_date => '25-Apr-2001'},
{:title => '2001: A Space Odyssey', :rating => 'G', :release_date => '6-Apr-1968'},
{:title => 'The Incredibles', :rating => 'PG', :release_date => '5-Nov-2004'},
{:title => 'Raiders of the Lost Ark', :rating => 'PG', :release_date => '12-Jun-1981'},
{:title => 'Chicken Run', :rating => 'G', :release_date => '21-Jun-2000'},
]
def up
MORE_MOVIES.each do |movie|
Movie.create!(movie)
end
end

def down
MORE_MOVIES.each do |movie|
Movie.find_by_title_and_rating(movie[:title], movie[:rating]).destroy
end
end
end
35 changes: 35 additions & 0 deletions features/filter_movie_list.feature
@@ -0,0 +1,35 @@
Feature: display list of movies filtered by MPAA rating

As a concerned parent
So that I can quickly browse movies appropriate for my family
I want to see movies matching only certain MPAA ratings

Background: movies have been added to database

Given the following movies exist:
| title | rating | release_date |
| Aladdin | G | 25-Nov-1992 |
| The Terminator | R | 26-Oct-1984 |
| When Harry Met Sally | R | 21-Jul-1989 |
| The Help | PG-13 | 10-Aug-2011 |
| Chocolat | PG-13 | 5-Jan-2001 |
| Amelie | R | 25-Apr-2001 |
| 2001: A Space Odyssey | G | 6-Apr-1968 |
| The Incredibles | PG | 5-Nov-2004 |
| Raiders of the Lost Ark | PG | 12-Jun-1981 |
| Chicken Run | G | 21-Jun-2000 |

And I am on the RottenPotatoes home page

Scenario: restrict to movies with 'PG' or 'R' ratings
# enter step(s) to check the 'PG' and 'R' checkboxes
# enter step(s) to uncheck all other checkboxes
# enter step to "submit" the search form on the homepage
# enter step(s) to ensure that PG and R movies are visible
# enter step(s) to ensure that other movies are not visible

Scenario: no checkboxes selected
# see assignment

Scenario: all checkboxes selected
# see assignment
29 changes: 29 additions & 0 deletions features/sort_movie_list.feature
@@ -0,0 +1,29 @@
Feature: display list of movies sorted by different criteria

As an avid moviegoer
So that I can quickly browse movies based on my preferences
I want to see movies sorted by title or release date

Background: movies have been added to database

Given the following movies exist:
| title | rating | release_date |
| Aladdin | G | 25-Nov-1992 |
| The Terminator | R | 26-Oct-1984 |
| When Harry Met Sally | R | 21-Jul-1989 |
| The Help | PG-13 | 10-Aug-2011 |
| Chocolat | PG-13 | 5-Jan-2001 |
| Amelie | R | 25-Apr-2001 |
| 2001: A Space Odyssey | G | 6-Apr-1968 |
| The Incredibles | PG | 5-Nov-2004 |
| Raiders of the Lost Ark | PG | 12-Jun-1981 |
| Chicken Run | G | 21-Jun-2000 |

And I am on the RottenPotatoes home page

Feature: sort movies alphabetically
# your steps here

Feature: sort movies in increasing order of release date
# your steps here

26 changes: 26 additions & 0 deletions features/step_definitions/movie_steps.rb
@@ -0,0 +1,26 @@
# Add a declarative step here for populating the DB with movies.

Given /the following movies exist/ do |movies_table|
movies_table.hashes.each do |movie|
# each returned element will be a hash whose key is the table header.
# you should arrange to add that movie to the database here.
end
end

# Make sure that one string (regexp) occurs before or after another one
# on the same page

Then /I should see "(.*)" before "(.*)"/ do |e1, e2|
# ensure that that e1 occurs before e2.
# page.content is the entire content of the page as a string.
end

# Make it easier to express checking or unchecking several boxes at once
# "When I uncheck the following ratings: PG, G, R"
# "When I check the following ratings: G"

When /I (un)?check the following ratings: (.*)/ do |uncheck, rating_list|
# HINT: use String#split to split up the rating_list, then
# iterate over the ratings and reuse the "When I check..." or
# "When I uncheck..." steps in lines 89-95 of web_steps.rb
end

0 comments on commit a25e60f

Please sign in to comment.