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

JLN - Project Complete #37

Open
wants to merge 38 commits into
base: jln/master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0fe6d42
Set up routes
noglows Nov 30, 2015
154571b
Created controllers
noglows Nov 30, 2015
3eaed4d
Generated models
noglows Nov 30, 2015
a40f4d8
Created seed data
noglows Nov 30, 2015
f8bc680
Root route shows all media
noglows Nov 30, 2015
96185c7
/movies page functional
noglows Nov 30, 2015
6580143
Movie details page
noglows Nov 30, 2015
3778de5
Created a partial for show
noglows Nov 30, 2015
e87f17d
Created a partial for the index page
noglows Nov 30, 2015
a1a9828
Added model validation
noglows Nov 30, 2015
bac7ad0
Added ability to delete movies
noglows Nov 30, 2015
1ce0a3b
Can edit a movie
noglows Nov 30, 2015
a7bd36e
Can vote for a movie
noglows Nov 30, 2015
f2b4ebb
Can view all books, add books, edit books, delete books, and vote for…
noglows Nov 30, 2015
a9ec8e7
Everything working for albums
noglows Nov 30, 2015
c41e10f
Fixed a grammatical error
noglows Nov 30, 2015
3638388
Added limits to amount of content shown on root page
noglows Dec 1, 2015
75159ea
Set up rspec files
noglows Dec 1, 2015
10206ea
Wrote some more specs
noglows Dec 1, 2015
8a5dadb
Created a new model method
noglows Dec 1, 2015
1f3268a
Fixed some partials
noglows Dec 1, 2015
764f5bd
Partial fixes and form change
noglows Dec 1, 2015
4c78ba4
Create bug fix
noglows Dec 1, 2015
1522a59
Added more rspec tests and added simplecov to gemfile
noglows Dec 1, 2015
0a92188
Specs added for albums and movies
noglows Dec 2, 2015
e0d89bb
Added polymorphic path to upvote
noglows Dec 2, 2015
16fd820
100% test coverage achieved
noglows Dec 2, 2015
e27c9f4
Fixed a bug where votes gets reset everytime there is an edit
noglows Dec 2, 2015
ecdea13
Initial Bootstrap set-up
noglows Dec 2, 2015
ee47433
Page title correctly styled
noglows Dec 2, 2015
218fb9f
Root route styled correctly
noglows Dec 2, 2015
bd8cd86
Content index page styled
noglows Dec 2, 2015
ef8642d
Form correctly styled
noglows Dec 2, 2015
9b47eaf
Show page correctly styled
noglows Dec 2, 2015
dd7cf4c
Link color was slightly different - fixed
noglows Dec 2, 2015
44c898e
Converted rspec tests to shared examples
noglows Dec 3, 2015
8710224
Tidied up shared specs
noglows Dec 3, 2015
7c4dbd9
Spec cleanup
noglows Dec 3, 2015
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
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
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ source 'https://rubygems.org'
gem 'rails', '4.2.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Bootstrap
gem 'bootstrap-sass', '~> 3.3.6'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
Expand Down Expand Up @@ -36,9 +38,13 @@ 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

# Debugging
gem 'better_errors'
gem 'binding_of_caller'
gem 'pry'
end

group :development do
Expand Down
47 changes: 47 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,21 @@ 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)
coderay (1.1.0)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
Expand All @@ -49,6 +60,8 @@ 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)
globalid (0.3.6)
Expand All @@ -66,12 +79,17 @@ GEM
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (2.99)
mini_portile2 (2.0.0)
minitest (5.8.3)
multi_json (1.11.2)
nokogiri (1.6.7)
mini_portile2 (~> 2.0.0.rc2)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
Expand Down Expand Up @@ -101,6 +119,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)
sass (3.4.19)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
Expand All @@ -111,6 +146,12 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
simplecov (0.11.0)
docile (~> 1.1.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
spring (1.5.0)
sprockets (3.4.1)
rack (> 1, < 3)
Expand Down Expand Up @@ -139,13 +180,19 @@ PLATFORMS
ruby

DEPENDENCIES
better_errors
binding_of_caller
bootstrap-sass (~> 3.3.6)
byebug
coffee-rails (~> 4.1.0)
jbuilder (~> 2.0)
jquery-rails
pry
rails (= 4.2.5)
rspec-rails
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
simplecov
spring
sqlite3
turbolinks
Expand Down
Binary file added app/assets/images/owl.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -11,6 +11,7 @@
// about supported directives.
//
//= require jquery
//= require bootstrap-sprockets
//= require jquery_ujs
//= require turbolinks
//= require_tree .
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/
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,25 @@
* 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
*/

// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";

.page-header {
background: url(owl.jpg);
background-repeat: no-repeat;
}

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

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

a {
color: #428bca;
}
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/
6 changes: 6 additions & 0 deletions app/assets/stylesheets/movies.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// 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/
.content-name {
font-weight: bolder;
}
70 changes: 70 additions & 0 deletions app/controllers/albums_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class AlbumsController < ApplicationController

def index
@content_list = Album.order(votes: :desc)
@item_path, @content_type = Album.page_grammer
@new_content_path = new_album_path
end

def show
@content = Album.find(params[:id])
@edit_path = edit_album_path(params[:id])
@content_path = albums_path
@item_path, @content_type = Album.page_grammer
@correct_string = "Recorded by: "
@person = @content.artist
end

def new
@item = Album.new
@person = :artist
@action = "create"
end

def create
@person = :author
@item = Album.new(album_params[:album])
if @item.save
redirect_to "/albums/#{@item.id}"
else
render "new"
end
end

def edit
@item = Album.find(params[:id])
@person = :artist
@action = "update"
end

def update
@person = :artist
@item = Album.update(params[:id], album_params[:album])
if @item.save
redirect_to "/albums/#{@item.id}"
else
render "new"
end
end


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

def upvote
id = params[:id]
album = Album.find(id)
votes = album.votes + 1
album.update(votes: votes)
redirect_to "/albums/#{id}"
end

private

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

end
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception

def index
@movies = Movie.all.order(votes: :desc).limit(10)
@books = Book.all.order(votes: :desc).limit(10)
@albums = Album.all.order(votes: :desc).limit(10)
end

end
69 changes: 69 additions & 0 deletions app/controllers/books_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
class BooksController < ApplicationController
def index
@content_list = Book.order(votes: :desc)
@item_path, @content_type = Book.page_grammer
@new_content_path = new_book_path
end

def show
@content = Book.find(params[:id])
@edit_path = edit_book_path(params[:id])
@content_path = books_path
@item_path, @content_type = Book.page_grammer
@correct_string = "Written by: "
@person = @content.author
end

def new
@item = Book.new
@person = :author
@action = "create"
end

def create
@person = :author
@item = Book.new(book_params[:book])
if @item.save
redirect_to "/books/#{@item.id}"
else
render "new"
end
end

def edit
@item = Book.find(params[:id])
@person = :author
@action = "update"
end

def update
@person = :author
@item = Book.update(params[:id], book_params[:book])
if @item.save
redirect_to "/books/#{@item.id}"
else
render "new"
end
end


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

def upvote
id = params[:id]
book = Book.find(id)
votes = book.votes + 1
book.update(votes: votes)
redirect_to "/books/#{id}"
end

private

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

end
Loading