From 3c1c56f8acc6ec458d39edfe325de04d2b5847ed Mon Sep 17 00:00:00 2001 From: Adriana Date: Mon, 16 May 2016 21:21:03 -0700 Subject: [PATCH 01/36] Boiler plate and Shaved yaks --- Gemfile | 16 ++++++- Gemfile.lock | 79 +++++++++++++++++++++++++++++++- app/models/tunes_takeout.rb | 89 +++++++++++++++++++++++++++++++++++++ config/application.rb | 13 +----- 4 files changed, 183 insertions(+), 14 deletions(-) create mode 100644 app/models/tunes_takeout.rb diff --git a/Gemfile b/Gemfile index 288bb87..4a2db22 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ ruby '2.3.1' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.2.6' # Use postgresql as the database for Active Record -gem 'pg', '~> 0.15' +# gem 'pg', '~> 0.15' # Use SCSS for stylesheets gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets @@ -13,6 +13,11 @@ gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby +gem 'httparty' + +gem 'yelp' + +gem 'rspotify' # Use jquery as the JavaScript library gem 'jquery-rails' @@ -33,13 +38,22 @@ 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' end group :development do # Access an IRB console on exception pages or by using <%= console %> in views gem 'web-console', '~> 2.0' + gem "pry-rails" + gem "better_errors" + gem "binding_of_caller" + gem 'rails-erd' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' end +group :production do + gem 'rails_12factor' + gem 'pg', '~> 0.15' +end diff --git a/Gemfile.lock b/Gemfile.lock index 6ff0f39..a940b8e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,10 +37,16 @@ GEM thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) 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) + 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) @@ -50,10 +56,19 @@ GEM coffee-script-source (1.10.0) concurrent-ruby (1.0.2) debug_inspector (0.0.2) + docile (1.1.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) + 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) @@ -63,19 +78,42 @@ 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) minitest (5.8.4) 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.4.0) + 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) @@ -96,8 +134,18 @@ 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) + rails_12factor (0.0.3) + rails_serve_static_assets + rails_stdout_logging + rails_serve_static_assets (0.0.5) + rails_stdout_logging (0.0.5) railties (4.2.6) actionpack (= 4.2.6) activesupport (= 4.2.6) @@ -106,6 +154,12 @@ 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-graphviz (1.2.2) sass (3.4.22) sass-rails (5.0.4) railties (>= 4.0.0, < 5.0) @@ -116,6 +170,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) @@ -136,22 +197,38 @@ GEM binding_of_caller (>= 0.7.2) railties (>= 4.0) sprockets-rails (>= 2.0, < 4.0) + 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) + httparty jbuilder (~> 2.0) jquery-rails pg (~> 0.15) + pry-rails rails (= 4.2.6) + rails-erd + rails_12factor + rspotify sass-rails (~> 5.0) sdoc (~> 0.4.0) + simplecov (~> 0.11.2) spring uglifier (>= 1.3.0) web-console (~> 2.0) + yelp + +RUBY VERSION + ruby 2.3.1p112 BUNDLED WITH - 1.12.3 + 1.12.4 diff --git a/app/models/tunes_takeout.rb b/app/models/tunes_takeout.rb new file mode 100644 index 0000000..ce8ff17 --- /dev/null +++ b/app/models/tunes_takeout.rb @@ -0,0 +1,89 @@ +require 'httparty' +require 'yelp' +require 'rspotify' + +class TunesTakeout + BASE_URL = "https://tunes-takeout-api.herokuapp.com/" + + def initialize + Yelp.client.configure do |config| + config.consumer_key = "DOZfhe1yESBrcYsFC_c53g" + config.consumer_secret = "wTESBjwnK7KqEUBnDH0glaoeGfg" + config.token = "UIlA5f8p0Y320Sv2kL6cpGU3-Qqf6lmC" + config.token_secret = "gvKsdHl7c_RfpJk16tb_NzL5Kwc" + end + end + + def self.yelp_search(city, query, limit, category = "restaurants") + yelp_params = { term: query, + limit: limit, + category: category + } + + Yelp.client.search(city, yelp_params) + end + + def self.yelp_find(business) + Yelp.client.business(business) + end + + def self.spotify_search(type, id) + if type == "album" + RSpotify::Album.find(id) + elsif type == "artist" + RSpotify::Artist.find(id) + elsif type == "track" + RSpotify::Track.find(id) + elsif type == "playlist" + RSpotify::Playlist.find(id) + end + end + + def self.connect(query, limit) + response = HTTParty.get(BASE_URL + "/v1/suggestions/search?query=#{query}&limit=#{limit}").parsed_response + # puts response + # puts "----------------" + # puts response[suggestions] + + yelp_business = self.yelp_find(response["suggestions"].first["food_id"]) + spotify_stuff = self.spotify_search(response["suggestions"].first["music_type"], response["suggestions"].first["music_id"]) + + puts "yelp: #{yelp_business.business.name} spotify: #{spotify_stuff.name}" + end +end + + + +# class Pokemon +# BASE_URL = "http://pokeapi.co/api/v2/" +# attr_reader :name, :moves, :sprites +# +# def initialize(data) +# @name = data["name"] +# @moves = data["moves"] +# @sprites = reject_null_sprites(data["sprites"]) +# end +# +# def sprite_urls +# sprites.values +# end +# +# def favorite_move +# HTTParty.get(moves.sample["move"]["url"]).parsed_response +# end +# +# def self.find(id) +# # http://pokeapi.co/api/v2/pokemon/25/ example we want to hit +# # find a pokemon with the passed id +# data = HTTParty.get(BASE_URL + "pokemon/#{id}/").parsed_response +# +# # return an instance of pokemon for that id +# self.new(data) +# end +# +# def reject_null_sprites(sprite_hash) +# sprite_hash.reject do |name, url| +# url.nil? +# end +# end +# end diff --git a/config/application.rb b/config/application.rb index 9b37a86..d61caa6 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,6 +1,7 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' +require 'yelp' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -8,19 +9,7 @@ module TunesTakeout class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de - - # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true end end From 0770a589ff514e00b1dd46cbf6e568e276271a8c Mon Sep 17 00:00:00 2001 From: Adriana Date: Tue, 17 May 2016 16:22:30 -0700 Subject: [PATCH 02/36] started using omniauth to sign a user in through spotify --- .gitignore | 2 + Gemfile | 6 ++ Gemfile.lock | 9 +++ app/assets/javascripts/home.coffee | 3 + app/assets/javascripts/sessions.coffee | 3 + app/assets/javascripts/users.coffee | 3 + app/assets/stylesheets/home.scss | 3 + app/assets/stylesheets/sessions.scss | 3 + app/assets/stylesheets/users.scss | 3 + app/controllers/home_controller.rb | 5 ++ app/controllers/sessions_controller.rb | 23 ++++++++ app/controllers/users_controller.rb | 5 ++ app/helpers/home_helper.rb | 2 + app/helpers/sessions_helper.rb | 2 + app/helpers/users_helper.rb | 2 + app/models/tunes_takeout.rb | 61 ++++---------------- app/models/user.rb | 33 +++++++++++ app/views/home/index.html.erb | 0 app/views/layouts/application.html.erb | 4 ++ app/views/users/index.html.erb | 1 + config/application.rb | 3 +- config/initializers/omniauth.rb | 5 ++ config/initializers/yelp.rb | 6 ++ config/routes.rb | 55 ++---------------- db/migrate/20160517175357_create_users.rb | 11 ++++ db/schema.rb | 27 +++++++++ test/controllers/home_controller_test.rb | 7 +++ test/controllers/sessions_controller_test.rb | 7 +++ test/controllers/users_controller_test.rb | 7 +++ test/fixtures/users.yml | 11 ++++ test/models/user_test.rb | 7 +++ 31 files changed, 216 insertions(+), 103 deletions(-) create mode 100644 app/assets/javascripts/home.coffee create mode 100644 app/assets/javascripts/sessions.coffee create mode 100644 app/assets/javascripts/users.coffee create mode 100644 app/assets/stylesheets/home.scss create mode 100644 app/assets/stylesheets/sessions.scss create mode 100644 app/assets/stylesheets/users.scss create mode 100644 app/controllers/home_controller.rb create mode 100644 app/controllers/sessions_controller.rb create mode 100644 app/controllers/users_controller.rb create mode 100644 app/helpers/home_helper.rb create mode 100644 app/helpers/sessions_helper.rb create mode 100644 app/helpers/users_helper.rb create mode 100644 app/models/user.rb create mode 100644 app/views/home/index.html.erb create mode 100644 app/views/users/index.html.erb create mode 100644 config/initializers/omniauth.rb create mode 100644 config/initializers/yelp.rb create mode 100644 db/migrate/20160517175357_create_users.rb create mode 100644 db/schema.rb create mode 100644 test/controllers/home_controller_test.rb create mode 100644 test/controllers/sessions_controller_test.rb create mode 100644 test/controllers/users_controller_test.rb create mode 100644 test/fixtures/users.yml create mode 100644 test/models/user_test.rb diff --git a/.gitignore b/.gitignore index 03f3ce7..882d639 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,5 @@ build-iPhoneSimulator/ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: .rvmrc + +/.env diff --git a/Gemfile b/Gemfile index 4a2db22..5fa6bc0 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,11 @@ gem 'yelp' gem 'rspotify' +gem 'omniauth' +gem 'omniauth-spotify' + +gem 'pg', '~> 0.15' + # Use jquery as the JavaScript library gem 'jquery-rails' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder @@ -39,6 +44,7 @@ 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 'dotenv-rails' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index a940b8e..29dc10f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -57,6 +57,10 @@ GEM concurrent-ruby (1.0.2) 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) @@ -107,6 +111,8 @@ GEM omniauth-oauth2 (1.4.0) oauth2 (~> 1.0) omniauth (~> 1.2) + omniauth-spotify (0.0.9) + omniauth-oauth2 (~> 1.1) pg (0.18.4) pry (0.10.3) coderay (~> 1.1.0) @@ -210,9 +216,12 @@ DEPENDENCIES binding_of_caller byebug coffee-rails (~> 4.1.0) + dotenv-rails httparty jbuilder (~> 2.0) jquery-rails + omniauth + omniauth-spotify pg (~> 0.15) pry-rails rails (= 4.2.6) diff --git a/app/assets/javascripts/home.coffee b/app/assets/javascripts/home.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/home.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/sessions.coffee b/app/assets/javascripts/sessions.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/sessions.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/users.coffee b/app/assets/javascripts/users.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/users.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/home.scss b/app/assets/stylesheets/home.scss new file mode 100644 index 0000000..f0ddc68 --- /dev/null +++ b/app/assets/stylesheets/home.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the home 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/sessions.scss b/app/assets/stylesheets/sessions.scss new file mode 100644 index 0000000..7bef9cf --- /dev/null +++ b/app/assets/stylesheets/sessions.scss @@ -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/ diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/users.scss new file mode 100644 index 0000000..31a2eac --- /dev/null +++ b/app/assets/stylesheets/users.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Users 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/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..3181ce6 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,5 @@ +class HomeController < ApplicationController + def index + + end +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000..48f7079 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,23 @@ +class SessionsController < ApplicationController + def new + + end + + def create + auth_hash = request.env['omniauth.auth'] + raise + 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 + end + end + + def destroy + session.delete :user_id + redirect_to root_path + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 0000000..4eae258 --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,5 @@ +class UsersController < ApplicationController + def index + + end +end diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb new file mode 100644 index 0000000..23de56a --- /dev/null +++ b/app/helpers/home_helper.rb @@ -0,0 +1,2 @@ +module HomeHelper +end diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb new file mode 100644 index 0000000..309f8b2 --- /dev/null +++ b/app/helpers/sessions_helper.rb @@ -0,0 +1,2 @@ +module SessionsHelper +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb new file mode 100644 index 0000000..2310a24 --- /dev/null +++ b/app/helpers/users_helper.rb @@ -0,0 +1,2 @@ +module UsersHelper +end diff --git a/app/models/tunes_takeout.rb b/app/models/tunes_takeout.rb index ce8ff17..db253fd 100644 --- a/app/models/tunes_takeout.rb +++ b/app/models/tunes_takeout.rb @@ -6,22 +6,17 @@ class TunesTakeout BASE_URL = "https://tunes-takeout-api.herokuapp.com/" def initialize - Yelp.client.configure do |config| - config.consumer_key = "DOZfhe1yESBrcYsFC_c53g" - config.consumer_secret = "wTESBjwnK7KqEUBnDH0glaoeGfg" - config.token = "UIlA5f8p0Y320Sv2kL6cpGU3-Qqf6lmC" - config.token_secret = "gvKsdHl7c_RfpJk16tb_NzL5Kwc" - end + end - def self.yelp_search(city, query, limit, category = "restaurants") - yelp_params = { term: query, - limit: limit, - category: category - } - - Yelp.client.search(city, yelp_params) - end + # def self.yelp_search(city, query, limit, category = "restaurants") + # yelp_params = { term: query, + # limit: limit, + # category: category + # } + # + # Yelp.client.search(city, yelp_params) + # end def self.yelp_find(business) Yelp.client.business(business) @@ -40,7 +35,7 @@ def self.spotify_search(type, id) end def self.connect(query, limit) - response = HTTParty.get(BASE_URL + "/v1/suggestions/search?query=#{query}&limit=#{limit}").parsed_response + response = HTTParty.get(BASE_URL + "v1/suggestions/search?query=#{query}&limit=#{limit}").parsed_response # puts response # puts "----------------" # puts response[suggestions] @@ -51,39 +46,3 @@ def self.connect(query, limit) puts "yelp: #{yelp_business.business.name} spotify: #{spotify_stuff.name}" end end - - - -# class Pokemon -# BASE_URL = "http://pokeapi.co/api/v2/" -# attr_reader :name, :moves, :sprites -# -# def initialize(data) -# @name = data["name"] -# @moves = data["moves"] -# @sprites = reject_null_sprites(data["sprites"]) -# end -# -# def sprite_urls -# sprites.values -# end -# -# def favorite_move -# HTTParty.get(moves.sample["move"]["url"]).parsed_response -# end -# -# def self.find(id) -# # http://pokeapi.co/api/v2/pokemon/25/ example we want to hit -# # find a pokemon with the passed id -# data = HTTParty.get(BASE_URL + "pokemon/#{id}/").parsed_response -# -# # return an instance of pokemon for that id -# self.new(data) -# end -# -# def reject_null_sprites(sprite_hash) -# sprite_hash.reject do |name, url| -# url.nil? -# end -# end -# end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..148f661 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,33 @@ +class User < ActiveRecord::Base + validates :email, :name, :uid, :provider, presence: true + + def self.find_or_create_from_omniauth(auth_hash) + user = self.find_by(uid: auth_hash["uid"], provider: auth_hash["provider"]) + raise + if !user.nil? + return user + else + user = User.new + user.uid = auth_hash["uid"] + user.provider = auth_hash["provider"] + user.name = auth_hash["info"]["name"] + user.email = auth_hash["info"]["email"] + + if user.save + return user + else + return nil + end + + end + # @user = User.find_by_uid_and_provider(auth_hash["uid"], auth_hash["provider"]) + #no user found do something here + # Find or create a user + # user = //something else here// + # if !user.nil? + # return user that was found + # else + # no user found, do something here + # end + end +end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 0000000..e69de29 diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 509d1a2..4ad8298 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,6 +7,10 @@ <%= csrf_meta_tags %> +

Tunes and Takeout

+ <%= link_to "Home", root_path %> + <%= link_to "Sign in with Spotify", '/auth/spotify' %> + <%= link_to "Log Out", logout_path, method: :delete %> <%= yield %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb new file mode 100644 index 0000000..4703b01 --- /dev/null +++ b/app/views/users/index.html.erb @@ -0,0 +1 @@ +

Welcome to Tunes and Takeout!

diff --git a/config/application.rb b/config/application.rb index d61caa6..a9448ac 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,7 +1,8 @@ require File.expand_path('../boot', __FILE__) require 'rails/all' -require 'yelp' +# require 'yelp' +# require 'rspotify' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb new file mode 100644 index 0000000..023c922 --- /dev/null +++ b/config/initializers/omniauth.rb @@ -0,0 +1,5 @@ +# require 'omniauth-spotify' +# config/initializers/omniauth.rb +Rails.application.config.middleware.use OmniAuth::Builder do + provider :spotify, ENV["SPOTIFY_CLIENT_ID"], ENV["SPOTIFY_CLIENT_SECRET"] +end diff --git a/config/initializers/yelp.rb b/config/initializers/yelp.rb new file mode 100644 index 0000000..609fc99 --- /dev/null +++ b/config/initializers/yelp.rb @@ -0,0 +1,6 @@ +Yelp.client.configure do |config| + config.consumer_key = ENV["YELP_CONSUMER_KEY"] + config.consumer_secret = ENV["YELP_CONSUMER_SECRET"] + config.token = ENV["YELP_TOKEN"] + config.token_secret = ENV["YELP_TOKEN_SECRET"] +end diff --git a/config/routes.rb b/config/routes.rb index 3f66539..cc1cb73 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,56 +1,9 @@ Rails.application.routes.draw do - # The priority is based upon order of creation: first created -> highest priority. - # See how all your routes lay out with "rake routes". + root "home#index" - # You can have the root of your site routed with "root" - # root 'welcome#index' + resources :users #:only[:show, :index] - # Example of regular route: - # get 'products/:id' => 'catalog#view' + get "/auth/:provider/callback" => "sessions#create" + delete "/logout" => "sessions#destroy" - # Example of named route that can be invoked with purchase_url(id: product.id) - # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase - - # Example resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Example resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Example resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Example resource route with more complex sub-resources: - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', on: :collection - # end - # end - - # Example resource route with concerns: - # concern :toggleable do - # post 'toggle' - # end - # resources :posts, concerns: :toggleable - # resources :photos, concerns: :toggleable - - # Example resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end end diff --git a/db/migrate/20160517175357_create_users.rb b/db/migrate/20160517175357_create_users.rb new file mode 100644 index 0000000..9f20750 --- /dev/null +++ b/db/migrate/20160517175357_create_users.rb @@ -0,0 +1,11 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :provider, default: "spotify", null: false + t.string :uid, null: false + t.string :name + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..231bd34 --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,27 @@ +# 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: 20160517175357) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "users", force: :cascade do |t| + t.string "provider", default: "spotify", null: false + t.string "uid", null: false + t.string "name" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + +end diff --git a/test/controllers/home_controller_test.rb b/test/controllers/home_controller_test.rb new file mode 100644 index 0000000..730478d --- /dev/null +++ b/test/controllers/home_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class HomeControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb new file mode 100644 index 0000000..d30ebc3 --- /dev/null +++ b/test/controllers/sessions_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SessionsControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb new file mode 100644 index 0000000..d23f182 --- /dev/null +++ b/test/controllers/users_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UsersControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml new file mode 100644 index 0000000..937a0c0 --- /dev/null +++ b/test/fixtures/users.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/models/user_test.rb b/test/models/user_test.rb new file mode 100644 index 0000000..82f61e0 --- /dev/null +++ b/test/models/user_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UserTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 6f7d0d60df8392b61ea89af8118c4702fe23b7cd Mon Sep 17 00:00:00 2001 From: Adriana Date: Tue, 17 May 2016 22:10:13 -0700 Subject: [PATCH 03/36] added new gems to the Gemfile, and added a new user. --- Gemfile | 4 +++- Gemfile.lock | 3 ++- app/controllers/application_controller.rb | 13 +++++++++++++ app/controllers/sessions_controller.rb | 1 - app/models/user.rb | 5 ++--- app/views/layouts/application.html.erb | 5 +++-- config/routes.rb | 2 +- 7 files changed, 24 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index 5fa6bc0..825b9e8 100644 --- a/Gemfile +++ b/Gemfile @@ -22,6 +22,8 @@ gem 'rspotify' gem 'omniauth' gem 'omniauth-spotify' +gem 'omniauth-oauth2', '~> 1.3.1' + gem 'pg', '~> 0.15' # Use jquery as the JavaScript library @@ -61,5 +63,5 @@ end group :production do gem 'rails_12factor' - gem 'pg', '~> 0.15' + # gem 'pg', '~> 0.15' end diff --git a/Gemfile.lock b/Gemfile.lock index 29dc10f..151bcdf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -108,7 +108,7 @@ GEM omniauth (1.3.1) hashie (>= 1.2, < 4) rack (>= 1.0, < 3) - omniauth-oauth2 (1.4.0) + omniauth-oauth2 (1.3.1) oauth2 (~> 1.0) omniauth (~> 1.2) omniauth-spotify (0.0.9) @@ -221,6 +221,7 @@ DEPENDENCIES jbuilder (~> 2.0) jquery-rails omniauth + omniauth-oauth2 (~> 1.3.1) omniauth-spotify pg (~> 0.15) pry-rails diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d83690e..7e8dff9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,4 +2,17 @@ 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 + + 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 diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 48f7079..92b1f0d 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -5,7 +5,6 @@ def new def create auth_hash = request.env['omniauth.auth'] - raise user = User.find_or_create_from_omniauth(auth_hash) if user diff --git a/app/models/user.rb b/app/models/user.rb index 148f661..f64bf57 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,9 +1,8 @@ class User < ActiveRecord::Base - validates :email, :name, :uid, :provider, presence: true + validates :name, :uid, :provider, presence: true def self.find_or_create_from_omniauth(auth_hash) user = self.find_by(uid: auth_hash["uid"], provider: auth_hash["provider"]) - raise if !user.nil? return user else @@ -11,7 +10,7 @@ def self.find_or_create_from_omniauth(auth_hash) user.uid = auth_hash["uid"] user.provider = auth_hash["provider"] user.name = auth_hash["info"]["name"] - user.email = auth_hash["info"]["email"] + # user.email = auth_hash["info"]["email"] if user.save return user diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 4ad8298..d5b6583 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -8,9 +8,10 @@

Tunes and Takeout

