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

All Features and Pages Complete - No Testing #15

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9ef022d
First commit, pre-bundle
nicosaki May 16, 2016
bba87ea
gitignore update
nicosaki May 16, 2016
c868958
gitignore fixed hopefully
nicosaki May 16, 2016
d37dc0b
env update
nicosaki May 16, 2016
16190a5
fixed gitignore for secrets and env
nicosaki May 16, 2016
d98e525
generated models, foods, musics, users
nicosaki May 16, 2016
a968ded
made my super secret secrets visible because charles says so
nicosaki May 17, 2016
ec7ed40
migrations created
nicosaki May 17, 2016
ddebf58
updated gitignore, BEGIN IGNORING
nicosaki May 17, 2016
6324e95
TunesTakeoutWrapper complete
nicosaki May 17, 2016
04e3654
Sessions controller with skeleton actions
nicosaki May 17, 2016
a9b0318
Suggestions controller with skeleton actions
nicosaki May 17, 2016
18cc8ab
test controllers
nicosaki May 17, 2016
d4c3447
incomplete but started suggestions controller
nicosaki May 17, 2016
f98cd01
Gemfile updates for omniauth
nicosaki May 17, 2016
fd84e9e
Controller updates with known omniauth information. Still needs tunes…
nicosaki May 17, 2016
de0ba2d
User model for omniauth functionality
nicosaki May 17, 2016
e824a61
Route and rename lib/tunestakeoutwrapper.rb
nicosaki May 17, 2016
b3d1b05
suggestion index view, migrations ran -> schema
nicosaki May 18, 2016
868ee96
pre-re-install, thanks rails/spotify fuck
nicosaki May 18, 2016
5350af3
Gemfile final(ish) in attempt to fix rest_client deprecation
nicosaki May 19, 2016
92d2db6
All functionality around logging in and out complete and working
nicosaki May 19, 2016
670d66c
added a bunch of non-functional tests because I have no idea what I'm…
nicosaki May 19, 2016
bf152dc
Gemfile with reporters, minitest stuff, other testing junk
nicosaki May 20, 2016
8cddc20
favorites in controller
nicosaki May 20, 2016
69f285a
Application controller, maybe unncessary methods to extract food and …
nicosaki May 20, 2016
aaf4398
changing yelp.rb and food.rb to function correctly and retrieve insta…
nicosaki May 20, 2016
4233533
controller method to retrieve top pairings
nicosaki May 20, 2016
40ec870
Updated routes for suggestions, search results, revisiting specific s…
nicosaki May 20, 2016
b6c832b
Completely useless testing garbage that was a huge waste of time.
nicosaki May 20, 2016
86954cb
Search results view - unstyles, retrieving results correctly but no d…
nicosaki May 20, 2016
621b941
Fixed music model to return most of necessary information. Fucking fi…
nicosaki May 20, 2016
d708f29
BARSAVE yardhouse style
nicosaki May 20, 2016
99a761d
most basic of styling for suggestion pairings
nicosaki May 22, 2016
dccb1a1
Application controller methods to extract music and food objects from…
nicosaki May 22, 2016
c573fdb
music model, added functionality to deal with differences in suggesti…
nicosaki May 22, 2016
7e7b83f
suggestion views for index and results refactored to use partial _sug…
nicosaki May 22, 2016
bd63de3
Controller refactored to remove spaghetti
nicosaki May 22, 2016
4bbddf8
Food model updated to include image urls
nicosaki May 22, 2016
a9fba31
added search bar to be a part of the application nav
nicosaki May 22, 2016
9dcc9ec
Everything works, don't you touch a fucking thing.
nicosaki May 22, 2016
b29a369
favoriting / unfavoriting functions
nicosaki May 23, 2016
c7b9249
displaying album art correctly - finally covered all edge cases as fa…
nicosaki May 23, 2016
a37dd56
attemted to pass path variable to re-render page pairing was favorite…
nicosaki May 23, 2016
b9704f3
Added user photo or guest photo to nav in layout
nicosaki May 23, 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/log/*
!/log/.keep
/tmp
.DS_Store

# From https://github.com/github/gitignore/blob/master/Ruby.gitignore
*.gem
Expand All @@ -26,7 +27,7 @@
/tmp/

# Used by dotenv library to load environment variables.
# .env
.env

Choose a reason for hiding this comment

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

good job not checking your secrets in to github!


## Specific to RubyMotion:
.dat*
Expand Down
28 changes: 25 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'httparty'

gem 'rspotify'

gem 'yelp', require: 'yelp'

gem "omniauth"

gem "omniauth-github"

gem 'omniauth-oauth2', '~> 1.3.1'




# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

Expand All @@ -33,13 +48,20 @@ 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 'simplecov', '~> 0.11.2'
gem 'pry-rails'
gem "better_errors"
gem "binding_of_caller"
gem "dotenv-rails"
# gem 'vcr'
gem "minitest-vcr"
gem "webmock"
gem "minitest-reporters"
end

group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
# gem 'spring'
end

104 changes: 101 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
ansi (1.5.0)
arel (6.0.3)
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)
builder (3.2.2)
byebug (8.2.5)
coderay (1.1.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
Expand All @@ -49,11 +56,27 @@ GEM
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
debug_inspector (0.0.2)
docile (1.1.5)
dotenv (2.1.1)
dotenv-rails (2.1.1)
dotenv (= 2.1.1)
railties (>= 4.0, < 5.1)
erubis (2.7.0)
execjs (2.6.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.10.0)
faraday (>= 0.7.4, < 0.10)
globalid (0.3.6)
activesupport (>= 4.1.0)
hashdiff (0.3.0)
hashie (3.4.4)
httparty (0.13.7)
json (~> 1.8)
multi_xml (>= 0.5.2)
i18n (0.7.0)
jbuilder (2.4.1)
activesupport (>= 3.0.0, < 5.1)
Expand All @@ -63,19 +86,56 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
jwt (1.5.1)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.0)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0221)
mini_portile2 (2.0.0)
minispec-metadata (2.0.0)
minitest
minitest (5.8.4)
minitest-reporters (1.1.9)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
minitest-vcr (1.4.0)
minispec-metadata (~> 2.0)
minitest (>= 4.7.5)
vcr (>= 2.9)
multi_json (1.12.0)
multi_xml (0.5.5)
multipart-post (2.0.0)
netrc (0.7.9)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
oauth2 (1.1.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0, < 1.5.2)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.3.1)
hashie (>= 1.2, < 4)
rack (>= 1.0, < 3)
omniauth-github (1.1.2)
omniauth (~> 1.0)
omniauth-oauth2 (~> 1.1)
omniauth-oauth2 (1.3.1)
oauth2 (~> 1.0)
omniauth (~> 1.2)
pg (0.18.4)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-rails (0.3.4)
pry (>= 0.9.10)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
Expand Down Expand Up @@ -106,6 +166,13 @@ GEM
rake (11.1.2)
rdoc (4.2.2)
json (~> 1.4)
rest_client (1.8.3)
netrc (~> 0.7.7)
rspotify (1.10.0)
omniauth-oauth2 (~> 1.1)
rest_client (~> 1.8)
ruby-progressbar (1.8.1)
safe_yaml (1.0.4)
sass (3.4.22)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
Expand All @@ -116,7 +183,13 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
spring (1.7.1)
simple_oauth (0.3.1)
simplecov (0.11.2)
docile (~> 1.1.0)
json (~> 1.8)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
sprockets (3.6.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand All @@ -131,27 +204,52 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
vcr (3.0.1)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
webmock (2.0.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
yelp (2.1.2)
faraday (~> 0.8, >= 0.8.0)
faraday_middleware (~> 0.8, >= 0.8.0)
simple_oauth (~> 0.3.1)

PLATFORMS
ruby

DEPENDENCIES
better_errors
binding_of_caller
byebug
coffee-rails (~> 4.1.0)
dotenv-rails
httparty
jbuilder (~> 2.0)
jquery-rails
minitest-reporters
minitest-vcr
omniauth
omniauth-github
omniauth-oauth2 (~> 1.3.1)
pg (~> 0.15)
pry-rails
rails (= 4.2.6)
rspotify
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
simplecov (~> 0.11.2)
uglifier (>= 1.3.0)
web-console (~> 2.0)
webmock
yelp

RUBY VERSION
ruby 2.3.1p112

BUNDLED WITH
1.12.3
1.12.4
3 changes: 3 additions & 0 deletions app/assets/javascripts/sessions.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/

Choose a reason for hiding this comment

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

Best practice is to delete these files you never use. They're auto-generated by rails.

3 changes: 3 additions & 0 deletions app/assets/javascripts/suggestions.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/
18 changes: 18 additions & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,21 @@
*= require_tree .
*= require_self
*/
.float-right {
float: right;
}

