Skip to content

Commit a25e60f

Browse files
author
Richard Xia
committed
Merge remote branch 'hw3_public/master' into hw3_start
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
2 parents b34151c + 609b1fc commit a25e60f

File tree

18 files changed

+560
-13
lines changed

18 files changed

+560
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#*
2+
\#*\#
23
*~
34
TAGS
45
db/schema.rb

Gemfile

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ gem 'rails', '3.1.0'
55
# Bundle edge Rails instead:
66
# gem 'rails', :git => 'git://github.com/rails/rails.git'
77

8+
# for Heroku deployment - as described in Ap. A of ELLS book
9+
group :development, :test do
10+
gem 'sqlite3'
11+
gem 'ruby-debug19', :require => 'ruby-debug'
12+
gem 'cucumber-rails'
13+
gem 'cucumber-rails-training-wheels'
14+
gem 'database_cleaner'
15+
gem 'capybara'
16+
gem 'launchy'
17+
end
18+
group :production do
19+
# gem 'pg'
20+
end
21+
822
# Gems used only for assets and not required
923
# in production environments by default.
1024
group :assets do
@@ -22,13 +36,5 @@ gem 'jquery-rails'
2236
# Deploy with Capistrano
2337
# gem 'capistrano'
2438

25-
group :development, :test do
26-
gem 'sqlite3'
27-
gem 'ruby-debug19'
28-
end
29-
30-
group :production do
31-
gem 'pg'
32-
end
33-
39+
# To use debugger
3440
gem 'haml'

app/controllers/movies_controller.rb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,27 @@ def new
3030
end
3131

3232
def create
33-
debugger
3433
@movie = Movie.create!(params[:movie])
3534
flash[:notice] = "#{@movie.title} was successfully created."
35+
redirect_to movies_path
36+
end
37+
38+
def edit
39+
@movie = Movie.find params[:id]
40+
end
41+
42+
def update
43+
@movie = Movie.find params[:id]
44+
@movie.update_attributes!(params[:movie])
45+
flash[:notice] = "#{@movie.title} was successfully updated."
46+
redirect_to movie_path(@movie)
47+
end
48+
49+
def destroy
50+
@movie = Movie.find(params[:id])
51+
@movie.destroy
52+
flash[:notice] = "Movie '#{@movie.title}' deleted."
53+
redirect_to movies_path
3654
end
3755

3856
end

app/models/.gitkeep

Whitespace-only changes.

config/cucumber.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<%
22
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
33
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4-
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip"
4+
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
55
%>
66
default: <%= std_opts %> features
77
wip: --tags @wip:3 --wip features

config/database.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ development:
1212
# Warning: The database defined as "test" will be erased and
1313
# re-generated from your development database when you run "rake".
1414
# Do not set this db to the same as development or production.
15-
test:
15+
test: &test
1616
adapter: sqlite3
1717
database: db/test.sqlite3
1818
pool: 5
@@ -23,3 +23,6 @@ production:
2323
database: db/production.sqlite3
2424
pool: 5
2525
timeout: 5000
26+
27+
cucumber:
28+
<<: *test

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# Sample resource route (maps HTTP verbs to controller actions automatically):
1414
# resources :products
1515
resources :movies
16-
16+
1717
# Sample resource route with options:
1818
# resources :products do
1919
# member do
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class AddMoreMovies < ActiveRecord::Migration
2+
MORE_MOVIES = [
3+
{:title => 'Aladdin', :rating => 'G', :release_date => '25-Nov-1992'},
4+
{:title => 'The Terminator', :rating => 'R', :release_date => '26-Oct-1984'},
5+
{:title => 'When Harry Met Sally', :rating => 'R', :release_date => '21-Jul-1989'},
6+
{:title => 'The Help', :rating => 'PG-13', :release_date => '10-Aug-2011'},
7+
{:title => 'Chocolat', :rating => 'PG-13', :release_date => '5-Jan-2001'},
8+
{:title => 'Amelie', :rating => 'R', :release_date => '25-Apr-2001'},
9+
{:title => '2001: A Space Odyssey', :rating => 'G', :release_date => '6-Apr-1968'},
10+
{:title => 'The Incredibles', :rating => 'PG', :release_date => '5-Nov-2004'},
11+
{:title => 'Raiders of the Lost Ark', :rating => 'PG', :release_date => '12-Jun-1981'},
12+
{:title => 'Chicken Run', :rating => 'G', :release_date => '21-Jun-2000'},
13+
]
14+
def up
15+
MORE_MOVIES.each do |movie|
16+
Movie.create!(movie)
17+
end
18+
end
19+
20+
def down
21+
MORE_MOVIES.each do |movie|
22+
Movie.find_by_title_and_rating(movie[:title], movie[:rating]).destroy
23+
end
24+
end
25+
end

features/filter_movie_list.feature

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Feature: display list of movies filtered by MPAA rating
2+
3+
As a concerned parent
4+
So that I can quickly browse movies appropriate for my family
5+
I want to see movies matching only certain MPAA ratings
6+
7+
Background: movies have been added to database
8+
9+
Given the following movies exist:
10+
| title | rating | release_date |
11+
| Aladdin | G | 25-Nov-1992 |
12+
| The Terminator | R | 26-Oct-1984 |
13+
| When Harry Met Sally | R | 21-Jul-1989 |
14+
| The Help | PG-13 | 10-Aug-2011 |
15+
| Chocolat | PG-13 | 5-Jan-2001 |
16+
| Amelie | R | 25-Apr-2001 |
17+
| 2001: A Space Odyssey | G | 6-Apr-1968 |
18+
| The Incredibles | PG | 5-Nov-2004 |
19+
| Raiders of the Lost Ark | PG | 12-Jun-1981 |
20+
| Chicken Run | G | 21-Jun-2000 |
21+
22+
And I am on the RottenPotatoes home page
23+
24+
Scenario: restrict to movies with 'PG' or 'R' ratings
25+
# enter step(s) to check the 'PG' and 'R' checkboxes
26+
# enter step(s) to uncheck all other checkboxes
27+
# enter step to "submit" the search form on the homepage
28+
# enter step(s) to ensure that PG and R movies are visible
29+
# enter step(s) to ensure that other movies are not visible
30+
31+
Scenario: no checkboxes selected
32+
# see assignment
33+
34+
Scenario: all checkboxes selected
35+
# see assignment

features/sort_movie_list.feature

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Feature: display list of movies sorted by different criteria
2+
3+
As an avid moviegoer
4+
So that I can quickly browse movies based on my preferences
5+
I want to see movies sorted by title or release date
6+
7+
Background: movies have been added to database
8+
9+
Given the following movies exist:
10+
| title | rating | release_date |
11+
| Aladdin | G | 25-Nov-1992 |
12+
| The Terminator | R | 26-Oct-1984 |
13+
| When Harry Met Sally | R | 21-Jul-1989 |
14+
| The Help | PG-13 | 10-Aug-2011 |
15+
| Chocolat | PG-13 | 5-Jan-2001 |
16+
| Amelie | R | 25-Apr-2001 |
17+
| 2001: A Space Odyssey | G | 6-Apr-1968 |
18+
| The Incredibles | PG | 5-Nov-2004 |
19+
| Raiders of the Lost Ark | PG | 12-Jun-1981 |
20+
| Chicken Run | G | 21-Jun-2000 |
21+
22+
And I am on the RottenPotatoes home page
23+
24+
Feature: sort movies alphabetically
25+
# your steps here
26+
27+
Feature: sort movies in increasing order of release date
28+
# your steps here
29+

0 commit comments

Comments
 (0)