+ <%= "Hi #{ current_user.name }!" if current_user %> <%= link_to "Home", root_path %> - <%= link_to "Sign in with Spotify", '/auth/spotify' %> - <%= link_to "Log Out", logout_path, method: :delete %> + <%= link_to "Sign in with Spotify", '/auth/spotify' unless current_user %> + <%= link_to "Log Out", logout_path, method: :delete if current_user %> <%= yield %> diff --git a/config/routes.rb b/config/routes.rb index cc1cb73..3f075dd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,7 @@ resources :users #:only[:show, :index] - get "/auth/:provider/callback" => "sessions#create" + get "/auth/spotify/callback" => "sessions#create" delete "/logout" => "sessions#destroy" end From 6ec4119671b12ca10097a28802356de8a858a9e1 Mon Sep 17 00:00:00 2001 From: Adriana Date: Wed, 18 May 2016 13:13:33 -0700 Subject: [PATCH 04/36] added a picture from spotify. Made it so that you can't view other pages unless you are signed in --- app/assets/javascripts/suggestions.coffee | 3 ++ app/assets/stylesheets/suggestions.scss | 3 ++ app/controllers/application_controller.rb | 14 ++++++---- app/controllers/home_controller.rb | 2 ++ app/controllers/sessions_controller.rb | 2 ++ app/controllers/suggestions_controller.rb | 5 ++++ app/controllers/users_controller.rb | 2 ++ app/helpers/suggestions_helper.rb | 2 ++ app/models/food.rb | 5 ++++ app/models/music.rb | 13 +++++++++ app/models/tunes_takeout.rb | 2 +- app/models/user.rb | 24 ++++++++++------ app/views/home/index.html.erb | 1 + app/views/layouts/application.html.erb | 8 +++++- app/views/suggestions/index.html.erb | 6 ++++ config/routes.rb | 1 + db/migrate/20160518051610_create_foods.rb | 8 ++++++ db/migrate/20160518051627_create_musics.rb | 8 ++++++ .../20160518053139_create_suggestions.rb | 10 +++++++ ...518164423_update_users_table_add_images.rb | 5 ++++ ...20160518193216_change_default_url_users.rb | 5 ++++ db/schema.rb | 28 +++++++++++++++---- .../suggestions_controller_test.rb | 7 +++++ test/fixtures/foods.yml | 11 ++++++++ test/fixtures/musics.yml | 11 ++++++++ test/models/food_test.rb | 7 +++++ test/models/music_test.rb | 7 +++++ 27 files changed, 178 insertions(+), 22 deletions(-) create mode 100644 app/assets/javascripts/suggestions.coffee create mode 100644 app/assets/stylesheets/suggestions.scss create mode 100644 app/controllers/suggestions_controller.rb create mode 100644 app/helpers/suggestions_helper.rb create mode 100644 app/models/food.rb create mode 100644 app/models/music.rb create mode 100644 app/views/suggestions/index.html.erb create mode 100644 db/migrate/20160518051610_create_foods.rb create mode 100644 db/migrate/20160518051627_create_musics.rb create mode 100644 db/migrate/20160518053139_create_suggestions.rb create mode 100644 db/migrate/20160518164423_update_users_table_add_images.rb create mode 100644 db/migrate/20160518193216_change_default_url_users.rb create mode 100644 test/controllers/suggestions_controller_test.rb create mode 100644 test/fixtures/foods.yml create mode 100644 test/fixtures/musics.yml create mode 100644 test/models/food_test.rb create mode 100644 test/models/music_test.rb diff --git a/app/assets/javascripts/suggestions.coffee b/app/assets/javascripts/suggestions.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/suggestions.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/suggestions.scss b/app/assets/stylesheets/suggestions.scss new file mode 100644 index 0000000..c0d3b8d --- /dev/null +++ b/app/assets/stylesheets/suggestions.scss @@ -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/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7e8dff9..f14bcac 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,14 +5,16 @@ class ApplicationController < ActionController::Base 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 + 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 diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 3181ce6..f4fac66 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,4 +1,6 @@ class HomeController < ApplicationController + skip_before_action :require_login, only: :index + def index end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 92b1f0d..95c63d9 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,4 +1,6 @@ class SessionsController < ApplicationController + skip_before_action :require_login, only: [:new, :create] + def new end diff --git a/app/controllers/suggestions_controller.rb b/app/controllers/suggestions_controller.rb new file mode 100644 index 0000000..eb70cd0 --- /dev/null +++ b/app/controllers/suggestions_controller.rb @@ -0,0 +1,5 @@ +class SuggestionsController < ApplicationController + def index + + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4eae258..788aa5b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,4 +1,6 @@ class UsersController < ApplicationController + skip_before_action :require_login, only: :index + def index end diff --git a/app/helpers/suggestions_helper.rb b/app/helpers/suggestions_helper.rb new file mode 100644 index 0000000..0e358dd --- /dev/null +++ b/app/helpers/suggestions_helper.rb @@ -0,0 +1,2 @@ +module SuggestionsHelper +end diff --git a/app/models/food.rb b/app/models/food.rb new file mode 100644 index 0000000..3bad6a9 --- /dev/null +++ b/app/models/food.rb @@ -0,0 +1,5 @@ +class Food < ActiveRecord::Base + def self.yelp_find(business) + Yelp.client.business(business) + end +end diff --git a/app/models/music.rb b/app/models/music.rb new file mode 100644 index 0000000..26d1d33 --- /dev/null +++ b/app/models/music.rb @@ -0,0 +1,13 @@ +class Music < ActiveRecord::Base + def self.spotify_search(type, id) + if type == "album" + RSpotify::Album.find(id) + elsif type == "artist" + RSpotify::Artist.find(id) + elsif type == "track" + RSpotify::Track.find(id) + elsif type == "playlist" + RSpotify::Playlist.find(id) + end + end +end diff --git a/app/models/tunes_takeout.rb b/app/models/tunes_takeout.rb index db253fd..2375af4 100644 --- a/app/models/tunes_takeout.rb +++ b/app/models/tunes_takeout.rb @@ -6,7 +6,7 @@ class TunesTakeout BASE_URL = "https://tunes-takeout-api.herokuapp.com/" def initialize - + end # def self.yelp_search(city, query, limit, category = "restaurants") diff --git a/app/models/user.rb b/app/models/user.rb index f64bf57..f6e4f71 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,6 +10,7 @@ def self.find_or_create_from_omniauth(auth_hash) user.uid = auth_hash["uid"] user.provider = auth_hash["provider"] user.name = auth_hash["info"]["name"] + user.image_url = auth_hash["info"]["image"] # user.email = auth_hash["info"]["email"] if user.save @@ -19,14 +20,19 @@ def self.find_or_create_from_omniauth(auth_hash) end end - # @user = User.find_by_uid_and_provider(auth_hash["uid"], auth_hash["provider"]) - #no user found do something here - # Find or create a user - # user = //something else here// - # if !user.nil? - # return user that was found - # else - # no user found, do something here - # end + end + + def self.connect(query, limit) + response = HTTParty.get(BASE_URL + "v1/suggestions/search?query=#{query}&limit=#{limit}").parsed_response + + yelp_business = self.yelp_find(response["suggestions"].first["food_id"]) + spotify_stuff = self.spotify_search(response["suggestions"].first["music_type"], response["suggestions"].first["music_id"]) + + puts "yelp: #{yelp_business.business.name} spotify: #{spotify_stuff.name}" + end + + def self.suggestions(suggest) + response = HTTParty.get(BASE_URL + "v1/suggestions/#{suggest}").parsed_response + end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index e69de29..8b13789 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -0,0 +1 @@ + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d5b6583..0affe3d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -8,12 +8,18 @@

Tunes and Takeout

- <%= "Hi #{ current_user.name }!" if current_user %> + <%= "Hi #{current_user.name}!" if current_user %> + <%= image_tag("#{current_user.image_url}", width: "70", height: "70", alt: "spotify avatar") if current_user %> <%= link_to "Home", root_path %> <%= link_to "Sign in with Spotify", '/auth/spotify' unless current_user %> <%= link_to "Log Out", logout_path, method: :delete if current_user %> + <%= link_to "suggestions", suggestions_path %> <%= yield %> +<% flash.each do |key, msg| %> + <%= content_tag :div, msg, :id => key %> +<% end %> + diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb new file mode 100644 index 0000000..d02da8d --- /dev/null +++ b/app/views/suggestions/index.html.erb @@ -0,0 +1,6 @@ +

Most Popular Suggestions!

+<%= form_tag suggestions_path do %> + <%= label_tag :food %> + <%= text_field_tag :food %> + <%= submit_tag %> +<% end %> diff --git a/config/routes.rb b/config/routes.rb index 3f075dd..4bf74ba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,6 +2,7 @@ root "home#index" resources :users #:only[:show, :index] + resources :suggestions get "/auth/spotify/callback" => "sessions#create" delete "/logout" => "sessions#destroy" diff --git a/db/migrate/20160518051610_create_foods.rb b/db/migrate/20160518051610_create_foods.rb new file mode 100644 index 0000000..5d62fcd --- /dev/null +++ b/db/migrate/20160518051610_create_foods.rb @@ -0,0 +1,8 @@ +class CreateFoods < ActiveRecord::Migration + def change + create_table :foods do |t| + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160518051627_create_musics.rb b/db/migrate/20160518051627_create_musics.rb new file mode 100644 index 0000000..2cc03f3 --- /dev/null +++ b/db/migrate/20160518051627_create_musics.rb @@ -0,0 +1,8 @@ +class CreateMusics < ActiveRecord::Migration + def change + create_table :musics do |t| + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160518053139_create_suggestions.rb b/db/migrate/20160518053139_create_suggestions.rb new file mode 100644 index 0000000..ce4cbf7 --- /dev/null +++ b/db/migrate/20160518053139_create_suggestions.rb @@ -0,0 +1,10 @@ +class CreateSuggestions < ActiveRecord::Migration + def change + create_table :suggestions do |t| + t.string :suggestion_id + t.string :user_id + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20160518164423_update_users_table_add_images.rb b/db/migrate/20160518164423_update_users_table_add_images.rb new file mode 100644 index 0000000..8aba8d1 --- /dev/null +++ b/db/migrate/20160518164423_update_users_table_add_images.rb @@ -0,0 +1,5 @@ +class UpdateUsersTableAddImages < ActiveRecord::Migration + def change + add_column :users, :image_url, :string + end +end diff --git a/db/migrate/20160518193216_change_default_url_users.rb b/db/migrate/20160518193216_change_default_url_users.rb new file mode 100644 index 0000000..49b32a8 --- /dev/null +++ b/db/migrate/20160518193216_change_default_url_users.rb @@ -0,0 +1,5 @@ +class ChangeDefaultUrlUsers < ActiveRecord::Migration + def change + change_column :users, :image_url, :string, default: "http://www.hiapphere.com/data/icon/201312/HiAppHere_com_com.spotify.mobile.android.ui.png" + end +end diff --git a/db/schema.rb b/db/schema.rb index 231bd34..6df4c0e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,17 +11,35 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160517175357) do +ActiveRecord::Schema.define(version: 20160518193216) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "foods", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "musics", force: :cascade do |t| + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + create_table "suggestions", force: :cascade do |t| + t.string "suggestion_id" + t.string "user_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "users", force: :cascade do |t| - t.string "provider", default: "spotify", null: false - t.string "uid", null: false + t.string "provider", default: "spotify", null: false + t.string "uid", null: false t.string "name" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "image_url", default: "http://www.hiapphere.com/data/icon/201312/HiAppHere_com_com.spotify.mobile.android.ui.png" end end diff --git a/test/controllers/suggestions_controller_test.rb b/test/controllers/suggestions_controller_test.rb new file mode 100644 index 0000000..f4587a5 --- /dev/null +++ b/test/controllers/suggestions_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class SuggestionsControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/fixtures/foods.yml b/test/fixtures/foods.yml new file mode 100644 index 0000000..937a0c0 --- /dev/null +++ b/test/fixtures/foods.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/fixtures/musics.yml b/test/fixtures/musics.yml new file mode 100644 index 0000000..937a0c0 --- /dev/null +++ b/test/fixtures/musics.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/test/models/food_test.rb b/test/models/food_test.rb new file mode 100644 index 0000000..8ad7dff --- /dev/null +++ b/test/models/food_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class FoodTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/models/music_test.rb b/test/models/music_test.rb new file mode 100644 index 0000000..c5c6737 --- /dev/null +++ b/test/models/music_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class MusicTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end From 7f65672996580a67dac20ae71b7b4c33612b1e02 Mon Sep 17 00:00:00 2001 From: Adriana Date: Wed, 18 May 2016 22:43:38 -0700 Subject: [PATCH 05/36] Lots of stuff --- app/controllers/home_controller.rb | 4 +- app/controllers/sessions_controller.rb | 7 +--- app/controllers/suggestions_controller.rb | 20 ++++++++- app/controllers/users_controller.rb | 6 ++- app/models/food.rb | 4 +- app/models/music.rb | 8 ++-- app/models/suggestions.rb | 5 +++ app/models/tunes_takeout.rb | 48 ---------------------- app/models/user.rb | 14 ------- app/views/home/index.html.erb | 2 +- app/views/layouts/application.html.erb | 2 +- app/views/suggestions/index.html.erb | 17 ++++++-- app/views/users/index.html.erb | 7 +++- db/migrate/20160518051610_create_foods.rb | 8 ---- db/migrate/20160518051627_create_musics.rb | 8 ---- lib/tunes_takeout.rb | 23 +++++++++++ test/fixtures/foods.yml | 11 ----- test/fixtures/musics.yml | 11 ----- test/models/food_test.rb | 7 ---- test/models/music_test.rb | 7 ---- 20 files changed, 84 insertions(+), 135 deletions(-) create mode 100644 app/models/suggestions.rb delete mode 100644 app/models/tunes_takeout.rb delete mode 100644 db/migrate/20160518051610_create_foods.rb delete mode 100644 db/migrate/20160518051627_create_musics.rb create mode 100644 lib/tunes_takeout.rb delete mode 100644 test/fixtures/foods.yml delete mode 100644 test/fixtures/musics.yml delete mode 100644 test/models/food_test.rb delete mode 100644 test/models/music_test.rb diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index f4fac66..7f15dce 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,7 +1,9 @@ +require 'tunes_takeout' + class HomeController < ApplicationController skip_before_action :require_login, only: :index def index - + end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 95c63d9..c71d8c1 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,18 +1,15 @@ class SessionsController < ApplicationController skip_before_action :require_login, only: [:new, :create] - def new - - end - def create auth_hash = request.env['omniauth.auth'] user = User.find_or_create_from_omniauth(auth_hash) if user session[:user_id] = user.id - redirect_to root_path + redirect_to users_path else + flash[:error] = "Nope" redirect_to root_path end end diff --git a/app/controllers/suggestions_controller.rb b/app/controllers/suggestions_controller.rb index eb70cd0..3a210c1 100644 --- a/app/controllers/suggestions_controller.rb +++ b/app/controllers/suggestions_controller.rb @@ -1,5 +1,23 @@ class SuggestionsController < ApplicationController def index - + @choices = TunesTakeoutWrapper.spotify_search(params[:query], params[:limit]) + if params[:query] + @choices_hash = @choices["suggestions"] + @suggestions = [] + + @choices_hash.each do |hash_id| + sugg = {} + yelp = Food.yelp_find(hash_id["food_id"]) + spotify = Music.spotify_find(hash_id["music_type"], hash_id["music_id"]) + sugg[:business_name] = yelp.business.name + sugg[:music_name] = spotify.name + sugg[:music_type] = hash_id["music_type"] + @suggestions << sugg + end + raise + # @yelp = Food.yelp_find(@choices["suggestions"]).first["food_id"]) + # @spotify = Music.spotify_find(@choices["suggestions"]).first["music_type"], @choices["suggestions"].first["music_id"]) + end end + end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 788aa5b..0c9f2ea 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,9 @@ class UsersController < ApplicationController - skip_before_action :require_login, only: :index - def index end + + def show + + end end diff --git a/app/models/food.rb b/app/models/food.rb index 3bad6a9..8d84513 100644 --- a/app/models/food.rb +++ b/app/models/food.rb @@ -1,4 +1,6 @@ -class Food < ActiveRecord::Base +require 'yelp' + +class Food #< ActiveRecord::Base def self.yelp_find(business) Yelp.client.business(business) end diff --git a/app/models/music.rb b/app/models/music.rb index 26d1d33..dcab528 100644 --- a/app/models/music.rb +++ b/app/models/music.rb @@ -1,13 +1,13 @@ -class Music < ActiveRecord::Base - def self.spotify_search(type, id) +require 'rspotify' + +class Music #< ActiveRecord::Base + def self.spotify_find(type, id) if type == "album" RSpotify::Album.find(id) elsif type == "artist" RSpotify::Artist.find(id) elsif type == "track" RSpotify::Track.find(id) - elsif type == "playlist" - RSpotify::Playlist.find(id) end end end diff --git a/app/models/suggestions.rb b/app/models/suggestions.rb new file mode 100644 index 0000000..fea7e49 --- /dev/null +++ b/app/models/suggestions.rb @@ -0,0 +1,5 @@ +class Suggest + BASE_URL = +#/v1/suggestions/top + +end diff --git a/app/models/tunes_takeout.rb b/app/models/tunes_takeout.rb deleted file mode 100644 index 2375af4..0000000 --- a/app/models/tunes_takeout.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'httparty' -require 'yelp' -require 'rspotify' - -class TunesTakeout - BASE_URL = "https://tunes-takeout-api.herokuapp.com/" - - def initialize - - end - - # def self.yelp_search(city, query, limit, category = "restaurants") - # yelp_params = { term: query, - # limit: limit, - # category: category - # } - # - # Yelp.client.search(city, yelp_params) - # end - - def self.yelp_find(business) - Yelp.client.business(business) - end - - def self.spotify_search(type, id) - if type == "album" - RSpotify::Album.find(id) - elsif type == "artist" - RSpotify::Artist.find(id) - elsif type == "track" - RSpotify::Track.find(id) - elsif type == "playlist" - RSpotify::Playlist.find(id) - end - end - - def self.connect(query, limit) - response = HTTParty.get(BASE_URL + "v1/suggestions/search?query=#{query}&limit=#{limit}").parsed_response - # puts response - # puts "----------------" - # puts response[suggestions] - - yelp_business = self.yelp_find(response["suggestions"].first["food_id"]) - spotify_stuff = self.spotify_search(response["suggestions"].first["music_type"], response["suggestions"].first["music_id"]) - - puts "yelp: #{yelp_business.business.name} spotify: #{spotify_stuff.name}" - end -end diff --git a/app/models/user.rb b/app/models/user.rb index f6e4f71..ad1f027 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -21,18 +21,4 @@ def self.find_or_create_from_omniauth(auth_hash) end end - - def self.connect(query, limit) - response = HTTParty.get(BASE_URL + "v1/suggestions/search?query=#{query}&limit=#{limit}").parsed_response - - yelp_business = self.yelp_find(response["suggestions"].first["food_id"]) - spotify_stuff = self.spotify_search(response["suggestions"].first["music_type"], response["suggestions"].first["music_id"]) - - puts "yelp: #{yelp_business.business.name} spotify: #{spotify_stuff.name}" - end - - def self.suggestions(suggest) - response = HTTParty.get(BASE_URL + "v1/suggestions/#{suggest}").parsed_response - - end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 8b13789..bafc482 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1 +1 @@ - +

Top Suggestions

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 0affe3d..7ba3c99 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,7 +13,7 @@ <%= link_to "Home", root_path %> <%= link_to "Sign in with Spotify", '/auth/spotify' unless current_user %> <%= link_to "Log Out", logout_path, method: :delete if current_user %> - <%= link_to "suggestions", suggestions_path %> + <%= link_to "Suggestions", suggestions_path %> <%= yield %> diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb index d02da8d..d8cbcd7 100644 --- a/app/views/suggestions/index.html.erb +++ b/app/views/suggestions/index.html.erb @@ -1,6 +1,15 @@ -

Most Popular Suggestions!

-<%= form_tag suggestions_path do %> - <%= label_tag :food %> - <%= text_field_tag :food %> +<%= form_tag suggestions_path, method: :get do %> + <%= label_tag :query %> + <%= text_field_tag :query %> + + <%= label_tag :limit %> + <%= text_field_tag :limit %> + <%= submit_tag %> <% end %> + +<% if @yelp %> + You should go to <%= @yelp.business.name %> if you want <%= params[:query] %>. + While you are there, you should listen to the + <%= @choices["suggestions"].first["music_type"] %> <%= @spotify.name %>. +<% end %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 4703b01..14ca083 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1 +1,6 @@ -

Welcome to Tunes and Takeout!

+

Your Favorites

+ + diff --git a/db/migrate/20160518051610_create_foods.rb b/db/migrate/20160518051610_create_foods.rb deleted file mode 100644 index 5d62fcd..0000000 --- a/db/migrate/20160518051610_create_foods.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateFoods < ActiveRecord::Migration - def change - create_table :foods do |t| - - t.timestamps null: false - end - end -end diff --git a/db/migrate/20160518051627_create_musics.rb b/db/migrate/20160518051627_create_musics.rb deleted file mode 100644 index 2cc03f3..0000000 --- a/db/migrate/20160518051627_create_musics.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateMusics < ActiveRecord::Migration - def change - create_table :musics do |t| - - t.timestamps null: false - end - end -end diff --git a/lib/tunes_takeout.rb b/lib/tunes_takeout.rb new file mode 100644 index 0000000..b44faa7 --- /dev/null +++ b/lib/tunes_takeout.rb @@ -0,0 +1,23 @@ +require 'httparty' +require 'yelp' +require 'rspotify' + +module TunesTakeoutWrapper + BASE_URL = "https://tunes-takeout-api.herokuapp.com/" + + def self.yelp_find(business) + Yelp.client.business(business) + end + + def self.spotify_search(query, limit) + HTTParty.get(BASE_URL + "v1/suggestions/search?query=#{query}&limit=#{limit}").parsed_response + end + + def self.favorites(user_id) + response = HTTParty.get(BASE_URL + "v1/suggestions/#{suggest}").parsed_response + end + + def self.top_suggest(limit = 10) + + end +end diff --git a/test/fixtures/foods.yml b/test/fixtures/foods.yml deleted file mode 100644 index 937a0c0..0000000 --- a/test/fixtures/foods.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/fixtures/musics.yml b/test/fixtures/musics.yml deleted file mode 100644 index 937a0c0..0000000 --- a/test/fixtures/musics.yml +++ /dev/null @@ -1,11 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html - -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value diff --git a/test/models/food_test.rb b/test/models/food_test.rb deleted file mode 100644 index 8ad7dff..0000000 --- a/test/models/food_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class FoodTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/models/music_test.rb b/test/models/music_test.rb deleted file mode 100644 index c5c6737..0000000 --- a/test/models/music_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class MusicTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end From 3bb164ba33603cc56b8285825ed5d091fd723d22 Mon Sep 17 00:00:00 2001 From: Adriana Date: Wed, 18 May 2016 23:18:38 -0700 Subject: [PATCH 06/36] suggestions view --- app/controllers/home_controller.rb | 2 +- app/controllers/suggestions_controller.rb | 3 --- app/controllers/users_controller.rb | 2 +- app/models/suggestions.rb | 5 ----- app/views/home/index.html.erb | 5 +++++ app/views/suggestions/index.html.erb | 10 ++++++---- lib/tunes_takeout.rb | 6 +----- 7 files changed, 14 insertions(+), 19 deletions(-) delete mode 100644 app/models/suggestions.rb diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 7f15dce..7c68763 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -4,6 +4,6 @@ class HomeController < ApplicationController skip_before_action :require_login, only: :index def index - + # @top_suggestions = TunesTakeoutWrapper.top_suggest end end diff --git a/app/controllers/suggestions_controller.rb b/app/controllers/suggestions_controller.rb index 3a210c1..44b9d52 100644 --- a/app/controllers/suggestions_controller.rb +++ b/app/controllers/suggestions_controller.rb @@ -14,9 +14,6 @@ def index sugg[:music_type] = hash_id["music_type"] @suggestions << sugg end - raise - # @yelp = Food.yelp_find(@choices["suggestions"]).first["food_id"]) - # @spotify = Music.spotify_find(@choices["suggestions"]).first["music_type"], @choices["suggestions"].first["music_id"]) end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0c9f2ea..58fb3b9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,6 @@ class UsersController < ApplicationController def index - + end def show diff --git a/app/models/suggestions.rb b/app/models/suggestions.rb deleted file mode 100644 index fea7e49..0000000 --- a/app/models/suggestions.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Suggest - BASE_URL = -#/v1/suggestions/top - -end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index bafc482..43f63d4 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1 +1,6 @@

Top Suggestions

+ +<%# @top_suggestions.each do |top_suggestion| %> + <%#= top_suggestion %> + +<%# end %> diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb index d8cbcd7..cf42497 100644 --- a/app/views/suggestions/index.html.erb +++ b/app/views/suggestions/index.html.erb @@ -8,8 +8,10 @@ <%= submit_tag %> <% end %> -<% if @yelp %> - You should go to <%= @yelp.business.name %> if you want <%= params[:query] %>. - While you are there, you should listen to the - <%= @choices["suggestions"].first["music_type"] %> <%= @spotify.name %>. +<% if @suggestions %> + <% @suggestions.each do |suggestion| %> +

You should go to <%= suggestion[:business_name] %> if you want <%= params[:query] %>. + While you are there, you should listen to the + <%= suggestion[:music_type] %> <%= suggestion[:music_name] %>.

+ <% end %> <% end %> diff --git a/lib/tunes_takeout.rb b/lib/tunes_takeout.rb index b44faa7..af4e0d6 100644 --- a/lib/tunes_takeout.rb +++ b/lib/tunes_takeout.rb @@ -5,10 +5,6 @@ module TunesTakeoutWrapper BASE_URL = "https://tunes-takeout-api.herokuapp.com/" - def self.yelp_find(business) - Yelp.client.business(business) - end - def self.spotify_search(query, limit) HTTParty.get(BASE_URL + "v1/suggestions/search?query=#{query}&limit=#{limit}").parsed_response end @@ -18,6 +14,6 @@ def self.favorites(user_id) end def self.top_suggest(limit = 10) - + HTTParty.get(BASE_URL + "v1/suggestions/top?limit=#{limit}").parsed_response end end From 7f54bc275ded36cf12054b4f8ed7530fb8ab0dbc Mon Sep 17 00:00:00 2001 From: Adriana Date: Wed, 18 May 2016 23:40:33 -0700 Subject: [PATCH 07/36] trying to add top suggestions to home page --- app/controllers/home_controller.rb | 9 ++++++++- app/controllers/suggestions_controller.rb | 2 ++ app/views/home/index.html.erb | 6 +++--- config/application.rb | 3 +++ lib/tunes_takeout.rb | 6 +++++- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 7c68763..9f8378d 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -4,6 +4,13 @@ class HomeController < ApplicationController skip_before_action :require_login, only: :index def index - # @top_suggestions = TunesTakeoutWrapper.top_suggest + @top_suggestions = TunesTakeoutWrapper.top_suggest + @suggestion_ids = @top_suggestions["suggestions"] + + @top_array = [] + @suggestion_ids.each do |suggestion_id| + @top_array << TunesTakeoutWrapper.find_suggest(suggestion_id)["suggestion"] + end + raise end end diff --git a/app/controllers/suggestions_controller.rb b/app/controllers/suggestions_controller.rb index 44b9d52..c16c0d0 100644 --- a/app/controllers/suggestions_controller.rb +++ b/app/controllers/suggestions_controller.rb @@ -1,3 +1,5 @@ +require 'tunes_takeout' + class SuggestionsController < ApplicationController def index @choices = TunesTakeoutWrapper.spotify_search(params[:query], params[:limit]) diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 43f63d4..22502ec 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,6 +1,6 @@

