Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MediaRanker #43

Open
wants to merge 47 commits into
base: arh/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
df58496
Create movie model and controller
lacuchilla Nov 30, 2015
23bfb5e
Finish movie controller
lacuchilla Nov 30, 2015
4ef8d4f
Make simple view of all movies
lacuchilla Nov 30, 2015
227b4dd
Create seed file for movie model
lacuchilla Nov 30, 2015
884b878
Add upvote button and show page for movies
lacuchilla Dec 1, 2015
e88a3a0
Remove @url from edit method and fixed edit_movie_path in the show page
lacuchilla Dec 1, 2015
e258c32
Fix upvote link so that it redirects properly to the show page for th…
lacuchilla Dec 1, 2015
0ef7ba2
Add rspec to gemfile with some simple tests and fix edit link on show…
lacuchilla Dec 1, 2015
8f7b043
Add link to new movie page and am able to create a new movie
lacuchilla Dec 1, 2015
df96949
Add delete function to movie show page and made movie names on the in…
lacuchilla Dec 1, 2015
6a4c3f9
Add link to go back to the list of all movies from the show page for …
lacuchilla Dec 1, 2015
f38f9d1
Add non working link to an all media page that has yet to be created …
lacuchilla Dec 1, 2015
208dfc3
Made books controller and created methods for all functions in the co…
lacuchilla Dec 1, 2015
bde207a
Add index view for books. Rename upvote methods to book_upvote and mo…
lacuchilla Dec 1, 2015
544a6ed
Made new view page for book and add link to it to show page
lacuchilla Dec 1, 2015
75205a2
add edit view for book
lacuchilla Dec 1, 2015
0a5ee90
Correct column name to artist, create and make methods in albums cont…
lacuchilla Dec 1, 2015
b2145f4
Make routes for albums in routes.rb
lacuchilla Dec 1, 2015
ce3fc96
Seeded album database and made an index view for albums
lacuchilla Dec 2, 2015
253d43d
Add show page for album view
lacuchilla Dec 2, 2015
a706cfb
Add new view for album
lacuchilla Dec 2, 2015
c395b5e
Add edit view for albums
lacuchilla Dec 2, 2015
ed1dde3
Create home page with lists of all three categories books albums and …
lacuchilla Dec 2, 2015
fd88520
Add header with link to root page in the application.html.erb file in…
lacuchilla Dec 2, 2015
3b74f6b
Add links to go back to the main page in the show pages for books, al…
lacuchilla Dec 2, 2015
17412c2
Changed url paths in movie controller from hardcoded to url helper paths
lacuchilla Dec 2, 2015
010f4dd
Install simplecov to project. currently at 48 percent coverage
lacuchilla Dec 2, 2015
55de772
Write controller get specs for movies, books, and albums. 57 percent …
lacuchilla Dec 2, 2015
4d55c60
Add tests for get new actions for books, albums, and movies. 64 perce…
lacuchilla Dec 2, 2015
4418583
Add tests for post create actions in movies and albums contollers. 71…
lacuchilla Dec 2, 2015
df893fa
Add post create tests for book controller. 74 percent code coverage
lacuchilla Dec 2, 2015
37084c1
Add text for home page in movies controller. 78 percent code coverage
lacuchilla Dec 2, 2015
35ae7ad
Added delete destroy test for movie class. 80 percent code coverage.
lacuchilla Dec 3, 2015
2a74db8
Add delete destroy tests for books and albums controller spec files. …
lacuchilla Dec 3, 2015
f4840c2
Add post update tests for movies controller spec. 85 percent code cov…
lacuchilla Dec 3, 2015
748b7d5
Add test for patch update action for movie and book. Changed hard cod…
lacuchilla Dec 3, 2015
7e21c71
Add patch update test to book class for success and error cases. 87 p…
lacuchilla Dec 3, 2015
17095b6
Add correct named routes to post create test in books controller spec…
lacuchilla Dec 3, 2015
357a8c9
Add upvote test to album, book, and movie controller specs. Still wor…
lacuchilla Dec 3, 2015
354a602
Added bootstrap gem and began styling of the home page
lacuchilla Dec 4, 2015
96c3d0d
Add html bootstrap styling to movies index page
lacuchilla Dec 4, 2015
86e8f97
Added html bootstrap styling for edit, show, and new views for movies
lacuchilla Dec 4, 2015
b9e0dda
Styled show pages for books, albums, and movies
lacuchilla Dec 4, 2015
c933b07
Fixed last bit of code missing in rspec test. 100 percent code coverage.
lacuchilla Dec 4, 2015
b8d793d
Add styling to index pages for books, movies and albums
lacuchilla Dec 4, 2015
f75ef3d
Add styling to edit and new pages
lacuchilla Dec 4, 2015
1a6d9b5
Add Factory Girl functionality to Media Ranker Project
lacuchilla Jan 13, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
/db/*.sqlite3-journal

# Ignore all logfiles and tempfiles.
/coverage
/log/*
!/log/.keep
/tmp
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--require spec_helper
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -35,6 +36,9 @@ 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'
gem 'simplecov'
gem 'factory_girl_rails'
end

group :development do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including only the gems you need, awesome! 👍 This is a good habit to have as the more dependencies you include the higher the change that your build will fail when deploying. I used to have the bad habit of copy pasta-ing gems from previous projects and it bit me at least once.

Expand Down
39 changes: 39 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -55,8 +61,15 @@ GEM
execjs
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)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
i18n (0.7.0)
Expand Down Expand Up @@ -112,6 +125,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)
Expand All @@ -123,6 +153,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)
Expand Down Expand Up @@ -152,14 +187,18 @@ PLATFORMS

DEPENDENCIES
better_errors
bootstrap-sass (~> 3.3.6)
byebug
coffee-rails (~> 4.1.0)
factory_girl_rails
jbuilder (~> 2.0)
jquery-rails
rails (= 4.2.5)
rails-erd
rspec-rails
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
simplecov
spring
sqlite3
turbolinks
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/albums.coffee
Original file line number Diff line number Diff line change
@@ -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/
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
//= require jquery_ujs
//= require turbolinks
//= require_tree .
//= require bootstrap-sprockets
3 changes: 3 additions & 0 deletions app/assets/javascripts/books.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/javascripts/movies.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/albums.scss
Original file line number Diff line number Diff line change
@@ -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/
15 changes: 0 additions & 15 deletions app/assets/stylesheets/application.css

This file was deleted.

84 changes: 84 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* 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";

.page-header {
background: url(http://media-ranker.herokuapp.com/assets/owl-5e51d9e0d49c787f2ebd143e32cbf41c.jpg);
background-repeat: no-repeat;
}

.page-header h1 {
margin-left: 150px;
}

a {
color: #428bca;
text-decoration: none;
}

form .btn-primary {
margin-bottom: 10px;
}

.btn-default {
color: #333;
background-color: #fff;
border-color: #ccc;
}

.btn-danger {
color: #fff;
background-color: #d9534f;
border-color: #d43f3a;
}

.row {
margin-right: -15px;
margin-left: -15px;
}

h1 small, .h1 small, h2 small, .h2 small, h3 small, .h3 small, h1 .small, .h1 .small, h2 .small, .h2 .small, h3 .small, .h3 .small {
font-size: 65%;
}

h1 small, h2 small, h3 small, h4 small, h5 small, h6 small, .h1 small, .h2 small, .h3 small, .h4 small, .h5 small, .h6 small, h1 .small, h2 .small, h3 .small, h4 .small, h5 .small, h6 .small, .h1 .small, .h2 .small, .h3 .small, .h4 .small, .h5 .small, .h6 .small {
font-weight: 400;
line-height: 1;
color: #777;
}

h4, .h4 {
font-size: 18px;
}

h4, .h4, h5, .h5, h6, .h6 {
margin-top: 10px;
margin-bottom: 10px;
}

element.style {
margin: 0;
padding: 0;
display: inline;
}

body {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 1.42857143;
color: #333;
background-color: #fff;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/books.scss
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/movies.scss
Original file line number Diff line number Diff line change
@@ -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/
62 changes: 62 additions & 0 deletions app/controllers/albums_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
class AlbumsController < ApplicationController
before_action :get_album, only: [:edit, :update, :destroy]
def get_album
@album = Album.find(params[:id])
end

def index
@albums = Album.all
end

def new
@url = "create"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have this included in the books and movies controllers as well but it doesn't appear that it is being used anywhere.

@legend = "New Album"
@album = Album.new
end

def create
@album = Album.create(album_params[:album])
if @album.save
redirect_to albums_path
else
render :new
end
end

def show
@album = Album.find(params[:id])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You made that handy dandy get_album before method but are re-writing that code here. Also you could add upvote and edit to your before action as those are also using @album = Album.find(params[:id])

end

def edit
@album = Album.find(params[:id])
@legend = "Edit Album"
end

def update
@album = Album.update(params[:id], album_params[:album])
if @album.save
redirect_to album_path(params[:id])
else
render :edit
end
end

def destroy
Album.destroy(params[:id])
redirect_to albums_path
end

def upvote
@album = Album.find(params[:id])
@album.rank += 1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works beautifully and is generally my go to as it works across many different programming languages. Another way to accomplish the same thing in Ruby is the method increment. Yay options!

@album.save
render :show
end

private

def album_params
params.permit(album: [:name, :artist, :description, :rank])
end

end
57 changes: 57 additions & 0 deletions app/controllers/books_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
class BooksController < ApplicationController

def index
@books = Book.all
end

def new
@url = "create"
@book = Book.new
end

def create
@book = Book.create(book_params[:book])
if @book.save
redirect_to books_path
else
render :new
end
end

def show
@book = Book.find(params[:id])
end

def edit
@book = Book.find(params[:id])
@legend = "Edit Book"
end

def update
@book = Book.update(params[:id], book_params[:book])
if @book.save
redirect_to book_path(params[:id])
else
render :edit
end
end

def destroy
Book.destroy(params[:id])
redirect_to books_path
end

def upvote
@book = Book.find(params[:id])
@book.rank += 1
@book.save
render :show
end

private

def book_params
params.permit(book: [:name, :author, :description, :rank])
end

end
Loading