From f3b274df4a7ff299ca2cbae859b2ca8d099f35b0 Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 30 Nov 2015 13:34:38 -0800 Subject: [PATCH 01/33] Created Movie, Book and Album models --- app/models/album.rb | 2 + app/models/book.rb | 2 + app/models/movie.rb | 2 + db/migrate/20151130213302_create_movies.rb | 12 ++++++ db/migrate/20151130213331_create_books.rb | 12 ++++++ db/migrate/20151130213356_create_albums.rb | 12 ++++++ db/schema.rb | 43 ++++++++++++++++++++++ 7 files changed, 85 insertions(+) create mode 100644 app/models/album.rb create mode 100644 app/models/book.rb create mode 100644 app/models/movie.rb create mode 100644 db/migrate/20151130213302_create_movies.rb create mode 100644 db/migrate/20151130213331_create_books.rb create mode 100644 db/migrate/20151130213356_create_albums.rb create mode 100644 db/schema.rb diff --git a/app/models/album.rb b/app/models/album.rb new file mode 100644 index 0000000000..46fa309e4e --- /dev/null +++ b/app/models/album.rb @@ -0,0 +1,2 @@ +class Album < ActiveRecord::Base +end diff --git a/app/models/book.rb b/app/models/book.rb new file mode 100644 index 0000000000..6f68b44465 --- /dev/null +++ b/app/models/book.rb @@ -0,0 +1,2 @@ +class Book < ActiveRecord::Base +end diff --git a/app/models/movie.rb b/app/models/movie.rb new file mode 100644 index 0000000000..49198a7d97 --- /dev/null +++ b/app/models/movie.rb @@ -0,0 +1,2 @@ +class Movie < ActiveRecord::Base +end diff --git a/db/migrate/20151130213302_create_movies.rb b/db/migrate/20151130213302_create_movies.rb new file mode 100644 index 0000000000..f25d7bd722 --- /dev/null +++ b/db/migrate/20151130213302_create_movies.rb @@ -0,0 +1,12 @@ +class CreateMovies < ActiveRecord::Migration + def change + create_table :movies do |t| + t.string :title + t.string :director + t.string :description + t.integer :ranking + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20151130213331_create_books.rb b/db/migrate/20151130213331_create_books.rb new file mode 100644 index 0000000000..2f98c06fa0 --- /dev/null +++ b/db/migrate/20151130213331_create_books.rb @@ -0,0 +1,12 @@ +class CreateBooks < ActiveRecord::Migration + def change + create_table :books do |t| + t.string :title + t.string :author + t.string :description + t.integer :ranking + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20151130213356_create_albums.rb b/db/migrate/20151130213356_create_albums.rb new file mode 100644 index 0000000000..ae883252f1 --- /dev/null +++ b/db/migrate/20151130213356_create_albums.rb @@ -0,0 +1,12 @@ +class CreateAlbums < ActiveRecord::Migration + def change + create_table :albums do |t| + t.string :title + t.string :artist + t.string :description + t.integer :ranking + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000000..5c9fb21f00 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,43 @@ +# encoding: UTF-8 +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# Note that this schema.rb definition is the authoritative source for your +# database schema. If you need to create the application database on another +# system, you should be using db:schema:load, not running all the migrations +# from scratch. The latter is a flawed and unsustainable approach (the more migrations +# you'll amass, the slower it'll run and the greater likelihood for issues). +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 20151130213356) do + + create_table "albums", force: :cascade do |t| + t.string "title" + t.string "artist" + t.string "description" + t.integer "ranking" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "books", force: :cascade do |t| + t.string "title" + t.string "author" + t.string "description" + t.integer "ranking" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "movies", force: :cascade do |t| + t.string "title" + t.string "director" + t.string "description" + t.integer "ranking" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end From 70363026ac56bffe0568e6684fe748448251324e Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 30 Nov 2015 13:37:07 -0800 Subject: [PATCH 02/33] generated books, movies and albums controllers --- app/assets/javascripts/albums.coffee | 3 +++ app/assets/javascripts/books.coffee | 3 +++ app/assets/javascripts/movies.coffee | 3 +++ app/assets/stylesheets/albums.scss | 3 +++ app/assets/stylesheets/books.scss | 3 +++ app/assets/stylesheets/movies.scss | 3 +++ app/controllers/albums_controller.rb | 2 ++ app/controllers/books_controller.rb | 2 ++ app/controllers/movies_controller.rb | 2 ++ app/helpers/albums_helper.rb | 2 ++ app/helpers/books_helper.rb | 2 ++ app/helpers/movies_helper.rb | 2 ++ 12 files changed, 30 insertions(+) create mode 100644 app/assets/javascripts/albums.coffee create mode 100644 app/assets/javascripts/books.coffee create mode 100644 app/assets/javascripts/movies.coffee create mode 100644 app/assets/stylesheets/albums.scss create mode 100644 app/assets/stylesheets/books.scss create mode 100644 app/assets/stylesheets/movies.scss create mode 100644 app/controllers/albums_controller.rb create mode 100644 app/controllers/books_controller.rb create mode 100644 app/controllers/movies_controller.rb create mode 100644 app/helpers/albums_helper.rb create mode 100644 app/helpers/books_helper.rb create mode 100644 app/helpers/movies_helper.rb diff --git a/app/assets/javascripts/albums.coffee b/app/assets/javascripts/albums.coffee new file mode 100644 index 0000000000..24f83d18bb --- /dev/null +++ b/app/assets/javascripts/albums.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/books.coffee b/app/assets/javascripts/books.coffee new file mode 100644 index 0000000000..24f83d18bb --- /dev/null +++ b/app/assets/javascripts/books.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/movies.coffee b/app/assets/javascripts/movies.coffee new file mode 100644 index 0000000000..24f83d18bb --- /dev/null +++ b/app/assets/javascripts/movies.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/albums.scss b/app/assets/stylesheets/albums.scss new file mode 100644 index 0000000000..0eb33ca0f6 --- /dev/null +++ b/app/assets/stylesheets/albums.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the albums controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/books.scss b/app/assets/stylesheets/books.scss new file mode 100644 index 0000000000..81379d103f --- /dev/null +++ b/app/assets/stylesheets/books.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the books controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/movies.scss b/app/assets/stylesheets/movies.scss new file mode 100644 index 0000000000..70aaa8a9a4 --- /dev/null +++ b/app/assets/stylesheets/movies.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the movies controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb new file mode 100644 index 0000000000..2f800bd33f --- /dev/null +++ b/app/controllers/albums_controller.rb @@ -0,0 +1,2 @@ +class AlbumsController < ApplicationController +end diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb new file mode 100644 index 0000000000..cdb437b99f --- /dev/null +++ b/app/controllers/books_controller.rb @@ -0,0 +1,2 @@ +class BooksController < ApplicationController +end diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb new file mode 100644 index 0000000000..6c4c516140 --- /dev/null +++ b/app/controllers/movies_controller.rb @@ -0,0 +1,2 @@ +class MoviesController < ApplicationController +end diff --git a/app/helpers/albums_helper.rb b/app/helpers/albums_helper.rb new file mode 100644 index 0000000000..d976b7cef8 --- /dev/null +++ b/app/helpers/albums_helper.rb @@ -0,0 +1,2 @@ +module AlbumsHelper +end diff --git a/app/helpers/books_helper.rb b/app/helpers/books_helper.rb new file mode 100644 index 0000000000..4b9311e0be --- /dev/null +++ b/app/helpers/books_helper.rb @@ -0,0 +1,2 @@ +module BooksHelper +end diff --git a/app/helpers/movies_helper.rb b/app/helpers/movies_helper.rb new file mode 100644 index 0000000000..493eee555f --- /dev/null +++ b/app/helpers/movies_helper.rb @@ -0,0 +1,2 @@ +module MoviesHelper +end From 68d1dd1733a88ab047dfe69af5d3d0e41ab9b127 Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 30 Nov 2015 13:39:10 -0800 Subject: [PATCH 03/33] generated routes for 3 models --- config/routes.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index 3f66539d54..05176f9361 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ Rails.application.routes.draw do + + resources :movies, :books, :albums # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". From c74fa0c8c7ab7f5bcfb2b98a283fee226942c124 Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 30 Nov 2015 14:43:42 -0800 Subject: [PATCH 04/33] Added all standard methods and views for movies controller --- app/controllers/movies_controller.rb | 46 ++++++++++++++++++++++++++ app/views/movies/edit.html.erb | 1 + app/views/movies/home.html.erb | 4 +++ app/views/movies/index.html.erb | 9 +++++ app/views/movies/new.html.erb | 1 + app/views/movies/show.html.erb | 7 ++++ app/views/shared/_moviedetail.html.erb | 14 ++++++++ config/routes.rb | 2 ++ 8 files changed, 84 insertions(+) create mode 100644 app/views/movies/edit.html.erb create mode 100644 app/views/movies/home.html.erb create mode 100644 app/views/movies/index.html.erb create mode 100644 app/views/movies/new.html.erb create mode 100644 app/views/movies/show.html.erb create mode 100644 app/views/shared/_moviedetail.html.erb diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 6c4c516140..903002158a 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,2 +1,48 @@ class MoviesController < ApplicationController + + def home + # some kind of code that only shows top 10 of each category by ranking + end + + def index + @movies = Movie.all + end + + def new + @action = :create + @movie = Movie.new + end + + def create + @movie = Movie.new(movie_params) + if @movie.save + redirect_to movie_path(@movie) + else + render "new" + end + end + + def show + id = params[:id] + @movie = Movie.find(id) + end + + def edit + id = params[:id] + @movie = Movie.find(id) + @action = :update + end + + def destroy + Movie.destroy(params[:id]) + redirect_to movies_path + + + end + + private + + def movie_params + params.require(:movie).permit(:title, :director, :ranking, :description) + end end diff --git a/app/views/movies/edit.html.erb b/app/views/movies/edit.html.erb new file mode 100644 index 0000000000..6590ec6709 --- /dev/null +++ b/app/views/movies/edit.html.erb @@ -0,0 +1 @@ +<%= render 'shared/moviedetail' %> diff --git a/app/views/movies/home.html.erb b/app/views/movies/home.html.erb new file mode 100644 index 0000000000..1e3cfe6046 --- /dev/null +++ b/app/views/movies/home.html.erb @@ -0,0 +1,4 @@ +

MediaRanker

+

This page will show the top 10 of each category

+ +<%= link_to "View More Movies", movies_path %> diff --git a/app/views/movies/index.html.erb b/app/views/movies/index.html.erb new file mode 100644 index 0000000000..fc758cab99 --- /dev/null +++ b/app/views/movies/index.html.erb @@ -0,0 +1,9 @@ +

View all movies

+ +
    +<% @movies.each do |movie| %> + <%= movie.title %> +<% end %> +
+ +<%= link_to "View all media", root_url %> <%= link_to "Add a movie", new_movie_path %> diff --git a/app/views/movies/new.html.erb b/app/views/movies/new.html.erb new file mode 100644 index 0000000000..6590ec6709 --- /dev/null +++ b/app/views/movies/new.html.erb @@ -0,0 +1 @@ +<%= render 'shared/moviedetail' %> diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb new file mode 100644 index 0000000000..b89b5680e0 --- /dev/null +++ b/app/views/movies/show.html.erb @@ -0,0 +1,7 @@ +<%= @movie.title %> +
+<%= @movie.director %> +<%= @movie.description %> + +<%= link_to "Edit", edit_movie_path %> +<%= link_to "Delete", movie_path, method: :delete %> diff --git a/app/views/shared/_moviedetail.html.erb b/app/views/shared/_moviedetail.html.erb new file mode 100644 index 0000000000..a319891d6e --- /dev/null +++ b/app/views/shared/_moviedetail.html.erb @@ -0,0 +1,14 @@ +

New Movie