Top Suggestions

-<%# @top_suggestions.each do |top_suggestion| %> - <%#= top_suggestion %> +<% @top_suggestions.each do |top_suggestion| %> + <%= top_suggestion %> -<%# end %> +<% end %> diff --git a/config/application.rb b/config/application.rb index a9448ac..88fc9b7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,6 +11,9 @@ module TunesTakeout class Application < Rails::Application + config.autoload_paths += %W(#{config.root}/lib) + config.autoload_paths += %W(#{config.root}/extras) + config.active_record.raise_in_transactional_callbacks = true end end diff --git a/lib/tunes_takeout.rb b/lib/tunes_takeout.rb index af4e0d6..252d2a9 100644 --- a/lib/tunes_takeout.rb +++ b/lib/tunes_takeout.rb @@ -10,10 +10,14 @@ def self.spotify_search(query, limit) end def self.favorites(user_id) - response = HTTParty.get(BASE_URL + "v1/suggestions/#{suggest}").parsed_response + HTTParty.get(BASE_URL + "v1/suggestions/#{suggest}").parsed_response end def self.top_suggest(limit = 10) HTTParty.get(BASE_URL + "v1/suggestions/top?limit=#{limit}").parsed_response end + + def self.find_suggest(suggestion_id) + HTTParty.get(BASE_URL + "v1/suggestions/#{suggestion_id}").parsed_response + end end From ced8d4ceb30bb2ac69767ba9dd797a9e566b34c3 Mon Sep 17 00:00:00 2001 From: Adriana Date: Thu, 19 May 2016 12:40:44 -0700 Subject: [PATCH 08/36] working with bootstrap and top suggestions --- app/controllers/home_controller.rb | 31 +++++++++++++++------ app/controllers/suggestions_controller.rb | 7 ++++- app/views/home/index.html.erb | 7 +++-- app/views/layouts/application.html.erb | 33 ++++++++++++++++------- app/views/suggestions/index.html.erb | 4 +-- lib/tunes_takeout.rb | 4 +-- 6 files changed, 59 insertions(+), 27 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 9f8378d..3bbfc6b 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -4,13 +4,28 @@ class HomeController < ApplicationController skip_before_action :require_login, only: :index def index - @top_suggestions = TunesTakeoutWrapper.top_suggest - @suggestion_ids = @top_suggestions["suggestions"] - - @top_array = [] - @suggestion_ids.each do |suggestion_id| - @top_array << TunesTakeoutWrapper.find_suggest(suggestion_id)["suggestion"] - end - raise + # @top_suggestions = TunesTakeoutWrapper.top_suggest + # @suggestion_ids = @top_suggestions["suggestions"] + # + # @top_ideas = [] + # @suggestion_ids.each do |suggestion_id| + # @top_ideas << TunesTakeoutWrapper.find_suggest(suggestion_id)["suggestion"] + # end + # + # @top_favorites = [] + # @top_ideas.each do |top_idea| + # top_sugg = {} + # yelp = Food.yelp_find(top_idea["food_id"]) + # spotify = Music.spotify_find(top_idea["music_type"], top_idea["music_id"]) + # top_sugg[:business_name] = yelp.business.name + # top_sugg[:business_image] = yelp.business.image_url + # top_sugg[:business_rating_image] = yelp.business.rating_img_url + # top_sugg[:business_phone] = yelp.business.phone + # top_sugg[:music_name] = spotify.name + # top_sugg[:music_type] = top_idea["music_type"] + # top_sugg[:music_image] = spotify.images[2]["url"] + # + # @top_favorites << top_sugg + # end end end diff --git a/app/controllers/suggestions_controller.rb b/app/controllers/suggestions_controller.rb index c16c0d0..accdf14 100644 --- a/app/controllers/suggestions_controller.rb +++ b/app/controllers/suggestions_controller.rb @@ -5,15 +5,20 @@ def index @choices = TunesTakeoutWrapper.spotify_search(params[:query], params[:limit]) if params[:query] @choices_hash = @choices["suggestions"] - @suggestions = [] + @suggestions = [] @choices_hash.each do |hash_id| sugg = {} yelp = Food.yelp_find(hash_id["food_id"]) spotify = Music.spotify_find(hash_id["music_type"], hash_id["music_id"]) sugg[:business_name] = yelp.business.name + sugg[:business_image] = yelp.business.image_url + sugg[:business_rating_image] = yelp.business.rating_img_url + sugg[:business_phone] = yelp.business.phone sugg[:music_name] = spotify.name sugg[:music_type] = hash_id["music_type"] + top_sugg[:music_image] = spotify.images[2]["url"] + @suggestions << sugg end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 22502ec..dbb52ff 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,6 +1,5 @@

Top Suggestions

-<% @top_suggestions.each do |top_suggestion| %> - <%= top_suggestion %> - -<% end %> +<%# @top_favorites.each do |top_favorite| %> + <%#= top_favorite[:business_name], top_favorite[:business_image]%> +<%# end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7ba3c99..502ae9b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -2,18 +2,31 @@ TunesTakeout - <%= stylesheet_link_tag 'application', media: 'all' %> - <%= javascript_include_tag 'application' %> + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> + - -

Tunes and Takeout

- <%= "Hi #{current_user.name}!" if current_user %> - <%= image_tag("#{current_user.image_url}", width: "70", height: "70", alt: "spotify avatar") if current_user %> - <%= link_to "Home", root_path %> - <%= link_to "Sign in with Spotify", '/auth/spotify' unless current_user %> - <%= link_to "Log Out", logout_path, method: :delete if current_user %> - <%= link_to "Suggestions", suggestions_path %> + + +
+
+

Tunes and Takeout

+

+ Info about Tunes and Takeout. Yay, it's looking like a real page! +

+
+
<%= yield %> diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb index cf42497..9971027 100644 --- a/app/views/suggestions/index.html.erb +++ b/app/views/suggestions/index.html.erb @@ -10,8 +10,8 @@ <% if @suggestions %> <% @suggestions.each do |suggestion| %> -

You should go to <%= suggestion[:business_name] %> if you want <%= params[:query] %>. +

<%= suggestion[:business_image] %> <%= suggestion[:business_rating_image] %> You should go to <%= suggestion[:business_name] %> if you want <%= params[:query] %>. While you are there, you should listen to the - <%= suggestion[:music_type] %> <%= suggestion[:music_name] %>.

+ <%= suggestion[:music_type] %> <%= suggestion[:music_name] %>. <%= suggestion[:music_image] %>

<% end %> <% end %> diff --git a/lib/tunes_takeout.rb b/lib/tunes_takeout.rb index 252d2a9..35a02e5 100644 --- a/lib/tunes_takeout.rb +++ b/lib/tunes_takeout.rb @@ -1,6 +1,6 @@ require 'httparty' -require 'yelp' -require 'rspotify' +# require 'yelp' +# require 'rspotify' module TunesTakeoutWrapper BASE_URL = "https://tunes-takeout-api.herokuapp.com/" From d6ca12d64a5f45e7463a3fbaaabc6c45be381744 Mon Sep 17 00:00:00 2001 From: Adriana Date: Thu, 19 May 2016 14:17:52 -0700 Subject: [PATCH 09/36] Added pictures for suggestions and top favorites --- app/controllers/home_controller.rb | 46 +++++++++++------------ app/controllers/suggestions_controller.rb | 4 +- app/views/home/index.html.erb | 14 +++++-- app/views/suggestions/index.html.erb | 8 ++-- 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 3bbfc6b..e2d5b46 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -4,28 +4,28 @@ class HomeController < ApplicationController skip_before_action :require_login, only: :index def index - # @top_suggestions = TunesTakeoutWrapper.top_suggest - # @suggestion_ids = @top_suggestions["suggestions"] - # - # @top_ideas = [] - # @suggestion_ids.each do |suggestion_id| - # @top_ideas << TunesTakeoutWrapper.find_suggest(suggestion_id)["suggestion"] - # end - # - # @top_favorites = [] - # @top_ideas.each do |top_idea| - # top_sugg = {} - # yelp = Food.yelp_find(top_idea["food_id"]) - # spotify = Music.spotify_find(top_idea["music_type"], top_idea["music_id"]) - # top_sugg[:business_name] = yelp.business.name - # top_sugg[:business_image] = yelp.business.image_url - # top_sugg[:business_rating_image] = yelp.business.rating_img_url - # top_sugg[:business_phone] = yelp.business.phone - # top_sugg[:music_name] = spotify.name - # top_sugg[:music_type] = top_idea["music_type"] - # top_sugg[:music_image] = spotify.images[2]["url"] - # - # @top_favorites << top_sugg - # end + @top_suggestions = TunesTakeoutWrapper.top_suggest + @suggestion_ids = @top_suggestions["suggestions"] + + @top_ideas = [] + @suggestion_ids.each do |suggestion_id| + @top_ideas << TunesTakeoutWrapper.find_suggest(suggestion_id)["suggestion"] + end + + @top_favorites = [] + @top_ideas.each do |top_idea| + top_sugg = {} + yelp = Food.yelp_find(top_idea["food_id"]) + spotify = Music.spotify_find(top_idea["music_type"], top_idea["music_id"]) + top_sugg[:business_name] = yelp.business.name + top_sugg[:business_image] = yelp.business.image_url + top_sugg[:business_rating_image] = yelp.business.rating_img_url + top_sugg[:business_phone] = yelp.business.phone + top_sugg[:music_name] = spotify.name + top_sugg[:music_type] = top_idea["music_type"] + # top_sugg[:music_image] = spotify.images[2]["url"] + + @top_favorites << top_sugg + end end end diff --git a/app/controllers/suggestions_controller.rb b/app/controllers/suggestions_controller.rb index accdf14..0a328d0 100644 --- a/app/controllers/suggestions_controller.rb +++ b/app/controllers/suggestions_controller.rb @@ -17,8 +17,8 @@ def index sugg[:business_phone] = yelp.business.phone sugg[:music_name] = spotify.name sugg[:music_type] = hash_id["music_type"] - top_sugg[:music_image] = spotify.images[2]["url"] - + # top_sugg[:music_image] = spotify.images[2]["url"] + @suggestions << sugg end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index dbb52ff..4f6a0ba 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,5 +1,13 @@

Top Suggestions

-<%# @top_favorites.each do |top_favorite| %> - <%#= top_favorite[:business_name], top_favorite[:business_image]%> -<%# end %> +<% @top_favorites.each do |top_favorite| %> +

+ <%= image_tag(top_favorite[:business_image], alt: "#{top_favorite[:business_image]} food picture") %> + <%= top_favorite[:business_name] %> + <%= image_tag(top_favorite[:business_rating_image], alt: "rating image") %> + You should listen to + <%= top_favorite[:music_name] %> + while you eat here! + <%#= top_favorite[:music_type] %> +

+<% end %> diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb index 9971027..537a39d 100644 --- a/app/views/suggestions/index.html.erb +++ b/app/views/suggestions/index.html.erb @@ -10,8 +10,10 @@ <% if @suggestions %> <% @suggestions.each do |suggestion| %> -

<%= suggestion[:business_image] %> <%= suggestion[:business_rating_image] %> You should go to <%= suggestion[:business_name] %> if you want <%= params[:query] %>. - While you are there, you should listen to the - <%= suggestion[:music_type] %> <%= suggestion[:music_name] %>. <%= suggestion[:music_image] %>

+

+ <%= image_tag(suggestion[:business_image], alt: "#{suggestion[:business_image]} food image") %> <%= image_tag(suggestion[:business_rating_image], alt: "rating image") %> You should go to <%= suggestion[:business_name] %> if you want <%= params[:query] %>. + While you are there, you should listen to the + <%= suggestion[:music_type] %> <%= suggestion[:music_name] %>. <%= suggestion[:music_image] %> +

<% end %> <% end %> From 8a02e3cf42d4daeff2e28962a9fea2e028cb5373 Mon Sep 17 00:00:00 2001 From: Adriana Date: Thu, 19 May 2016 15:41:00 -0700 Subject: [PATCH 10/36] added images for music, can click on all images to take you to yelp or spotify page --- app/controllers/home_controller.rb | 20 ++++++++++++++++--- app/views/home/index.html.erb | 6 ++++-- app/views/layouts/application.html.erb | 2 +- .../20160518053139_create_suggestions.rb | 10 ---------- 4 files changed, 22 insertions(+), 16 deletions(-) delete mode 100644 db/migrate/20160518053139_create_suggestions.rb diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index e2d5b46..70c9217 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -18,13 +18,27 @@ def index yelp = Food.yelp_find(top_idea["food_id"]) spotify = Music.spotify_find(top_idea["music_type"], top_idea["music_id"]) top_sugg[:business_name] = yelp.business.name + top_sugg[:business_url] = yelp.business.url top_sugg[:business_image] = yelp.business.image_url top_sugg[:business_rating_image] = yelp.business.rating_img_url top_sugg[:business_phone] = yelp.business.phone top_sugg[:music_name] = spotify.name - top_sugg[:music_type] = top_idea["music_type"] - # top_sugg[:music_image] = spotify.images[2]["url"] - + top_sugg[:music_type] = spotify.type + if spotify.type == "artist" + top_sugg[:music_artist] = nil + else + top_sugg[:music_artist] = spotify.artists[0].name + end + top_sugg[:music_url] = spotify.external_urls["spotify"] + if spotify.type == "album" + top_sugg[:music_image] = spotify.images[2]["url"] + elsif spotify.type == "artist" + top_sugg[:music_image] = "http://www.shootersconnectionstore.com/App_Themes/SC_Responsive/Images/no-thumbnail-available.png" + elsif spotify.type == "track" + top_sugg[:music_image] = spotify.album.images[2]["url"] + else + top_sugg[:music_image] = spotify.albums.images[2]["url"] + end @top_favorites << top_sugg end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 4f6a0ba..0cd5652 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -2,12 +2,14 @@ <% @top_favorites.each do |top_favorite| %>

- <%= image_tag(top_favorite[:business_image], alt: "#{top_favorite[:business_image]} food picture") %> + <%= link_to(image_tag(top_favorite[:business_image], alt: "#{top_favorite[:business_image]} food picture"), top_favorite[:business_url]) %> <%= top_favorite[:business_name] %> <%= image_tag(top_favorite[:business_rating_image], alt: "rating image") %> You should listen to - <%= top_favorite[:music_name] %> + <%= top_favorite[:music_name] %> by + <%= top_favorite[:music_artist] %> while you eat here! + <%= link_to(image_tag(top_favorite[:music_image], width: "64", height: "64"), top_favorite[:music_url]) %> <%#= top_favorite[:music_type] %>

<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 502ae9b..664e8f8 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -23,7 +23,7 @@

Tunes and Takeout

- Info about Tunes and Takeout. Yay, it's looking like a real page! +

Rock out, while you eat out!

diff --git a/db/migrate/20160518053139_create_suggestions.rb b/db/migrate/20160518053139_create_suggestions.rb deleted file mode 100644 index ce4cbf7..0000000 --- a/db/migrate/20160518053139_create_suggestions.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateSuggestions < ActiveRecord::Migration - def change - create_table :suggestions do |t| - t.string :suggestion_id - t.string :user_id - - t.timestamps null: false - end - end -end From 21d7ba0a5c4b4f6aba0785b664a101c53a6075e2 Mon Sep 17 00:00:00 2001 From: Adriana Date: Thu, 19 May 2016 15:45:32 -0700 Subject: [PATCH 11/36] When clicking user image or hi, you go to spotify overview page --- app/views/layouts/application.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 664e8f8..1bedb7a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -11,8 +11,8 @@
diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb index 537a39d..cae3c26 100644 --- a/app/views/suggestions/index.html.erb +++ b/app/views/suggestions/index.html.erb @@ -11,9 +11,19 @@ <% if @suggestions %> <% @suggestions.each do |suggestion| %>

- <%= image_tag(suggestion[:business_image], alt: "#{suggestion[:business_image]} food image") %> <%= image_tag(suggestion[:business_rating_image], alt: "rating image") %> You should go to <%= suggestion[:business_name] %> if you want <%= params[:query] %>. + <%= image_tag(suggestion[:business_image], alt: "#{suggestion[:business_image]} food image") %> + <%= image_tag(suggestion[:business_rating_image], alt: "rating image") %> + You should go to + <%= suggestion[:business_name] %> + if you want + <%= params[:query] %>. While you are there, you should listen to the - <%= suggestion[:music_type] %> <%= suggestion[:music_name] %>. <%= suggestion[:music_image] %> + <%= suggestion[:music_type] %> + <%= suggestion[:music_name] %> + by + <%= suggestion[:music_artist] %>. + <%= image_tag(suggestion[:music_image]) %> + <%= button_to "Add to Favorites", favorite_path(current_user.uid) %>

<% end %> <% end %> diff --git a/app/views/users/favorite.html.erb b/app/views/users/favorite.html.erb new file mode 100644 index 0000000..23c8f25 --- /dev/null +++ b/app/views/users/favorite.html.erb @@ -0,0 +1,4 @@ +

You've Just Added to Your Favorites!

+ +You've Just Added +<%= params[:suggestion] %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 14ca083..9771020 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,6 +1,6 @@

Your Favorites

- +

The Most Popular Suggestions

+<%# @user_favorites.each do |url| %> + <%#= @user_favorites %> +<%# end %> diff --git a/config/routes.rb b/config/routes.rb index 4bf74ba..4e42bec 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,7 @@ resources :users #:only[:show, :index] resources :suggestions + post "users/:user_id/favorites" => "users#favorite", as: :favorite get "/auth/spotify/callback" => "sessions#create" delete "/logout" => "sessions#destroy" diff --git a/lib/tunes_takeout.rb b/lib/tunes_takeout.rb index 35a02e5..8c93e53 100644 --- a/lib/tunes_takeout.rb +++ b/lib/tunes_takeout.rb @@ -10,7 +10,12 @@ def self.spotify_search(query, limit) end def self.favorites(user_id) - HTTParty.get(BASE_URL + "v1/suggestions/#{suggest}").parsed_response + HTTParty.get(BASE_URL + "/v1/users/#{user_id}/favorites").parsed_response + end + + def self.create_favorites(user_id, suggestion_id) + HTTParty.post(BASE_URL + "/v1/users/#{user_id}/favorites", :body => { :suggestion => suggestion_id }.to_json, + :headers => { 'Content-Type' => 'application/json' }).parsed_response end def self.top_suggest(limit = 10) From 0bfa37b8a907067df1c3913a7c6c8b27acd58b9b Mon Sep 17 00:00:00 2001 From: Adriana Date: Thu, 19 May 2016 20:55:23 -0700 Subject: [PATCH 13/36] cleaned up, redirected when you add, added a flash, saved to API --- app/controllers/users_controller.rb | 38 +++++++++++++++++++++++++- app/views/home/index.html.erb | 5 ++-- app/views/layouts/application.html.erb | 7 +++-- app/views/suggestions/index.html.erb | 13 +++++---- app/views/users/index.html.erb | 21 ++++++++++---- lib/tunes_takeout.rb | 2 +- 6 files changed, 68 insertions(+), 18 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 94771b8..0ac96a1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,10 +1,46 @@ class UsersController < ApplicationController def index - # @user_favorites = TunesTakeoutWrapper.favorites(current_user.uid) + @user_favorites = TunesTakeoutWrapper.favorites(current_user.uid) + @favorites = [] + @user_favorites["suggestions"].each do |user_favorite| + @favorites << TunesTakeoutWrapper.find_suggest(user_favorite)["suggestion"] + end + @your_favorites = [] + @favorites.each do |favorite| + fave_sugg = {} + yelp = Food.yelp_find(favorite["food_id"]) + spotify = Music.spotify_find(favorite["music_type"], favorite["music_id"]) + fave_sugg[:suggestion_id] = favorite["id"] + fave_sugg[:business_name] = yelp.business.name + fave_sugg[:business_url] = yelp.business.url + fave_sugg[:business_image] = yelp.business.image_url + fave_sugg[:business_rating_image] = yelp.business.rating_img_url + fave_sugg[:business_phone] = yelp.business.phone + fave_sugg[:music_name] = spotify.name + fave_sugg[:music_type] = spotify.type + if spotify.type == "artist" + fave_sugg[:music_artist] = nil + else + fave_sugg[:music_artist] = spotify.artists[0].name + end + fave_sugg[:music_url] = spotify.external_urls["spotify"] + if spotify.type == "album" + fave_sugg[:music_image] = spotify.images[2]["url"] + elsif spotify.type == "artist" + fave_sugg[:music_image] = "http://www.shootersconnectionstore.com/App_Themes/SC_Responsive/Images/no-thumbnail-available.png" + elsif spotify.type == "track" + fave_sugg[:music_image] = spotify.album.images[2]["url"] + else + fave_sugg[:music_image] = spotify.albums.images[2]["url"] + end + @your_favorites << fave_sugg + end end def favorite TunesTakeoutWrapper.create_favorites(current_user.uid, params[:suggestion]) + flash[:yay] = "New Favorite Saved!" + redirect_to users_path end def show diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 8be4369..1d5376b 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -2,14 +2,15 @@ <% @top_favorites.each do |top_favorite| %>

- <%= link_to(image_tag(top_favorite[:business_image], alt: "#{top_favorite[:business_image]} food picture"), top_favorite[:business_url]) %> + <%= link_to(image_tag(top_favorite[:business_image], alt: "#{top_favorite[:business_image]} food picture"), top_favorite[:business_url], target: '_blank') %> <%= top_favorite[:business_name] %> <%= image_tag(top_favorite[:business_rating_image], alt: "rating image") %> You should listen to <%= top_favorite[:music_name] %> by <%= top_favorite[:music_artist] %> while you eat here! - <%= link_to(image_tag(top_favorite[:music_image], width: "64", height: "64"), top_favorite[:music_url]) %> + <%= link_to(image_tag(top_favorite[:music_image], width: "64", height: "64", alt: "album image"), top_favorite[:music_url]) %> + <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: top_favorite[:suggestion_id] }, form: { "data-type" => "json"} %> <%#= top_favorite[:music_type] %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 88aca3d..2521cf1 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -29,11 +29,12 @@

+ <% flash.each do |key, msg| %> + <%= content_tag :div, msg, :id => key %> + <% end %> + <%= yield %> -<% flash.each do |key, msg| %> - <%= content_tag :div, msg, :id => key %> -<% end %> diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb index cae3c26..51f8a8d 100644 --- a/app/views/suggestions/index.html.erb +++ b/app/views/suggestions/index.html.erb @@ -1,9 +1,9 @@ <%= form_tag suggestions_path, method: :get do %> - <%= label_tag :query %> - <%= text_field_tag :query %> + <%= label_tag :query, "Food Craving" %> + <%= text_field_tag :query, '', :required => true %> <%= label_tag :limit %> - <%= text_field_tag :limit %> + <%= number_field_tag :limit, '', :required => true, min: 1, max: 100 %> <%= submit_tag %> <% end %> @@ -11,7 +11,7 @@ <% if @suggestions %> <% @suggestions.each do |suggestion| %>

- <%= image_tag(suggestion[:business_image], alt: "#{suggestion[:business_image]} food image") %> + <%= link_to(image_tag(suggestion[:business_image], alt: "#{suggestion[:business_image]} food image"), suggestion[:business_url], target: '_blank') %> <%= image_tag(suggestion[:business_rating_image], alt: "rating image") %> You should go to <%= suggestion[:business_name] %> @@ -22,8 +22,9 @@ <%= suggestion[:music_name] %> by <%= suggestion[:music_artist] %>. - <%= image_tag(suggestion[:music_image]) %> - <%= button_to "Add to Favorites", favorite_path(current_user.uid) %> + <%= link_to(image_tag(suggestion[:music_image], alt: "album image}"), suggestion[:music_url], target: '_blank') %> + + <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: suggestion[:suggestion_id] }, form: { "data-type" => "json"} %>

