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

TunesTakeOut #11

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9defff3
bundle
pottery123 May 16, 2016
9f55132
bundle again
pottery123 May 16, 2016
7df5004
added controllers
pottery123 May 16, 2016
64b262c
ran migrations
pottery123 May 17, 2016
6ed7f70
login working but I can't log out
pottery123 May 18, 2016
4b536d8
got search for pairing working now working on show top favorities
pottery123 May 18, 2016
8b47909
got spotify working
pottery123 May 19, 2016
575036a
got images and links
pottery123 May 19, 2016
4fd63f2
working on combining food and music
pottery123 May 19, 2016
f494aec
searching for suggestions is working
pottery123 May 19, 2016
6ff6b95
log in and log out is working
pottery123 May 20, 2016
8b29f31
working again
pottery123 May 20, 2016
2cc7d72
favorting working
pottery123 May 21, 2016
edc3d7d
favoriting is working again
pottery123 May 21, 2016
bf77de1
favorite ids are out of array not quite sure how thought
pottery123 May 21, 2016
64f03a5
i can see individual favorites
pottery123 May 21, 2016
fadabae
i can press favorite and unfavorite a suggestion but I cannot do both…
pottery123 May 21, 2016
0621344
I can view the top twenty favorites but now I cant view suggestions
pottery123 May 22, 2016
929e161
attempted to make a partial, but unfavoring does not work form some s…
pottery123 May 22, 2016
b79e51d
have user photo
pottery123 May 22, 2016
836db83
comminging more stuff I think in got the image or somthing
pottery123 May 22, 2016
c3aeb64
favorite and unfavorite work and we added bootstrap shout out to Melissa
pottery123 May 23, 2016
008fb24
got rid of ugly route
pottery123 May 23, 2016
0d2cbc1
all features are working
pottery123 May 23, 2016
c52d947
finished with features now on to testing
pottery123 May 23, 2016
b8ead80
100% test coverage for food
pottery123 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
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SPOTIFY_CLIENT_ID: f5367bbd4d5f4886a60eade686bf8f63
SPOTIFY_CLIENT_SECRET: 6ae2a615d6424ac28af5df02b0ccc45d




YOUR_CONSUMER_KEY: YyEMdut41--kJVxTsOnNqA
YOUR_CONSUMER_SECRET: UZgbBTeOmLBrCHTUTCvdy-v4TY4
YOUR_TOKEN: 1pKD5WOtU89W8rorhjxCO77B_TA7-7nK
YOUR_TOKEN_SECRET: qb6kS2hbWFyLGoMIxSiaShpGUos

Choose a reason for hiding this comment

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

Don't check in your .env file! 🙀 (add .env to gitignore file)

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/tmp/

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

## Specific to RubyMotion:
.dat*
Expand Down
21 changes: 19 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
source 'https://rubygems.org'
ruby '2.3.1'

gem 'httparty'
gem 'yelp'
gem 'rspotify'
gem 'rest-client'
gem "omniauth"
gem "addressable"


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
# Use postgresql as the database for Active Record
Expand All @@ -20,6 +28,7 @@ gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'omniauth-oauth2', '~> 1.3.1'

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
Expand All @@ -33,13 +42,21 @@ 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'
gem 'better_errors'
gem 'dotenv-rails'
gem 'pry-rails'
gem 'minitest-vcr'
gem 'minitest-reporters'
gem 'webmock'
end

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

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

118 changes: 117 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,24 @@ 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)
autoprefixer-rails (6.3.6.1)
execjs
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.5)
choice (0.2.0)
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 +62,30 @@ 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)
erd (0.4.0)
nokogiri
rails-erd (>= 0.4.5)
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 +95,53 @@ 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-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 All @@ -96,6 +162,11 @@ GEM
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-erd (1.4.7)
activerecord (>= 3.2)
activesupport (>= 3.2)
choice (~> 0.2.0)
ruby-graphviz (~> 1.2)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (4.2.6)
Expand All @@ -106,6 +177,16 @@ GEM
rake (11.1.2)
rdoc (4.2.2)
json (~> 1.4)
rest-client (1.6.7)
mime-types (>= 1.16)
rest_client (1.8.3)
netrc (~> 0.7.7)
rspotify (1.10.0)
omniauth-oauth2 (~> 1.1)
rest_client (~> 1.8)
ruby-graphviz (1.2.2)
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,6 +197,13 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
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)
spring (1.7.1)
sprockets (3.6.0)
concurrent-ruby (~> 1.0)
Expand All @@ -131,27 +219,55 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
vcr (3.0.3)
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.3)
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
addressable
better_errors
bootstrap-sass
byebug
coffee-rails (~> 4.1.0)
dotenv-rails
erd
httparty
jbuilder (~> 2.0)
jquery-rails
minitest-reporters
minitest-vcr
omniauth
omniauth-oauth2 (~> 1.3.1)
pg (~> 0.15)
pry-rails
rails (= 4.2.6)
rest-client
rspotify
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
simplecov
spring
uglifier (>= 1.3.0)
web-console (~> 2.0)
webmock
yelp

RUBY VERSION
ruby 2.3.0p0

BUNDLED WITH
1.12.3
1.12.4
3 changes: 3 additions & 0 deletions app/assets/javascripts/favorites.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/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/
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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/favorites.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the favorites 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/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/
18 changes: 17 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
# 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
@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
end
73 changes: 73 additions & 0 deletions app/controllers/favorites_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
require 'tunestakeout.rb'

class FavoritesController < ApplicationController

def favorite_a_suggestion

favorite = TunesTakeOut.new.favorite_a_suggestion(params[:user_id],params[:suggestion_id])

Choose a reason for hiding this comment

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

why is this variable called "favorite"? It seems to be a reference to the response from an HTTP request. If so, something like "favorite_response" makes more sense.

if favorite == 201
@message = "Good!"
else
@message = "Not so good :("
end
@print_status = favorite
redirect_to get_my_favs_path

Choose a reason for hiding this comment

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

Indent the above 2 lines and the line above end.

end

def get_my_favs
@id_array = []
@food_array = []
@music_array = []

@show_favorites = TunesTakeOut.new.my_favorites(current_user.uid)

@show_favorites.each do |entire_suggestion|
a = entire_suggestion["suggestion"]

Choose a reason for hiding this comment

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

What is a? A more descriptive name would make the code easier to read.

if a["music_type"] == "artist"
@artist = Music.find_artist(a["music_id"])
@music_array << @artist
elsif a["music_type"] == "album"
@album = Music.find_album(a["music_id"])
@music_array << @album
else a["music_type"] == "track"
@track = Music.find_track(a["music_id"])
@music_array << @track
end

@food = Food.find_business(a["food_id"])
@food_array << @food

id = a["id"]

@id_array << id


end


@food_array
@music_array
@id_array



Choose a reason for hiding this comment

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

Lots of unnecessary white space.

render :my_favs
end



def destroy
unfavorite = TunesTakeOut.new.unfavorite_a_suggestion(params[:user_id],params[:suggestion_id])
if unfavorite == 201
@message = "Good!"
else
@message = "Not so good :("
end
@print_status = unfavorite
redirect_to get_my_favs_path
end




end
Loading