+ <%= form_for @movie, url: {action: @create} do |f| %> + <%= f.label :title %> + <%= f.text_field :title %> +
+ <%= f.label :director %> + <%= f.text_field :director %> +
+
+ <%= f.label :description %> + <%= f.text_area :description %> +
+ <%= f.submit "Save" %> + <% end %> diff --git a/config/routes.rb b/config/routes.rb index 05176f9361..d7318b331b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,7 @@ Rails.application.routes.draw do +root 'movies#home' + resources :movies, :books, :albums # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". From ee9a7836a4eabcc360c6e945ebca8b66bba511ba Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 30 Nov 2015 15:29:53 -0800 Subject: [PATCH 05/33] Added views and methods for books class --- app/controllers/books_controller.rb | 48 ++++++++++++++++++++++++++ app/controllers/movies_controller.rb | 13 +++++-- app/views/books/edit.html.erb | 1 + app/views/books/index.html.erb | 9 +++++ app/views/books/new.html.erb | 1 + app/views/books/show.html.erb | 8 +++++ app/views/movies/home.html.erb | 1 + app/views/movies/index.html.erb | 2 +- app/views/movies/show.html.erb | 4 ++- app/views/shared/_bookdetail.html.erb | 15 ++++++++ app/views/shared/_moviedetail.html.erb | 4 +-- 11 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 app/views/books/edit.html.erb create mode 100644 app/views/books/index.html.erb create mode 100644 app/views/books/new.html.erb create mode 100644 app/views/books/show.html.erb create mode 100644 app/views/shared/_bookdetail.html.erb diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index cdb437b99f..e09b3d1006 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -1,2 +1,50 @@ class BooksController < ApplicationController + def index + @books = Book.all + end + + def new + @title = "Add a Book" + @action = :create + @book = Book.new + end + + def create + @book = Book.new(book_params) + if @book.save + redirect_to book_path(@book) + else + render "new" + end + end + + def show + id = params[:id] + @book = Book.find(id) + end + + def edit + @title = "Edit a book" + id = params[:id] + @book = Book.find(id) + @action = :update + end + + def update + id = params[:id] + @book = Book.find(id) + @book.update(book_params[:book]) + redirect_to book_path(params[:id]) + end + + def destroy + Book.destroy(params[:id]) + redirect_to books_path + end + + private + + def book_params + params.permit(book:[:author, :title, :ranking, :description]) + end end diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 903002158a..6ead2ebeb1 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -14,6 +14,7 @@ def new end def create + @title = "Add a movie" @movie = Movie.new(movie_params) if @movie.save redirect_to movie_path(@movie) @@ -28,21 +29,27 @@ def show end def edit + @title = "Edit a movie" id = params[:id] @movie = Movie.find(id) @action = :update end + def update + id = params[:id] + @movie = Movie.find(id) + @movie.update(movie_params[:movie]) + redirect_to movie_path(params[:id]) + end + def destroy Movie.destroy(params[:id]) redirect_to movies_path - - end private def movie_params - params.require(:movie).permit(:title, :director, :ranking, :description) + params.permit(movie: [:title, :director, :ranking, :description]) end end diff --git a/app/views/books/edit.html.erb b/app/views/books/edit.html.erb new file mode 100644 index 0000000000..c5bb3a2074 --- /dev/null +++ b/app/views/books/edit.html.erb @@ -0,0 +1 @@ +<%= render 'shared/bookdetail' %> diff --git a/app/views/books/index.html.erb b/app/views/books/index.html.erb new file mode 100644 index 0000000000..ae084b8756 --- /dev/null +++ b/app/views/books/index.html.erb @@ -0,0 +1,9 @@ +

View all books

+ +
    +<% @books.each do |book| %> +
  • <%= link_to book.title, book_path(book.id) %>
  • +<% end %> +
+ +<%= link_to "View all media", root_url %> <%= link_to "Add a book", new_book_path %> diff --git a/app/views/books/new.html.erb b/app/views/books/new.html.erb new file mode 100644 index 0000000000..c5bb3a2074 --- /dev/null +++ b/app/views/books/new.html.erb @@ -0,0 +1 @@ +<%= render 'shared/bookdetail' %> diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb new file mode 100644 index 0000000000..34bf81129b --- /dev/null +++ b/app/views/books/show.html.erb @@ -0,0 +1,8 @@ +<%= @book.title %> +
+<%= @book.author %> +
+<%= @book.description %> + +<%= link_to "Edit", edit_book_path %> +<%= link_to "Delete", book_path, method: :delete %> diff --git a/app/views/movies/home.html.erb b/app/views/movies/home.html.erb index 1e3cfe6046..8f48545f4c 100644 --- a/app/views/movies/home.html.erb +++ b/app/views/movies/home.html.erb @@ -2,3 +2,4 @@

This page will show the top 10 of each category

<%= link_to "View More Movies", movies_path %> +<%= link_to "View More Books", books_path %> diff --git a/app/views/movies/index.html.erb b/app/views/movies/index.html.erb index fc758cab99..a1a475ea03 100644 --- a/app/views/movies/index.html.erb +++ b/app/views/movies/index.html.erb @@ -2,7 +2,7 @@
    <% @movies.each do |movie| %> - <%= movie.title %> +
  • <%= link_to movie.title, movie_path(movie.id) %>
  • <% end %>
diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb index b89b5680e0..c8672a0ea0 100644 --- a/app/views/movies/show.html.erb +++ b/app/views/movies/show.html.erb @@ -1,7 +1,9 @@ <%= @movie.title %>
<%= @movie.director %> +
<%= @movie.description %> - +
+
<%= link_to "Edit", edit_movie_path %> <%= link_to "Delete", movie_path, method: :delete %> diff --git a/app/views/shared/_bookdetail.html.erb b/app/views/shared/_bookdetail.html.erb new file mode 100644 index 0000000000..20938627c7 --- /dev/null +++ b/app/views/shared/_bookdetail.html.erb @@ -0,0 +1,15 @@ +

<%= @title %>

+ <%= form_for @book, url: {action: @action} do |f| %> + <%= f.label :title %> + <%= f.text_field :title %> +
+ <%= f.label :author %> + <%= f.text_field :author %> +
+
+ <%= f.label :description %> + <%= f.text_area :description %> +
+
+ <%= f.submit "Save" %> + <% end %> diff --git a/app/views/shared/_moviedetail.html.erb b/app/views/shared/_moviedetail.html.erb index a319891d6e..11e24199db 100644 --- a/app/views/shared/_moviedetail.html.erb +++ b/app/views/shared/_moviedetail.html.erb @@ -1,5 +1,5 @@ -

New Movie

- <%= form_for @movie, url: {action: @create} do |f| %> +

<%= @title %>

+ <%= form_for @movie, url: {action: @action} do |f| %> <%= f.label :title %> <%= f.text_field :title %>
From 510c87b031bc7da1b94eca15bacd598dff763e6d Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 30 Nov 2015 16:53:46 -0800 Subject: [PATCH 06/33] unworking method for upvotes --- app/controllers/movies_controller.rb | 20 ++++++++++++++++++++ app/views/movies/show.html.erb | 5 +++++ config/routes.rb | 3 +++ 3 files changed, 28 insertions(+) diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 6ead2ebeb1..18d5e503e9 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -47,6 +47,26 @@ def destroy redirect_to movies_path end + def edit + @title = "Edit a movie" + id = params[:id] + @movie = Movie.find(id) + @action = :update + end + + def upvote + id = params[:id] + @movie = Movie.find(id) + ranking = @movie.ranking + @r = ranking.to_i + @r += 1 + ranking = @r + @movie.update(movie_params[:movie]) + redirect_to movies_path + end + + + private def movie_params diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb index c8672a0ea0..b17ab9e721 100644 --- a/app/views/movies/show.html.erb +++ b/app/views/movies/show.html.erb @@ -4,6 +4,11 @@
<%= @movie.description %>
+Ranking: +<%= @movie.ranking %> +
+
+<%= button_to "Upvote", action: :upvote, method: :patch %>
<%= link_to "Edit", edit_movie_path %> <%= link_to "Delete", movie_path, method: :delete %> diff --git a/config/routes.rb b/config/routes.rb index d7318b331b..63f8b49bdb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,9 @@ root 'movies#home' +get '/movies/:id/upvote' => 'movies#upvote' +patch '/movies/:id/upvote' => 'movies#upvote' + resources :movies, :books, :albums # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". From 05a10223c93d5a931541ba7bf8898246bee27a55 Mon Sep 17 00:00:00 2001 From: Sarah Date: Mon, 30 Nov 2015 17:26:07 -0800 Subject: [PATCH 07/33] Working upvote method --- app/controllers/movies_controller.rb | 14 ++++++-------- app/views/books/show.html.erb | 5 ++++- app/views/movies/show.html.erb | 5 ++--- app/views/shared/_moviedetail.html.erb | 1 + config/routes.rb | 3 +-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 18d5e503e9..da3caeaffe 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -15,7 +15,7 @@ def new def create @title = "Add a movie" - @movie = Movie.new(movie_params) + @movie = Movie.new(movie_params[:movie]) if @movie.save redirect_to movie_path(@movie) else @@ -57,15 +57,13 @@ def edit def upvote id = params[:id] @movie = Movie.find(id) - ranking = @movie.ranking - @r = ranking.to_i - @r += 1 - ranking = @r - @movie.update(movie_params[:movie]) - redirect_to movies_path + r = @movie.ranking + r += 1 + @movie.update(ranking: r) + redirect_to :back end - + private diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index 34bf81129b..7901ca672f 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -3,6 +3,9 @@ <%= @book.author %>
<%= @book.description %> - +
+Ranking: +<% end %> +
<%= link_to "Edit", edit_book_path %> <%= link_to "Delete", book_path, method: :delete %> diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb index b17ab9e721..3713730e88 100644 --- a/app/views/movies/show.html.erb +++ b/app/views/movies/show.html.erb @@ -4,11 +4,10 @@
<%= @movie.description %>
-Ranking: -<%= @movie.ranking %> +Ranked: <%= @movie.ranking %>

-<%= button_to "Upvote", action: :upvote, method: :patch %> +<%= button_to "Upvote", action: :upvote, method: :post %>
<%= link_to "Edit", edit_movie_path %> <%= link_to "Delete", movie_path, method: :delete %> diff --git a/app/views/shared/_moviedetail.html.erb b/app/views/shared/_moviedetail.html.erb index 11e24199db..cdd863de89 100644 --- a/app/views/shared/_moviedetail.html.erb +++ b/app/views/shared/_moviedetail.html.erb @@ -9,6 +9,7 @@
<%= f.label :description %> <%= f.text_area :description %> + <%= f.hidden_field :ranking, value: 0 %>
<%= f.submit "Save" %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 63f8b49bdb..1030ed9e95 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,8 +2,7 @@ root 'movies#home' -get '/movies/:id/upvote' => 'movies#upvote' -patch '/movies/:id/upvote' => 'movies#upvote' +post '/movies/:id/upvote' => 'movies#upvote' resources :movies, :books, :albums # The priority is based upon order of creation: first created -> highest priority. From 12b538dcb1f0da77bd44a6fc82f0d1cbff29eade Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 1 Dec 2015 13:59:37 -0800 Subject: [PATCH 08/33] Made a named route for upvote movie path, added link to movie index page --- .rspec | 2 + Gemfile | 1 + Gemfile.lock | 19 +++++ app/models/book.rb | 3 + app/models/movie.rb | 3 + app/views/movies/index.html.erb | 2 +- app/views/movies/show.html.erb | 2 +- app/views/shared/_bookdetail.html.erb | 2 + config/routes.rb | 2 +- spec/controllers/albums_controller_spec.rb | 16 ++++ spec/controllers/books_controller_spec.rb | 16 ++++ spec/controllers/movies_controller_spec.rb | 16 ++++ spec/helpers/albums_helper_spec.rb | 15 ++++ spec/helpers/books_helper_spec.rb | 15 ++++ spec/helpers/movies_helper_spec.rb | 15 ++++ spec/models/album_spec.rb | 5 ++ spec/models/book_spec.rb | 11 +++ spec/models/movie_spec.rb | 11 +++ spec/rails_helper.rb | 57 ++++++++++++++ spec/spec_helper.rb | 92 ++++++++++++++++++++++ 20 files changed, 302 insertions(+), 3 deletions(-) create mode 100644 .rspec create mode 100644 spec/controllers/albums_controller_spec.rb create mode 100644 spec/controllers/books_controller_spec.rb create mode 100644 spec/controllers/movies_controller_spec.rb create mode 100644 spec/helpers/albums_helper_spec.rb create mode 100644 spec/helpers/books_helper_spec.rb create mode 100644 spec/helpers/movies_helper_spec.rb create mode 100644 spec/models/album_spec.rb create mode 100644 spec/models/book_spec.rb create mode 100644 spec/models/movie_spec.rb create mode 100644 spec/rails_helper.rb create mode 100644 spec/spec_helper.rb diff --git a/.rspec b/.rspec new file mode 100644 index 0000000000..83e16f8044 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--color +--require spec_helper diff --git a/Gemfile b/Gemfile index 74d742d683..e31032940d 100644 --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,7 @@ gem 'sdoc', '~> 0.4.0', group: :doc group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' + gem 'rspec-rails' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index fb94889cd0..c48e8a80fe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -55,6 +55,7 @@ GEM execjs coffee-script-source (1.10.0) debug_inspector (0.0.2) + diff-lcs (1.2.5) erubis (2.7.0) execjs (2.6.0) globalid (0.3.6) @@ -112,6 +113,23 @@ GEM thor (>= 0.18.1, < 2.0) rake (10.4.2) rdoc (4.2.0) + rspec-core (3.4.1) + rspec-support (~> 3.4.0) + rspec-expectations (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-mocks (3.4.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.4.0) + rspec-rails (3.4.0) + actionpack (>= 3.0, < 4.3) + activesupport (>= 3.0, < 4.3) + railties (>= 3.0, < 4.3) + rspec-core (~> 3.4.0) + rspec-expectations (~> 3.4.0) + rspec-mocks (~> 3.4.0) + rspec-support (~> 3.4.0) + rspec-support (3.4.1) ruby-graphviz (1.2.2) sass (3.4.19) sass-rails (5.0.4) @@ -159,6 +177,7 @@ DEPENDENCIES jquery-rails rails (= 4.2.5) rails-erd + rspec-rails sass-rails (~> 5.0) sdoc (~> 0.4.0) spring diff --git a/app/models/book.rb b/app/models/book.rb index 6f68b44465..abc613e9b3 100644 --- a/app/models/book.rb +++ b/app/models/book.rb @@ -1,2 +1,5 @@ class Book < ActiveRecord::Base + + validates :title, presence: true + end diff --git a/app/models/movie.rb b/app/models/movie.rb index 49198a7d97..8619be1399 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -1,2 +1,5 @@ class Movie < ActiveRecord::Base + + validates :title, presence: true + end diff --git a/app/views/movies/index.html.erb b/app/views/movies/index.html.erb index a1a475ea03..c2346f4be4 100644 --- a/app/views/movies/index.html.erb +++ b/app/views/movies/index.html.erb @@ -2,7 +2,7 @@
    <% @movies.each do |movie| %> -
  • <%= link_to movie.title, movie_path(movie.id) %>
  • +
  • Ranked: <%= movie.ranking %> | <%= link_to movie.title, movie_path(movie.id) %> <%= button_to "Upvote", upvote_movie_path(movie.id) %>
  • <% end %>
diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb index 3713730e88..cec06cad19 100644 --- a/app/views/movies/show.html.erb +++ b/app/views/movies/show.html.erb @@ -7,7 +7,7 @@ Ranked: <%= @movie.ranking %>

-<%= button_to "Upvote", action: :upvote, method: :post %> +<%= button_to "Upvote", upvote_movie_path %>
<%= link_to "Edit", edit_movie_path %> <%= link_to "Delete", movie_path, method: :delete %> diff --git a/app/views/shared/_bookdetail.html.erb b/app/views/shared/_bookdetail.html.erb index 20938627c7..e79e4b5d85 100644 --- a/app/views/shared/_bookdetail.html.erb +++ b/app/views/shared/_bookdetail.html.erb @@ -10,6 +10,8 @@ <%= f.label :description %> <%= f.text_area :description %>
+ <%= f.hidden_field :ranking, value: 0 %> +

<%= f.submit "Save" %> <% end %> diff --git a/config/routes.rb b/config/routes.rb index 1030ed9e95..da1a77e644 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,7 +2,7 @@ root 'movies#home' -post '/movies/:id/upvote' => 'movies#upvote' +post '/movies/:id/upvote' => 'movies#upvote', as: :upvote_movie resources :movies, :books, :albums # The priority is based upon order of creation: first created -> highest priority. diff --git a/spec/controllers/albums_controller_spec.rb b/spec/controllers/albums_controller_spec.rb new file mode 100644 index 0000000000..d665bbdb16 --- /dev/null +++ b/spec/controllers/albums_controller_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +RSpec.describe AlbumsController, type: :controller do + #write the spec to correspond to verb you hope to get and action associated w/ it + # this simply checks for success, not whether or not content is correct + # describe "GET 'index'" do + # it "is successful" do + # # you can simply use verb and action + # get :index + # #this invokes a request and the result of the request is a response + # expect(response.status).to eq 200 + # other things can come in response besides status but that is the 1st + # thing we'll check for. + # end + # end +end diff --git a/spec/controllers/books_controller_spec.rb b/spec/controllers/books_controller_spec.rb new file mode 100644 index 0000000000..fd4a1d7b08 --- /dev/null +++ b/spec/controllers/books_controller_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +RSpec.describe BooksController, type: :controller do + #write the spec to correspond to verb you hope to get and action associated w/ it + # this simply checks for success, not whether or not content is correct + describe "GET 'index'" do + it "is successful" do + # you can simply use verb and action + get :index + #this invokes a request and the result of the request is a response + expect(response.status).to eq 200 + # other things can come in response besides status but that is the 1st + # thing we'll check for. + end + end +end diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb new file mode 100644 index 0000000000..8f44aa5964 --- /dev/null +++ b/spec/controllers/movies_controller_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +RSpec.describe MoviesController, type: :controller do + #write the spec to correspond to verb you hope to get and action associated w/ it + # this simply checks for success, not whether or not content is correct + describe "GET 'index'" do + it "is successful" do + # you can simply use verb and action + get :index + #this invokes a request and the result of the request is a response + expect(response.status).to eq 200 + # other things can come in response besides status but that is the 1st + # thing we'll check for. + end + end +end diff --git a/spec/helpers/albums_helper_spec.rb b/spec/helpers/albums_helper_spec.rb new file mode 100644 index 0000000000..ac869969d4 --- /dev/null +++ b/spec/helpers/albums_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the MoviesHelper. For example: +# +# describe MoviesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe AlbumsHelper, type: :helper do + # pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/books_helper_spec.rb b/spec/helpers/books_helper_spec.rb new file mode 100644 index 0000000000..3fbff5f29a --- /dev/null +++ b/spec/helpers/books_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the MoviesHelper. For example: +# +# describe MoviesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe BooksHelper, type: :helper do + # pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/helpers/movies_helper_spec.rb b/spec/helpers/movies_helper_spec.rb new file mode 100644 index 0000000000..32bd66a14a --- /dev/null +++ b/spec/helpers/movies_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the MoviesHelper. For example: +# +# describe MoviesHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe MoviesHelper, type: :helper do + # pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/album_spec.rb b/spec/models/album_spec.rb new file mode 100644 index 0000000000..8dd0ed93e6 --- /dev/null +++ b/spec/models/album_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Album, type: :model do + +end diff --git a/spec/models/book_spec.rb b/spec/models/book_spec.rb new file mode 100644 index 0000000000..ba9dcc1ce0 --- /dev/null +++ b/spec/models/book_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' + +RSpec.describe Book, type: :model do + + describe ".validates" do + it "must have a title" do + expect(Book.new(title: nil)).to_not be_valid + end + end + +end diff --git a/spec/models/movie_spec.rb b/spec/models/movie_spec.rb new file mode 100644 index 0000000000..46815ec80d --- /dev/null +++ b/spec/models/movie_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' + +RSpec.describe Movie, type: :model do + +describe ".validates" do + it "must have a title" do + expect(Movie.new(title: nil)).to_not be_valid + end +end + +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000000..6f1ab14638 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,57 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV['RAILS_ENV'] ||= 'test' +require File.expand_path('../../config/environment', __FILE__) +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +require 'spec_helper' +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } + +# Checks for pending migration and applies them before tests are run. +# If you are not using ActiveRecord, you can remove this line. +ActiveRecord::Migration.maintain_test_schema! + +RSpec.configure do |config| + # 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 + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, :type => :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000000..61e27385c3 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,92 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# The `.rspec` file also contains a few flags that are not defaults but that +# users commonly want. +# +# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # These two settings work together to allow you to limit a spec run + # to individual examples or groups you care about by tagging them with + # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # get run. + config.filter_run :focus + config.run_all_when_everything_filtered = true + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ + # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode + config.disable_monkey_patching! + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = 'doc' + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # 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 + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end From 5b1d2546db67f21f1de21754f555a9a66da3a5f1 Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 1 Dec 2015 15:40:00 -0800 Subject: [PATCH 09/33] Added specs for create, new, index methods --- spec/controllers/movies_controller_spec.rb | 82 ++++++++++++++++++++-- spec/models/movie_spec.rb | 2 + 2 files changed, 78 insertions(+), 6 deletions(-) diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index 8f44aa5964..d0d3027e33 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -1,16 +1,86 @@ require 'rails_helper' RSpec.describe MoviesController, type: :controller do - #write the spec to correspond to verb you hope to get and action associated w/ it - # this simply checks for success, not whether or not content is correct + + let(:create_params) do + { + movie: { + title: "Something", + director: "Uncle Bob", + ranking: 0, + description: "description" + } + } + end + + let(:movie) do + Movie.create(create_params[:movie]) + end + describe "GET 'index'" do it "is successful" do - # you can simply use verb and action get :index - #this invokes a request and the result of the request is a response expect(response.status).to eq 200 - # other things can come in response besides status but that is the 1st - # thing we'll check for. + end + end + + describe "GET 'new'" do + it "renders new view" do + get :new + expect(subject). to render_template :new + end + end + + describe "GET 'show'" do + + it "renders the show view" do + get :show, id: movie.id + expect(subject).to render_template :show + end + end + + describe "POST 'create'" do + + let(:bad_params) do + { + movie: {} + } + end + + it "redirects to show page" do + post :create, create_params + + expect(subject).to redirect_to movie_path(1) + end + + it "renders new template on error" do + post :create, bad_params + expect(subject).to render_template :new + end + end + + describe "PATCH 'update'" do + let(:movie) do + { id: movie.id, + movie: { + title: "Something", + director: "Uncle Joe", + ranking: 0, + description: "description" + } + } + end + + let(:bad_params) do + { + movie: {} + } + end + + it "redirects to show page" do + + patch :update, create_params + expect(subject).to redirect_to movie_path(movie.id) end end end diff --git a/spec/models/movie_spec.rb b/spec/models/movie_spec.rb index 46815ec80d..962a916b5f 100644 --- a/spec/models/movie_spec.rb +++ b/spec/models/movie_spec.rb @@ -8,4 +8,6 @@ end end + + end From bea4a5fbbfa3784a7dd5f0df2ef28f77cf47969d Mon Sep 17 00:00:00 2001 From: Sarah Date: Tue, 1 Dec 2015 15:52:39 -0800 Subject: [PATCH 10/33] Successfully created update spec for movies --- spec/controllers/movies_controller_spec.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index d0d3027e33..a02093b200 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -60,13 +60,13 @@ end describe "PATCH 'update'" do - let(:movie) do + let(:update_params) do { id: movie.id, movie: { title: "Something", director: "Uncle Joe", ranking: 0, - description: "description" + description: "new description" } } end @@ -79,8 +79,11 @@ it "redirects to show page" do - patch :update, create_params + patch :update, update_params expect(subject).to redirect_to movie_path(movie.id) end end + + + end From 9b42653df027e65c280b8de3bc298734bdbafbb2 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 2 Dec 2015 13:46:04 -0800 Subject: [PATCH 11/33] Added Bootstrap --- Gemfile | 1 + Gemfile.lock | 7 ++++ app/assets/javascripts/application.js | 1 + .../{application.css => application.scss} | 5 ++- app/controllers/movies_controller.rb | 13 ++++--- spec/controllers/movies_controller_spec.rb | 34 +++++++++++++++++-- 6 files changed, 51 insertions(+), 10 deletions(-) rename app/assets/stylesheets/{application.css => application.scss} (92%) diff --git a/Gemfile b/Gemfile index e31032940d..7f6296fe5e 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gem 'rails', '4.2.5' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets +gem 'bootstrap-sass', '~> 3.3.6' gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' diff --git a/Gemfile.lock b/Gemfile.lock index c48e8a80fe..9c24219466 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,12 +37,18 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) arel (6.0.3) + autoprefixer-rails (6.1.2) + execjs + json better_errors (2.1.1) coderay (>= 1.0.0) erubis (>= 2.6.6) rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) + bootstrap-sass (3.3.6) + autoprefixer-rails (>= 5.2.1) + sass (>= 3.3.4) builder (3.2.2) byebug (8.2.1) choice (0.2.0) @@ -171,6 +177,7 @@ PLATFORMS DEPENDENCIES better_errors binding_of_caller + bootstrap-sass (~> 3.3.6) byebug coffee-rails (~> 4.1.0) jbuilder (~> 2.0) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e07c5a830f..f91cae5d9b 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -11,6 +11,7 @@ // about supported directives. // //= require jquery +//= require bootstrap-sprockets //= require jquery_ujs //= require turbolinks //= require_tree . diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.scss similarity index 92% rename from app/assets/stylesheets/application.css rename to app/assets/stylesheets/application.scss index f9cd5b3483..07ac031e4a 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.scss @@ -1,3 +1,5 @@ +@import "bootstrap-sprockets"; +@import "bootstrap"; /* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. @@ -10,6 +12,3 @@ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new * file per style scope. * - *= require_tree . - *= require_self - */ diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index da3caeaffe..bdd37bc12c 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -35,11 +35,18 @@ def edit @action = :update end +## use attributes, save it to a local variable (its a hash) +# then use .save boolean to test against def update id = params[:id] @movie = Movie.find(id) - @movie.update(movie_params[:movie]) - redirect_to movie_path(params[:id]) + @movie.attributes = movie_params[:movie] + if @movie.save + # @movie.update(movie_params[:movie]) + redirect_to movie_path(params[:id]) + else + redirect_to edit_movie_path(params[:id]) + end end def destroy @@ -63,8 +70,6 @@ def upvote redirect_to :back end - - private def movie_params diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index a02093b200..bef8feeb0c 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -31,6 +31,13 @@ end end + # describe "GET 'edit'" do + # it "renders new view" do + # get :new + # expect(subject). to render_template :new + # end + # end + describe "GET 'show'" do it "renders the show view" do @@ -49,8 +56,8 @@ it "redirects to show page" do post :create, create_params - - expect(subject).to redirect_to movie_path(1) + new_movie = Movie.last + expect(subject).to redirect_to movie_path(new_movie.id) end it "renders new template on error" do @@ -82,8 +89,29 @@ patch :update, update_params expect(subject).to redirect_to movie_path(movie.id) end - end + it "renders new template on error" do + post :create, bad_params + expect(subject).to render_template :new + end + end + describe "DELETE 'destroy'" do + let(:update_params) do + { id: movie.id, + movie: { + title: "Something", + director: "Uncle Joe", + ranking: 0, + description: "new description" + } + } + end + + it "redirects to index page" do + delete :destroy, update_params + expect(subject).to redirect_to movies_path + end + end end From fc22e9bcdc1ad16babc746663c3e5c3bc22dcc5b Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 2 Dec 2015 14:09:16 -0800 Subject: [PATCH 12/33] Added simplecov gem --- .gitignore | 2 ++ Gemfile | 1 + Gemfile.lock | 7 +++++++ app/assets/stylesheets/application.scss | 6 ++++-- app/controllers/movies_controller.rb | 8 -------- app/views/layouts/application.html.erb | 4 ++-- spec/controllers/movies_controller_spec.rb | 12 ++++++------ spec/spec_helper.rb | 3 +++ 8 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 050c9d95c7..2eb6f54617 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ /log/* !/log/.keep /tmp + +coverage diff --git a/Gemfile b/Gemfile index 7f6296fe5e..a443301bfc 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,7 @@ group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug' gem 'rspec-rails' + gem 'simplecov', :require => false end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 9c24219466..a0cfe3cf8a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -62,6 +62,7 @@ GEM coffee-script-source (1.10.0) debug_inspector (0.0.2) diff-lcs (1.2.5) + docile (1.1.5) erubis (2.7.0) execjs (2.6.0) globalid (0.3.6) @@ -147,6 +148,11 @@ GEM sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) + simplecov (0.11.1) + docile (~> 1.1.0) + json (~> 1.8) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.0) spring (1.5.0) sprockets (3.4.1) rack (> 1, < 3) @@ -187,6 +193,7 @@ DEPENDENCIES rspec-rails sass-rails (~> 5.0) sdoc (~> 0.4.0) + simplecov spring sqlite3 turbolinks diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 07ac031e4a..924e34c1ca 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,5 +1,4 @@ -@import "bootstrap-sprockets"; -@import "bootstrap"; + /* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. @@ -12,3 +11,6 @@ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new * file per style scope. * + */ + @import "bootstrap-sprockets"; + @import "bootstrap"; diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index bdd37bc12c..03aae0eb1d 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -42,7 +42,6 @@ def update @movie = Movie.find(id) @movie.attributes = movie_params[:movie] if @movie.save - # @movie.update(movie_params[:movie]) redirect_to movie_path(params[:id]) else redirect_to edit_movie_path(params[:id]) @@ -54,13 +53,6 @@ def destroy redirect_to movies_path end - def edit - @title = "Edit a movie" - id = params[:id] - @movie = Movie.find(id) - @action = :update - end - def upvote id = params[:id] @movie = Movie.find(id) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2d02e8fbd4..93467c6d4c 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,8 +7,8 @@ <%= csrf_meta_tags %> - +
<%= yield %> - +
diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index bef8feeb0c..918c83c2eb 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -31,12 +31,12 @@ end end - # describe "GET 'edit'" do - # it "renders new view" do - # get :new - # expect(subject). to render_template :new - # end - # end + describe "GET 'edit'" do + it "renders new view" do + get :new + expect(subject). to render_template :new + end + end describe "GET 'show'" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 61e27385c3..c1697e0176 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,6 @@ +require 'simplecov' +SimpleCov.start 'rails' + # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause From 81d52d262a0b5e9f8e7bd2dcf90e9b2b788c0217 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 2 Dec 2015 15:06:58 -0800 Subject: [PATCH 13/33] Successfully created spec for update method --- app/controllers/movies_controller.rb | 6 ++++-- spec/controllers/movies_controller_spec.rb | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 03aae0eb1d..f6c7b1a15e 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -19,7 +19,7 @@ def create if @movie.save redirect_to movie_path(@movie) else - render "new" + render :new end end @@ -44,7 +44,9 @@ def update if @movie.save redirect_to movie_path(params[:id]) else - redirect_to edit_movie_path(params[:id]) + @title = "Edit a movie" + @action = :update + render :edit end end diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index 918c83c2eb..df649b5a26 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -33,8 +33,8 @@ describe "GET 'edit'" do it "renders new view" do - get :new - expect(subject). to render_template :new + get :edit, id: movie.id + expect(subject). to render_template :edit end end @@ -63,6 +63,7 @@ it "renders new template on error" do post :create, bad_params expect(subject).to render_template :new + end end @@ -79,8 +80,8 @@ end let(:bad_params) do - { - movie: {} + {id: movie.id, + movie: {title: ""} } end @@ -90,9 +91,9 @@ expect(subject).to redirect_to movie_path(movie.id) end - it "renders new template on error" do - post :create, bad_params - expect(subject).to render_template :new + it "renders edit template on error" do + post :update, bad_params + expect(subject).to render_template :edit end end From 4643c2dc19e72f5ba6ed6e343189cea205c96a49 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 2 Dec 2015 15:36:24 -0800 Subject: [PATCH 14/33] Working method for upvote --- app/controllers/movies_controller.rb | 2 ++ app/views/shared/_moviedetail.html.erb | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index f6c7b1a15e..3d00ada411 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -16,6 +16,7 @@ def new def create @title = "Add a movie" @movie = Movie.new(movie_params[:movie]) + @movie.update(:ranking => 0) if @movie.save redirect_to movie_path(@movie) else @@ -38,6 +39,7 @@ def edit ## use attributes, save it to a local variable (its a hash) # then use .save boolean to test against def update + @value = params[:ranking] id = params[:id] @movie = Movie.find(id) @movie.attributes = movie_params[:movie] diff --git a/app/views/shared/_moviedetail.html.erb b/app/views/shared/_moviedetail.html.erb index cdd863de89..11e24199db 100644 --- a/app/views/shared/_moviedetail.html.erb +++ b/app/views/shared/_moviedetail.html.erb @@ -9,7 +9,6 @@
<%= f.label :description %> <%= f.text_area :description %> - <%= f.hidden_field :ranking, value: 0 %>
<%= f.submit "Save" %> <% end %> From c404605e7c803d7ff7b1a5fbc5bbf691379f78d7 Mon Sep 17 00:00:00 2001 From: Sarah Date: Wed, 2 Dec 2015 15:50:19 -0800 Subject: [PATCH 15/33] Created test for testing incrementation and redirect of upvote method --- spec/controllers/movies_controller_spec.rb | 70 +++++++++++----------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index df649b5a26..43cc0584ca 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -7,12 +7,29 @@ movie: { title: "Something", director: "Uncle Bob", - ranking: 0, + ranking: 3, description: "description" } } end + let(:update_params) do + { id: movie.id, + movie: { + title: "Something", + director: "Uncle Joe", + ranking: 0, + description: "new description" + } + } + end + + let(:bad_params) do + {id: movie.id, + movie: {title: ""} + } + end + let(:movie) do Movie.create(create_params[:movie]) end @@ -32,6 +49,7 @@ end describe "GET 'edit'" do + it "renders new view" do get :edit, id: movie.id expect(subject). to render_template :edit @@ -48,12 +66,6 @@ describe "POST 'create'" do - let(:bad_params) do - { - movie: {} - } - end - it "redirects to show page" do post :create, create_params new_movie = Movie.last @@ -63,30 +75,12 @@ it "renders new template on error" do post :create, bad_params expect(subject).to render_template :new - end end describe "PATCH 'update'" do - let(:update_params) do - { id: movie.id, - movie: { - title: "Something", - director: "Uncle Joe", - ranking: 0, - description: "new description" - } - } - end - - let(:bad_params) do - {id: movie.id, - movie: {title: ""} - } - end it "redirects to show page" do - patch :update, update_params expect(subject).to redirect_to movie_path(movie.id) end @@ -99,20 +93,24 @@ end describe "DELETE 'destroy'" do - let(:update_params) do - { id: movie.id, - movie: { - title: "Something", - director: "Uncle Joe", - ranking: 0, - description: "new description" - } - } - end - it "redirects to index page" do delete :destroy, update_params expect(subject).to redirect_to movies_path end end + + + describe "POST ''#upvote_movie'" do + + before :each do + request.env["HTTP_REFERER"] = "from_where_I_was" + end + + it "increments :votes" do + patch :upvote, id: movie.id + movie.reload + expect(movie.ranking).to eq 4 + expect(subject).to redirect_to "from_where_I_was" + end + end end From 0a29eb8d48ef331645280d5e6a8a26c96d0ddfd4 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 3 Dec 2015 12:10:19 -0800 Subject: [PATCH 16/33] Added additional bootstrap styling --- app/assets/images/owl.jpeg | Bin 0 -> 8145 bytes app/assets/images/owl.jpg | Bin 0 -> 13218 bytes app/assets/images/owl_final.jpg | Bin 0 -> 13218 bytes app/assets/stylesheets/application.scss | 12 +++++++++ app/controllers/movies_controller.rb | 3 ++- app/views/layouts/application.html.erb | 8 ++++++ app/views/movies/home.html.erb | 27 +++++++++++++++++---- spec/controllers/movies_controller_spec.rb | 6 ++--- 8 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 app/assets/images/owl.jpeg create mode 100644 app/assets/images/owl.jpg create mode 100644 app/assets/images/owl_final.jpg diff --git a/app/assets/images/owl.jpeg b/app/assets/images/owl.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..c1d6ac18d2b131ff637880d3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CBT;fs@?6RTx z?$wWb_XLFS=1BJqGydR___0oVKf?J=Trw5f5ev+241T0vhX zPSZX*y8z)BHXQ<*the81CZwVHIlAVpGQZaTK9{>tCvshYeLBcy-G69vtZ-GvN0$sP z<1v)AmN~Jy%qP36Ra)1oY-8{jf+o~5IS{qIHQPX;#ift577bX$aCpx$2%!jy$pOhFwz) zY;ixNus}ynuW}H-&yTx{fdoO4(-t?UdWLdZr+l<}H4GjRXsG^g{HfHmv5eqK84c@= zPJ=k)CpRoNqhKdv@3n5t$^@&FpU&q)J}!D>@v?=$|8f_&C08inPLVFCTmQ#xx0$RA z@->~M<<;gt6(#K5fuPJ@Amyxk3zRxv)fy;29R8CdS}$q0cyR||-kRxVGZ5ADR`rc1 zjg;r(C1#d*G74Ka?;2AKlXp|4#|%V|2b kPYu(#kt>)?_yZ72Zd60(Zx(VaxwH=g>HKGV?Pl)(0CKfQQ2+n{ literal 0 HcmV?d00001 diff --git a/app/assets/images/owl.jpg b/app/assets/images/owl.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b3ded309503e7f923da57cb00fa145fbf656ae56 GIT binary patch literal 13218 zcmbVy2UrtJ_xD0*f`TX=1q4I{DJn&31O-H;OD_>26zNR@gyafR1OWj-MF9Z;ktQAK zy(mSxbP}o*NvHu5@-5!`dhh)|@AI|Ev%9}NbLPxBXJ*cs-3|FWc?LLnTU}EfprD`t zZh=35jHRvAym14jtFNQ3c~=dr007z#*6!}klzaf-;_B_Guc69kVrs@mI|@(&oB#vB z1u$6Kc)6?S>fQywa>RRd{dd_J20%#wFd+8d>;KLDKkgW8;a)ZXKtTu6-E6&VTtJKf z0BUC&cTaBspqT^d*L=O*K}>rF#4Mhmf*_VW!uEgSn@9M;pV;IV&prJcAkUGmj5ZF| zwjf4=_|k)a(Cz<$|I`8G0Oe@FUE!XNHhf3E(Dih)b99FPs`&Htf2jTk=l>46IQxJ$ z|0+D-`M8&p!5#1_d}O6WrW%MZftbg^=hk2HA-BCA8644n$?~s4q}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R+vzabUC16e0W$Ojvqq0Gd4dzW|J{wv7M) literal 0 HcmV?d00001 diff --git a/app/assets/images/owl_final.jpg b/app/assets/images/owl_final.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b3ded309503e7f923da57cb00fa145fbf656ae56 GIT binary patch literal 13218 zcmbVy2UrtJ_xD0*f`TX=1q4I{DJn&31O-H;OD_>26zNR@gyafR1OWj-MF9Z;ktQAK zy(mSxbP}o*NvHu5@-5!`dhh)|@AI|Ev%9}NbLPxBXJ*cs-3|FWc?LLnTU}EfprD`t zZh=35jHRvAym14jtFNQ3c~=dr007z#*6!}klzaf-;_B_Guc69kVrs@mI|@(&oB#vB z1u$6Kc)6?S>fQywa>RRd{dd_J20%#wFd+8d>;KLDKkgW8;a)ZXKtTu6-E6&VTtJKf z0BUC&cTaBspqT^d*L=O*K}>rF#4Mhmf*_VW!uEgSn@9M;pV;IV&prJcAkUGmj5ZF| zwjf4=_|k)a(Cz<$|I`8G0Oe@FUE!XNHhf3E(Dih)b99FPs`&Htf2jTk=l>46IQxJ$ z|0+D-`M8&p!5#1_d}O6WrW%MZftbg^=hk2HA-BCA8644n$?~s4q}Hq|M!1_b(kFORmn^M}2|zQZd54e%T1hge-YG+ym$7QClh*Z_j&w zwWTt%b5z&-iy!Ik{A(_Px>3FN^wB@k4U|vy&Dv8<1H_;lstvfS;gR1!OwD0yee=k- z;viNAj3}%DIN%060M9mnD?kGH0DV9MPzA5b#wh2I+J{zFebz#jMkYWk-f55NcP`A82VK=nD7kMQp{d_kTtN1NUl9H`CTR=WLN z56by%F{rcKKRp0=fgbpebz=YYQ#-PT<97|;5LKnc!0~n@p!0w7FZCSt67>*x9;Kf6 zyFK+d^#u4E1ysNhaQ>x{3#gUjuaWTj%_sIR8yZ1QZ@?NnV?aJPP}l!x`mYhSbA8VB zcg>L};9=T3+Cb2yzp0WVl53Jfl4+9fC0G8{$KMkFPbt60{+GQ+v?FVeM&UpG{nOWQz?o5%k(*I~@g^fL<9Wurzq$Ar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VX zn$X>5Ti&Lc`1TaWzDvsI5NJ$l(50@il8$_I;N@x2j@fx5C00FOIbGm~W&1Ov95|nR zTT>YD*f19sp`cqn zxFxEj+Gbc;`Z)w1p|jOy3neXFS*`S~Uo|=yR~V+OObFH)I#l?v zbGbx|CJG3}wLg35$U4cAg1OFX0Mkd_!N299C71{1mZ-a#_!%)59c)U@;;c*#=y43t z;9ai5Rq**>LVXi4wPTPg&;dp4@h+Q_<^{<>jYcNw4%QiOntTy{O)yiqeXO@rZR+xN zys=e^{nA^yPkVueudtKp(8y5F5YnYz~ek z)b8MEt7jZ+tw>YcZlf|gAr)6P^Wtk7pi$+V_(@m$#>NLVQnkJLDi6Fo2Lbo77jC7Zt>ktzGsSO7in z;0b-_Ru9IH^oZ-o_4M&Z@b76u=XU+bP?dZ0m5Ym7aSU$)p}`H-O+ zA)Y2Pdbyj!NARRdV|oNJ<02T*c)&*knCM~l)BYB?c zl%{Q`u6+~vFm?@a7tKtMAn{%x10ETN9EZ0EtIee4Y(naSd!6Ed_nJ=gF!QomU}72< ztfk|naIM-QD?VRXcAC_fN{_(KFzuagCK^Jw=Au);z#03tzL|-{ ZFR+vzabUC16e0W$Ojvqq0Gd4dzW|J{wv7M) literal 0 HcmV?d00001 diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 924e34c1ca..073663686f 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -14,3 +14,15 @@ */ @import "bootstrap-sprockets"; @import "bootstrap"; + + .page-header { + background: url("owl_final.jpg"); + background-repeat: no-repeat; + padding-bottom: 9px; + margin: 40px 0 20px; + border-bottom: 1px solid #eee; + } + + .page-header h1 { + margin-left: 150px; + } diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 3d00ada411..8e40416ed8 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,7 +1,8 @@ class MoviesController < ApplicationController def home - # some kind of code that only shows top 10 of each category by ranking + @movies = Movie.all + # make it so only top 10 show up end def index diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 93467c6d4c..91d938a7b1 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -8,6 +8,14 @@
+
+ +
<%= yield %>
diff --git a/app/views/movies/home.html.erb b/app/views/movies/home.html.erb index 8f48545f4c..a453aa0261 100644 --- a/app/views/movies/home.html.erb +++ b/app/views/movies/home.html.erb @@ -1,5 +1,22 @@ -

MediaRanker

-

This page will show the top 10 of each category

- -<%= link_to "View More Movies", movies_path %> -<%= link_to "View More Books", books_path %> +
+
+
+

Top Movies

+ <% @movies.each do |movie| %> +

<%= link_to movie.title, movie_path(movie.id) %> + Ranked: <%= movie.ranking %> +

+ <% end %> + <%= link_to "View More Movies", movies_path %> +
+
+

Top Books +

Book Loop

+
+
+

Top Albums

+

Album Loop

+
+
+
+ diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index 43cc0584ca..d67ec3c256 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -44,7 +44,7 @@ describe "GET 'new'" do it "renders new view" do get :new - expect(subject). to render_template :new + expect(subject).to render_template :new end end @@ -52,7 +52,7 @@ it "renders new view" do get :edit, id: movie.id - expect(subject). to render_template :edit + expect(subject).to render_template :edit end end @@ -112,5 +112,5 @@ expect(movie.ranking).to eq 4 expect(subject).to redirect_to "from_where_I_was" end - end + end end From 31616e037b674c53215eb8d851d312e98734e6a2 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 3 Dec 2015 12:22:02 -0800 Subject: [PATCH 17/33] Added errors message when title not included --- app/views/shared/_moviedetail.html.erb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/views/shared/_moviedetail.html.erb b/app/views/shared/_moviedetail.html.erb index 11e24199db..a0c3021dcd 100644 --- a/app/views/shared/_moviedetail.html.erb +++ b/app/views/shared/_moviedetail.html.erb @@ -1,4 +1,9 @@

<%= @title %>

+ + <% @movie.errors.each do |column, message| %> +
  • <%=column.capitalize %> <%= message %>
  • + <% end %> + <%= form_for @movie, url: {action: @action} do |f| %> <%= f.label :title %> <%= f.text_field :title %> From ec1656a5bc31d7301b330886d13634efe339f4a3 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 3 Dec 2015 14:44:12 -0800 Subject: [PATCH 18/33] Added new medium controller spec --- app/controllers/movies_controller.rb | 6 +++--- app/models/album.rb | 3 +++ app/views/shared/_full_list.html.erb | 1 + spec/models/album_spec.rb | 1 + spec/models/book_spec.rb | 7 +------ spec/models/movie_spec.rb | 9 +-------- spec/rails_helper.rb | 4 ++++ spec/spec_helper.rb | 8 +++++++- spec/support/medium_controller_spec.rb | 7 +++++++ spec/support/medium_spec.rb | 12 ++++++++++++ 10 files changed, 40 insertions(+), 18 deletions(-) create mode 100644 app/views/shared/_full_list.html.erb create mode 100644 spec/support/medium_controller_spec.rb create mode 100644 spec/support/medium_spec.rb diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 8e40416ed8..1ba9fb28e4 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -60,10 +60,10 @@ def destroy def upvote id = params[:id] - @movie = Movie.find(id) - r = @movie.ranking + movie = Movie.find(id) + r = movie.ranking r += 1 - @movie.update(ranking: r) + movie.update(ranking: r) redirect_to :back end diff --git a/app/models/album.rb b/app/models/album.rb index 46fa309e4e..cf4e23b9c3 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -1,2 +1,5 @@ class Album < ActiveRecord::Base + + validates :title, presence: true + end diff --git a/app/views/shared/_full_list.html.erb b/app/views/shared/_full_list.html.erb new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/app/views/shared/_full_list.html.erb @@ -0,0 +1 @@ + diff --git a/spec/models/album_spec.rb b/spec/models/album_spec.rb index 8dd0ed93e6..df364d0def 100644 --- a/spec/models/album_spec.rb +++ b/spec/models/album_spec.rb @@ -1,5 +1,6 @@ require 'rails_helper' RSpec.describe Album, type: :model do + it_behaves_like "a medium" end diff --git a/spec/models/book_spec.rb b/spec/models/book_spec.rb index ba9dcc1ce0..c51e7859d3 100644 --- a/spec/models/book_spec.rb +++ b/spec/models/book_spec.rb @@ -1,11 +1,6 @@ require 'rails_helper' RSpec.describe Book, type: :model do - - describe ".validates" do - it "must have a title" do - expect(Book.new(title: nil)).to_not be_valid - end - end + it_behaves_like "a medium" end diff --git a/spec/models/movie_spec.rb b/spec/models/movie_spec.rb index 962a916b5f..848984679f 100644 --- a/spec/models/movie_spec.rb +++ b/spec/models/movie_spec.rb @@ -1,13 +1,6 @@ require 'rails_helper' RSpec.describe Movie, type: :model do - -describe ".validates" do - it "must have a title" do - expect(Movie.new(title: nil)).to_not be_valid - end -end - - + it_behaves_like "a medium" end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 6f1ab14638..bd796327fd 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -5,6 +5,10 @@ abort("The Rails environment is running in production mode!") if Rails.env.production? require 'spec_helper' require 'rspec/rails' + +SimpleCov.start do + add_filter "support/" +end # Add additional requires below this line. Rails is not loaded until this point! # Requires supporting ruby files with custom matchers and macros, etc, in diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c1697e0176..dd9e12df55 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,9 @@ require 'simplecov' -SimpleCov.start 'rails' +require 'rails_helper' + +SimpleCov.start do + add_filter 'spec/' +end # This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. @@ -20,6 +24,8 @@ # # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| + config.include Rails.application.routes.url_helpers + Dir["./spec/support/**/*.rb"].sort.each { |f| require f} # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest # assertions if you prefer. diff --git a/spec/support/medium_controller_spec.rb b/spec/support/medium_controller_spec.rb new file mode 100644 index 0000000000..bfb0181705 --- /dev/null +++ b/spec/support/medium_controller_spec.rb @@ -0,0 +1,7 @@ +RSpec.shared_examples "a medium" do + + + + + +end diff --git a/spec/support/medium_spec.rb b/spec/support/medium_spec.rb new file mode 100644 index 0000000000..4f2f3edb11 --- /dev/null +++ b/spec/support/medium_spec.rb @@ -0,0 +1,12 @@ +RSpec.shared_examples "a medium" do + + describe "model validations" do + it "requires a title" do + medium = described_class.new + + expect(medium).to be_invalid + expect(medium.errors.keys).to include :title + end + end + +end From 3bd514b73be86da781f2cc8df173c85810ba39ca Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 3 Dec 2015 15:24:47 -0800 Subject: [PATCH 19/33] Added album views and controller methods --- app/controllers/albums_controller.rb | 50 ++++++++++++++++++++++ app/views/albums/edit.html.erb | 1 + app/views/albums/index.html.erb | 9 ++++ app/views/albums/new.html.erb | 1 + app/views/albums/show.html.erb | 11 +++++ app/views/shared/_albumdetail.html.erb | 17 ++++++++ app/views/shared/_full_list.html.erb | 1 - spec/controllers/books_controller_spec.rb | 49 +++++++++++++++++---- spec/controllers/movies_controller_spec.rb | 15 +------ spec/support/medium_controller_spec.rb | 13 +++++- spec/support/medium_spec.rb | 2 + 11 files changed, 145 insertions(+), 24 deletions(-) create mode 100644 app/views/albums/edit.html.erb create mode 100644 app/views/albums/index.html.erb create mode 100644 app/views/albums/new.html.erb create mode 100644 app/views/albums/show.html.erb create mode 100644 app/views/shared/_albumdetail.html.erb delete mode 100644 app/views/shared/_full_list.html.erb diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 2f800bd33f..186389276b 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -1,2 +1,52 @@ class AlbumsController < ApplicationController + + def index + @albums = Album.all + end + + def new + @title = "Add an Album" + @action = :create + @album = Album.new + end + + def create + @album = Album.new(album_params) + if @album.save + redirect_to album_path(@album) + else + render "new" + end + end + + def show + id = params[:id] + @album = Album.find(id) + end + + def edit + @title = "Edit an Album" + id = params[:id] + @album = Album.find(id) + @action = :update + end + + def update + id = params[:id] + @album = Album.find(id) + @album.update(album_params[:album]) + redirect_to album_path(params[:id]) + end + + def destroy + Album.destroy(params[:id]) + redirect_to albums_path + end + + private + + def album_params + params.permit(album:[:author, :title, :ranking, :description]) + end + end diff --git a/app/views/albums/edit.html.erb b/app/views/albums/edit.html.erb new file mode 100644 index 0000000000..6590ec6709 --- /dev/null +++ b/app/views/albums/edit.html.erb @@ -0,0 +1 @@ +<%= render 'shared/moviedetail' %> diff --git a/app/views/albums/index.html.erb b/app/views/albums/index.html.erb new file mode 100644 index 0000000000..fb4e43a1b4 --- /dev/null +++ b/app/views/albums/index.html.erb @@ -0,0 +1,9 @@ +

    View all albums

    + +
      +<% @albums.each do |album| %> +
    • <%= link_to album.title, album_path(album.id) %>
    • +<% end %> +
    + +<%= link_to "View all media", root_url %> <%= link_to "Add an album", new_album_path %> diff --git a/app/views/albums/new.html.erb b/app/views/albums/new.html.erb new file mode 100644 index 0000000000..98e6d61ee7 --- /dev/null +++ b/app/views/albums/new.html.erb @@ -0,0 +1 @@ +<%= render 'shared/albumdetail' %> diff --git a/app/views/albums/show.html.erb b/app/views/albums/show.html.erb new file mode 100644 index 0000000000..b12b12ee00 --- /dev/null +++ b/app/views/albums/show.html.erb @@ -0,0 +1,11 @@ +<%= @album.title %> +
    +<%= @album.artist %> +
    +<%= @album.description %> +
    +Ranking: +<% end %> +
    +<%= link_to "Edit", edit_album_path %> +<%= link_to "Delete", album_path, method: :delete %> diff --git a/app/views/shared/_albumdetail.html.erb b/app/views/shared/_albumdetail.html.erb new file mode 100644 index 0000000000..6de0b185b6 --- /dev/null +++ b/app/views/shared/_albumdetail.html.erb @@ -0,0 +1,17 @@ +

    <%= @title %>

    + <%= form_for @album, url: {action: @action} do |f| %> + <%= f.label :title %> + <%= f.text_field :title %> +
    + <%= f.label :artist %> + <%= f.text_field :artist %> +
    +
    + <%= f.label :description %> + <%= f.text_area :description %> +
    + <%= f.hidden_field :ranking, value: 0 %> +
    +
    + <%= f.submit "Save" %> + <% end %> diff --git a/app/views/shared/_full_list.html.erb b/app/views/shared/_full_list.html.erb deleted file mode 100644 index 8b13789179..0000000000 --- a/app/views/shared/_full_list.html.erb +++ /dev/null @@ -1 +0,0 @@ - diff --git a/spec/controllers/books_controller_spec.rb b/spec/controllers/books_controller_spec.rb index fd4a1d7b08..67d1047d39 100644 --- a/spec/controllers/books_controller_spec.rb +++ b/spec/controllers/books_controller_spec.rb @@ -1,16 +1,49 @@ require 'rails_helper' RSpec.describe BooksController, type: :controller do + it_behaves_like "a medium" #write the spec to correspond to verb you hope to get and action associated w/ it # this simply checks for success, not whether or not content is correct - describe "GET 'index'" do - it "is successful" do - # you can simply use verb and action - get :index - #this invokes a request and the result of the request is a response - expect(response.status).to eq 200 - # other things can come in response besides status but that is the 1st + # describe "GET 'index'" do + # it "is successful" do + # # you can simply use verb and action + # get :index + # #this invokes a request and the result of the request is a response + # expect(response.status).to eq 200 + # # other things can come in response besides status but that is the 1st # thing we'll check for. - end + # end + # end + + let(:create_params) do + { + book: { + title: "Something", + author: "Uncle Bob", + ranking: 3, + description: "description" + } + } + end + + let(:update_params) do + { id: book.id, + book: { + title: "Something", + author: "Uncle Joe", + ranking: 0, + description: "new description" + } + } + end + + let(:bad_params) do + {id: book.id, + movie: {title: ""} + } + end + + let(:book) do + Book.create(create_params[:book]) end end diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index d67ec3c256..fbb55a1b96 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -1,6 +1,7 @@ require 'rails_helper' RSpec.describe MoviesController, type: :controller do + it_behaves_like "a medium" let(:create_params) do { @@ -34,20 +35,6 @@ Movie.create(create_params[:movie]) end - describe "GET 'index'" do - it "is successful" do - get :index - expect(response.status).to eq 200 - end - end - - describe "GET 'new'" do - it "renders new view" do - get :new - expect(subject).to render_template :new - end - end - describe "GET 'edit'" do it "renders new view" do diff --git a/spec/support/medium_controller_spec.rb b/spec/support/medium_controller_spec.rb index bfb0181705..fb338dfea3 100644 --- a/spec/support/medium_controller_spec.rb +++ b/spec/support/medium_controller_spec.rb @@ -1,7 +1,18 @@ RSpec.shared_examples "a medium" do + describe "GET 'index'" do + it "is successful" do + get :index + expect(response.status).to eq 200 + end + end - + describe "GET 'new'" do + it "renders new view" do + get :new + expect(subject).to render_template :new + end + end end diff --git a/spec/support/medium_spec.rb b/spec/support/medium_spec.rb index 4f2f3edb11..191dbf4581 100644 --- a/spec/support/medium_spec.rb +++ b/spec/support/medium_spec.rb @@ -9,4 +9,6 @@ end end + + end From 9ea93dea17e8e1674fe4416b59a5a388b07083f1 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 3 Dec 2015 15:35:02 -0800 Subject: [PATCH 20/33] Updated home view --- app/controllers/albums_controller.rb | 9 +++++++++ app/controllers/books_controller.rb | 9 +++++++++ app/controllers/movies_controller.rb | 2 ++ app/views/movies/home.html.erb | 15 ++++++++++++--- config/routes.rb | 2 ++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 186389276b..3d4a0bbdcd 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -43,6 +43,15 @@ def destroy redirect_to albums_path end + def upvote + id = params[:id] + album = Album.find(id) + r = album.ranking + r += 1 + album.update(ranking: r) + redirect_to :back + end + private def album_params diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index e09b3d1006..b7636eeb5a 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -42,6 +42,15 @@ def destroy redirect_to books_path end + def upvote + id = params[:id] + book = Book.find(id) + r = book.ranking + r += 1 + book.update(ranking: r) + redirect_to :back + end + private def book_params diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 1ba9fb28e4..ce2887ba72 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -2,6 +2,8 @@ class MoviesController < ApplicationController def home @movies = Movie.all + @books = Book.all + @albums = Album.all # make it so only top 10 show up end diff --git a/app/views/movies/home.html.erb b/app/views/movies/home.html.erb index a453aa0261..cd8473fcdc 100644 --- a/app/views/movies/home.html.erb +++ b/app/views/movies/home.html.erb @@ -11,12 +11,21 @@

    Top Books -

    Book Loop

    + <% @books.each do |book| %> +

    <%= link_to book.title, book_path(book.id) %> + Ranked: <%= book.ranking %> +

    + <% end %> + <%= link_to "View More Books", books_path %>

    Top Albums

    -

    Album Loop

    -
    + <% @albums.each do |album| %> +

    <%= link_to album.title, album_path(album.id) %> + Ranked: <%= album.ranking %> +

    + <% end %> + <%= link_to "View More Albums", albums_path %> diff --git a/config/routes.rb b/config/routes.rb index da1a77e644..c16c2c9c8d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,8 @@ root 'movies#home' post '/movies/:id/upvote' => 'movies#upvote', as: :upvote_movie +post '/albums/:id/upvote' => 'albums#upvote', as: :upvote_album +post '/books/:id/upvote' => 'books#upvote', as: :upvote_book resources :movies, :books, :albums # The priority is based upon order of creation: first created -> highest priority. From 4c948e3d7ba33cf25694916179f35c71764f49e7 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 3 Dec 2015 15:42:36 -0800 Subject: [PATCH 21/33] Updated show view for books --- app/controllers/books_controller.rb | 5 ++++- app/views/books/show.html.erb | 3 +-- app/views/movies/home.html.erb | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index b7636eeb5a..54b460350e 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -9,8 +9,11 @@ def new @book = Book.new end + def create - @book = Book.new(book_params) + @title = "Add a book" + @book = Book.new(book_params[:book]) + @book.update(:ranking => 0) if @book.save redirect_to book_path(@book) else diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index 7901ca672f..100a8249e1 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -4,8 +4,7 @@
    <%= @book.description %>
    -Ranking: -<% end %> +Ranking: <%= @book.ranking %>
    <%= link_to "Edit", edit_book_path %> <%= link_to "Delete", book_path, method: :delete %> diff --git a/app/views/movies/home.html.erb b/app/views/movies/home.html.erb index cd8473fcdc..9d884c4174 100644 --- a/app/views/movies/home.html.erb +++ b/app/views/movies/home.html.erb @@ -10,7 +10,7 @@ <%= link_to "View More Movies", movies_path %>
    -

    Top Books +

    Top Books

    <% @books.each do |book| %>

    <%= link_to book.title, book_path(book.id) %> Ranked: <%= book.ranking %> From 8aeb30065179634eb85c69d1db78faaface3a003 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 3 Dec 2015 16:27:24 -0800 Subject: [PATCH 22/33] Added method to show top 10 ranked items on home page --- app/controllers/albums_controller.rb | 2 +- app/controllers/movies_controller.rb | 7 +++---- app/views/albums/show.html.erb | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index 3d4a0bbdcd..d321b9efde 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -11,7 +11,7 @@ def new end def create - @album = Album.new(album_params) + @album = Album.new(album_params[:album]) if @album.save redirect_to album_path(@album) else diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index ce2887ba72..9cc3b6e84a 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,10 +1,9 @@ class MoviesController < ApplicationController def home - @movies = Movie.all - @books = Book.all - @albums = Album.all - # make it so only top 10 show up + @movies = Movie.all.order(:ranking).reverse.take(10) + @books = Book.all.order(:ranking).reverse.take(10) + @albums = Album.all.order(:ranking).reverse.take(10) end def index diff --git a/app/views/albums/show.html.erb b/app/views/albums/show.html.erb index b12b12ee00..1e0ea08cbd 100644 --- a/app/views/albums/show.html.erb +++ b/app/views/albums/show.html.erb @@ -4,8 +4,7 @@
    <%= @album.description %>
    -Ranking: -<% end %> +Ranking: <%= @album.ranking %>
    <%= link_to "Edit", edit_album_path %> <%= link_to "Delete", album_path, method: :delete %> From 92e71146cf810d66de2360f6e8927b15393dc26c Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 3 Dec 2015 16:32:58 -0800 Subject: [PATCH 23/33] Added method for upvoting on show page of albums --- app/views/albums/index.html.erb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/app/views/albums/index.html.erb b/app/views/albums/index.html.erb index fb4e43a1b4..e80496fb1b 100644 --- a/app/views/albums/index.html.erb +++ b/app/views/albums/index.html.erb @@ -1,9 +1,14 @@ -

    View all albums

    - -
      -<% @albums.each do |album| %> -
    • <%= link_to album.title, album_path(album.id) %>
    • -<% end %> -
    +
    + + + + + + + + <% @albums.each do |album| %> + <% @albums.each do |album| %> - + + + <% end %> + + +
    Ranking Name Upvote
    <%= album.ranking %><%= link_to album.title, album_path(album.id) %><%= button_for upvote_album_path %> + <% end %> + <%= link_to "View all media", root_url %> <%= link_to "Add an album", new_album_path %> From bc45bef7d734113531d59669cf6e060003c7a06e Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 3 Dec 2015 17:04:00 -0800 Subject: [PATCH 24/33] Added additional bootstrap styling to show view --- app/views/albums/index.html.erb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/albums/index.html.erb b/app/views/albums/index.html.erb index e80496fb1b..8bcc6630ea 100644 --- a/app/views/albums/index.html.erb +++ b/app/views/albums/index.html.erb @@ -7,8 +7,13 @@ Upvote
    <%= album.ranking %><%= link_to album.title, album_path(album.id) %><%= button_for upvote_album_path %> +
    <%= album.ranking %><%= link_to album.title, album_path(album.id) %><%= button_to "Upvote", upvote_album_path(album.id) %>
    +<%= link_to "View all media", root_url, class: "btn btn-default" %> <%= link_to "Add an album", new_album_path, class: "btn btn-default" %>
    - -<%= link_to "View all media", root_url %> <%= link_to "Add an album", new_album_path %> From 233d91b1fac368e5de615bc421bfa7ea31c2edc9 Mon Sep 17 00:00:00 2001 From: Sarah Date: Thu, 3 Dec 2015 17:07:45 -0800 Subject: [PATCH 25/33] Added additional bootstrap styling --- app/views/books/index.html.erb | 28 +++++++++++++++++++--------- app/views/movies/index.html.erb | 28 +++++++++++++++++++--------- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/app/views/books/index.html.erb b/app/views/books/index.html.erb index ae084b8756..1767a13b9d 100644 --- a/app/views/books/index.html.erb +++ b/app/views/books/index.html.erb @@ -1,9 +1,19 @@ -

    View all books

    - -
      -<% @books.each do |book| %> -
    • <%= link_to book.title, book_path(book.id) %>
    • -<% end %> -
    - -<%= link_to "View all media", root_url %> <%= link_to "Add a book", new_book_path %> +
    + + + + + + + + <% @books.each do |book| %> + + + + + <% end %> + + +
    Ranking Name Upvote
    <%= book.ranking %><%= link_to book.title, book_path(book.id) %><%= button_to "Upvote", upvote_book_path(book.id) %>
    +<%= link_to "View all media", root_url, class: "btn btn-default" %> <%= link_to "Add a book", new_book_path, class: "btn btn-default" %> +
    diff --git a/app/views/movies/index.html.erb b/app/views/movies/index.html.erb index c2346f4be4..3cf45a9774 100644 --- a/app/views/movies/index.html.erb +++ b/app/views/movies/index.html.erb @@ -1,9 +1,19 @@ -

    View all movies

    - -
      -<% @movies.each do |movie| %> -
    • Ranked: <%= movie.ranking %> | <%= link_to movie.title, movie_path(movie.id) %> <%= button_to "Upvote", upvote_movie_path(movie.id) %>
    • -<% end %> -
    - -<%= link_to "View all media", root_url %> <%= link_to "Add a movie", new_movie_path %> +
    + + + + + + + + <% @movies.each do |movie| %> + + + + + <% end %> + + +
    Ranking Name Upvote
    <%= movie.ranking %><%= link_to movie.title, movie_path(movie.id) %><%= button_to "Upvote", upvote_movie_path(movie.id) %>
    +<%= link_to "View all media", root_url, class: "btn btn-default" %> <%= link_to "Add a movie", new_movie_path, class: "btn btn-default" %> +
    From 06eb3ca8b9548c205a50c774e343fa949c951a54 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 4 Dec 2015 09:41:10 -0800 Subject: [PATCH 26/33] Generalized movie rspec tests to make availabel for all controllers --- app/views/movies/home.html.erb | 2 +- spec/controllers/books_controller_spec.rb | 13 +---------- spec/controllers/movies_controller_spec.rb | 25 +++++----------------- spec/support/medium_controller_spec.rb | 13 +++++++++++ 4 files changed, 20 insertions(+), 33 deletions(-) diff --git a/app/views/movies/home.html.erb b/app/views/movies/home.html.erb index 9d884c4174..5c61c76d5b 100644 --- a/app/views/movies/home.html.erb +++ b/app/views/movies/home.html.erb @@ -13,7 +13,7 @@

    Top Books

    <% @books.each do |book| %>

    <%= link_to book.title, book_path(book.id) %> - Ranked: <%= book.ranking %> + Ranked: <%= book.ranking %>

    <% end %> <%= link_to "View More Books", books_path %> diff --git a/spec/controllers/books_controller_spec.rb b/spec/controllers/books_controller_spec.rb index 67d1047d39..dd285c68fd 100644 --- a/spec/controllers/books_controller_spec.rb +++ b/spec/controllers/books_controller_spec.rb @@ -2,18 +2,7 @@ RSpec.describe BooksController, type: :controller do it_behaves_like "a medium" - #write the spec to correspond to verb you hope to get and action associated w/ it - # this simply checks for success, not whether or not content is correct - # describe "GET 'index'" do - # it "is successful" do - # # you can simply use verb and action - # get :index - # #this invokes a request and the result of the request is a response - # expect(response.status).to eq 200 - # # other things can come in response besides status but that is the 1st - # thing we'll check for. - # end - # end + let(:create_params) do { diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index fbb55a1b96..0d90c8563e 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -1,6 +1,11 @@ require 'rails_helper' RSpec.describe MoviesController, type: :controller do + + let(:medium) do + Movie.create(create_params[:movie]) + end + it_behaves_like "a medium" let(:create_params) do @@ -31,25 +36,6 @@ } end - let(:movie) do - Movie.create(create_params[:movie]) - end - - describe "GET 'edit'" do - - it "renders new view" do - get :edit, id: movie.id - expect(subject).to render_template :edit - end - end - - describe "GET 'show'" do - - it "renders the show view" do - get :show, id: movie.id - expect(subject).to render_template :show - end - end describe "POST 'create'" do @@ -86,7 +72,6 @@ end end - describe "POST ''#upvote_movie'" do before :each do diff --git a/spec/support/medium_controller_spec.rb b/spec/support/medium_controller_spec.rb index fb338dfea3..598b1e396a 100644 --- a/spec/support/medium_controller_spec.rb +++ b/spec/support/medium_controller_spec.rb @@ -14,5 +14,18 @@ end end + describe "GET 'edit'" do + it "renders new view" do + get :edit, id: medium.id + expect(subject).to render_template :edit + end + end + + describe "GET 'show'" do + it "renders the show view" do + get :show, id: medium.id + expect(subject).to render_template :show + end + end end From c29c6089b7960d1c1fb999ce36e10a1784116018 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 4 Dec 2015 09:50:38 -0800 Subject: [PATCH 27/33] Refined rspec tests to make them work --- spec/controllers/books_controller_spec.rb | 5 +++++ spec/controllers/movies_controller_spec.rb | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/spec/controllers/books_controller_spec.rb b/spec/controllers/books_controller_spec.rb index dd285c68fd..bb6f30538f 100644 --- a/spec/controllers/books_controller_spec.rb +++ b/spec/controllers/books_controller_spec.rb @@ -1,6 +1,11 @@ require 'rails_helper' RSpec.describe BooksController, type: :controller do + + let(:medium) do + Movie.create(create_params[:book]) + end + it_behaves_like "a medium" diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index 0d90c8563e..fe654c31db 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -20,7 +20,7 @@ end let(:update_params) do - { id: movie.id, + { id: medium.id, movie: { title: "Something", director: "Uncle Joe", @@ -31,7 +31,7 @@ end let(:bad_params) do - {id: movie.id, + {id: medium.id, movie: {title: ""} } end @@ -55,7 +55,7 @@ it "redirects to show page" do patch :update, update_params - expect(subject).to redirect_to movie_path(movie.id) + expect(subject).to redirect_to movie_path(medium.id) end it "renders edit template on error" do @@ -79,9 +79,9 @@ end it "increments :votes" do - patch :upvote, id: movie.id - movie.reload - expect(movie.ranking).to eq 4 + patch :upvote, id: medium.id + medium.reload + expect(medium.ranking).to eq 4 expect(subject).to redirect_to "from_where_I_was" end end From f4c2d6b8cdbe7362f5e742ae320f4e4a0335829d Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 4 Dec 2015 10:38:23 -0800 Subject: [PATCH 28/33] Wrote more tests for album and books controller --- spec/controllers/albums_controller_spec.rb | 47 ++++++++++++++++------ spec/controllers/books_controller_spec.rb | 11 ++--- spec/controllers/movies_controller_spec.rb | 7 ++++ spec/models/movie_spec.rb | 17 ++++++++ spec/support/medium_spec.rb | 2 +- 5 files changed, 64 insertions(+), 20 deletions(-) diff --git a/spec/controllers/albums_controller_spec.rb b/spec/controllers/albums_controller_spec.rb index d665bbdb16..72089bccf2 100644 --- a/spec/controllers/albums_controller_spec.rb +++ b/spec/controllers/albums_controller_spec.rb @@ -1,16 +1,39 @@ require 'rails_helper' RSpec.describe AlbumsController, type: :controller do - #write the spec to correspond to verb you hope to get and action associated w/ it - # this simply checks for success, not whether or not content is correct - # describe "GET 'index'" do - # it "is successful" do - # # you can simply use verb and action - # get :index - # #this invokes a request and the result of the request is a response - # expect(response.status).to eq 200 - # other things can come in response besides status but that is the 1st - # thing we'll check for. - # end - # end + + let(:medium) do + Album.create(create_params[:album]) + end + + it_behaves_like "a medium" + + + let(:create_params) do + { + album: { + title: "Something", + artist: "Uncle Bob", + ranking: 3, + description: "description" + } + } + end + + let(:update_params) do + { id: medium.id, + album: { + title: "Something", + artist: "Uncle Joe", + ranking: 0, + description: "new description" + } + } + end + + let(:bad_params) do + {id: medium.id, + album: {title: ""} + } + end end diff --git a/spec/controllers/books_controller_spec.rb b/spec/controllers/books_controller_spec.rb index bb6f30538f..0bf98740b0 100644 --- a/spec/controllers/books_controller_spec.rb +++ b/spec/controllers/books_controller_spec.rb @@ -3,7 +3,7 @@ RSpec.describe BooksController, type: :controller do let(:medium) do - Movie.create(create_params[:book]) + Book.create(create_params[:book]) end it_behaves_like "a medium" @@ -21,7 +21,7 @@ end let(:update_params) do - { id: book.id, + { id: medium.id, book: { title: "Something", author: "Uncle Joe", @@ -32,12 +32,9 @@ end let(:bad_params) do - {id: book.id, - movie: {title: ""} + {id: medium.id, + book: {title: ""} } end - let(:book) do - Book.create(create_params[:book]) - end end diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index fe654c31db..5086b6e5ff 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -36,6 +36,13 @@ } end + describe "GET 'home'" do + it "renders the home view" do + get :home + expect(subject).to render_template :home + end + end + describe "POST 'create'" do diff --git a/spec/models/movie_spec.rb b/spec/models/movie_spec.rb index 848984679f..d957ff7833 100644 --- a/spec/models/movie_spec.rb +++ b/spec/models/movie_spec.rb @@ -1,6 +1,23 @@ require 'rails_helper' RSpec.describe Movie, type: :model do + + # let(:medium) do + # Movie.create(create_params[:movie]) + # end + it_behaves_like "a medium" + # + # let(:create_params) do + # { + # movie: { + # title: "Something", + # director: "Uncle Bob", + # ranking: 3, + # description: "description" + # } + # } + # end + end diff --git a/spec/support/medium_spec.rb b/spec/support/medium_spec.rb index 191dbf4581..0630144df8 100644 --- a/spec/support/medium_spec.rb +++ b/spec/support/medium_spec.rb @@ -1,5 +1,5 @@ RSpec.shared_examples "a medium" do - + describe "model validations" do it "requires a title" do medium = described_class.new From bee34d9c05e233fda02d3cb5c0c02c91a19823c8 Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 4 Dec 2015 10:58:39 -0800 Subject: [PATCH 29/33] Updated bootstrap on home page --- app/views/movies/home.html.erb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/movies/home.html.erb b/app/views/movies/home.html.erb index 5c61c76d5b..3954194980 100644 --- a/app/views/movies/home.html.erb +++ b/app/views/movies/home.html.erb @@ -1,6 +1,7 @@ -
    -
    -
    +
    +
    +
    +

    Top Movies

    <% @movies.each do |movie| %>

    <%= link_to movie.title, movie_path(movie.id) %> From 0e3d975bd2a7da65257001d163a6bde053d2e1ad Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 4 Dec 2015 13:51:37 -0800 Subject: [PATCH 30/33] Updated specs --- spec/controllers/albums_controller_spec.rb | 2 +- spec/controllers/books_controller_spec.rb | 2 +- spec/controllers/movies_controller_spec.rb | 12 ++++++++++-- spec/support/medium_controller_spec.rb | 16 +++++++++++++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/spec/controllers/albums_controller_spec.rb b/spec/controllers/albums_controller_spec.rb index 72089bccf2..235be4f7db 100644 --- a/spec/controllers/albums_controller_spec.rb +++ b/spec/controllers/albums_controller_spec.rb @@ -6,7 +6,7 @@ Album.create(create_params[:album]) end - it_behaves_like "a medium" + it_behaves_like "a medium controller" let(:create_params) do diff --git a/spec/controllers/books_controller_spec.rb b/spec/controllers/books_controller_spec.rb index 0bf98740b0..aa5ca3b3b8 100644 --- a/spec/controllers/books_controller_spec.rb +++ b/spec/controllers/books_controller_spec.rb @@ -6,7 +6,7 @@ Book.create(create_params[:book]) end - it_behaves_like "a medium" + it_behaves_like "a medium controller" let(:create_params) do diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index 5086b6e5ff..dd7339dfde 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -6,7 +6,13 @@ Movie.create(create_params[:movie]) end - it_behaves_like "a medium" + let(:show_path) do + movie_path(medium.id) + end + + + + it_behaves_like "a medium controller" let(:create_params) do { @@ -62,7 +68,7 @@ it "redirects to show page" do patch :update, update_params - expect(subject).to redirect_to movie_path(medium.id) + expect(subject).to redirect_to show_path end it "renders edit template on error" do @@ -72,6 +78,8 @@ end + + describe "DELETE 'destroy'" do it "redirects to index page" do delete :destroy, update_params diff --git a/spec/support/medium_controller_spec.rb b/spec/support/medium_controller_spec.rb index 598b1e396a..364ba86ab8 100644 --- a/spec/support/medium_controller_spec.rb +++ b/spec/support/medium_controller_spec.rb @@ -1,4 +1,4 @@ -RSpec.shared_examples "a medium" do +RSpec.shared_examples "a medium controller" do describe "GET 'index'" do it "is successful" do @@ -28,4 +28,18 @@ end end + describe "PATCH 'update'" do + + it "redirects to show page" do + patch :update, update_params + expect(subject).to redirect_to show_path + end + + it "renders edit template on error" do + post :update, bad_params + expect(subject).to render_template :edit + end + + end + end From 3885c21a11e042539cc47db2b7d3c6c8f3878fce Mon Sep 17 00:00:00 2001 From: Sarah Date: Fri, 4 Dec 2015 14:54:13 -0800 Subject: [PATCH 31/33] Generalized all tests for each controller --- spec/controllers/albums_controller_spec.rb | 3 +- spec/controllers/books_controller_spec.rb | 3 +- spec/controllers/movies_controller_spec.rb | 63 +++------------------- spec/spec_helper.rb | 3 ++ spec/support/medium_controller_spec.rb | 50 ++++++++++++++++- 5 files changed, 59 insertions(+), 63 deletions(-) diff --git a/spec/controllers/albums_controller_spec.rb b/spec/controllers/albums_controller_spec.rb index 235be4f7db..b3e2a0b8c5 100644 --- a/spec/controllers/albums_controller_spec.rb +++ b/spec/controllers/albums_controller_spec.rb @@ -6,8 +6,7 @@ Album.create(create_params[:album]) end - it_behaves_like "a medium controller" - + it_behaves_like "a medium controller", "album_path", Album, "albums_path" let(:create_params) do { diff --git a/spec/controllers/books_controller_spec.rb b/spec/controllers/books_controller_spec.rb index aa5ca3b3b8..717be3d597 100644 --- a/spec/controllers/books_controller_spec.rb +++ b/spec/controllers/books_controller_spec.rb @@ -6,8 +6,7 @@ Book.create(create_params[:book]) end - it_behaves_like "a medium controller" - + it_behaves_like "a medium controller", "book_path", Book, "books_path" let(:create_params) do { diff --git a/spec/controllers/movies_controller_spec.rb b/spec/controllers/movies_controller_spec.rb index dd7339dfde..5dca3c8b0b 100644 --- a/spec/controllers/movies_controller_spec.rb +++ b/spec/controllers/movies_controller_spec.rb @@ -6,13 +6,11 @@ Movie.create(create_params[:movie]) end - let(:show_path) do - movie_path(medium.id) - end + # let(:medium_class) do + # Movie + # end - - it_behaves_like "a medium controller" let(:create_params) do { @@ -42,62 +40,13 @@ } end + it_behaves_like "a medium controller", "movie_path", Movie, "movies_path" + + describe "GET 'home'" do it "renders the home view" do get :home expect(subject).to render_template :home end end - - - describe "POST 'create'" do - - it "redirects to show page" do - post :create, create_params - new_movie = Movie.last - expect(subject).to redirect_to movie_path(new_movie.id) - end - - it "renders new template on error" do - post :create, bad_params - expect(subject).to render_template :new - end - end - - describe "PATCH 'update'" do - - it "redirects to show page" do - patch :update, update_params - expect(subject).to redirect_to show_path - end - - it "renders edit template on error" do - post :update, bad_params - expect(subject).to render_template :edit - end - - end - - - - describe "DELETE 'destroy'" do - it "redirects to index page" do - delete :destroy, update_params - expect(subject).to redirect_to movies_path - end - end - - describe "POST ''#upvote_movie'" do - - before :each do - request.env["HTTP_REFERER"] = "from_where_I_was" - end - - it "increments :votes" do - patch :upvote, id: medium.id - medium.reload - expect(medium.ranking).to eq 4 - expect(subject).to redirect_to "from_where_I_was" - end - end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index dd9e12df55..447cc36b1e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -26,6 +26,9 @@ RSpec.configure do |config| config.include Rails.application.routes.url_helpers Dir["./spec/support/**/*.rb"].sort.each { |f| require f} + config.filter_run focus: true + config.run_all_when_everything_filtered = true + # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest # assertions if you prefer. diff --git a/spec/support/medium_controller_spec.rb b/spec/support/medium_controller_spec.rb index 364ba86ab8..0828900d21 100644 --- a/spec/support/medium_controller_spec.rb +++ b/spec/support/medium_controller_spec.rb @@ -1,4 +1,4 @@ -RSpec.shared_examples "a medium controller" do +RSpec.shared_examples "a medium controller" do |medium_path, medium_class, medium_index_path| describe "GET 'index'" do it "is successful" do @@ -32,14 +32,60 @@ it "redirects to show page" do patch :update, update_params - expect(subject).to redirect_to show_path + expect(subject).to redirect_to send(medium_path,*medium.id) end it "renders edit template on error" do post :update, bad_params expect(subject).to render_template :edit end + end + + describe "POST 'create'" do + + it "redirects to show page" do + post :create, create_params + new_object = medium_class.last + expect(subject).to redirect_to send(medium_path,*new_object.id) + end + + it "renders new template on error" do + post :create, bad_params + expect(subject).to render_template :new + end + end + + describe "PATCH 'update'" do + + it "redirects to show page" do + patch :update, update_params + expect(subject).to redirect_to send(medium_path,*medium.id) + end + it "renders edit template on error" do + post :update, bad_params + expect(subject).to render_template :edit + end end + describe "DELETE 'destroy'" do + it "redirects to index page" do + delete :destroy, update_params + expect(subject).to redirect_to send(medium_index_path) + end + end + + describe "POST ''#upvote_method'" do + + before :each do + request.env["HTTP_REFERER"] = "from_where_I_was" + end + + it "increments :votes" do + patch :upvote, id: medium.id + medium.reload + expect(medium.ranking).to eq 4 + expect(subject).to redirect_to "from_where_I_was" + end + end end From 38203b4b9836b91798a008f4f3cca242856b808b Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 6 Dec 2015 12:06:26 -0800 Subject: [PATCH 32/33] Added bootstrap styling to 'show' view for all controllers --- app/views/albums/show.html.erb | 23 +++++++++++++---------- app/views/books/show.html.erb | 23 +++++++++++++---------- app/views/movies/show.html.erb | 26 +++++++++++++------------- 3 files changed, 39 insertions(+), 33 deletions(-) diff --git a/app/views/albums/show.html.erb b/app/views/albums/show.html.erb index 1e0ea08cbd..44a374cfd1 100644 --- a/app/views/albums/show.html.erb +++ b/app/views/albums/show.html.erb @@ -1,10 +1,13 @@ -<%= @album.title %> -
    -<%= @album.artist %> -
    -<%= @album.description %> -
    -Ranking: <%= @album.ranking %> -
    -<%= link_to "Edit", edit_album_path %> -<%= link_to "Delete", album_path, method: :delete %> +
    +

    + <%= @album.title %> + <%= @album.artist %> +

    +

    Ranked: <%= @album.ranking %>

    +

    <%= @album.description %>

    + <%= button_to "Upvote", upvote_album_path(@album.id), class: "btn btn-primary" %> +
    +<%= link_to "Edit #{@album.title}", edit_album_path, class: "btn btn-default" %> +<%= link_to "Delete", album_path, method: :delete, data: {confirm: "Are you sure?"}, class: "btn btn-danger" %> +<%= link_to "View All Albums", albums_path, class: "btn btn-default" %> +<%= link_to "View All Media", root_path, class: "btn btn-default" %> diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index 100a8249e1..78135d6d3e 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -1,10 +1,13 @@ -<%= @book.title %> -
    -<%= @book.author %> -
    -<%= @book.description %> -
    -Ranking: <%= @book.ranking %> -
    -<%= link_to "Edit", edit_book_path %> -<%= link_to "Delete", book_path, method: :delete %> +
    +

    + <%= @book.title %> + <%= @book.author %> +

    +

    Ranked: <%= @book.ranking %>

    +

    <%= @book.description %>

    + <%= button_to "Upvote", upvote_book_path(@book.id), class: "btn btn-primary" %> +
    +<%= link_to "Edit #{@book.title}", edit_book_path, class: "btn btn-default" %> +<%= link_to "Delete", book_path, method: :delete, data: {confirm: "Are you sure?"}, class: "btn btn-danger" %> +<%= link_to "View All Books", books_path, class: "btn btn-default" %> +<%= link_to "View All Media", root_path, class: "btn btn-default" %> diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb index cec06cad19..9ee4a28bf8 100644 --- a/app/views/movies/show.html.erb +++ b/app/views/movies/show.html.erb @@ -1,13 +1,13 @@ -<%= @movie.title %> -
    -<%= @movie.director %> -
    -<%= @movie.description %> -
    -Ranked: <%= @movie.ranking %> -
    -
    -<%= button_to "Upvote", upvote_movie_path %> -
    -<%= link_to "Edit", edit_movie_path %> -<%= link_to "Delete", movie_path, method: :delete %> +
    +

    + <%= @movie.title %> + <%= @movie.director %> +

    +

    Ranked: <%= @movie.ranking %>

    +

    <%= @movie.description %>

    + <%= button_to "Upvote", upvote_movie_path(@movie.id), class: "btn btn-primary" %> +
    +<%= link_to "Edit #{@movie.title}", edit_movie_path, class: "btn btn-default" %> +<%= link_to "Delete", movie_path, method: :delete, data: {confirm: "Are you sure?"}, class: "btn btn-danger" %> +<%= link_to "View All Movies", movies_path, class: "btn btn-default" %> +<%= link_to "View All Media", root_path, class: "btn btn-default" %> From 9a2756d7d6458f5167fc16af1600a82ec3e5c43f Mon Sep 17 00:00:00 2001 From: Sarah Date: Sun, 6 Dec 2015 12:37:08 -0800 Subject: [PATCH 33/33] Finalized 'edit' method for books and albums controller --- app/controllers/albums_controller.rb | 11 +++++++++-- app/controllers/books_controller.rb | 12 ++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb index d321b9efde..1d2eaa56c7 100644 --- a/app/controllers/albums_controller.rb +++ b/app/controllers/albums_controller.rb @@ -32,10 +32,17 @@ def edit end def update + @value = params[:ranking] id = params[:id] @album = Album.find(id) - @album.update(album_params[:album]) - redirect_to album_path(params[:id]) + @album.attributes = album_params[:album] + if @album.save + redirect_to album_path(params[:id]) + else + @title = "Edit an album" + @action = :update + render :edit + end end def destroy diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index 54b460350e..44a98df1e9 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -34,12 +34,20 @@ def edit end def update + @value = params[:ranking] id = params[:id] @book = Book.find(id) - @book.update(book_params[:book]) - redirect_to book_path(params[:id]) + @book.attributes = book_params[:book] + if @book.save + redirect_to book_path(params[:id]) + else + @title = "Edit a book" + @action = :update + render :edit + end end + def destroy Book.destroy(params[:id]) redirect_to books_path