<% end %> <% end %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 9771020..67070b0 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,6 +1,17 @@ -

Your Favorites

+ -

The Most Popular Suggestions

-<%# @user_favorites.each do |url| %> - <%#= @user_favorites %> -<%# end %> +

Your Favorite Places to Eat and Accompanying Music

+ +<% @your_favorites.each do |your_favorite| %> +

+ <%= link_to(image_tag(your_favorite[:business_image], alt: "#{your_favorite[:business_image]} food picture"), your_favorite[:business_url], target: '_blank') %> + <%= your_favorite[:business_name] %> + <%= image_tag(your_favorite[:business_rating_image], alt: "rating image") %> + You should listen to + <%= your_favorite[:music_name] %> by + <%= your_favorite[:music_artist] %> + while you eat here! + <%= link_to(image_tag(your_favorite[:music_image], width: "64", height: "64"), your_favorite[:music_url], target: '_blank') %> + <%#= your_favorite[:music_type] %> +

+<% end %> diff --git a/lib/tunes_takeout.rb b/lib/tunes_takeout.rb index 8c93e53..71ae5ad 100644 --- a/lib/tunes_takeout.rb +++ b/lib/tunes_takeout.rb @@ -5,7 +5,7 @@ module TunesTakeoutWrapper BASE_URL = "https://tunes-takeout-api.herokuapp.com/" - def self.spotify_search(query, limit) + def self.spotify_search(query, limit = 10) HTTParty.get(BASE_URL + "v1/suggestions/search?query=#{query}&limit=#{limit}").parsed_response end From 9eb41cbaa6da601a3a619ccb79241d75d8bf6d7e Mon Sep 17 00:00:00 2001 From: Adriana Date: Thu, 19 May 2016 21:35:48 -0700 Subject: [PATCH 14/36] got delete favorite function to work. Added gem so that you can confirm delete --- Gemfile | 2 ++ app/controllers/users_controller.rb | 6 ++++++ app/views/users/index.html.erb | 2 ++ config/routes.rb | 6 ++++-- lib/tunes_takeout.rb | 4 ++++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 825b9e8..d78eac1 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,8 @@ gem 'httparty' gem 'yelp' +gem 'jquery-rails' + gem 'rspotify' gem 'omniauth' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0ac96a1..9390656 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -43,6 +43,12 @@ def favorite redirect_to users_path end + def destroy + TunesTakeoutWrapper.delete_favorites(current_user.uid, params[:suggestion]) + flash[:boo] = "Favorite Deleted" + redirect_to users_path + end + def show end diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 67070b0..b7e0f1b 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -12,6 +12,8 @@ <%= your_favorite[:music_artist] %> while you eat here! <%= link_to(image_tag(your_favorite[:music_image], width: "64", height: "64"), your_favorite[:music_url], target: '_blank') %> + + <%= button_to "Delete Favorite", favorites_path(current_user.uid), params: { suggestion: your_favorite[:suggestion_id] }, :method => :delete, data: {confirm: "Are you sure?"} %> <%#= your_favorite[:music_type] %>

<% end %> diff --git a/config/routes.rb b/config/routes.rb index 4e42bec..b3e977f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,10 +1,12 @@ Rails.application.routes.draw do root "home#index" - resources :users #:only[:show, :index] - resources :suggestions + resources :users, :only => [:show, :index] + resources :suggestions, :only => [:index] post "users/:user_id/favorites" => "users#favorite", as: :favorite + delete "users/:user_id/favorites" => "users#destroy", as: :favorites + get "/auth/spotify/callback" => "sessions#create" delete "/logout" => "sessions#destroy" diff --git a/lib/tunes_takeout.rb b/lib/tunes_takeout.rb index 71ae5ad..5381420 100644 --- a/lib/tunes_takeout.rb +++ b/lib/tunes_takeout.rb @@ -18,6 +18,10 @@ def self.create_favorites(user_id, suggestion_id) :headers => { 'Content-Type' => 'application/json' }).parsed_response end + def self.delete_favorites(user_id, suggestion_id) + HTTParty.delete(BASE_URL + "/v1/users/#{user_id}/favorites", :body => { :suggestion => suggestion_id }.to_json, :headers => { 'Content-Type' => 'application/json' }).parsed_response + end + def self.top_suggest(limit = 10) HTTParty.get(BASE_URL + "v1/suggestions/top?limit=#{limit}").parsed_response end From 6268e7aebbde909f4318f58e4f37964032ae83fc Mon Sep 17 00:00:00 2001 From: Adriana Date: Thu, 19 May 2016 21:58:18 -0700 Subject: [PATCH 15/36] Added if statements to favorites button if there is no user --- app/views/home/index.html.erb | 5 +++-- app/views/suggestions/index.html.erb | 4 +++- app/views/users/index.html.erb | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 1d5376b..c8f24f8 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -11,8 +11,9 @@ while you eat here! <%= link_to(image_tag(top_favorite[:music_image], width: "64", height: "64", alt: "album image"), top_favorite[:music_url]) %> - <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: top_favorite[:suggestion_id] }, form: { "data-type" => "json"} %> - + <% if !current_user.nil? %> + <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: top_favorite[:suggestion_id] }, form: { "data-type" => "json"} %> + <% end %> <%#= top_favorite[:music_type] %>

<% end %> diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb index 51f8a8d..5b39f27 100644 --- a/app/views/suggestions/index.html.erb +++ b/app/views/suggestions/index.html.erb @@ -24,7 +24,9 @@ <%= suggestion[:music_artist] %>. <%= link_to(image_tag(suggestion[:music_image], alt: "album image}"), suggestion[:music_url], target: '_blank') %> - <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: suggestion[:suggestion_id] }, form: { "data-type" => "json"} %> + <% if !current_user.nil? %> + <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: suggestion[:suggestion_id] }, form: { "data-type" => "json"} %> + <% end %>

<% end %> <% end %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index b7e0f1b..b3c7c0b 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -13,7 +13,9 @@ while you eat here! <%= link_to(image_tag(your_favorite[:music_image], width: "64", height: "64"), your_favorite[:music_url], target: '_blank') %> - <%= button_to "Delete Favorite", favorites_path(current_user.uid), params: { suggestion: your_favorite[:suggestion_id] }, :method => :delete, data: {confirm: "Are you sure?"} %> + <% if !current_user.nil? %> + <%= button_to "Delete Favorite", favorites_path(current_user.uid), params: { suggestion: your_favorite[:suggestion_id] }, :method => :delete, data: {confirm: "Are you sure?"} %> + <% end %> <%#= your_favorite[:music_type] %>

<% end %> From 7c7e63442e865e5cdc0327ac331ed95d496da36f Mon Sep 17 00:00:00 2001 From: Adriana Date: Fri, 20 May 2016 11:31:46 -0700 Subject: [PATCH 16/36] Adding partial form for all files --- app/views/home/index.html.erb | 24 ++++++++++++++---------- app/views/shared/_suggestions.html.erb | 12 ++++++++++++ lib/tunes_takeout.rb | 2 ++ 3 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 app/views/shared/_suggestions.html.erb diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index c8f24f8..d55647e 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,19 +1,23 @@

Top Suggestions

-<% @top_favorites.each do |top_favorite| %> +<%# @top_favorites.each do |top_favorite| %>

- <%= link_to(image_tag(top_favorite[:business_image], alt: "#{top_favorite[:business_image]} food picture"), top_favorite[:business_url], target: '_blank') %> - <%= top_favorite[:business_name] %> - <%= image_tag(top_favorite[:business_rating_image], alt: "rating image") %> - You should listen to - <%= top_favorite[:music_name] %> by - <%= top_favorite[:music_artist] %> - while you eat here! - <%= link_to(image_tag(top_favorite[:music_image], width: "64", height: "64", alt: "album image"), top_favorite[:music_url]) %> + <%#= link_to(image_tag(top_favorite[:business_image], alt: "#{top_favorite[:business_image]} food picture"), top_favorite[:business_url], target: '_blank') %> + <%#= top_favorite[:business_name] %> + <%#= image_tag(top_favorite[:business_rating_image], alt: "rating image") %> + + <%#= top_favorite[:music_name] %> by + <%#= top_favorite[:music_artist] %> + + <%#= link_to(image_tag(top_favorite[:music_image], width: "64", height: "64", alt: "album image"), top_favorite[:music_url]) %> + + <% @top_favorites.each do |top_favorite| %> + <%= render partial: "shared/suggestions", locals: { partial_variable: top_favorite } %> + <% end %> <% if !current_user.nil? %> <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: top_favorite[:suggestion_id] }, form: { "data-type" => "json"} %> <% end %> <%#= top_favorite[:music_type] %>

-<% end %> +<%# end %> diff --git a/app/views/shared/_suggestions.html.erb b/app/views/shared/_suggestions.html.erb new file mode 100644 index 0000000..c09a41c --- /dev/null +++ b/app/views/shared/_suggestions.html.erb @@ -0,0 +1,12 @@ +

+ <%= link_to(image_tag(partial_variable[:business_image], alt: "#{partial_variable[:business_image]} food picture"), partial_variable[:business_url], target: '_blank') %> + <%= partial_variable[:business_name] %> + <%= image_tag(partial_variable[:business_rating_image], alt: "rating image") %> + You should listen to + <%= partial_variable[:music_name] %> by + <%= partial_variable[:music_artist] %> + while you eat here! + <%= link_to(image_tag(partial_variable[:music_image], width: "64", height: "64"), partial_variable[:music_url], target: '_blank') %> + + <%#= partial_variable[:music_type] %> +

diff --git a/lib/tunes_takeout.rb b/lib/tunes_takeout.rb index 5381420..073d257 100644 --- a/lib/tunes_takeout.rb +++ b/lib/tunes_takeout.rb @@ -14,8 +14,10 @@ def self.favorites(user_id) end def self.create_favorites(user_id, suggestion_id) + #response = HTTParty.post(BASE_URL + "/v1/users/#{user_id}/favorites", :body => { :suggestion => suggestion_id }.to_json, :headers => { 'Content-Type' => 'application/json' }).parsed_response + #response.code end def self.delete_favorites(user_id, suggestion_id) From ab725c390ef660ca8b0a9b9214101f8deb92e98f Mon Sep 17 00:00:00 2001 From: Adriana Date: Fri, 20 May 2016 12:52:05 -0700 Subject: [PATCH 17/36] Added partial views --- app/views/home/index.html.erb | 16 ---------------- app/views/shared/_suggestions.html.erb | 3 +++ lib/tunes_takeout.rb | 3 +-- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index d55647e..f27e775 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,23 +1,7 @@

Top Suggestions

-<%# @top_favorites.each do |top_favorite| %>

- <%#= link_to(image_tag(top_favorite[:business_image], alt: "#{top_favorite[:business_image]} food picture"), top_favorite[:business_url], target: '_blank') %> - <%#= top_favorite[:business_name] %> - <%#= image_tag(top_favorite[:business_rating_image], alt: "rating image") %> - - <%#= top_favorite[:music_name] %> by - <%#= top_favorite[:music_artist] %> - - <%#= link_to(image_tag(top_favorite[:music_image], width: "64", height: "64", alt: "album image"), top_favorite[:music_url]) %> - <% @top_favorites.each do |top_favorite| %> <%= render partial: "shared/suggestions", locals: { partial_variable: top_favorite } %> <% end %> - - <% if !current_user.nil? %> - <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: top_favorite[:suggestion_id] }, form: { "data-type" => "json"} %> - <% end %> - <%#= top_favorite[:music_type] %>

-<%# end %> diff --git a/app/views/shared/_suggestions.html.erb b/app/views/shared/_suggestions.html.erb index c09a41c..5d781a8 100644 --- a/app/views/shared/_suggestions.html.erb +++ b/app/views/shared/_suggestions.html.erb @@ -8,5 +8,8 @@ while you eat here! <%= link_to(image_tag(partial_variable[:music_image], width: "64", height: "64"), partial_variable[:music_url], target: '_blank') %> + <% if !current_user.nil? %> + <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, form: { "data-type" => "json"} %> + <% end %> <%#= partial_variable[:music_type] %>

diff --git a/lib/tunes_takeout.rb b/lib/tunes_takeout.rb index 073d257..946aac8 100644 --- a/lib/tunes_takeout.rb +++ b/lib/tunes_takeout.rb @@ -15,8 +15,7 @@ def self.favorites(user_id) def self.create_favorites(user_id, suggestion_id) #response = - HTTParty.post(BASE_URL + "/v1/users/#{user_id}/favorites", :body => { :suggestion => suggestion_id }.to_json, - :headers => { 'Content-Type' => 'application/json' }).parsed_response + HTTParty.post(BASE_URL + "/v1/users/#{user_id}/favorites", :body => { :suggestion => suggestion_id }.to_json, :headers => { 'Content-Type' => 'application/json' }).parsed_response #response.code end From ed5bd30176fa927355f539bc0482aadad23c0a17 Mon Sep 17 00:00:00 2001 From: Adriana Date: Fri, 20 May 2016 13:00:03 -0700 Subject: [PATCH 18/36] Added partials to all index views --- app/views/suggestions/index.html.erb | 19 +------------------ app/views/users/index.html.erb | 20 ++++---------------- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb index 5b39f27..0fa3e61 100644 --- a/app/views/suggestions/index.html.erb +++ b/app/views/suggestions/index.html.erb @@ -10,23 +10,6 @@ <% if @suggestions %> <% @suggestions.each do |suggestion| %> -

- <%= link_to(image_tag(suggestion[:business_image], alt: "#{suggestion[:business_image]} food image"), suggestion[:business_url], target: '_blank') %> - <%= image_tag(suggestion[:business_rating_image], alt: "rating image") %> - You should go to - <%= suggestion[:business_name] %> - if you want - <%= params[:query] %>. - While you are there, you should listen to the - <%= suggestion[:music_type] %> - <%= suggestion[:music_name] %> - by - <%= suggestion[:music_artist] %>. - <%= link_to(image_tag(suggestion[:music_image], alt: "album image}"), suggestion[:music_url], target: '_blank') %> - - <% if !current_user.nil? %> - <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: suggestion[:suggestion_id] }, form: { "data-type" => "json"} %> - <% end %> -

+ <%= render partial: "shared/suggestions", locals: { partial_variable: suggestion } %> <% end %> <% end %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index b3c7c0b..60a149b 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -2,20 +2,8 @@

Your Favorite Places to Eat and Accompanying Music

-<% @your_favorites.each do |your_favorite| %> -

- <%= link_to(image_tag(your_favorite[:business_image], alt: "#{your_favorite[:business_image]} food picture"), your_favorite[:business_url], target: '_blank') %> - <%= your_favorite[:business_name] %> - <%= image_tag(your_favorite[:business_rating_image], alt: "rating image") %> - You should listen to - <%= your_favorite[:music_name] %> by - <%= your_favorite[:music_artist] %> - while you eat here! - <%= link_to(image_tag(your_favorite[:music_image], width: "64", height: "64"), your_favorite[:music_url], target: '_blank') %> - - <% if !current_user.nil? %> - <%= button_to "Delete Favorite", favorites_path(current_user.uid), params: { suggestion: your_favorite[:suggestion_id] }, :method => :delete, data: {confirm: "Are you sure?"} %> - <% end %> - <%#= your_favorite[:music_type] %> -

+<% if @your_favorites %> + <% @your_favorites.each do |your_favorite| %> + <%= render partial: "shared/suggestions", locals: { partial_variable: your_favorite } %> + <% end %> <% end %> From 338a047e8c0cd784969e53b7fbdcfd7c1383719c Mon Sep 17 00:00:00 2001 From: Adriana Date: Fri, 20 May 2016 13:30:31 -0700 Subject: [PATCH 19/36] Delete button shows for favorites, Add button shows on suggestions and top --- app/views/home/index.html.erb | 2 +- app/views/layouts/application.html.erb | 2 +- app/views/shared/_suggestions.html.erb | 7 +++++-- app/views/suggestions/index.html.erb | 2 +- app/views/users/index.html.erb | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index f27e775..b5464ab 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -2,6 +2,6 @@

<% @top_favorites.each do |top_favorite| %> - <%= render partial: "shared/suggestions", locals: { partial_variable: top_favorite } %> + <%= render partial: "shared/suggestions", locals: { partial_variable: top_favorite, delete_button: false } %> <% end %>

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2521cf1..b9e4a2f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -32,7 +32,7 @@ <% flash.each do |key, msg| %> <%= content_tag :div, msg, :id => key %> <% end %> - + <%= yield %> diff --git a/app/views/shared/_suggestions.html.erb b/app/views/shared/_suggestions.html.erb index 5d781a8..49a30c9 100644 --- a/app/views/shared/_suggestions.html.erb +++ b/app/views/shared/_suggestions.html.erb @@ -9,7 +9,10 @@ <%= link_to(image_tag(partial_variable[:music_image], width: "64", height: "64"), partial_variable[:music_url], target: '_blank') %> <% if !current_user.nil? %> - <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, form: { "data-type" => "json"} %> + <% if delete_button %> + <%= button_to "Delete Favorite", favorites_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, :method => :delete, data: {confirm: "Are you sure?"} %> + <% else %> + <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, form: { "data-type" => "json"} %> + <% end %> <% end %> - <%#= partial_variable[:music_type] %>

diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb index 0fa3e61..9eecb82 100644 --- a/app/views/suggestions/index.html.erb +++ b/app/views/suggestions/index.html.erb @@ -10,6 +10,6 @@ <% if @suggestions %> <% @suggestions.each do |suggestion| %> - <%= render partial: "shared/suggestions", locals: { partial_variable: suggestion } %> + <%= render partial: "shared/suggestions", locals: { partial_variable: suggestion, delete_button: false } %> <% end %> <% end %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index 60a149b..a3480d8 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -4,6 +4,6 @@ <% if @your_favorites %> <% @your_favorites.each do |your_favorite| %> - <%= render partial: "shared/suggestions", locals: { partial_variable: your_favorite } %> + <%= render partial: "shared/suggestions", locals: { partial_variable: your_favorite, delete_button: true } %> <% end %> <% end %> From a9e088a0f3776c0b9137ac701ca9c3e650674546 Mon Sep 17 00:00:00 2001 From: Adriana Date: Fri, 20 May 2016 13:46:24 -0700 Subject: [PATCH 20/36] Adding a new method to show the artist logo for sign in --- app/controllers/sessions_controller.rb | 4 ++ app/views/layouts/application.html.erb | 62 +++++++++++++------------- app/views/sessions/new.html.erb | 1 + 3 files changed, 36 insertions(+), 31 deletions(-) create mode 100644 app/views/sessions/new.html.erb diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index c71d8c1..8756793 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,6 +1,10 @@ class SessionsController < ApplicationController skip_before_action :require_login, only: [:new, :create] + def new + + end + def create auth_hash = request.env['omniauth.auth'] user = User.find_or_create_from_omniauth(auth_hash) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index b9e4a2f..8a533dd 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,40 +1,40 @@ - - TunesTakeout - - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> - <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> - <%= csrf_meta_tags %> + + TunesTakeout + + <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> + <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> + <%= csrf_meta_tags %> - - - -
-
-

Tunes and Takeout

-

-

Rock out, while you eat out!

-

-
-
- <% flash.each do |key, msg| %> - <%= content_tag :div, msg, :id => key %> - <% end %> + <% flash.each do |key, msg| %> + <%= content_tag :div, msg, :id => key %> + <% end %> -<%= yield %> + <%= yield %> - + diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb new file mode 100644 index 0000000..497ef97 --- /dev/null +++ b/app/views/sessions/new.html.erb @@ -0,0 +1 @@ +Sign in with Spotify From 57abd87e574fd5053905bf146df819f15d186720 Mon Sep 17 00:00:00 2001 From: Adriana Date: Fri, 20 May 2016 14:08:21 -0700 Subject: [PATCH 21/36] adding spotify image logo if not signed in --- app/assets/images/spotify_user_logo.jpeg | Bin 0 -> 6041 bytes app/views/layouts/application.html.erb | 13 ++++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 app/assets/images/spotify_user_logo.jpeg diff --git a/app/assets/images/spotify_user_logo.jpeg b/app/assets/images/spotify_user_logo.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..2afb1404cf65139aed55572a95469ad4da30f550 GIT binary patch literal 6041 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 + +

Tunes and Takeout

@@ -35,6 +43,5 @@ <%= yield %> - From a4e8b5ba6794e9495f88fda10e90a5aa2400f15a Mon Sep 17 00:00:00 2001 From: Adriana Date: Fri, 20 May 2016 14:18:45 -0700 Subject: [PATCH 22/36] Added phone number as well as formatted it --- app/views/shared/_suggestions.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/shared/_suggestions.html.erb b/app/views/shared/_suggestions.html.erb index 49a30c9..268b189 100644 --- a/app/views/shared/_suggestions.html.erb +++ b/app/views/shared/_suggestions.html.erb @@ -1,6 +1,7 @@

<%= link_to(image_tag(partial_variable[:business_image], alt: "#{partial_variable[:business_image]} food picture"), partial_variable[:business_url], target: '_blank') %> <%= partial_variable[:business_name] %> + <%= number_to_phone(partial_variable[:business_phone], area_code: true) %> <%= image_tag(partial_variable[:business_rating_image], alt: "rating image") %> You should listen to <%= partial_variable[:music_name] %> by From 21cbf554c16fefbc86047eb725247fd0721660ce Mon Sep 17 00:00:00 2001 From: Adriana Date: Fri, 20 May 2016 14:21:27 -0700 Subject: [PATCH 23/36] Added spotify.type requirement --- app/views/shared/_suggestions.html.erb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/shared/_suggestions.html.erb b/app/views/shared/_suggestions.html.erb index 268b189..c1feb80 100644 --- a/app/views/shared/_suggestions.html.erb +++ b/app/views/shared/_suggestions.html.erb @@ -3,7 +3,8 @@ <%= partial_variable[:business_name] %> <%= number_to_phone(partial_variable[:business_phone], area_code: true) %> <%= image_tag(partial_variable[:business_rating_image], alt: "rating image") %> - You should listen to + You should listen to the + <%= partial_variable[:music_type] %> by <%= partial_variable[:music_name] %> by <%= partial_variable[:music_artist] %> while you eat here! From fd5c0325e86b340ccf10a08dfbf1406b55eed769 Mon Sep 17 00:00:00 2001 From: Adriana Date: Fri, 20 May 2016 15:16:42 -0700 Subject: [PATCH 24/36] added an embedded software player that has album image or is just black if no image. Then linked to spotify page by artist name --- app/controllers/home_controller.rb | 2 ++ app/controllers/suggestions_controller.rb | 2 ++ app/controllers/users_controller.rb | 1 + app/views/shared/_suggestions.html.erb | 6 ++++-- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index edefaac..daab101 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -25,6 +25,8 @@ def index top_sugg[:business_phone] = yelp.business.phone top_sugg[:music_name] = spotify.name top_sugg[:music_type] = spotify.type + top_sugg[:music_embed] = spotify.uri + if spotify.type == "artist" top_sugg[:music_artist] = nil else diff --git a/app/controllers/suggestions_controller.rb b/app/controllers/suggestions_controller.rb index 3694288..f1ebfa6 100644 --- a/app/controllers/suggestions_controller.rb +++ b/app/controllers/suggestions_controller.rb @@ -19,6 +19,8 @@ def index sugg[:business_phone] = yelp.business.phone sugg[:music_name] = spotify.name sugg[:music_type] = spotify.type + sugg[:music_embed] = spotify.uri + if spotify.type == "artist" sugg[:music_artist] = nil else diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9390656..ca939db 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -18,6 +18,7 @@ def index fave_sugg[:business_phone] = yelp.business.phone fave_sugg[:music_name] = spotify.name fave_sugg[:music_type] = spotify.type + fave_sugg[:music_embed] = spotify.uri if spotify.type == "artist" fave_sugg[:music_artist] = nil else diff --git a/app/views/shared/_suggestions.html.erb b/app/views/shared/_suggestions.html.erb index c1feb80..20a3e2f 100644 --- a/app/views/shared/_suggestions.html.erb +++ b/app/views/shared/_suggestions.html.erb @@ -5,10 +5,12 @@ <%= image_tag(partial_variable[:business_rating_image], alt: "rating image") %> You should listen to the <%= partial_variable[:music_type] %> by - <%= partial_variable[:music_name] %> by + <%= link_to(partial_variable[:music_name], partial_variable[:music_url], target: '_blank') %> by <%= partial_variable[:music_artist] %> while you eat here! - <%= link_to(image_tag(partial_variable[:music_image], width: "64", height: "64"), partial_variable[:music_url], target: '_blank') %> + <%#= link_to(image_tag(partial_variable[:music_image], width: "64", height: "64"), partial_variable[:music_url], target: '_blank') %> + + <% if !current_user.nil? %> <% if delete_button %> From 55e0af2b9e7dd0a26ce8e863a0744c64ae7f92a6 Mon Sep 17 00:00:00 2001 From: Adriana Date: Fri, 20 May 2016 15:31:58 -0700 Subject: [PATCH 25/36] trying to add user logo if no one signed in --- ...potify_user_logo.jpeg => spotify-user-logo.jpeg} | Bin app/views/layouts/application.html.erb | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) rename app/assets/images/{spotify_user_logo.jpeg => spotify-user-logo.jpeg} (100%) diff --git a/app/assets/images/spotify_user_logo.jpeg b/app/assets/images/spotify-user-logo.jpeg similarity index 100% rename from app/assets/images/spotify_user_logo.jpeg rename to app/assets/images/spotify-user-logo.jpeg diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 709f8a7..e88c450 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -14,20 +14,20 @@