.covers img{
height: 170px;
width: 170px;
}

.suggestion {
clear: both;
float: left:
}

.user-photo img {
height: 70px;
width: 70px;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/sessions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Sessions 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/suggestions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Suggestions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
66 changes: 66 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,70 @@ 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
helper_method :current_user

before_action :require_login

def current_user
@current_user ||= User.find_by(id: session[:user_id])
end

def require_login
if current_user.nil?
flash[:error] = "You must be logged in to view this section"
redirect_to root_path
end
end

def extract_suggestions(suggestions)
if suggestions.class != Array
suggestions = pull_from_id(suggestions.suggestions)
suggestions.each do |suggestion_hash|
food = suggestion_hash.suggestion["food_id"]
suggestion_hash.suggestion["food_suggestion"]= Food.retrieve(food)
suggestion_hash.suggestion["music_suggestion"] = Music.retrieve(suggestion_hash.suggestion["music_id"], suggestion_hash.suggestion["music_type"])
end
return suggestions
end
suggestions.each do |suggestion_hash|
food = suggestion_hash["food_id"]
suggestion_hash["food_suggestion"]= Food.retrieve(food)
suggestion_hash["music_suggestion"] = Music.retrieve(suggestion_hash["music_id"], suggestion_hash["music_type"])
end
return suggestions
end
Copy link

@hougland hougland May 24, 2016

Choose a reason for hiding this comment

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

This logic is confusing to me. What is the class of suggestions you're expecting? Is it a string? Why not do:

if suggestions.class == String
do stuff
elsif suggestions.class == Array
do stuff
else
something else
end


def pull_from_id(suggestions)
hashes = []

Choose a reason for hiding this comment

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

Consider better naming for this variable. It's an array, but it's called "hashes."

suggestions.each do |id|
hashes << TunesTakeoutWrapper.specific_suggestion(id)
end
return hashes
end

def get_food(suggestions)
if suggestions.count == 1
food = Food.find(id)
end
food_array = []
suggestions.each do |hash|
hash["food_id"] = id
food = Food.find(id)
food_array << food
end
return food_array
end

def get_music(suggestions)
if suggestions.count == 1
music = Music.find(id)
end
music_array = []
suggestions.each do |hash|
hash["music_id"] = id
music = Music.find(id)
music_array << music
end
return music_array
end
end

Choose a reason for hiding this comment

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

On first glance, I feel like these methods belong in models, not in the application_controller. Remember that all your controllers have access to these methods, which is bad separation of concerns.

(current_user and require_login totally do make sense in the application_controller)

29 changes: 29 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class SessionsController < ApplicationController
skip_before_action :require_login, only: [:new, :create]

def new

end

Choose a reason for hiding this comment

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

A nice way to write this would be def new; end
This makes it easier to read :)


def create
auth_hash = request.env['omniauth.auth']
if auth_hash["info"]["id"]
@user = User.find_or_create_from_omniauth(auth_hash)
if @user
session[:user_id] = @user.id
redirect_to root_path
else
redirect_to root_path, notice: "Failed to save the user"
end
else
redirect_to root_path, notice: "Failed to save the user"
end
end

Choose a reason for hiding this comment

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

yayyyy authentication!



def destroy
session.delete :user_id
redirect_to root_path
end

end
Loading