<% if current_user.nil? %> <%= link_to("Hello, please sign in!", "https://www.spotify.com/us/account/overview/") %> - <%= link_to(image_tag("/images/spotify_user_logo.jpeg", width: "64", height: "64", alt: "spotify avatar")," https://www.spotify.com/us/account/overview/") %> + <%= link_to(image_tag("/images/spotify-user-logo.jpeg", width: "64", height: "64", alt: "spotify avatar")," https://www.spotify.com/us/account/overview/") %> <% else %> <%= link_to("Hi #{current_user.name}!", "https://www.spotify.com/us/account/overview/") %> <%= link_to(image_tag("#{current_user.image_url}", width: "64", height: "64", alt: "spotify avatar")," https://www.spotify.com/us/account/overview/") %> <% end %> <%= link_to "Home", root_path %> - <%= link_to "Favorites", users_path %> + <%= link_to "Favorites", users_path if current_user %> <%= link_to "Sign in with Spotify", '/auth/spotify' unless current_user %> - <%= link_to "Suggestions", suggestions_path %> + <%= link_to "Suggestions", suggestions_path if current_user %> <%= link_to "Log Out", logout_path, method: :delete if current_user %>
- +

Tunes and Takeout

From c351bdc1dcb0275c3bad63e2803e1849dbef08d0 Mon Sep 17 00:00:00 2001 From: Adriana Date: Sat, 21 May 2016 12:18:17 -0700 Subject: [PATCH 26/36] cleaned up files from unneccessary data, made spotify image work when not signed in --- app/controllers/home_controller.rb | 6 +++--- app/controllers/suggestions_controller.rb | 6 ++---- app/controllers/users_controller.rb | 7 ++++--- app/views/layouts/application.html.erb | 2 +- app/views/shared/_suggestions.html.erb | 2 +- app/views/users/index.html.erb | 2 -- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index daab101..3735c7c 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -26,22 +26,22 @@ def index top_sugg[:music_name] = spotify.name top_sugg[:music_type] = spotify.type top_sugg[:music_embed] = spotify.uri + top_sugg[:music_url] = spotify.external_urls["spotify"] if spotify.type == "artist" top_sugg[:music_artist] = nil else top_sugg[:music_artist] = spotify.artists[0].name end - top_sugg[:music_url] = spotify.external_urls["spotify"] + if spotify.type == "album" top_sugg[:music_image] = spotify.images[2]["url"] elsif spotify.type == "artist" top_sugg[:music_image] = "http://www.shootersconnectionstore.com/App_Themes/SC_Responsive/Images/no-thumbnail-available.png" elsif spotify.type == "track" top_sugg[:music_image] = spotify.album.images[2]["url"] - else - top_sugg[:music_image] = spotify.albums.images[2]["url"] end + @top_favorites << top_sugg end end diff --git a/app/controllers/suggestions_controller.rb b/app/controllers/suggestions_controller.rb index f1ebfa6..8b82f6b 100644 --- a/app/controllers/suggestions_controller.rb +++ b/app/controllers/suggestions_controller.rb @@ -20,23 +20,21 @@ def index sugg[:music_name] = spotify.name sugg[:music_type] = spotify.type sugg[:music_embed] = spotify.uri + sugg[:music_url] = spotify.external_urls["spotify"] if spotify.type == "artist" sugg[:music_artist] = nil else sugg[:music_artist] = spotify.artists[0].name end - sugg[:music_url] = spotify.external_urls["spotify"] + if spotify.type == "album" sugg[:music_image] = spotify.images[2]["url"] elsif spotify.type == "artist" sugg[:music_image] = "http://www.shootersconnectionstore.com/App_Themes/SC_Responsive/Images/no-thumbnail-available.png" elsif spotify.type == "track" sugg[:music_image] = spotify.album.images[2]["url"] - else - sugg[:music_image] = spotify.albums.images[2]["url"] end - # sugg[:music_image] = spotify.images[2]["url"] @suggestions << sugg end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ca939db..c7f8bfa 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -19,21 +19,22 @@ def index fave_sugg[:music_name] = spotify.name fave_sugg[:music_type] = spotify.type fave_sugg[:music_embed] = spotify.uri + fave_sugg[:music_url] = spotify.external_urls["spotify"] + if spotify.type == "artist" fave_sugg[:music_artist] = nil else fave_sugg[:music_artist] = spotify.artists[0].name end - fave_sugg[:music_url] = spotify.external_urls["spotify"] + if spotify.type == "album" fave_sugg[:music_image] = spotify.images[2]["url"] elsif spotify.type == "artist" fave_sugg[:music_image] = "http://www.shootersconnectionstore.com/App_Themes/SC_Responsive/Images/no-thumbnail-available.png" elsif spotify.type == "track" fave_sugg[:music_image] = spotify.album.images[2]["url"] - else - fave_sugg[:music_image] = spotify.albums.images[2]["url"] end + @your_favorites << fave_sugg end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e88c450..daf4921 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -14,7 +14,7 @@
<% if current_user.nil? %> <%= link_to("Hello, please sign in!", "https://www.spotify.com/us/account/overview/") %> - <%= link_to(image_tag("/images/spotify-user-logo.jpeg", width: "64", height: "64", alt: "spotify avatar")," https://www.spotify.com/us/account/overview/") %> + <%= link_to(image_tag("/assets/spotify-user-logo.jpeg", width: "64", height: "64", alt: "spotify avatar")," https://www.spotify.com/us/account/overview/") %> <% else %> <%= link_to("Hi #{current_user.name}!", "https://www.spotify.com/us/account/overview/") %> <%= link_to(image_tag("#{current_user.image_url}", width: "64", height: "64", alt: "spotify avatar")," https://www.spotify.com/us/account/overview/") %> diff --git a/app/views/shared/_suggestions.html.erb b/app/views/shared/_suggestions.html.erb index 20a3e2f..480d31e 100644 --- a/app/views/shared/_suggestions.html.erb +++ b/app/views/shared/_suggestions.html.erb @@ -10,7 +10,7 @@ while you eat here! <%#= link_to(image_tag(partial_variable[:music_image], width: "64", height: "64"), partial_variable[:music_url], target: '_blank') %> - + <% if !current_user.nil? %> <% if delete_button %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index a3480d8..f661e92 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,5 +1,3 @@ - -

Your Favorite Places to Eat and Accompanying Music

<% if @your_favorites %> From 655ca3f477b586049a6ae86a7a2bf206ba92a54e Mon Sep 17 00:00:00 2001 From: Adriana Date: Sat, 21 May 2016 13:03:23 -0700 Subject: [PATCH 27/36] Added a flash error for creating and deleting favorites --- app/controllers/users_controller.rb | 16 ++++++++++++---- lib/tunes_takeout.rb | 8 ++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index c7f8bfa..427c5da 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -40,14 +40,22 @@ def index end def favorite - TunesTakeoutWrapper.create_favorites(current_user.uid, params[:suggestion]) - flash[:yay] = "New Favorite Saved!" + response = TunesTakeoutWrapper.create_favorites(current_user.uid, params[:suggestion]) + if response.code == 201 + flash[:yay] = "New Favorite Saved" + else + flash[:nope] = "Something Went Wrong" + end redirect_to users_path end def destroy - TunesTakeoutWrapper.delete_favorites(current_user.uid, params[:suggestion]) - flash[:boo] = "Favorite Deleted" + response = TunesTakeoutWrapper.delete_favorites(current_user.uid, params[:suggestion]) + if response.code == 204 + flash[:yay] = "Favorite Deleted #{response.code}" + else + flash[:nope] = "Something Went Wrong #{response.code}" + end redirect_to users_path end diff --git a/lib/tunes_takeout.rb b/lib/tunes_takeout.rb index 946aac8..78f6632 100644 --- a/lib/tunes_takeout.rb +++ b/lib/tunes_takeout.rb @@ -14,13 +14,13 @@ def self.favorites(user_id) end def self.create_favorites(user_id, suggestion_id) - #response = - HTTParty.post(BASE_URL + "/v1/users/#{user_id}/favorites", :body => { :suggestion => suggestion_id }.to_json, :headers => { 'Content-Type' => 'application/json' }).parsed_response - #response.code + response = HTTParty.post(BASE_URL + "/v1/users/#{user_id}/favorites", :body => { :suggestion => suggestion_id }.to_json, :headers => { 'Content-Type' => 'application/json' }) + return response end def self.delete_favorites(user_id, suggestion_id) - HTTParty.delete(BASE_URL + "/v1/users/#{user_id}/favorites", :body => { :suggestion => suggestion_id }.to_json, :headers => { 'Content-Type' => 'application/json' }).parsed_response + response = HTTParty.delete(BASE_URL + "/v1/users/#{user_id}/favorites", :body => { :suggestion => suggestion_id }.to_json, :headers => { 'Content-Type' => 'application/json' }) + return response end def self.top_suggest(limit = 10) From 71aa2b6df11ff806e887ea8cbd2558e3c57d6e6d Mon Sep 17 00:00:00 2001 From: Adriana Date: Sat, 21 May 2016 20:44:21 -0700 Subject: [PATCH 28/36] Added a bootstrap navbar --- app/views/layouts/application.html.erb | 34 ++++++++++++++++---------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index daf4921..21fefce 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -12,23 +12,31 @@
+ ::before

Tunes and Takeout

From bc4dc553027cfe1407396c5f2da39ceab6130248 Mon Sep 17 00:00:00 2001 From: Adriana Date: Sat, 21 May 2016 21:22:23 -0700 Subject: [PATCH 29/36] Adding bootstrap stylings --- app/assets/stylesheets/application.css | 18 ++-------- app/views/layouts/application.html.erb | 50 ++++++++++++-------------- 2 files changed, 26 insertions(+), 42 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index f9cd5b3..b47bcc8 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1,15 +1,3 @@ -/* - * 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. - * - *= require_tree . - *= require_self - */ +.fix-bs { + margin-top: 60px; +} diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 21fefce..36a3799 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -12,44 +12,40 @@

-
- ::before -
+
+

Tunes and Takeout

-

Rock out, while you eat out!

+ Rock out, while you eat out!

-
- <% flash.each do |key, msg| %> - <%= content_tag :div, msg, :id => key %> - <% end %> + <% flash.each do |key, msg| %> + <%= content_tag :div, msg, :id => key %> + <% end %> - <%= yield %> + <%= yield %> +
From 0a706842cf9434616b2f0cbe0c804b1f1a6ec16c Mon Sep 17 00:00:00 2001 From: Adriana Date: Sat, 21 May 2016 22:55:18 -0700 Subject: [PATCH 30/36] Added bootstrap styling --- app/assets/stylesheets/application.css | 8 +++- app/views/home/index.html.erb | 10 ++-- app/views/layouts/application.html.erb | 6 +-- app/views/shared/_suggestions.html.erb | 66 ++++++++++++++++++-------- app/views/suggestions/index.html.erb | 10 ++-- app/views/users/index.html.erb | 10 ++-- 6 files changed, 72 insertions(+), 38 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index b47bcc8..93a82af 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1,3 +1,7 @@ -.fix-bs { - margin-top: 60px; +.jumbo-fix { + margin-top: 110px; } + +h1, h2, h3, h4, h5, h6 { + text-align: center; + } diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index b5464ab..bc613ae 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,7 +1,7 @@

Top Suggestions

-

- <% @top_favorites.each do |top_favorite| %> - <%= render partial: "shared/suggestions", locals: { partial_variable: top_favorite, delete_button: false } %> - <% end %> -

+
+ <% @top_favorites.each do |top_favorite| %> + <%= render partial: "shared/suggestions", locals: { partial_variable: top_favorite, delete_button: false } %> + <% end %> +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 36a3799..6e95e49 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,7 +9,7 @@ - + -
-
+
+

Tunes and Takeout

Rock out, while you eat out! diff --git a/app/views/shared/_suggestions.html.erb b/app/views/shared/_suggestions.html.erb index 480d31e..f2b015f 100644 --- a/app/views/shared/_suggestions.html.erb +++ b/app/views/shared/_suggestions.html.erb @@ -1,22 +1,48 @@ -

- <%= link_to(image_tag(partial_variable[:business_image], alt: "#{partial_variable[:business_image]} food picture"), partial_variable[:business_url], target: '_blank') %> - <%= partial_variable[:business_name] %> - <%= number_to_phone(partial_variable[:business_phone], area_code: true) %> - <%= image_tag(partial_variable[:business_rating_image], alt: "rating image") %> - You should listen to the - <%= partial_variable[:music_type] %> by - <%= link_to(partial_variable[:music_name], partial_variable[:music_url], target: '_blank') %> by - <%= partial_variable[:music_artist] %> - while you eat here! - <%#= link_to(image_tag(partial_variable[:music_image], width: "64", height: "64"), partial_variable[:music_url], target: '_blank') %> - +

+
+ <%= link_to(image_tag(partial_variable[:business_image], alt: "#{partial_variable[:business_image]} food picture", class: "thumnail"), partial_variable[:business_url], target: '_blank') %> +
+

<%= partial_variable[:business_name] %>

+
+

+ <%= image_tag(partial_variable[:business_rating_image], alt: "rating image") %> +

+ <%= number_to_phone(partial_variable[:business_phone], area_code: true) %> +

+ You should listen to +

+ <%= link_to(partial_variable[:music_name], partial_variable[:music_url], target: '_blank') %> +

+

+ while you eat here! +

+

+ Artist: + <% if partial_variable[:music_type] == "artist" %> + <%= partial_variable[:music_name] %> + <% else %> + <%= partial_variable[:music_artist] %> + <% end %> +

+

+ Type: <%= (partial_variable[:music_type]).titleize %> +

+ <%#= link_to(image_tag(partial_variable[:music_image], width: "64", height: "64"), partial_variable[:music_url], target: '_blank') %> +

- <% if !current_user.nil? %> - <% if delete_button %> - <%= button_to "Delete Favorite", favorites_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, :method => :delete, data: {confirm: "Are you sure?"} %> - <% else %> - <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, form: { "data-type" => "json"} %> - <% end %> - <% end %> -

+

+ +

+ +
+ <% if !current_user.nil? %> + <% if delete_button %> + <%= button_to "Delete Favorite", favorites_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, :method => :delete, data: {confirm: "Are you sure?"} %> + <% else %> + <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, form: { "data-type" => "json"} %> + <% end %> + <% end %> +
+
+
diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb index 9eecb82..9c586c2 100644 --- a/app/views/suggestions/index.html.erb +++ b/app/views/suggestions/index.html.erb @@ -8,8 +8,10 @@ <%= submit_tag %> <% end %> -<% if @suggestions %> - <% @suggestions.each do |suggestion| %> - <%= render partial: "shared/suggestions", locals: { partial_variable: suggestion, delete_button: false } %> +
+ <% if @suggestions %> + <% @suggestions.each do |suggestion| %> + <%= render partial: "shared/suggestions", locals: { partial_variable: suggestion, delete_button: false } %> + <% end %> <% end %> -<% end %> +
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index f661e92..dc77b28 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,7 +1,9 @@

Your Favorite Places to Eat and Accompanying Music

-<% if @your_favorites %> - <% @your_favorites.each do |your_favorite| %> - <%= render partial: "shared/suggestions", locals: { partial_variable: your_favorite, delete_button: true } %> +
+ <% if @your_favorites %> + <% @your_favorites.each do |your_favorite| %> + <%= render partial: "shared/suggestions", locals: { partial_variable: your_favorite, delete_button: true } %> + <% end %> <% end %> -<% end %> +
From d13ce48333256433a6021796e1fa8cb6b7320bb1 Mon Sep 17 00:00:00 2001 From: Adriana Date: Sat, 21 May 2016 23:13:36 -0700 Subject: [PATCH 31/36] Added more styling in --- app/assets/stylesheets/application.css | 12 ++++++++++-- app/views/shared/_suggestions.html.erb | 10 +++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 93a82af..a128914 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -3,5 +3,13 @@ } h1, h2, h3, h4, h5, h6 { - text-align: center; - } + text-align: center; +} + +.card-h { + height: 55rem; +} + +body { + background-color: #ccc; +} diff --git a/app/views/shared/_suggestions.html.erb b/app/views/shared/_suggestions.html.erb index f2b015f..b2db8b5 100644 --- a/app/views/shared/_suggestions.html.erb +++ b/app/views/shared/_suggestions.html.erb @@ -1,5 +1,5 @@ -
+
<%= link_to(image_tag(partial_variable[:business_image], alt: "#{partial_variable[:business_image]} food picture", class: "thumnail"), partial_variable[:business_url], target: '_blank') %>
@@ -38,9 +38,13 @@
<% if !current_user.nil? %> <% if delete_button %> - <%= button_to "Delete Favorite", favorites_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, :method => :delete, data: {confirm: "Are you sure?"} %> + <%= button_to favorites_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, :method => :delete, data: {confirm: "Are you sure?"}, class: "btn btn-default" do %> + + <% end %> <% else %> - <%= button_to "Add to Favorites", favorite_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, form: { "data-type" => "json"} %> + <%= button_to favorite_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, form: { "data-type" => "json"}, class: "btn btn-default" do %> + + <% end %> <% end %> <% end %>
From 00d968e9d1e7f4e7ed64e704ea9966e7330516a8 Mon Sep 17 00:00:00 2001 From: Adriana Date: Sat, 21 May 2016 23:26:36 -0700 Subject: [PATCH 32/36] bootstrap --- app/assets/stylesheets/application.css | 7 ++++++- app/views/shared/_suggestions.html.erb | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index a128914..9c8ef3e 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -7,9 +7,14 @@ h1, h2, h3, h4, h5, h6 { } .card-h { - height: 55rem; + height: 65rem; + /*padding: 2rem 0rem;*/ } body { background-color: #ccc; } + +.card-p { + padding: 3rem 0rem; +} diff --git a/app/views/shared/_suggestions.html.erb b/app/views/shared/_suggestions.html.erb index b2db8b5..dae5e03 100644 --- a/app/views/shared/_suggestions.html.erb +++ b/app/views/shared/_suggestions.html.erb @@ -1,7 +1,7 @@
-
- <%= link_to(image_tag(partial_variable[:business_image], alt: "#{partial_variable[:business_image]} food picture", class: "thumnail"), partial_variable[:business_url], target: '_blank') %> +
+ <%= link_to(image_tag(partial_variable[:business_image], alt: "#{partial_variable[:business_image]} food picture", class: "thumbnail"), partial_variable[:business_url], target: '_blank') %>

<%= partial_variable[:business_name] %>

From 3912b432d208ba1dd18d79421d40959afd85fa78 Mon Sep 17 00:00:00 2001 From: Adriana Date: Sun, 22 May 2016 14:10:07 -0700 Subject: [PATCH 33/36] Added user test --- Gemfile | 9 ++++-- Gemfile.lock | 27 ++++++++++++++++ app/controllers/users_controller.rb | 4 +-- app/views/layouts/application.html.erb | 8 +++-- app/views/shared/_suggestions.html.erb | 4 +-- app/views/suggestions/index.html.erb | 2 ++ config/routes.rb | 4 +-- test/controllers/home_controller_test.rb | 14 ++++----- test/controllers/sessions_controller_test.rb | 14 ++++----- .../suggestions_controller_test.rb | 14 ++++----- test/controllers/users_controller_test.rb | 14 ++++----- test/fixtures/users.yml | 19 ++++++------ test/models/food_test.rb | 7 +++++ test/models/music_test.rb | 7 +++++ test/models/user_test.rb | 31 +++++++++++++++++-- test/test_helper.rb | 26 ++++++++++++++-- 16 files changed, 151 insertions(+), 53 deletions(-) create mode 100644 test/models/food_test.rb create mode 100644 test/models/music_test.rb diff --git a/Gemfile b/Gemfile index d78eac1..7fb3327 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,6 @@ gem 'omniauth-oauth2', '~> 1.3.1' gem 'pg', '~> 0.15' # Use jquery as the JavaScript library -gem 'jquery-rails' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. @@ -49,12 +48,17 @@ group :development, :test do gem 'byebug' gem 'simplecov', '~> 0.11.2' gem 'dotenv-rails' + gem 'pry-rails' + gem 'minitest-vcr' + gem 'minitest-reporters' + gem 'webmock' + gem 'vcr' end group :development do # Access an IRB console on exception pages or by using <%= console %> in views gem 'web-console', '~> 2.0' - gem "pry-rails" + # gem "pry-rails" gem "better_errors" gem "binding_of_caller" gem 'rails-erd' @@ -65,5 +69,4 @@ end group :production do gem 'rails_12factor' - # gem 'pg', '~> 0.15' end diff --git a/Gemfile.lock b/Gemfile.lock index 151bcdf..65d7680 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -36,6 +36,8 @@ 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) @@ -55,6 +57,8 @@ 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) @@ -69,6 +73,7 @@ GEM 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) @@ -92,7 +97,18 @@ GEM 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) @@ -166,6 +182,8 @@ GEM 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) @@ -198,11 +216,16 @@ 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) @@ -220,6 +243,8 @@ DEPENDENCIES httparty jbuilder (~> 2.0) jquery-rails + minitest-reporters + minitest-vcr omniauth omniauth-oauth2 (~> 1.3.1) omniauth-spotify @@ -234,7 +259,9 @@ DEPENDENCIES simplecov (~> 0.11.2) spring uglifier (>= 1.3.0) + vcr web-console (~> 2.0) + webmock yelp RUBY VERSION diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 427c5da..6e7290f 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -40,7 +40,7 @@ def index end def favorite - response = TunesTakeoutWrapper.create_favorites(current_user.uid, params[:suggestion]) + response = TunesTakeoutWrapper.create_favorites(current_user.uid, params[:suggestion_id]) if response.code == 201 flash[:yay] = "New Favorite Saved" else @@ -50,7 +50,7 @@ def favorite end def destroy - response = TunesTakeoutWrapper.delete_favorites(current_user.uid, params[:suggestion]) + response = TunesTakeoutWrapper.delete_favorites(current_user.uid, params[:suggestion_id]) if response.code == 204 flash[:yay] = "Favorite Deleted #{response.code}" else diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6e95e49..523ee3b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -40,8 +40,12 @@

- <% flash.each do |key, msg| %> - <%= content_tag :div, msg, :id => key %> + <% if !flash.empty? %> +
+ <% flash.each do |key, msg| %> + <%= content_tag :div, msg, :id => key %> + <% end %> +
<% end %> <%= yield %> diff --git a/app/views/shared/_suggestions.html.erb b/app/views/shared/_suggestions.html.erb index dae5e03..8c324a2 100644 --- a/app/views/shared/_suggestions.html.erb +++ b/app/views/shared/_suggestions.html.erb @@ -38,11 +38,11 @@
<% if !current_user.nil? %> <% if delete_button %> - <%= button_to favorites_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, :method => :delete, data: {confirm: "Are you sure?"}, class: "btn btn-default" do %> + <%= button_to favorites_path(partial_variable[:suggestion_id]), :method => :delete, data: {confirm: "Are you sure?"}, class: "btn btn-default" do %> <% end %> <% else %> - <%= button_to favorite_path(current_user.uid), params: { suggestion: partial_variable[:suggestion_id] }, form: { "data-type" => "json"}, class: "btn btn-default" do %> + <%= button_to favorite_path(partial_variable[:suggestion_id]), form: { "data-type" => "json"}, class: "btn btn-default" do %> <% end %> <% end %> diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb index 9c586c2..7efc124 100644 --- a/app/views/suggestions/index.html.erb +++ b/app/views/suggestions/index.html.erb @@ -8,6 +8,8 @@ <%= submit_tag %> <% end %> +
+
<% if @suggestions %> <% @suggestions.each do |suggestion| %> diff --git a/config/routes.rb b/config/routes.rb index b3e977f..c2424a5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,8 +4,8 @@ resources :users, :only => [:show, :index] resources :suggestions, :only => [:index] - post "users/:user_id/favorites" => "users#favorite", as: :favorite - delete "users/:user_id/favorites" => "users#destroy", as: :favorites + post "users/favorites/:suggestion_id" => "users#favorite", as: :favorite + delete "users/favorites/:suggestion_id" => "users#destroy", as: :favorites get "/auth/spotify/callback" => "sessions#create" delete "/logout" => "sessions#destroy" diff --git a/test/controllers/home_controller_test.rb b/test/controllers/home_controller_test.rb index 730478d..b935438 100644 --- a/test/controllers/home_controller_test.rb +++ b/test/controllers/home_controller_test.rb @@ -1,7 +1,7 @@ -require 'test_helper' - -class HomeControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end +# require 'test_helper' +# +# class HomeControllerTest < ActionController::TestCase +# # test "the truth" do +# # assert true +# # end +# end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb index d30ebc3..a3ff0db 100644 --- a/test/controllers/sessions_controller_test.rb +++ b/test/controllers/sessions_controller_test.rb @@ -1,7 +1,7 @@ -require 'test_helper' - -class SessionsControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end +# require 'test_helper' +# +# class SessionsControllerTest < ActionController::TestCase +# # test "the truth" do +# # assert true +# # end +# end diff --git a/test/controllers/suggestions_controller_test.rb b/test/controllers/suggestions_controller_test.rb index f4587a5..b248bbe 100644 --- a/test/controllers/suggestions_controller_test.rb +++ b/test/controllers/suggestions_controller_test.rb @@ -1,7 +1,7 @@ -require 'test_helper' - -class SuggestionsControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end +# require 'test_helper' +# +# class SuggestionsControllerTest < ActionController::TestCase +# # test "the truth" do +# # assert true +# # end +# end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index d23f182..37cd41e 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -1,7 +1,7 @@ -require 'test_helper' - -class UsersControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end +# require 'test_helper' +# +# class UsersControllerTest < ActionController::TestCase +# # test "the truth" do +# # assert true +# # end +# end diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 937a0c0..b14ee7f 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,11 +1,10 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html -# This model initially had no columns defined. If you add columns to the -# model remove the '{}' from the fixture names and add the columns immediately -# below each fixture, per the syntax in the comments below -# -one: {} -# column: value -# -two: {} -# column: value +known_user: + provider: "spotify" + uid: "dri19tcc" + name: Adriana Cannon + +unknown_user: + provider: "" + uid: "" + name: "" diff --git a/test/models/food_test.rb b/test/models/food_test.rb new file mode 100644 index 0000000..3fc78fc --- /dev/null +++ b/test/models/food_test.rb @@ -0,0 +1,7 @@ +# require 'test_helper' +# +# class FoodTest < ActiveSupport::TestCase +# # test "the truth" do +# # assert true +# # end +# end diff --git a/test/models/music_test.rb b/test/models/music_test.rb new file mode 100644 index 0000000..42383ae --- /dev/null +++ b/test/models/music_test.rb @@ -0,0 +1,7 @@ +# require 'test_helper' +# +# class MusicTest < ActiveSupport::TestCase +# # test "the truth" do +# # assert true +# # end +# end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 82f61e0..f39d771 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -1,7 +1,34 @@ require 'test_helper' class UserTest < ActiveSupport::TestCase - # test "the truth" do - # assert true + def setup + # @known = OmniAuth.config.mock_auth[:spotify_known] + @known = users(:known_user) + @unknown = OmniAuth.config.mock_auth[:spotify_unknown] + @unknown_with_uid = OmniAuth.config.mock_auth[:spotify_uid] + end + + test "can find an existing user given an oauth spotify hash" do + puts @known + assert_equal users(:known_user), User.find_or_create_from_omniauth(@known) + end + + # test "can make a new user given the oauth spotify hash of an unknown user" do + # assert_difference 'User.count', 1 do + # @user = User.find_or_create_from_omniauth @unknown + # end + # end + # + # test "uses oauth data to set user name, provider and uid for new users" do + # user = User.find_or_create_from_omniauth @unknown + # + # assert_equal @unknown['name'], user.name + # assert_equal @unknown['provider'], user.provider + # assert_equal @unknown['uid'], user.uid + # end + # + # test "prefers a top-level uid over a nested id when creating an oauth user" do + # user = User.find_or_create_from_omniauth @unknown_with_uid + # assert_equal @unknown_with_uid['uid'], user.uid # end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 92e39b2..81cc548 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,10 +1,32 @@ +SimpleCov.start 'rails' + ENV['RAILS_ENV'] ||= 'test' + require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +require 'minitest/spec' +require 'minispec-metadata' +require 'vcr' +require 'minitest-vcr' +require 'webmock/minitest' +require 'minitest/reporters' + +VCR.configure do |c| + c.cassette_library_dir = 'test/cassettes' + c.hook_into :webmock +end + +Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new +MinitestVcr::Spec.configure! + class ActiveSupport::TestCase - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all - # Add more helper methods to be used by all tests here... + OmniAuth.config.test_mode = true + OmniAuth.config.mock_auth[:spotify_known] = OmniAuth::AuthHash.new( { provider: 'spotify', info: { id: "known_user", display_name: "known user" } }) + + OmniAuth.config.mock_auth[:spotify_unknown] = OmniAuth::AuthHash.new( { provider: 'spotify', info: { id: "dri19tcc", display_name: "Adriana Cannon" } }) + + OmniAuth.config.mock_auth[:spotify_uid] = OmniAuth::AuthHash.new( { provider: 'spotify', uid: "preferred", info: { id: "not", display_name: " " } }) end From 0f0fb3001a4b454a7ea30336a5d06873b79d1fc2 Mon Sep 17 00:00:00 2001 From: Adriana Date: Sun, 22 May 2016 16:02:32 -0700 Subject: [PATCH 34/36] One passing users test --- app/controllers/sessions_controller.rb | 4 ++-- app/models/user.rb | 1 - test/fixtures/users.yml | 6 +++--- test/models/user_test.rb | 23 +++++++++++++---------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 8756793..1ca80e5 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -2,7 +2,7 @@ class SessionsController < ApplicationController skip_before_action :require_login, only: [:new, :create] def new - + end def create @@ -13,7 +13,7 @@ def create session[:user_id] = user.id redirect_to users_path else - flash[:error] = "Nope" + flash[:error] = "Nope #{auth_hash.inspect}" redirect_to root_path end end diff --git a/app/models/user.rb b/app/models/user.rb index ad1f027..b8949f1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -11,7 +11,6 @@ def self.find_or_create_from_omniauth(auth_hash) user.provider = auth_hash["provider"] user.name = auth_hash["info"]["name"] user.image_url = auth_hash["info"]["image"] - # user.email = auth_hash["info"]["email"] if user.save return user diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index b14ee7f..c819726 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -5,6 +5,6 @@ known_user: name: Adriana Cannon unknown_user: - provider: "" - uid: "" - name: "" + provider: "spotify" + uid: "1226771573" + name: "Suzanne Convertino Harrison" diff --git a/test/models/user_test.rb b/test/models/user_test.rb index f39d771..4dbe2ef 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -4,21 +4,24 @@ class UserTest < ActiveSupport::TestCase def setup # @known = OmniAuth.config.mock_auth[:spotify_known] @known = users(:known_user) - @unknown = OmniAuth.config.mock_auth[:spotify_unknown] - @unknown_with_uid = OmniAuth.config.mock_auth[:spotify_uid] + @auth_hash = {"info" => {"name" => "Adriana Cannon"}, "provider" => "spotify", "uid" => "dri19tcc"} + # @unknown = users(:unknown_user["info"]) + # @unknown_with_uid = OmniAuth.config.mock_auth[:spotify_uid] end test "can find an existing user given an oauth spotify hash" do - puts @known - assert_equal users(:known_user), User.find_or_create_from_omniauth(@known) + assert_equal @known, User.find_or_create_from_omniauth(@auth_hash) + end + + test "can make a new user given the oauth spotify hash of an unknown user" do + # puts "User count first is #{User.count}" + puts @unknown.inspect + assert_difference 'User.count', 1 do + @user = User.find_or_create_from_omniauth(@unknown) + # puts "User count after block is #{User.count}" + end end - # test "can make a new user given the oauth spotify hash of an unknown user" do - # assert_difference 'User.count', 1 do - # @user = User.find_or_create_from_omniauth @unknown - # end - # end - # # test "uses oauth data to set user name, provider and uid for new users" do # user = User.find_or_create_from_omniauth @unknown # From 7a6dcec82b1f63c300dcd30f650d55ec89699969 Mon Sep 17 00:00:00 2001 From: Adriana Date: Sun, 22 May 2016 17:50:22 -0700 Subject: [PATCH 35/36] Added food model testing --- test/cassettes/Food/Knows_phone_number.yml | 89 +++++++++++++++++++ test/cassettes/Food/Knows_the_name.yml | 89 +++++++++++++++++++ .../Food/Knows_the_name_of_the_restaurant.yml | 89 +++++++++++++++++++ .../Food/Knows_various_attributes.yml | 89 +++++++++++++++++++ test/models/food_test.rb | 25 ++++-- test/models/music_test.rb | 25 ++++-- test/models/user_test.rb | 31 +++---- 7 files changed, 404 insertions(+), 33 deletions(-) create mode 100644 test/cassettes/Food/Knows_phone_number.yml create mode 100644 test/cassettes/Food/Knows_the_name.yml create mode 100644 test/cassettes/Food/Knows_the_name_of_the_restaurant.yml create mode 100644 test/cassettes/Food/Knows_various_attributes.yml diff --git a/test/cassettes/Food/Knows_phone_number.yml b/test/cassettes/Food/Knows_phone_number.yml new file mode 100644 index 0000000..912806b --- /dev/null +++ b/test/cassettes/Food/Knows_phone_number.yml @@ -0,0 +1,89 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.yelp.com/v2/business/india-bistro-seattle + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Faraday v0.9.2 + Authorization: + - OAuth oauth_consumer_key="DOZfhe1yESBrcYsFC_c53g", oauth_nonce="60de4d6d8052a66973949fd358d8dca0", + oauth_signature="xGbFgK7qp%2FZqF12QpBUmi3Kwh%2FI%3D", oauth_signature_method="HMAC-SHA1", + oauth_timestamp="1463963887", oauth_token="-1E4rzH9gpDSawEw2r__LDIUlg04SqWq", + oauth_version="1.0" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Date: + - Mon, 23 May 2016 00:38:07 GMT + Content-Type: + - application/json; charset=UTF-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=da32194302de6a21a864a70ba1661d9f31463963887; expires=Tue, 23-May-17 + 00:38:07 GMT; path=/; domain=.yelp.com; HttpOnly + - bse=274c5c3d0c570df963dfe316bdee2799; Domain=.yelp.com; Path=/; HttpOnly + - yuv=MNb-Q2HNZDuQ00Kwyvk_goCi0F3wKH-gR-CvapUwXAlWsDxNxBfICLpwzujzzGx1D2Z5Vc97iNnL8kk1b1ALy8eNjBlmabKP; + Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Sun, 18-May-2036 00:38:07 + GMT + X-Node: + - 10-64-167-42-uswest1bprod + - api_com + Cache-Control: + - max-age=0, must-revalidate, no-cache, no-store, private + Expires: + - Mon, 23 May 2016 00:38:07 GMT + Pragma: + - no-cache + Vary: + - Accept-Encoding,User-Agent + X-Mode: + - ro + X-Proxied: + - 10-64-16-56-uswest1bprod + Server: + - cloudflare-nginx + Cf-Ray: + - 2a74717768841bc1-SEA + body: + encoding: ASCII-8BIT + string: '{"is_claimed": true, "rating": 3.5, "mobile_url": "http://m.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", + "rating_img_url": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png", + "review_count": 267, "name": "India Bistro", "rating_img_url_small": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/2e909d5d3536/ico/stars/v1/stars_small_3_half.png", + "url": "http://www.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", + "categories": [["Indian", "indpak"], ["Buffets", "buffets"]], "menu_date_updated": + 1455157947, "reviews": [{"rating": 4, "excerpt": "Ate dinner here last night. + Enjoyed the murg masala and the chicken coconut curry was delicious!\n\nDon''t + miss the garlic naan. Huge piece and I wish I had...", "time_created": 1458923372, + "rating_image_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png", + "rating_image_small_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png", + "user": {"image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", + "id": "6Xv5PcR-yAatNNOahI0gNw", "name": "Sarah F."}, "rating_image_large_url": + "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png", + "id": "EPBXa3ijwAaWlO87E91A2A"}], "phone": "2067835080", "snippet_text": "Ate + dinner here last night. Enjoyed the murg masala and the chicken coconut curry + was delicious!\n\nDon''t miss the garlic naan. Huge piece and I wish I had...", + "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/zr-A22q08n2GYI1CGW7yBQ/ms.jpg", + "snippet_image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", + "display_phone": "+1-206-783-5080", "rating_img_url_large": "https://s3-media3.fl.yelpcdn.com/assets/2/www/img/bd9b7a815d1b/ico/stars/v1/stars_large_3_half.png", + "menu_provider": "eat24", "id": "india-bistro-seattle", "is_closed": false, + "location": {"cross_streets": "N Ballard Ave \u0026 N 24th Ave", "city": "Seattle", + "display_address": ["2301 NW Market St", "Ballard", "Seattle, WA 98107"], + "geo_accuracy": 9.5, "neighborhoods": ["Ballard"], "postal_code": "98107", + "country_code": "US", "address": ["2301 NW Market St"], "coordinate": {"latitude": + 47.6684978107312, "longitude": -122.386471302877}, "state_code": "WA"}}' + http_version: + recorded_at: Mon, 23 May 2016 00:38:07 GMT +recorded_with: VCR 3.0.3 diff --git a/test/cassettes/Food/Knows_the_name.yml b/test/cassettes/Food/Knows_the_name.yml new file mode 100644 index 0000000..6999d7b --- /dev/null +++ b/test/cassettes/Food/Knows_the_name.yml @@ -0,0 +1,89 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.yelp.com/v2/business/india-bistro-seattle + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Faraday v0.9.2 + Authorization: + - OAuth oauth_consumer_key="DOZfhe1yESBrcYsFC_c53g", oauth_nonce="0714ef3487de888465ac0f40f3997ebc", + oauth_signature="H%2Bhf8cKeCyuiOEdsI9ZVLkaV77s%3D", oauth_signature_method="HMAC-SHA1", + oauth_timestamp="1463963886", oauth_token="-1E4rzH9gpDSawEw2r__LDIUlg04SqWq", + oauth_version="1.0" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Date: + - Mon, 23 May 2016 00:38:07 GMT + Content-Type: + - application/json; charset=UTF-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d43ad801fe44996b29f5dde41579c14f81463963886; expires=Tue, 23-May-17 + 00:38:06 GMT; path=/; domain=.yelp.com; HttpOnly + - bse=9ac0091762152f6d4a0b9c5439151d53; Domain=.yelp.com; Path=/; HttpOnly + - yuv=4gJdVytRV_s9Q5cG0k24KryuwGG__qS6biL2cBeKy63XoiEucnc2d7DhZxocoP5FBYKUszLydPD6tNpaqrAfkhXoYfgQklf1; + Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Sun, 18-May-2036 00:38:07 + GMT + X-Node: + - 10-64-106-52-uswest1aprod + - api_com + Cache-Control: + - max-age=0, must-revalidate, no-cache, no-store, private + Expires: + - Mon, 23 May 2016 00:38:07 GMT + Pragma: + - no-cache + Vary: + - Accept-Encoding,User-Agent + X-Mode: + - ro + X-Proxied: + - 10-64-16-235-uswest1bprod + Server: + - cloudflare-nginx + Cf-Ray: + - 2a7471757f3a0c47-SEA + body: + encoding: ASCII-8BIT + string: '{"is_claimed": true, "rating": 3.5, "mobile_url": "http://m.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", + "rating_img_url": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png", + "review_count": 267, "name": "India Bistro", "rating_img_url_small": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/2e909d5d3536/ico/stars/v1/stars_small_3_half.png", + "url": "http://www.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", + "categories": [["Indian", "indpak"], ["Buffets", "buffets"]], "menu_date_updated": + 1455157947, "reviews": [{"rating": 4, "excerpt": "Ate dinner here last night. + Enjoyed the murg masala and the chicken coconut curry was delicious!\n\nDon''t + miss the garlic naan. Huge piece and I wish I had...", "time_created": 1458923372, + "rating_image_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png", + "rating_image_small_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png", + "user": {"image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", + "id": "6Xv5PcR-yAatNNOahI0gNw", "name": "Sarah F."}, "rating_image_large_url": + "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png", + "id": "EPBXa3ijwAaWlO87E91A2A"}], "phone": "2067835080", "snippet_text": "Ate + dinner here last night. Enjoyed the murg masala and the chicken coconut curry + was delicious!\n\nDon''t miss the garlic naan. Huge piece and I wish I had...", + "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/zr-A22q08n2GYI1CGW7yBQ/ms.jpg", + "snippet_image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", + "display_phone": "+1-206-783-5080", "rating_img_url_large": "https://s3-media3.fl.yelpcdn.com/assets/2/www/img/bd9b7a815d1b/ico/stars/v1/stars_large_3_half.png", + "menu_provider": "eat24", "id": "india-bistro-seattle", "is_closed": false, + "location": {"cross_streets": "N Ballard Ave \u0026 N 24th Ave", "city": "Seattle", + "display_address": ["2301 NW Market St", "Ballard", "Seattle, WA 98107"], + "geo_accuracy": 9.5, "neighborhoods": ["Ballard"], "postal_code": "98107", + "country_code": "US", "address": ["2301 NW Market St"], "coordinate": {"latitude": + 47.6684978107312, "longitude": -122.386471302877}, "state_code": "WA"}}' + http_version: + recorded_at: Mon, 23 May 2016 00:38:07 GMT +recorded_with: VCR 3.0.3 diff --git a/test/cassettes/Food/Knows_the_name_of_the_restaurant.yml b/test/cassettes/Food/Knows_the_name_of_the_restaurant.yml new file mode 100644 index 0000000..54549bb --- /dev/null +++ b/test/cassettes/Food/Knows_the_name_of_the_restaurant.yml @@ -0,0 +1,89 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.yelp.com/v2/business/india-bistro-seattle + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Faraday v0.9.2 + Authorization: + - OAuth oauth_consumer_key="DOZfhe1yESBrcYsFC_c53g", oauth_nonce="0f8645697813984e893853cd54dd93c7", + oauth_signature="be8e8wwXsJQ2DBA0rWFhuGd0RAA%3D", oauth_signature_method="HMAC-SHA1", + oauth_timestamp="1463963674", oauth_token="-1E4rzH9gpDSawEw2r__LDIUlg04SqWq", + oauth_version="1.0" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Date: + - Mon, 23 May 2016 00:34:35 GMT + Content-Type: + - application/json; charset=UTF-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=d260435fda87aa86357824c5f1aad68e01463963675; expires=Tue, 23-May-17 + 00:34:35 GMT; path=/; domain=.yelp.com; HttpOnly + - bse=a48d483a1c345cde7c4a8ad3da959d73; Domain=.yelp.com; Path=/; HttpOnly + - yuv=Cf9RDZqXlEh1hmSFA95LoM5k2D7irbX9W04aTFF4NwZBQCv7sypsJIpyg3B0UuzgqEeFLZNjl0j7rnqtLvQFpBHjOrjRQ2dq; + Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Sun, 18-May-2036 00:34:35 + GMT + X-Node: + - api_com + - internalapi2-r3-sfo2 + Cache-Control: + - max-age=0, must-revalidate, no-cache, no-store, private + Expires: + - Mon, 23 May 2016 00:34:35 GMT + Pragma: + - no-cache + Vary: + - Accept-Encoding,User-Agent + X-Mode: + - ro + X-Proxied: + - extlb8-r11-sfo2 + Server: + - cloudflare-nginx + Cf-Ray: + - 2a746c4bd0802a1f-SEA + body: + encoding: ASCII-8BIT + string: '{"is_claimed": true, "rating": 3.5, "mobile_url": "http://m.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", + "rating_img_url": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png", + "review_count": 267, "name": "India Bistro", "rating_img_url_small": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/2e909d5d3536/ico/stars/v1/stars_small_3_half.png", + "url": "http://www.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", + "categories": [["Indian", "indpak"], ["Buffets", "buffets"]], "menu_date_updated": + 1455157947, "reviews": [{"rating": 4, "excerpt": "Ate dinner here last night. + Enjoyed the murg masala and the chicken coconut curry was delicious!\n\nDon''t + miss the garlic naan. Huge piece and I wish I had...", "time_created": 1458923372, + "rating_image_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png", + "rating_image_small_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png", + "user": {"image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", + "id": "6Xv5PcR-yAatNNOahI0gNw", "name": "Sarah F."}, "rating_image_large_url": + "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png", + "id": "EPBXa3ijwAaWlO87E91A2A"}], "phone": "2067835080", "snippet_text": "Ate + dinner here last night. Enjoyed the murg masala and the chicken coconut curry + was delicious!\n\nDon''t miss the garlic naan. Huge piece and I wish I had...", + "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/zr-A22q08n2GYI1CGW7yBQ/ms.jpg", + "snippet_image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", + "display_phone": "+1-206-783-5080", "rating_img_url_large": "https://s3-media3.fl.yelpcdn.com/assets/2/www/img/bd9b7a815d1b/ico/stars/v1/stars_large_3_half.png", + "menu_provider": "eat24", "id": "india-bistro-seattle", "is_closed": false, + "location": {"cross_streets": "N Ballard Ave \u0026 N 24th Ave", "city": "Seattle", + "display_address": ["2301 NW Market St", "Ballard", "Seattle, WA 98107"], + "geo_accuracy": 9.5, "neighborhoods": ["Ballard"], "postal_code": "98107", + "country_code": "US", "address": ["2301 NW Market St"], "coordinate": {"latitude": + 47.6684978107312, "longitude": -122.386471302877}, "state_code": "WA"}}' + http_version: + recorded_at: Mon, 23 May 2016 00:34:35 GMT +recorded_with: VCR 3.0.3 diff --git a/test/cassettes/Food/Knows_various_attributes.yml b/test/cassettes/Food/Knows_various_attributes.yml new file mode 100644 index 0000000..e80d2f1 --- /dev/null +++ b/test/cassettes/Food/Knows_various_attributes.yml @@ -0,0 +1,89 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.yelp.com/v2/business/india-bistro-seattle + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Faraday v0.9.2 + Authorization: + - OAuth oauth_consumer_key="DOZfhe1yESBrcYsFC_c53g", oauth_nonce="e7fc934177cd501441b2a8c3330c73ab", + oauth_signature="lk1CmUh46nxHle5dzTFRxg62VtA%3D", oauth_signature_method="HMAC-SHA1", + oauth_timestamp="1463964443", oauth_token="-1E4rzH9gpDSawEw2r__LDIUlg04SqWq", + oauth_version="1.0" + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + response: + status: + code: 200 + message: OK + headers: + Date: + - Mon, 23 May 2016 00:47:25 GMT + Content-Type: + - application/json; charset=UTF-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Set-Cookie: + - __cfduid=df4432ec795eb33621062348db058efba1463964444; expires=Tue, 23-May-17 + 00:47:24 GMT; path=/; domain=.yelp.com; HttpOnly + - bse=22b73f3796f38a8fd211f3e38ab87336; Domain=.yelp.com; Path=/; HttpOnly + - yuv=if3RljzwU2Kv-6uP0qy4ZC9kZJFHr6fsJdoYlu789245wYzZtXfPr5Bx9tP-IZRb0OHosbifODMzNLJNEmfwTKPq_uyhcenp; + Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Sun, 18-May-2036 00:47:25 + GMT + X-Node: + - api_com + - web112-r10-sfo2 + Cache-Control: + - max-age=0, must-revalidate, no-cache, no-store, private + Expires: + - Mon, 23 May 2016 00:47:25 GMT + Pragma: + - no-cache + Vary: + - Accept-Encoding,User-Agent + X-Mode: + - ro + X-Proxied: + - extlb7-r10-sfo2 + Server: + - cloudflare-nginx + Cf-Ray: + - 2a747f14ca182a8b-SEA + body: + encoding: ASCII-8BIT + string: '{"is_claimed": true, "rating": 3.5, "mobile_url": "http://m.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", + "rating_img_url": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png", + "review_count": 267, "name": "India Bistro", "rating_img_url_small": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/2e909d5d3536/ico/stars/v1/stars_small_3_half.png", + "url": "http://www.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", + "categories": [["Indian", "indpak"], ["Buffets", "buffets"]], "menu_date_updated": + 1455157947, "reviews": [{"rating": 4, "excerpt": "Ate dinner here last night. + Enjoyed the murg masala and the chicken coconut curry was delicious!\n\nDon''t + miss the garlic naan. Huge piece and I wish I had...", "time_created": 1458923372, + "rating_image_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png", + "rating_image_small_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png", + "user": {"image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", + "id": "6Xv5PcR-yAatNNOahI0gNw", "name": "Sarah F."}, "rating_image_large_url": + "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png", + "id": "EPBXa3ijwAaWlO87E91A2A"}], "phone": "2067835080", "snippet_text": "Ate + dinner here last night. Enjoyed the murg masala and the chicken coconut curry + was delicious!\n\nDon''t miss the garlic naan. Huge piece and I wish I had...", + "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/zr-A22q08n2GYI1CGW7yBQ/ms.jpg", + "snippet_image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", + "display_phone": "+1-206-783-5080", "rating_img_url_large": "https://s3-media3.fl.yelpcdn.com/assets/2/www/img/bd9b7a815d1b/ico/stars/v1/stars_large_3_half.png", + "menu_provider": "eat24", "id": "india-bistro-seattle", "is_closed": false, + "location": {"cross_streets": "N Ballard Ave \u0026 N 24th Ave", "city": "Seattle", + "display_address": ["2301 NW Market St", "Ballard", "Seattle, WA 98107"], + "geo_accuracy": 9.5, "neighborhoods": ["Ballard"], "postal_code": "98107", + "country_code": "US", "address": ["2301 NW Market St"], "coordinate": {"latitude": + 47.6684978107312, "longitude": -122.386471302877}, "state_code": "WA"}}' + http_version: + recorded_at: Mon, 23 May 2016 00:47:25 GMT +recorded_with: VCR 3.0.3 diff --git a/test/models/food_test.rb b/test/models/food_test.rb index 3fc78fc..6b19eef 100644 --- a/test/models/food_test.rb +++ b/test/models/food_test.rb @@ -1,7 +1,18 @@ -# require 'test_helper' -# -# class FoodTest < ActiveSupport::TestCase -# # test "the truth" do -# # assert true -# # end -# end +require 'test_helper' + +class FoodTest < ActiveSupport::TestCase + + describe "Food" do + before do + @food = Food.yelp_find("india-bistro-seattle") + end + + it "Knows various attributes", :vcr do + assert_equal @food.business.name, "India Bistro" + assert_equal @food.business.phone, "2067835080" + assert_equal @food.business.url, "http://www.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api&utm_medium=api_v2_business&utm_source=DOZfhe1yESBrcYsFC_c53g" + assert_equal @food.business.image_url, "https://s3-media2.fl.yelpcdn.com/bphoto/zr-A22q08n2GYI1CGW7yBQ/ms.jpg" + assert_equal @food.business.rating_img_url, "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png" + end + end +end diff --git a/test/models/music_test.rb b/test/models/music_test.rb index 42383ae..d4ad922 100644 --- a/test/models/music_test.rb +++ b/test/models/music_test.rb @@ -1,7 +1,18 @@ -# require 'test_helper' -# -# class MusicTest < ActiveSupport::TestCase -# # test "the truth" do -# # assert true -# # end -# end +require 'test_helper' + +class MusicTest < ActiveSupport::TestCase + describe "Music" do + before do + @music = Music.spotify_find("") + end + + it "Knows various attributes", :vcr do + assert_equal @food.business.name, "India Bistro" + assert_equal @food.business.phone, "2067835080" + assert_equal @food.business.url, "http://www.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api&utm_medium=api_v2_business&utm_source=DOZfhe1yESBrcYsFC_c53g" + assert_equal @food.business.image_url, "https://s3-media2.fl.yelpcdn.com/bphoto/zr-A22q08n2GYI1CGW7yBQ/ms.jpg" + assert_equal @food.business.rating_img_url, "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png" + end + end +end +end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 4dbe2ef..3551aa5 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -4,34 +4,27 @@ class UserTest < ActiveSupport::TestCase def setup # @known = OmniAuth.config.mock_auth[:spotify_known] @known = users(:known_user) - @auth_hash = {"info" => {"name" => "Adriana Cannon"}, "provider" => "spotify", "uid" => "dri19tcc"} - # @unknown = users(:unknown_user["info"]) - # @unknown_with_uid = OmniAuth.config.mock_auth[:spotify_uid] + @unknown = users(:unknown_user) end test "can find an existing user given an oauth spotify hash" do + @auth_hash = {"info" => {"name" => "Adriana Cannon"}, "provider" => "spotify", "uid" => "dri19tcc"} assert_equal @known, User.find_or_create_from_omniauth(@auth_hash) end test "can make a new user given the oauth spotify hash of an unknown user" do - # puts "User count first is #{User.count}" - puts @unknown.inspect + @auth_hash = {"info" => {"name" => "Chris Cannon"}, "provider" => "spotify", "uid" => "cannonc"} assert_difference 'User.count', 1 do - @user = User.find_or_create_from_omniauth(@unknown) - # puts "User count after block is #{User.count}" + @user = User.find_or_create_from_omniauth(@auth_hash) end end - # test "uses oauth data to set user name, provider and uid for new users" do - # user = User.find_or_create_from_omniauth @unknown - # - # assert_equal @unknown['name'], user.name - # assert_equal @unknown['provider'], user.provider - # assert_equal @unknown['uid'], user.uid - # end - # - # test "prefers a top-level uid over a nested id when creating an oauth user" do - # user = User.find_or_create_from_omniauth @unknown_with_uid - # assert_equal @unknown_with_uid['uid'], user.uid - # end + test "uses oauth data to set user name, provider and uid for new users" do + @auth_hash = {"info" => {"name" => "Suzanne Convertino Harrison"}, "provider" => "spotify", "uid" => "1226771573"} + user = User.find_or_create_from_omniauth(@auth_hash) + + assert_equal @unknown['name'], user.name + assert_equal @unknown['provider'], user.provider + assert_equal @unknown['uid'], user.uid + end end From 3a6a31a47083c305cb9289b86b2cb7f8833231d2 Mon Sep 17 00:00:00 2001 From: Adriana Date: Sun, 22 May 2016 20:20:56 -0700 Subject: [PATCH 36/36] testing --- app/controllers/sessions_controller.rb | 2 +- test/cassettes/Food/Knows_phone_number.yml | 89 ------- test/cassettes/Food/Knows_the_name.yml | 89 ------- .../Food/Knows_the_name_of_the_restaurant.yml | 89 ------- .../Food/Knows_various_attributes.yml | 26 +- .../Music/Knows_various_album_attributes.yml | 232 ++++++++++++++++++ .../Music/Knows_various_artist_attributes.yml | 232 ++++++++++++++++++ .../Music/Knows_various_track_attributes.yml | 232 ++++++++++++++++++ test/controllers/home_controller_test.rb | 21 +- test/controllers/sessions_controller_test.rb | 7 +- test/models/music_test.rb | 30 ++- 11 files changed, 754 insertions(+), 295 deletions(-) delete mode 100644 test/cassettes/Food/Knows_phone_number.yml delete mode 100644 test/cassettes/Food/Knows_the_name.yml delete mode 100644 test/cassettes/Food/Knows_the_name_of_the_restaurant.yml create mode 100644 test/cassettes/Music/Knows_various_album_attributes.yml create mode 100644 test/cassettes/Music/Knows_various_artist_attributes.yml create mode 100644 test/cassettes/Music/Knows_various_track_attributes.yml diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 1ca80e5..3886fda 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -13,7 +13,7 @@ def create session[:user_id] = user.id redirect_to users_path else - flash[:error] = "Nope #{auth_hash.inspect}" + flash[:notice] = "Nope" redirect_to root_path end end diff --git a/test/cassettes/Food/Knows_phone_number.yml b/test/cassettes/Food/Knows_phone_number.yml deleted file mode 100644 index 912806b..0000000 --- a/test/cassettes/Food/Knows_phone_number.yml +++ /dev/null @@ -1,89 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: https://api.yelp.com/v2/business/india-bistro-seattle - body: - encoding: US-ASCII - string: '' - headers: - User-Agent: - - Faraday v0.9.2 - Authorization: - - OAuth oauth_consumer_key="DOZfhe1yESBrcYsFC_c53g", oauth_nonce="60de4d6d8052a66973949fd358d8dca0", - oauth_signature="xGbFgK7qp%2FZqF12QpBUmi3Kwh%2FI%3D", oauth_signature_method="HMAC-SHA1", - oauth_timestamp="1463963887", oauth_token="-1E4rzH9gpDSawEw2r__LDIUlg04SqWq", - oauth_version="1.0" - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - response: - status: - code: 200 - message: OK - headers: - Date: - - Mon, 23 May 2016 00:38:07 GMT - Content-Type: - - application/json; charset=UTF-8 - Transfer-Encoding: - - chunked - Connection: - - keep-alive - Set-Cookie: - - __cfduid=da32194302de6a21a864a70ba1661d9f31463963887; expires=Tue, 23-May-17 - 00:38:07 GMT; path=/; domain=.yelp.com; HttpOnly - - bse=274c5c3d0c570df963dfe316bdee2799; Domain=.yelp.com; Path=/; HttpOnly - - yuv=MNb-Q2HNZDuQ00Kwyvk_goCi0F3wKH-gR-CvapUwXAlWsDxNxBfICLpwzujzzGx1D2Z5Vc97iNnL8kk1b1ALy8eNjBlmabKP; - Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Sun, 18-May-2036 00:38:07 - GMT - X-Node: - - 10-64-167-42-uswest1bprod - - api_com - Cache-Control: - - max-age=0, must-revalidate, no-cache, no-store, private - Expires: - - Mon, 23 May 2016 00:38:07 GMT - Pragma: - - no-cache - Vary: - - Accept-Encoding,User-Agent - X-Mode: - - ro - X-Proxied: - - 10-64-16-56-uswest1bprod - Server: - - cloudflare-nginx - Cf-Ray: - - 2a74717768841bc1-SEA - body: - encoding: ASCII-8BIT - string: '{"is_claimed": true, "rating": 3.5, "mobile_url": "http://m.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", - "rating_img_url": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png", - "review_count": 267, "name": "India Bistro", "rating_img_url_small": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/2e909d5d3536/ico/stars/v1/stars_small_3_half.png", - "url": "http://www.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", - "categories": [["Indian", "indpak"], ["Buffets", "buffets"]], "menu_date_updated": - 1455157947, "reviews": [{"rating": 4, "excerpt": "Ate dinner here last night. - Enjoyed the murg masala and the chicken coconut curry was delicious!\n\nDon''t - miss the garlic naan. Huge piece and I wish I had...", "time_created": 1458923372, - "rating_image_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png", - "rating_image_small_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png", - "user": {"image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", - "id": "6Xv5PcR-yAatNNOahI0gNw", "name": "Sarah F."}, "rating_image_large_url": - "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png", - "id": "EPBXa3ijwAaWlO87E91A2A"}], "phone": "2067835080", "snippet_text": "Ate - dinner here last night. Enjoyed the murg masala and the chicken coconut curry - was delicious!\n\nDon''t miss the garlic naan. Huge piece and I wish I had...", - "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/zr-A22q08n2GYI1CGW7yBQ/ms.jpg", - "snippet_image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", - "display_phone": "+1-206-783-5080", "rating_img_url_large": "https://s3-media3.fl.yelpcdn.com/assets/2/www/img/bd9b7a815d1b/ico/stars/v1/stars_large_3_half.png", - "menu_provider": "eat24", "id": "india-bistro-seattle", "is_closed": false, - "location": {"cross_streets": "N Ballard Ave \u0026 N 24th Ave", "city": "Seattle", - "display_address": ["2301 NW Market St", "Ballard", "Seattle, WA 98107"], - "geo_accuracy": 9.5, "neighborhoods": ["Ballard"], "postal_code": "98107", - "country_code": "US", "address": ["2301 NW Market St"], "coordinate": {"latitude": - 47.6684978107312, "longitude": -122.386471302877}, "state_code": "WA"}}' - http_version: - recorded_at: Mon, 23 May 2016 00:38:07 GMT -recorded_with: VCR 3.0.3 diff --git a/test/cassettes/Food/Knows_the_name.yml b/test/cassettes/Food/Knows_the_name.yml deleted file mode 100644 index 6999d7b..0000000 --- a/test/cassettes/Food/Knows_the_name.yml +++ /dev/null @@ -1,89 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: https://api.yelp.com/v2/business/india-bistro-seattle - body: - encoding: US-ASCII - string: '' - headers: - User-Agent: - - Faraday v0.9.2 - Authorization: - - OAuth oauth_consumer_key="DOZfhe1yESBrcYsFC_c53g", oauth_nonce="0714ef3487de888465ac0f40f3997ebc", - oauth_signature="H%2Bhf8cKeCyuiOEdsI9ZVLkaV77s%3D", oauth_signature_method="HMAC-SHA1", - oauth_timestamp="1463963886", oauth_token="-1E4rzH9gpDSawEw2r__LDIUlg04SqWq", - oauth_version="1.0" - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - response: - status: - code: 200 - message: OK - headers: - Date: - - Mon, 23 May 2016 00:38:07 GMT - Content-Type: - - application/json; charset=UTF-8 - Transfer-Encoding: - - chunked - Connection: - - keep-alive - Set-Cookie: - - __cfduid=d43ad801fe44996b29f5dde41579c14f81463963886; expires=Tue, 23-May-17 - 00:38:06 GMT; path=/; domain=.yelp.com; HttpOnly - - bse=9ac0091762152f6d4a0b9c5439151d53; Domain=.yelp.com; Path=/; HttpOnly - - yuv=4gJdVytRV_s9Q5cG0k24KryuwGG__qS6biL2cBeKy63XoiEucnc2d7DhZxocoP5FBYKUszLydPD6tNpaqrAfkhXoYfgQklf1; - Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Sun, 18-May-2036 00:38:07 - GMT - X-Node: - - 10-64-106-52-uswest1aprod - - api_com - Cache-Control: - - max-age=0, must-revalidate, no-cache, no-store, private - Expires: - - Mon, 23 May 2016 00:38:07 GMT - Pragma: - - no-cache - Vary: - - Accept-Encoding,User-Agent - X-Mode: - - ro - X-Proxied: - - 10-64-16-235-uswest1bprod - Server: - - cloudflare-nginx - Cf-Ray: - - 2a7471757f3a0c47-SEA - body: - encoding: ASCII-8BIT - string: '{"is_claimed": true, "rating": 3.5, "mobile_url": "http://m.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", - "rating_img_url": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png", - "review_count": 267, "name": "India Bistro", "rating_img_url_small": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/2e909d5d3536/ico/stars/v1/stars_small_3_half.png", - "url": "http://www.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", - "categories": [["Indian", "indpak"], ["Buffets", "buffets"]], "menu_date_updated": - 1455157947, "reviews": [{"rating": 4, "excerpt": "Ate dinner here last night. - Enjoyed the murg masala and the chicken coconut curry was delicious!\n\nDon''t - miss the garlic naan. Huge piece and I wish I had...", "time_created": 1458923372, - "rating_image_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png", - "rating_image_small_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png", - "user": {"image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", - "id": "6Xv5PcR-yAatNNOahI0gNw", "name": "Sarah F."}, "rating_image_large_url": - "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png", - "id": "EPBXa3ijwAaWlO87E91A2A"}], "phone": "2067835080", "snippet_text": "Ate - dinner here last night. Enjoyed the murg masala and the chicken coconut curry - was delicious!\n\nDon''t miss the garlic naan. Huge piece and I wish I had...", - "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/zr-A22q08n2GYI1CGW7yBQ/ms.jpg", - "snippet_image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", - "display_phone": "+1-206-783-5080", "rating_img_url_large": "https://s3-media3.fl.yelpcdn.com/assets/2/www/img/bd9b7a815d1b/ico/stars/v1/stars_large_3_half.png", - "menu_provider": "eat24", "id": "india-bistro-seattle", "is_closed": false, - "location": {"cross_streets": "N Ballard Ave \u0026 N 24th Ave", "city": "Seattle", - "display_address": ["2301 NW Market St", "Ballard", "Seattle, WA 98107"], - "geo_accuracy": 9.5, "neighborhoods": ["Ballard"], "postal_code": "98107", - "country_code": "US", "address": ["2301 NW Market St"], "coordinate": {"latitude": - 47.6684978107312, "longitude": -122.386471302877}, "state_code": "WA"}}' - http_version: - recorded_at: Mon, 23 May 2016 00:38:07 GMT -recorded_with: VCR 3.0.3 diff --git a/test/cassettes/Food/Knows_the_name_of_the_restaurant.yml b/test/cassettes/Food/Knows_the_name_of_the_restaurant.yml deleted file mode 100644 index 54549bb..0000000 --- a/test/cassettes/Food/Knows_the_name_of_the_restaurant.yml +++ /dev/null @@ -1,89 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: https://api.yelp.com/v2/business/india-bistro-seattle - body: - encoding: US-ASCII - string: '' - headers: - User-Agent: - - Faraday v0.9.2 - Authorization: - - OAuth oauth_consumer_key="DOZfhe1yESBrcYsFC_c53g", oauth_nonce="0f8645697813984e893853cd54dd93c7", - oauth_signature="be8e8wwXsJQ2DBA0rWFhuGd0RAA%3D", oauth_signature_method="HMAC-SHA1", - oauth_timestamp="1463963674", oauth_token="-1E4rzH9gpDSawEw2r__LDIUlg04SqWq", - oauth_version="1.0" - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - response: - status: - code: 200 - message: OK - headers: - Date: - - Mon, 23 May 2016 00:34:35 GMT - Content-Type: - - application/json; charset=UTF-8 - Transfer-Encoding: - - chunked - Connection: - - keep-alive - Set-Cookie: - - __cfduid=d260435fda87aa86357824c5f1aad68e01463963675; expires=Tue, 23-May-17 - 00:34:35 GMT; path=/; domain=.yelp.com; HttpOnly - - bse=a48d483a1c345cde7c4a8ad3da959d73; Domain=.yelp.com; Path=/; HttpOnly - - yuv=Cf9RDZqXlEh1hmSFA95LoM5k2D7irbX9W04aTFF4NwZBQCv7sypsJIpyg3B0UuzgqEeFLZNjl0j7rnqtLvQFpBHjOrjRQ2dq; - Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Sun, 18-May-2036 00:34:35 - GMT - X-Node: - - api_com - - internalapi2-r3-sfo2 - Cache-Control: - - max-age=0, must-revalidate, no-cache, no-store, private - Expires: - - Mon, 23 May 2016 00:34:35 GMT - Pragma: - - no-cache - Vary: - - Accept-Encoding,User-Agent - X-Mode: - - ro - X-Proxied: - - extlb8-r11-sfo2 - Server: - - cloudflare-nginx - Cf-Ray: - - 2a746c4bd0802a1f-SEA - body: - encoding: ASCII-8BIT - string: '{"is_claimed": true, "rating": 3.5, "mobile_url": "http://m.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", - "rating_img_url": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png", - "review_count": 267, "name": "India Bistro", "rating_img_url_small": "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/2e909d5d3536/ico/stars/v1/stars_small_3_half.png", - "url": "http://www.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", - "categories": [["Indian", "indpak"], ["Buffets", "buffets"]], "menu_date_updated": - 1455157947, "reviews": [{"rating": 4, "excerpt": "Ate dinner here last night. - Enjoyed the murg masala and the chicken coconut curry was delicious!\n\nDon''t - miss the garlic naan. Huge piece and I wish I had...", "time_created": 1458923372, - "rating_image_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/c2f3dd9799a5/ico/stars/v1/stars_4.png", - "rating_image_small_url": "https://s3-media4.fl.yelpcdn.com/assets/2/www/img/f62a5be2f902/ico/stars/v1/stars_small_4.png", - "user": {"image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", - "id": "6Xv5PcR-yAatNNOahI0gNw", "name": "Sarah F."}, "rating_image_large_url": - "https://s3-media2.fl.yelpcdn.com/assets/2/www/img/ccf2b76faa2c/ico/stars/v1/stars_large_4.png", - "id": "EPBXa3ijwAaWlO87E91A2A"}], "phone": "2067835080", "snippet_text": "Ate - dinner here last night. Enjoyed the murg masala and the chicken coconut curry - was delicious!\n\nDon''t miss the garlic naan. Huge piece and I wish I had...", - "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/zr-A22q08n2GYI1CGW7yBQ/ms.jpg", - "snippet_image_url": "http://s3-media1.fl.yelpcdn.com/photo/w58cMKJawxivNw8nmeKMRA/ms.jpg", - "display_phone": "+1-206-783-5080", "rating_img_url_large": "https://s3-media3.fl.yelpcdn.com/assets/2/www/img/bd9b7a815d1b/ico/stars/v1/stars_large_3_half.png", - "menu_provider": "eat24", "id": "india-bistro-seattle", "is_closed": false, - "location": {"cross_streets": "N Ballard Ave \u0026 N 24th Ave", "city": "Seattle", - "display_address": ["2301 NW Market St", "Ballard", "Seattle, WA 98107"], - "geo_accuracy": 9.5, "neighborhoods": ["Ballard"], "postal_code": "98107", - "country_code": "US", "address": ["2301 NW Market St"], "coordinate": {"latitude": - 47.6684978107312, "longitude": -122.386471302877}, "state_code": "WA"}}' - http_version: - recorded_at: Mon, 23 May 2016 00:34:35 GMT -recorded_with: VCR 3.0.3 diff --git a/test/cassettes/Food/Knows_various_attributes.yml b/test/cassettes/Food/Knows_various_attributes.yml index e80d2f1..25c918d 100644 --- a/test/cassettes/Food/Knows_various_attributes.yml +++ b/test/cassettes/Food/Knows_various_attributes.yml @@ -10,9 +10,9 @@ http_interactions: User-Agent: - Faraday v0.9.2 Authorization: - - OAuth oauth_consumer_key="DOZfhe1yESBrcYsFC_c53g", oauth_nonce="e7fc934177cd501441b2a8c3330c73ab", - oauth_signature="lk1CmUh46nxHle5dzTFRxg62VtA%3D", oauth_signature_method="HMAC-SHA1", - oauth_timestamp="1463964443", oauth_token="-1E4rzH9gpDSawEw2r__LDIUlg04SqWq", + - OAuth oauth_consumer_key="DOZfhe1yESBrcYsFC_c53g", oauth_nonce="44f255003b6c506b60572d1c5f6a657e", + oauth_signature="jeTuSaWHTh0QQiHQPEViBGrWwlA%3D", oauth_signature_method="HMAC-SHA1", + oauth_timestamp="1463967058", oauth_token="-1E4rzH9gpDSawEw2r__LDIUlg04SqWq", oauth_version="1.0" Accept-Encoding: - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 @@ -24,7 +24,7 @@ http_interactions: message: OK headers: Date: - - Mon, 23 May 2016 00:47:25 GMT + - Mon, 23 May 2016 01:30:59 GMT Content-Type: - application/json; charset=UTF-8 Transfer-Encoding: @@ -32,19 +32,19 @@ http_interactions: Connection: - keep-alive Set-Cookie: - - __cfduid=df4432ec795eb33621062348db058efba1463964444; expires=Tue, 23-May-17 - 00:47:24 GMT; path=/; domain=.yelp.com; HttpOnly - - bse=22b73f3796f38a8fd211f3e38ab87336; Domain=.yelp.com; Path=/; HttpOnly - - yuv=if3RljzwU2Kv-6uP0qy4ZC9kZJFHr6fsJdoYlu789245wYzZtXfPr5Bx9tP-IZRb0OHosbifODMzNLJNEmfwTKPq_uyhcenp; - Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Sun, 18-May-2036 00:47:25 + - __cfduid=dab968353636eca73d2dba5de4a5f35a41463967059; expires=Tue, 23-May-17 + 01:30:59 GMT; path=/; domain=.yelp.com; HttpOnly + - bse=f94dcf01013d1838bb45ff7ce987a4af; Domain=.yelp.com; Path=/; HttpOnly + - yuv=VjPpd-t7Hy2DvptDaGD8iLMM4ovKSco_O2MFyqRM9o1598U7MVipVB4ZeVtmmq1_f_N8a3MTqsMUu0zP1AZOXld258L2-xw2; + Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Sun, 18-May-2036 01:30:59 GMT X-Node: - api_com - - web112-r10-sfo2 + - web63-r7-sfo2 Cache-Control: - max-age=0, must-revalidate, no-cache, no-store, private Expires: - - Mon, 23 May 2016 00:47:25 GMT + - Mon, 23 May 2016 01:30:59 GMT Pragma: - no-cache Vary: @@ -56,7 +56,7 @@ http_interactions: Server: - cloudflare-nginx Cf-Ray: - - 2a747f14ca182a8b-SEA + - 2a74bee9c5fb1bd9-SEA body: encoding: ASCII-8BIT string: '{"is_claimed": true, "rating": 3.5, "mobile_url": "http://m.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api\u0026utm_medium=api_v2_business\u0026utm_source=DOZfhe1yESBrcYsFC_c53g", @@ -85,5 +85,5 @@ http_interactions: "country_code": "US", "address": ["2301 NW Market St"], "coordinate": {"latitude": 47.6684978107312, "longitude": -122.386471302877}, "state_code": "WA"}}' http_version: - recorded_at: Mon, 23 May 2016 00:47:25 GMT + recorded_at: Mon, 23 May 2016 01:30:59 GMT recorded_with: VCR 3.0.3 diff --git a/test/cassettes/Music/Knows_various_album_attributes.yml b/test/cassettes/Music/Knows_various_album_attributes.yml new file mode 100644 index 0000000..4261784 --- /dev/null +++ b/test/cassettes/Music/Knows_various_album_attributes.yml @@ -0,0 +1,232 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.spotify.com/v1/tracks/0fDFzVTG8c2fW9EM5f1RHM + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Mon, 23 May 2016 01:31:59 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=600 + Cache-Control: + - public, max-age=7200 + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET, POST, OPTIONS, PUT, DELETE + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Max-Age: + - '604800' + Access-Control-Allow-Headers: + - Accept, Authorization, Origin, Content-Type + Content-Encoding: + - gzip + X-Content-Type-Options: + - nosniff + Strict-Transport-Security: + - max-age=31536000; + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAAOxVyXLaQBC95ytUOjvWaJe42YCBBDAxeIlTKWo0GpmJkZC1 + eC3/e6QngY0DDqkccsnlldTdev2mp7v19EGSZDr38lCWGtJT8bZ8n2YPMS+N + tXuv9t1SMafenE9DmlzzLC1DvknywYm8V+ApcFLiYRt4DIT3sFNi8wDYB8Lb + hLf5FXhZYuszEN4WeNpNIJ7HZyUe9YD4tlMh8naHQDB0oac3BuLbHmL6YOhX + z4gZIPsAlsFFiUMoHELPELmG0DOC/hHiR+AcdYGIH4FhjJOOoaGN7GNENhE5 + OQdC8yl4ThHTOUT1WlCFjAOcuteSpe91/fl9xpOIzqd5Mk9f7qzwpPEiE8ED + rmyWZXHaUJRFzKP92rHPFqGCu1TUtGt61/6nNklviP4jGh4fJX4gg+m5TjRL + eLDGRWOxRnWrVmzpNrqaSPig+U1QSK943UurE824uJplpdEyyN7SWhx8TVeh + ivlRIUkBiaL7tucHjFgGs4pnylQ18JljMN2mph4EhmMHjsuYvGK8E342q9PU + NdgkQie7i3A0lxuM+czlmmkGLiWOY3mOYRGqEo1qvqNbmu9aG0QUad4RYRm7 + a3BVi9uaagQO16lhE0elNrVczTFV0/KIplue5Xn2xkJUElZtF9GwWgZfchpl + eSj1OY2Xl7d5U+SJgLHumQacje2th8aTaZKJNFvrhL/ueVAqpk7Eg955PJ7c + nHO33+biMi82zJ83faVwG996178ftKpqKw+9hdQp1qk0oP6vdUXKrYWFt7H9 + fPU1/t/d/3J3y75I2TQqLponZd3VypgnNBOLaBriMjRVtx0LHn4fzwUTGPqA + zlNeW+tREP6rSZBFmrBqPAejzxeqrmqq474M1ZYB2m18soSya4UEraPHs0nH + YVpw7rYHZqCedAcvKXaZHDCl26hAU4/NeyGroelFvqCRdLRYVBMjx4s4n9NE + ZDiRSSpjwm8Fv5u+3ZbxaluGsf6xjlKKHRkY1DadYj1qKqGu6To6Ycw1OXE9 + 4hVbPKBMq34eMg706k61yrocW7iryLczC1djW1GffwIAAP//AwB63aiglwkA + AA== + http_version: + recorded_at: Mon, 23 May 2016 01:31:59 GMT +- request: + method: get + uri: https://api.spotify.com/v1/albums/1OYLLmDS0pJVFRbUo19vrG + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Mon, 23 May 2016 01:31:59 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=600 + Cache-Control: + - public, max-age=7200 + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET, POST, OPTIONS, PUT, DELETE + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Max-Age: + - '604800' + Access-Control-Allow-Headers: + - Accept, Authorization, Origin, Content-Type + Content-Encoding: + - gzip + X-Content-Type-Options: + - nosniff + Strict-Transport-Security: + - max-age=31536000; + body: + encoding: ASCII-8BIT + string: !binary |- + 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 + AwAA//8DAJ35z7pwNAAA + http_version: + recorded_at: Mon, 23 May 2016 01:31:59 GMT +- request: + method: get + uri: https://api.spotify.com/v1/artists/0cOpQTKJdCEzz2wplnnyP6 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Mon, 23 May 2016 01:31:59 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=600 + Cache-Control: + - public, max-age=7200 + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET, POST, OPTIONS, PUT, DELETE + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Max-Age: + - '604800' + Access-Control-Allow-Headers: + - Accept, Authorization, Origin, Content-Type + Content-Encoding: + - gzip + X-Content-Type-Options: + - nosniff + Strict-Transport-Security: + - max-age=31536000; + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAAIySS08DIRSF9/6KyaybzpuBLjVuNEZNujPGMDw6JBQIw1jb + pv9dhpkam1rTsOLAPd/hcvc3URSzL8eswvKjt7KLo0W096rXO6Od4NtBiVvn + TLdIEm2Ymk8Hc6LXCbZOdC5JybN5XT4+0Lv73S7fGKnU9gXE3ugwGxhcS6k3 + zP72by3jw1b1Us5GyWmH5aBlP5UrpiwLZW/Re1COdT+hsBEnmT6zKVZ3KVfw + ETS4/HtljVdH+DE1E6vWDRIo0ym2b9xJIB+HUOWzJMEgYYzAmpMM4SKlsGFV + A2nVVBDhiiJECSAoRRVs4slvI6hrJ0RoxDm8SK+FIw5oTVPAK8g5LvOSlFmG + cUZrDOq8zEqOSUFofQb3iAtwUF7JLpuMAlQjCAtEClBQAitMKkLyIYfPhWqW + FpT/8fABPX24wmsWME+i09EtVn5FSyv0+ElGm15iK1wY1dCW2G3NWDIOwnix + tyJo06wsxrPFpdk9fAMAAP//AwBXgrNaHgMAAA== + http_version: + recorded_at: Mon, 23 May 2016 01:31:59 GMT +recorded_with: VCR 3.0.3 diff --git a/test/cassettes/Music/Knows_various_artist_attributes.yml b/test/cassettes/Music/Knows_various_artist_attributes.yml new file mode 100644 index 0000000..a014481 --- /dev/null +++ b/test/cassettes/Music/Knows_various_artist_attributes.yml @@ -0,0 +1,232 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.spotify.com/v1/tracks/0fDFzVTG8c2fW9EM5f1RHM + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Mon, 23 May 2016 01:32:00 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=600 + Cache-Control: + - public, max-age=7200 + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET, POST, OPTIONS, PUT, DELETE + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Max-Age: + - '604800' + Access-Control-Allow-Headers: + - Accept, Authorization, Origin, Content-Type + Content-Encoding: + - gzip + X-Content-Type-Options: + - nosniff + Strict-Transport-Security: + - max-age=31536000; + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAAOxVyXLaQBC95ytUOjvWaJe42YCBBDAxeIlTKWo0GpmJkZC1 + eC3/e6QngY0DDqkccsnlldTdev2mp7v19EGSZDr38lCWGtJT8bZ8n2YPMS+N + tXuv9t1SMafenE9DmlzzLC1DvknywYm8V+ApcFLiYRt4DIT3sFNi8wDYB8Lb + hLf5FXhZYuszEN4WeNpNIJ7HZyUe9YD4tlMh8naHQDB0oac3BuLbHmL6YOhX + z4gZIPsAlsFFiUMoHELPELmG0DOC/hHiR+AcdYGIH4FhjJOOoaGN7GNENhE5 + OQdC8yl4ThHTOUT1WlCFjAOcuteSpe91/fl9xpOIzqd5Mk9f7qzwpPEiE8ED + rmyWZXHaUJRFzKP92rHPFqGCu1TUtGt61/6nNklviP4jGh4fJX4gg+m5TjRL + eLDGRWOxRnWrVmzpNrqaSPig+U1QSK943UurE824uJplpdEyyN7SWhx8TVeh + ivlRIUkBiaL7tucHjFgGs4pnylQ18JljMN2mph4EhmMHjsuYvGK8E342q9PU + NdgkQie7i3A0lxuM+czlmmkGLiWOY3mOYRGqEo1qvqNbmu9aG0QUad4RYRm7 + a3BVi9uaagQO16lhE0elNrVczTFV0/KIplue5Xn2xkJUElZtF9GwWgZfchpl + eSj1OY2Xl7d5U+SJgLHumQacje2th8aTaZKJNFvrhL/ueVAqpk7Eg955PJ7c + nHO33+biMi82zJ83faVwG996178ftKpqKw+9hdQp1qk0oP6vdUXKrYWFt7H9 + fPU1/t/d/3J3y75I2TQqLponZd3VypgnNBOLaBriMjRVtx0LHn4fzwUTGPqA + zlNeW+tREP6rSZBFmrBqPAejzxeqrmqq474M1ZYB2m18soSya4UEraPHs0nH + YVpw7rYHZqCedAcvKXaZHDCl26hAU4/NeyGroelFvqCRdLRYVBMjx4s4n9NE + ZDiRSSpjwm8Fv5u+3ZbxaluGsf6xjlKKHRkY1DadYj1qKqGu6To6Ycw1OXE9 + 4hVbPKBMq34eMg706k61yrocW7iryLczC1djW1GffwIAAP//AwB63aiglwkA + AA== + http_version: + recorded_at: Mon, 23 May 2016 01:32:00 GMT +- request: + method: get + uri: https://api.spotify.com/v1/albums/1OYLLmDS0pJVFRbUo19vrG + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Mon, 23 May 2016 01:32:00 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=600 + Cache-Control: + - public, max-age=7200 + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET, POST, OPTIONS, PUT, DELETE + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Max-Age: + - '604800' + Access-Control-Allow-Headers: + - Accept, Authorization, Origin, Content-Type + Content-Encoding: + - gzip + X-Content-Type-Options: + - nosniff + Strict-Transport-Security: + - max-age=31536000; + body: + encoding: ASCII-8BIT + string: !binary |- + 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 + AwAA//8DAJ35z7pwNAAA + http_version: + recorded_at: Mon, 23 May 2016 01:32:00 GMT +- request: + method: get + uri: https://api.spotify.com/v1/artists/0cOpQTKJdCEzz2wplnnyP6 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Mon, 23 May 2016 01:32:00 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=600 + Cache-Control: + - public, max-age=7200 + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET, POST, OPTIONS, PUT, DELETE + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Max-Age: + - '604800' + Access-Control-Allow-Headers: + - Accept, Authorization, Origin, Content-Type + Content-Encoding: + - gzip + X-Content-Type-Options: + - nosniff + Strict-Transport-Security: + - max-age=31536000; + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAAIySS08DIRSF9/6KyaybzpuBLjVuNEZNujPGMDw6JBQIw1jb + pv9dhpkam1rTsOLAPd/hcvc3URSzL8eswvKjt7KLo0W096rXO6Od4NtBiVvn + TLdIEm2Ymk8Hc6LXCbZOdC5JybN5XT4+0Lv73S7fGKnU9gXE3ugwGxhcS6k3 + zP72by3jw1b1Us5GyWmH5aBlP5UrpiwLZW/Re1COdT+hsBEnmT6zKVZ3KVfw + ETS4/HtljVdH+DE1E6vWDRIo0ym2b9xJIB+HUOWzJMEgYYzAmpMM4SKlsGFV + A2nVVBDhiiJECSAoRRVs4slvI6hrJ0RoxDm8SK+FIw5oTVPAK8g5LvOSlFmG + cUZrDOq8zEqOSUFofQb3iAtwUF7JLpuMAlQjCAtEClBQAitMKkLyIYfPhWqW + FpT/8fABPX24wmsWME+i09EtVn5FSyv0+ElGm15iK1wY1dCW2G3NWDIOwnix + tyJo06wsxrPFpdk9fAMAAP//AwBXgrNaHgMAAA== + http_version: + recorded_at: Mon, 23 May 2016 01:32:00 GMT +recorded_with: VCR 3.0.3 diff --git a/test/cassettes/Music/Knows_various_track_attributes.yml b/test/cassettes/Music/Knows_various_track_attributes.yml new file mode 100644 index 0000000..9dbac3f --- /dev/null +++ b/test/cassettes/Music/Knows_various_track_attributes.yml @@ -0,0 +1,232 @@ +--- +http_interactions: +- request: + method: get + uri: https://api.spotify.com/v1/tracks/0fDFzVTG8c2fW9EM5f1RHM + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Mon, 23 May 2016 01:31:57 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=600 + Cache-Control: + - public, max-age=7200 + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET, POST, OPTIONS, PUT, DELETE + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Max-Age: + - '604800' + Access-Control-Allow-Headers: + - Accept, Authorization, Origin, Content-Type + Content-Encoding: + - gzip + X-Content-Type-Options: + - nosniff + Strict-Transport-Security: + - max-age=31536000; + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAAOxVyXLaQBC95ytUOjvWaJe42YCBBDAxeIlTKWo0GpmJkZC1 + eC3/e6QngY0DDqkccsnlldTdev2mp7v19EGSZDr38lCWGtJT8bZ8n2YPMS+N + tXuv9t1SMafenE9DmlzzLC1DvknywYm8V+ApcFLiYRt4DIT3sFNi8wDYB8Lb + hLf5FXhZYuszEN4WeNpNIJ7HZyUe9YD4tlMh8naHQDB0oac3BuLbHmL6YOhX + z4gZIPsAlsFFiUMoHELPELmG0DOC/hHiR+AcdYGIH4FhjJOOoaGN7GNENhE5 + OQdC8yl4ThHTOUT1WlCFjAOcuteSpe91/fl9xpOIzqd5Mk9f7qzwpPEiE8ED + rmyWZXHaUJRFzKP92rHPFqGCu1TUtGt61/6nNklviP4jGh4fJX4gg+m5TjRL + eLDGRWOxRnWrVmzpNrqaSPig+U1QSK943UurE824uJplpdEyyN7SWhx8TVeh + ivlRIUkBiaL7tucHjFgGs4pnylQ18JljMN2mph4EhmMHjsuYvGK8E342q9PU + NdgkQie7i3A0lxuM+czlmmkGLiWOY3mOYRGqEo1qvqNbmu9aG0QUad4RYRm7 + a3BVi9uaagQO16lhE0elNrVczTFV0/KIplue5Xn2xkJUElZtF9GwWgZfchpl + eSj1OY2Xl7d5U+SJgLHumQacje2th8aTaZKJNFvrhL/ueVAqpk7Eg955PJ7c + nHO33+biMi82zJ83faVwG996178ftKpqKw+9hdQp1qk0oP6vdUXKrYWFt7H9 + fPU1/t/d/3J3y75I2TQqLponZd3VypgnNBOLaBriMjRVtx0LHn4fzwUTGPqA + zlNeW+tREP6rSZBFmrBqPAejzxeqrmqq474M1ZYB2m18soSya4UEraPHs0nH + YVpw7rYHZqCedAcvKXaZHDCl26hAU4/NeyGroelFvqCRdLRYVBMjx4s4n9NE + ZDiRSSpjwm8Fv5u+3ZbxaluGsf6xjlKKHRkY1DadYj1qKqGu6To6Ycw1OXE9 + 4hVbPKBMq34eMg706k61yrocW7iryLczC1djW1GffwIAAP//AwB63aiglwkA + AA== + http_version: + recorded_at: Mon, 23 May 2016 01:31:57 GMT +- request: + method: get + uri: https://api.spotify.com/v1/albums/1OYLLmDS0pJVFRbUo19vrG + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Mon, 23 May 2016 01:31:58 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=600 + Cache-Control: + - public, max-age=7200 + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET, POST, OPTIONS, PUT, DELETE + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Max-Age: + - '604800' + Access-Control-Allow-Headers: + - Accept, Authorization, Origin, Content-Type + Content-Encoding: + - gzip + X-Content-Type-Options: + - nosniff + Strict-Transport-Security: + - max-age=31536000; + body: + encoding: ASCII-8BIT + string: !binary |- + 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 + AwAA//8DAJ35z7pwNAAA + http_version: + recorded_at: Mon, 23 May 2016 01:31:58 GMT +- request: + method: get + uri: https://api.spotify.com/v1/artists/0cOpQTKJdCEzz2wplnnyP6 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Server: + - nginx + Date: + - Mon, 23 May 2016 01:31:58 GMT + Content-Type: + - application/json; charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Keep-Alive: + - timeout=600 + Cache-Control: + - public, max-age=7200 + Access-Control-Allow-Origin: + - "*" + Access-Control-Allow-Methods: + - GET, POST, OPTIONS, PUT, DELETE + Access-Control-Allow-Credentials: + - 'true' + Access-Control-Max-Age: + - '604800' + Access-Control-Allow-Headers: + - Accept, Authorization, Origin, Content-Type + Content-Encoding: + - gzip + X-Content-Type-Options: + - nosniff + Strict-Transport-Security: + - max-age=31536000; + body: + encoding: ASCII-8BIT + string: !binary |- + H4sIAAAAAAAAAIySS08DIRSF9/6KyaybzpuBLjVuNEZNujPGMDw6JBQIw1jb + pv9dhpkam1rTsOLAPd/hcvc3URSzL8eswvKjt7KLo0W096rXO6Od4NtBiVvn + TLdIEm2Ymk8Hc6LXCbZOdC5JybN5XT4+0Lv73S7fGKnU9gXE3ugwGxhcS6k3 + zP72by3jw1b1Us5GyWmH5aBlP5UrpiwLZW/Re1COdT+hsBEnmT6zKVZ3KVfw + ETS4/HtljVdH+DE1E6vWDRIo0ym2b9xJIB+HUOWzJMEgYYzAmpMM4SKlsGFV + A2nVVBDhiiJECSAoRRVs4slvI6hrJ0RoxDm8SK+FIw5oTVPAK8g5LvOSlFmG + cUZrDOq8zEqOSUFofQb3iAtwUF7JLpuMAlQjCAtEClBQAitMKkLyIYfPhWqW + FpT/8fABPX24wmsWME+i09EtVn5FSyv0+ElGm15iK1wY1dCW2G3NWDIOwnix + tyJo06wsxrPFpdk9fAMAAP//AwBXgrNaHgMAAA== + http_version: + recorded_at: Mon, 23 May 2016 01:31:59 GMT +recorded_with: VCR 3.0.3 diff --git a/test/controllers/home_controller_test.rb b/test/controllers/home_controller_test.rb index b935438..0bc87d9 100644 --- a/test/controllers/home_controller_test.rb +++ b/test/controllers/home_controller_test.rb @@ -1,7 +1,22 @@ # require 'test_helper' # # class HomeControllerTest < ActionController::TestCase -# # test "the truth" do -# # assert true -# # end +# it "Should render home#index page", :vcr do +# get :index +# assert_response :success +# end +# end + +# describe "Food" do +# before do +# @food = Food.yelp_find("india-bistro-seattle") +# end +# +# it "Knows various attributes", :vcr do +# assert_equal @food.business.name, "India Bistro" +# assert_equal @food.business.phone, "2067835080" +# assert_equal @food.business.url, "http://www.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api&utm_medium=api_v2_business&utm_source=DOZfhe1yESBrcYsFC_c53g" +# assert_equal @food.business.image_url, "https://s3-media2.fl.yelpcdn.com/bphoto/zr-A22q08n2GYI1CGW7yBQ/ms.jpg" +# assert_equal @food.business.rating_img_url, "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png" +# end # end diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb index a3ff0db..4ca3926 100644 --- a/test/controllers/sessions_controller_test.rb +++ b/test/controllers/sessions_controller_test.rb @@ -1,7 +1,8 @@ # require 'test_helper' # # class SessionsControllerTest < ActionController::TestCase -# # test "the truth" do -# # assert true -# # end + # test "should go to home#index" do + # get :index + # end + # end diff --git a/test/models/music_test.rb b/test/models/music_test.rb index d4ad922..9364346 100644 --- a/test/models/music_test.rb +++ b/test/models/music_test.rb @@ -3,16 +3,30 @@ class MusicTest < ActiveSupport::TestCase describe "Music" do before do - @music = Music.spotify_find("") + @music_track = Music.spotify_find("track", "0fDFzVTG8c2fW9EM5f1RHM") + @music_album = Music.spotify_find("album", "1OYLLmDS0pJVFRbUo19vrG") + @music_artist = Music.spotify_find("artist", "0cOpQTKJdCEzz2wplnnyP6") end - it "Knows various attributes", :vcr do - assert_equal @food.business.name, "India Bistro" - assert_equal @food.business.phone, "2067835080" - assert_equal @food.business.url, "http://www.yelp.com/biz/india-bistro-seattle?utm_campaign=yelp_api&utm_medium=api_v2_business&utm_source=DOZfhe1yESBrcYsFC_c53g" - assert_equal @food.business.image_url, "https://s3-media2.fl.yelpcdn.com/bphoto/zr-A22q08n2GYI1CGW7yBQ/ms.jpg" - assert_equal @food.business.rating_img_url, "https://s3-media1.fl.yelpcdn.com/assets/2/www/img/5ef3eb3cb162/ico/stars/v1/stars_3_half.png" + it "Knows various track attributes", :vcr do + assert_equal @music_track.name, "Indian Food" + assert_equal @music_track.type, "track" + assert_equal @music_track.uri, "spotify:track:0fDFzVTG8c2fW9EM5f1RHM" + assert_equal @music_track.external_urls["spotify"], "https://open.spotify.com/track/0fDFzVTG8c2fW9EM5f1RHM" + end + + it "Knows various album attributes", :vcr do + assert_equal @music_album.name, "Thunderbox" + assert_equal @music_album.type, "album" + assert_equal @music_album.uri, "spotify:album:1OYLLmDS0pJVFRbUo19vrG" + assert_equal @music_album.external_urls["spotify"], "https://open.spotify.com/album/1OYLLmDS0pJVFRbUo19vrG" + end + + it "Knows various artist attributes", :vcr do + assert_equal @music_artist.name, "Miso Banana Trio" + assert_equal @music_artist.type, "artist" + assert_equal @music_artist.uri, "spotify:artist:0cOpQTKJdCEzz2wplnnyP6" + assert_equal @music_artist.external_urls["spotify"], "https://open.spotify.com/artist/0cOpQTKJdCEzz2wplnnyP6" end end end -end