From 9e299d50365337bfe757bd782cd97ae1010724d8 Mon Sep 17 00:00:00 2001 From: cemccabe <46434166+cemccabe@users.noreply.github.com> Date: Mon, 30 Jan 2023 16:44:15 -0700 Subject: [PATCH 01/14] Gem and version setup --- .gitignore | 3 + Gemfile | 4 +- Gemfile.lock | 214 +++++++++++++++++++++++------------------- README.md | 4 +- config/application.rb | 16 +--- 5 files changed, 126 insertions(+), 115 deletions(-) diff --git a/.gitignore b/.gitignore index 18b43c9cd2..a8c8d6900e 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ # Ignore master key for decrypting credentials and more. /config/master.key + +/coverage +/config/application.yml \ No newline at end of file diff --git a/Gemfile b/Gemfile index 2e86ac3e16..94dc14b41a 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.7.4' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '~> 5.2.6' +gem 'rails', '~> 5.2.8' # Use postgresql as the database for Active Record gem 'pg', '>= 0.18', '< 2.0' # Use Puma as the app server @@ -51,6 +51,8 @@ group :test do gem 'capybara' gem 'launchy' gem 'simplecov' + gem 'shoulda-matchers' + gem 'launchy' end diff --git a/Gemfile.lock b/Gemfile.lock index c8ab2fd7c1..01c9f663b9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,56 +1,56 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.2.6) - actionpack (= 5.2.6) + actioncable (5.2.8.1) + actionpack (= 5.2.8.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.6) - actionpack (= 5.2.6) - actionview (= 5.2.6) - activejob (= 5.2.6) + actionmailer (5.2.8.1) + actionpack (= 5.2.8.1) + actionview (= 5.2.8.1) + activejob (= 5.2.8.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.6) - actionview (= 5.2.6) - activesupport (= 5.2.6) + actionpack (5.2.8.1) + actionview (= 5.2.8.1) + activesupport (= 5.2.8.1) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.6) - activesupport (= 5.2.6) + actionview (5.2.8.1) + activesupport (= 5.2.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.6) - activesupport (= 5.2.6) + activejob (5.2.8.1) + activesupport (= 5.2.8.1) globalid (>= 0.3.6) - activemodel (5.2.6) - activesupport (= 5.2.6) - activerecord (5.2.6) - activemodel (= 5.2.6) - activesupport (= 5.2.6) + activemodel (5.2.8.1) + activesupport (= 5.2.8.1) + activerecord (5.2.8.1) + activemodel (= 5.2.8.1) + activesupport (= 5.2.8.1) arel (>= 9.0) - activestorage (5.2.6) - actionpack (= 5.2.6) - activerecord (= 5.2.6) + activestorage (5.2.8.1) + actionpack (= 5.2.8.1) + activerecord (= 5.2.8.1) marcel (~> 1.0.0) - activesupport (5.2.6) + activesupport (5.2.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) arel (9.0.0) ast (2.4.2) bindex (0.8.1) - bootsnap (1.9.1) - msgpack (~> 1.0) + bootsnap (1.16.0) + msgpack (~> 1.2) builder (3.2.4) - capybara (3.36.0) + capybara (3.38.0) addressable matrix mini_mime (>= 0.1.3) @@ -67,96 +67,111 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.9) + concurrent-ruby (1.2.0) crass (1.0.6) - diff-lcs (1.4.4) + date (3.3.3) + diff-lcs (1.5.0) docile (1.4.0) - erubi (1.10.0) + erubi (1.12.0) execjs (2.8.1) - ffi (1.15.4) - globalid (0.5.2) + ffi (1.15.5) + globalid (1.1.0) activesupport (>= 5.0) - i18n (1.8.11) + i18n (1.12.0) concurrent-ruby (~> 1.0) - jbuilder (2.11.3) + jbuilder (2.11.5) + actionview (>= 5.0.0) activesupport (>= 5.0.0) - launchy (2.5.0) - addressable (~> 2.7) + json (2.6.3) + launchy (2.5.2) + addressable (~> 2.8) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) - loofah (2.12.0) + loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.1) + mail (2.8.0.1) mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.2) - mini_portile2 (2.6.1) - minitest (5.14.4) - msgpack (1.4.2) + mini_portile2 (2.8.1) + minitest (5.17.0) + msgpack (1.6.0) + net-imap (0.3.4) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.3.3) + net-protocol nio4r (2.5.8) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + nokogiri (1.14.1) + mini_portile2 (~> 2.8.0) racc (~> 1.4) - nokogiri (1.12.5-arm64-darwin) + nokogiri (1.14.1-arm64-darwin) racc (~> 1.4) - parallel (1.21.0) - parser (3.0.2.0) + parallel (1.22.1) + parser (3.2.0.0) ast (~> 2.4.1) - pg (1.2.3) - pry (0.14.1) + pg (1.4.5) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - public_suffix (4.0.6) + public_suffix (5.0.1) puma (3.12.6) - racc (1.6.0) - rack (2.2.3) - rack-test (1.1.0) - rack (>= 1.0, < 3) - rails (5.2.6) - actioncable (= 5.2.6) - actionmailer (= 5.2.6) - actionpack (= 5.2.6) - actionview (= 5.2.6) - activejob (= 5.2.6) - activemodel (= 5.2.6) - activerecord (= 5.2.6) - activestorage (= 5.2.6) - activesupport (= 5.2.6) + racc (1.6.2) + rack (2.2.6.2) + rack-test (2.0.2) + rack (>= 1.3) + rails (5.2.8.1) + actioncable (= 5.2.8.1) + actionmailer (= 5.2.8.1) + actionpack (= 5.2.8.1) + actionview (= 5.2.8.1) + activejob (= 5.2.8.1) + activemodel (= 5.2.8.1) + activerecord (= 5.2.8.1) + activestorage (= 5.2.8.1) + activesupport (= 5.2.8.1) bundler (>= 1.3.0) - railties (= 5.2.6) + railties (= 5.2.8.1) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.4.2) - loofah (~> 2.3) - railties (5.2.6) - actionpack (= 5.2.6) - activesupport (= 5.2.6) + rails-html-sanitizer (1.5.0) + loofah (~> 2.19, >= 2.19.1) + railties (5.2.8.1) + actionpack (= 5.2.8.1) + activesupport (= 5.2.8.1) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) - rainbow (3.0.0) + rainbow (3.1.1) rake (13.0.6) - rb-fsevent (0.11.0) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - regexp_parser (2.1.1) + regexp_parser (2.6.2) rexml (3.2.5) - rspec-core (3.10.1) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) + rspec-core (3.12.0) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) + rspec-support (~> 3.12.0) + rspec-mocks (3.12.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-rails (5.0.2) + rspec-support (~> 3.12.0) + rspec-rails (5.1.2) actionpack (>= 5.2) activesupport (>= 5.2) railties (>= 5.2) @@ -164,22 +179,23 @@ GEM rspec-expectations (~> 3.10) rspec-mocks (~> 3.10) rspec-support (~> 3.10) - rspec-support (3.10.3) - rubocop (1.23.0) + rspec-support (3.12.0) + rubocop (1.44.1) + json (~> 2.3) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.2.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.12.0, < 2.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.24.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.13.0) - parser (>= 3.0.1.1) - rubocop-rails (2.12.4) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.24.1) + parser (>= 3.1.1.0) + rubocop-rails (2.17.4) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.7.0, < 2.0) + rubocop (>= 1.33.0, < 2.0) ruby-progressbar (1.11.0) ruby_dep (1.5.0) sass (3.7.4) @@ -193,27 +209,30 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - simplecov (0.21.2) + shoulda-matchers (5.3.0) + activesupport (>= 5.2.0) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) - simplecov_json_formatter (0.1.3) + simplecov_json_formatter (0.1.4) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.4.0) + sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - thor (1.1.0) + thor (1.2.1) thread_safe (0.3.6) - tilt (2.0.10) - tzinfo (1.2.9) + tilt (2.0.11) + timeout (0.3.1) + tzinfo (1.2.11) thread_safe (~> 0.1) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (2.1.0) + unicode-display_width (2.4.2) web-console (3.7.0) actionview (>= 5.0) activemodel (>= 5.0) @@ -239,10 +258,11 @@ DEPENDENCIES pg (>= 0.18, < 2.0) pry puma (~> 3.11) - rails (~> 5.2.6) + rails (~> 5.2.8) rspec-rails rubocop-rails sass-rails (~> 5.0) + shoulda-matchers simplecov tzinfo-data uglifier (>= 1.3.0) diff --git a/README.md b/README.md index a4cf56b566..89a8aea64b 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ Viewing Party Lite is an application in which users can explore movie options an ## Versions -- Ruby 2.7.2 +- Ruby 2.7.4 -- Rails 5.2.6 +- Rails 5.2.8 Example wireframes to follow are found [here](https://backend.turing.edu/module3/projects/viewing_party_lite/wireframes) diff --git a/config/application.rb b/config/application.rb index 793027a648..80554086d9 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,17 +1,6 @@ require_relative 'boot' -require "rails" -# Pick the frameworks you want: -require "active_model/railtie" -require "active_job/railtie" -require "active_record/railtie" -require "active_storage/engine" -require "action_controller/railtie" -require "action_mailer/railtie" -require "action_view/railtie" -require "action_cable/engine" -require "sprockets/railtie" -# require "rails/test_unit/railtie" +require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -26,8 +15,5 @@ class Application < Rails::Application # Application configuration can go into files in config/initializers # -- all .rb files in that directory are automatically loaded after loading # the framework and any gems in your application. - - # Don't generate system test files. - config.generators.system_tests = nil end end From 14e6af7de9b7eecc41005e0f4e5800bdce853694 Mon Sep 17 00:00:00 2001 From: cemccabe <46434166+cemccabe@users.noreply.github.com> Date: Tue, 31 Jan 2023 14:15:17 -0700 Subject: [PATCH 02/14] Create model tests; create models; pass all tests; complete US3 --- .gitignore | 3 +- Gemfile | 1 + Gemfile.lock | 3 ++ app/controllers/welcome_controller.rb | 5 +++ app/models/user.rb | 4 ++ app/models/viewing_party.rb | 4 ++ app/models/viewing_party_user.rb | 4 ++ app/views/layouts/application.html.erb | 1 + app/views/welcome/index.html.erb | 13 +++++++ config/routes.rb | 2 +- db/migrate/20230131203435_create_users.rb | 8 ++++ .../20230131203613_create_viewing_parties.rb | 9 +++++ ...230131203719_create_viewing_party_users.rb | 8 ++++ db/schema.rb | 38 +++++++++++++++++++ spec/features/welcome/index_spec.rb | 38 +++++++++++++++++++ spec/models/user_spec.rb | 8 ++++ spec/models/viewing_party_spec.rb | 8 ++++ spec/models/viewing_party_user_spec.rb | 8 ++++ 18 files changed, 163 insertions(+), 2 deletions(-) create mode 100644 app/controllers/welcome_controller.rb create mode 100644 app/models/user.rb create mode 100644 app/models/viewing_party.rb create mode 100644 app/models/viewing_party_user.rb create mode 100644 app/views/welcome/index.html.erb create mode 100644 db/migrate/20230131203435_create_users.rb create mode 100644 db/migrate/20230131203613_create_viewing_parties.rb create mode 100644 db/migrate/20230131203719_create_viewing_party_users.rb create mode 100644 db/schema.rb create mode 100644 spec/features/welcome/index_spec.rb create mode 100644 spec/models/user_spec.rb create mode 100644 spec/models/viewing_party_spec.rb create mode 100644 spec/models/viewing_party_user_spec.rb diff --git a/.gitignore b/.gitignore index a8c8d6900e..04ede70701 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,5 @@ /config/master.key /coverage -/config/application.yml \ No newline at end of file +# Ignore application configuration +/config/application.yml diff --git a/Gemfile b/Gemfile index 94dc14b41a..9d321739f8 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,7 @@ gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'pry' + gem 'figaro' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 01c9f663b9..f4baedabbc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,6 +75,8 @@ GEM erubi (1.12.0) execjs (2.8.1) ffi (1.15.5) + figaro (1.2.0) + thor (>= 0.14.0, < 2) globalid (1.1.0) activesupport (>= 5.0) i18n (1.12.0) @@ -252,6 +254,7 @@ DEPENDENCIES bootsnap (>= 1.1.0) capybara coffee-rails (~> 4.2) + figaro jbuilder (~> 2.5) launchy listen (>= 3.0.5, < 3.2) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb new file mode 100644 index 0000000000..756fe86914 --- /dev/null +++ b/app/controllers/welcome_controller.rb @@ -0,0 +1,5 @@ +class WelcomeController < ApplicationController + def index + @users = User.all + end +end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000000..0d9442a344 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,4 @@ +class User < ApplicationRecord + has_many :viewing_party_users + has_many :viewing_parties, through: :viewing_party_users +end \ No newline at end of file diff --git a/app/models/viewing_party.rb b/app/models/viewing_party.rb new file mode 100644 index 0000000000..422f37ef41 --- /dev/null +++ b/app/models/viewing_party.rb @@ -0,0 +1,4 @@ +class ViewingParty < ApplicationRecord + has_many :viewing_party_users + has_many :users, through: :viewing_party_users +end \ No newline at end of file diff --git a/app/models/viewing_party_user.rb b/app/models/viewing_party_user.rb new file mode 100644 index 0000000000..574f84feea --- /dev/null +++ b/app/models/viewing_party_user.rb @@ -0,0 +1,4 @@ +class ViewingPartyUser < ApplicationRecord + belongs_to :user + belongs_to :viewing_party +end \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 1379b8373b..6472675fe3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,6 +10,7 @@ + <%= link_to 'Home', root_path, method: :get, local: true %> <%= yield %> diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb new file mode 100644 index 0000000000..89addadcda --- /dev/null +++ b/app/views/welcome/index.html.erb @@ -0,0 +1,13 @@ +

Viewing Party

+ +<%= link_to 'User Dashboard', "/users", method: :get, local: true %> + +<% @users.each do |user| %> + +<% end %> + +<%= form_with url: "/users/new", method: :post, local: true do |f| %> + <%= f.submit 'New User' %> +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 787824f888..bc557ceacc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,3 @@ Rails.application.routes.draw do - # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + root 'welcome#index' end diff --git a/db/migrate/20230131203435_create_users.rb b/db/migrate/20230131203435_create_users.rb new file mode 100644 index 0000000000..10ce944385 --- /dev/null +++ b/db/migrate/20230131203435_create_users.rb @@ -0,0 +1,8 @@ +class CreateUsers < ActiveRecord::Migration[5.2] + def change + create_table :users do |t| + t.string :name + t.string :email + end + end +end diff --git a/db/migrate/20230131203613_create_viewing_parties.rb b/db/migrate/20230131203613_create_viewing_parties.rb new file mode 100644 index 0000000000..c783cac6ce --- /dev/null +++ b/db/migrate/20230131203613_create_viewing_parties.rb @@ -0,0 +1,9 @@ +class CreateViewingParties < ActiveRecord::Migration[5.2] + def change + create_table :viewing_parties do |t| + t.string :title + t.integer :duration + t.time :start_time + end + end +end diff --git a/db/migrate/20230131203719_create_viewing_party_users.rb b/db/migrate/20230131203719_create_viewing_party_users.rb new file mode 100644 index 0000000000..d14fe2e38a --- /dev/null +++ b/db/migrate/20230131203719_create_viewing_party_users.rb @@ -0,0 +1,8 @@ +class CreateViewingPartyUsers < ActiveRecord::Migration[5.2] + def change + create_table :viewing_party_users do |t| + t.references :user, foreign_key: true + t.references :viewing_party, foreign_key: true + end + end +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000000..7cf9e46add --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,38 @@ +# 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: 2023_01_31_203719) 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 "name" + t.string "email" + end + + create_table "viewing_parties", force: :cascade do |t| + t.string "title" + t.integer "duration" + t.time "start_time" + end + + create_table "viewing_party_users", force: :cascade do |t| + t.bigint "user_id" + t.bigint "viewing_party_id" + t.index ["user_id"], name: "index_viewing_party_users_on_user_id" + t.index ["viewing_party_id"], name: "index_viewing_party_users_on_viewing_party_id" + end + + add_foreign_key "viewing_party_users", "users" + add_foreign_key "viewing_party_users", "viewing_parties" +end diff --git a/spec/features/welcome/index_spec.rb b/spec/features/welcome/index_spec.rb new file mode 100644 index 0000000000..042ebddb9b --- /dev/null +++ b/spec/features/welcome/index_spec.rb @@ -0,0 +1,38 @@ +require 'rails_helper' + +RSpec.describe 'landing page' do + describe 'when a user visits the landing page' do + before(:each) do + @user_1 = User.create!(name: 'William', email: 'william@gmail.com') + @user_2 = User.create!(name: 'Christian', email: 'christian@gmail.com') + @user_3 = User.create!(name: 'Fake', email: 'fake@gmail.com') + + @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22') + @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46') + + @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) + @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) + + visit '/' + end + + it 'displays title of application' do + expect(page).to have_content('Viewing Party') + end + + it 'has a button to create a new user' do + expect(page).to have_button('New User') + end + + it 'has a list of existing users which links to the users dashboard' do + expect(page).to have_content('User Dashboard') + expect(page).to have_content('William') + expect(page).to have_content('Christian') + expect(page).to have_content('Fake') + end + + it 'has a Link to go back to the landing page' do + expect(page).to have_content('Home') + end + end +end \ No newline at end of file diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 0000000000..51e49cd7fc --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,8 @@ +require 'rails_helper' + +RSpec.describe User, type: :model do + describe 'relationships' do + it {should have_many(:viewing_party_users)} + it {should have_many(:viewing_parties).through(:viewing_party_users)} + end +end \ No newline at end of file diff --git a/spec/models/viewing_party_spec.rb b/spec/models/viewing_party_spec.rb new file mode 100644 index 0000000000..2d11f83b47 --- /dev/null +++ b/spec/models/viewing_party_spec.rb @@ -0,0 +1,8 @@ +require 'rails_helper' + +RSpec.describe ViewingParty, type: :model do + describe 'relationships' do + it {should have_many(:viewing_party_users)} + it {should have_many(:users).through(:viewing_party_users)} + end +end \ No newline at end of file diff --git a/spec/models/viewing_party_user_spec.rb b/spec/models/viewing_party_user_spec.rb new file mode 100644 index 0000000000..bc31fd94bd --- /dev/null +++ b/spec/models/viewing_party_user_spec.rb @@ -0,0 +1,8 @@ +require 'rails_helper' + +RSpec.describe ViewingPartyUser, type: :model do + describe 'relationships' do + it {should belong_to(:viewing_party)} + it {should belong_to(:user)} + end +end \ No newline at end of file From f1be151331fd3c470190870eae0c32f4c1340e32 Mon Sep 17 00:00:00 2001 From: William Lampke Date: Tue, 31 Jan 2023 16:50:52 -0500 Subject: [PATCH 03/14] complete userstory 4 and tests --- app/controllers/users_controller.rb | 16 ++++++++++++++++ app/views/users/index.html.erb | 5 +++++ app/views/users/new.html.erb | 9 +++++++++ app/views/users/show.html.erb | 1 + app/views/welcome/index.html.erb | 2 +- config/routes.rb | 2 ++ spec/features/users/index_spec.rb | 29 +++++++++++++++++++++++++++++ spec/features/welcome/index_spec.rb | 1 + 8 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 app/controllers/users_controller.rb create mode 100644 app/views/users/index.html.erb create mode 100644 app/views/users/new.html.erb create mode 100644 app/views/users/show.html.erb create mode 100644 spec/features/users/index_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 0000000000..a229a2876d --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,16 @@ +class UsersController < ApplicationController + def index + @users = User.all + end + def show + @user = User.find(params[:id]) + end + def new + + end + def create + user = User.create!(name: params[:name], email: params[:email]) + redirect_to "/users/#{user.id}" + end + +end \ No newline at end of file diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb new file mode 100644 index 0000000000..a6e1573f1e --- /dev/null +++ b/app/views/users/index.html.erb @@ -0,0 +1,5 @@ +<% @users.each do |user| %> + +<% end %> \ No newline at end of file diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb new file mode 100644 index 0000000000..db3e3c2105 --- /dev/null +++ b/app/views/users/new.html.erb @@ -0,0 +1,9 @@ +
Create a User
+ +<%= form_with url: "/users", method: :post, local: true do |f| %> + <%= f.label :name, "Name" %> + <%= f.text_field :name %> + <%= f.label :email, "Email" %> + <%= f.text_field :email %> + <%= f.submit "Submit" %> + <% end %> \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb new file mode 100644 index 0000000000..1a786a3617 --- /dev/null +++ b/app/views/users/show.html.erb @@ -0,0 +1 @@ +
<%= @user.name %> Show Page
\ No newline at end of file diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 89addadcda..af7cca5742 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -8,6 +8,6 @@ <% end %> -<%= form_with url: "/users/new", method: :post, local: true do |f| %> +<%= form_with url: "/register", method: :get, local: true do |f| %> <%= f.submit 'New User' %> <% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bc557ceacc..c30f3bb4d7 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ Rails.application.routes.draw do root 'welcome#index' + get "/register", to: "users#new" + resources :users, only: [:index, :new, :create, :show] end diff --git a/spec/features/users/index_spec.rb b/spec/features/users/index_spec.rb new file mode 100644 index 0000000000..e03bc2bfc0 --- /dev/null +++ b/spec/features/users/index_spec.rb @@ -0,0 +1,29 @@ +require 'rails_helper' + +RSpec.describe 'User index spec' do + before(:each) do + @user_1 = User.create!(name: 'William', email: 'william@gmail.com') + @user_2 = User.create!(name: 'Christian', email: 'christian@gmail.com') + @user_3 = User.create!(name: 'Fake', email: 'fake@gmail.com') + + @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22') + @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46') + + @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) + @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) + end + describe 'User Register' do + it "The form should include: + -Name + -Email (must be unique) + -Register Button + Once the user registers they should be taken to a dashboard page '/users/:id', where :id is the id for the user that was just created." do + visit register_path + fill_in :name, with: "Bob" + fill_in :email, with: "Bob@gmail.com" + click_on "Submit" + expect(page).to have_content("Bob Show Page") + + end + end +end diff --git a/spec/features/welcome/index_spec.rb b/spec/features/welcome/index_spec.rb index 042ebddb9b..e5f24f7f50 100644 --- a/spec/features/welcome/index_spec.rb +++ b/spec/features/welcome/index_spec.rb @@ -35,4 +35,5 @@ expect(page).to have_content('Home') end end + end \ No newline at end of file From d200cb46ab140bdc996d13f80941018773703249 Mon Sep 17 00:00:00 2001 From: cemccabe <46434166+cemccabe@users.noreply.github.com> Date: Tue, 31 Jan 2023 15:27:22 -0700 Subject: [PATCH 04/14] Complete US5 --- app/controllers/users_controller.rb | 1 + app/views/users/show.html.erb | 12 ++++++++++- spec/features/users/index_spec.rb | 2 +- spec/features/users/show_spec.rb | 32 +++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 spec/features/users/show_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a229a2876d..f829a11a52 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,6 +4,7 @@ def index end def show @user = User.find(params[:id]) + @viewing_parties = ViewingParty.all end def new diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 1a786a3617..c439a7132a 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1 +1,11 @@ -
<%= @user.name %> Show Page
\ No newline at end of file +
<%= @user.name %>'s Dashboard
+ +<%= form_with url: "/users/#{@user.id}/discover", method: :get, local: true do |f| %> + <%= f.submit 'Discover Movies' %> +<% end %> + +<% @viewing_parties.each do |vp| %> +

Title: <%= vp.title %>

+

Start time: <%= vp.start_time %>

+

Duration (minutes): <%= vp.duration %>

+<% end %> \ No newline at end of file diff --git a/spec/features/users/index_spec.rb b/spec/features/users/index_spec.rb index e03bc2bfc0..5a2cf1cb3b 100644 --- a/spec/features/users/index_spec.rb +++ b/spec/features/users/index_spec.rb @@ -22,7 +22,7 @@ fill_in :name, with: "Bob" fill_in :email, with: "Bob@gmail.com" click_on "Submit" - expect(page).to have_content("Bob Show Page") + expect(page).to have_content("Bob's Dashboard") end end diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb new file mode 100644 index 0000000000..c1a4cb1853 --- /dev/null +++ b/spec/features/users/show_spec.rb @@ -0,0 +1,32 @@ +require 'rails_helper' + +RSpec.describe 'User dashboard' do + describe 'when I visit a user dashboard' do + before(:each) do + @user_1 = User.create!(name: 'William', email: 'william@gmail.com') + @user_2 = User.create!(name: 'Christian', email: 'christian@gmail.com') + @user_3 = User.create!(name: 'Fake', email: 'fake@gmail.com') + + @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22') + @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46') + + @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) + @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) + + visit user_path(@user_1) + end + + it 'displays the users name at the top of the page' do + expect(page).to have_content("#{@user_1.name}'s Dashboard") + end + + it 'has a button to Discover Movies' do + expect(page).to have_button('Discover Movies') + end + + it 'has a section that lists viewing parties' do + expect(page).to have_content(@viewing_party_1.title) + expect(page).to have_content(@viewing_party_2.title) + end + end +end \ No newline at end of file From f6be18442873fe3875b7690f8465b476fe699643 Mon Sep 17 00:00:00 2001 From: William Lampke Date: Tue, 31 Jan 2023 17:44:04 -0500 Subject: [PATCH 05/14] complete userstory 6 and test --- app/controllers/discover_controller.rb | 5 +++++ app/views/discover/index.html.erb | 0 config/routes.rb | 5 ++++- spec/features/users/show_spec.rb | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 app/controllers/discover_controller.rb create mode 100644 app/views/discover/index.html.erb diff --git a/app/controllers/discover_controller.rb b/app/controllers/discover_controller.rb new file mode 100644 index 0000000000..12862295a6 --- /dev/null +++ b/app/controllers/discover_controller.rb @@ -0,0 +1,5 @@ +class DiscoverController < ApplicationController + def index + + end +end \ No newline at end of file diff --git a/app/views/discover/index.html.erb b/app/views/discover/index.html.erb new file mode 100644 index 0000000000..e69de29bb2 diff --git a/config/routes.rb b/config/routes.rb index c30f3bb4d7..c5e86dcd5d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,8 @@ Rails.application.routes.draw do root 'welcome#index' get "/register", to: "users#new" - resources :users, only: [:index, :new, :create, :show] + resources :users, only: [:index, :new, :create, :show] do + resources :discover, only: [:index] + end + end diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb index c1a4cb1853..dc573ee8e4 100644 --- a/spec/features/users/show_spec.rb +++ b/spec/features/users/show_spec.rb @@ -28,5 +28,10 @@ expect(page).to have_content(@viewing_party_1.title) expect(page).to have_content(@viewing_party_2.title) end + it "has a link that takes you to a discover page" do + click_on "Discover Movies" do + expect(current_path).to eq("/users/#{@user_1.id}/discover") + end + end end end \ No newline at end of file From 81d9cfb364829e9f061c21da63a380f45690887c Mon Sep 17 00:00:00 2001 From: William Lampke Date: Wed, 1 Feb 2023 14:41:37 -0500 Subject: [PATCH 06/14] add loop for userstory 7 and tests --- app/controllers/users_controller.rb | 2 +- app/views/users/show.html.erb | 32 +++++++++++++++-- config/routes.rb | 2 +- ...30201183342_add_host_to_viewing_parties.rb | 5 +++ db/schema.rb | 3 +- spec/features/users/index_spec.rb | 6 ++-- spec/features/users/show_spec.rb | 35 ++++++++++++++----- spec/features/welcome/index_spec.rb | 4 +-- 8 files changed, 69 insertions(+), 20 deletions(-) create mode 100644 db/migrate/20230201183342_add_host_to_viewing_parties.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f829a11a52..95e33f5ae1 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -4,7 +4,7 @@ def index end def show @user = User.find(params[:id]) - @viewing_parties = ViewingParty.all + end def new diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index c439a7132a..e87a11af37 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -4,8 +4,34 @@ <%= f.submit 'Discover Movies' %> <% end %> -<% @viewing_parties.each do |vp| %> -

Title: <%= vp.title %>

+<% @user.viewing_parties.each do |vp| %> +
> + <%= link_to "#{vp.title}", "/viewing_parties/#{vp.id}", method: :get, local: true %>

Start time: <%= vp.start_time %>

-

Duration (minutes): <%= vp.duration %>

+ <% if @user.id == vp.host %> +

Hosting

+ <% else %> +

Invited

+ <% end %> +

Participants:

+ + <% vp.users.each do |user| %> + <% if user.id == vp.host %> + <% if user.id == @user.id %> +
Host: <%= user.name %>
+ <% else %> +

Host: <%= user.name %>

+ <% end %> + <% else %> + <% if user.id == @user.id %> +
<%= user.name %>
+ <% else %> +

<%= user.name %>

+ <% end %> + <% end %> + <% end %> + + +
+
<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c5e86dcd5d..f32385191c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,5 +4,5 @@ resources :users, only: [:index, :new, :create, :show] do resources :discover, only: [:index] end - + resources :viewing_parties, only: [:show] end diff --git a/db/migrate/20230201183342_add_host_to_viewing_parties.rb b/db/migrate/20230201183342_add_host_to_viewing_parties.rb new file mode 100644 index 0000000000..e852ea860f --- /dev/null +++ b/db/migrate/20230201183342_add_host_to_viewing_parties.rb @@ -0,0 +1,5 @@ +class AddHostToViewingParties < ActiveRecord::Migration[5.2] + def change + add_column :viewing_parties, :host, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 7cf9e46add..8308cc7f47 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_01_31_203719) do +ActiveRecord::Schema.define(version: 2023_02_01_183342) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -24,6 +24,7 @@ t.string "title" t.integer "duration" t.time "start_time" + t.integer "host" end create_table "viewing_party_users", force: :cascade do |t| diff --git a/spec/features/users/index_spec.rb b/spec/features/users/index_spec.rb index 5a2cf1cb3b..56045231ab 100644 --- a/spec/features/users/index_spec.rb +++ b/spec/features/users/index_spec.rb @@ -6,9 +6,9 @@ @user_2 = User.create!(name: 'Christian', email: 'christian@gmail.com') @user_3 = User.create!(name: 'Fake', email: 'fake@gmail.com') - @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22') - @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46') - + @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22', host: @user_2.id) + @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46', host: @user_1.id) + @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) end diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb index dc573ee8e4..bb6bcec5c4 100644 --- a/spec/features/users/show_spec.rb +++ b/spec/features/users/show_spec.rb @@ -7,12 +7,15 @@ @user_2 = User.create!(name: 'Christian', email: 'christian@gmail.com') @user_3 = User.create!(name: 'Fake', email: 'fake@gmail.com') - @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22') - @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46') + @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22', host: @user_2.id) + @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46', host: @user_1.id) @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) + @viewing_party_user_3 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_2.id) + @viewing_party_user_4 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_2.id) + visit user_path(@user_1) end @@ -24,14 +27,28 @@ expect(page).to have_button('Discover Movies') end - it 'has a section that lists viewing parties' do - expect(page).to have_content(@viewing_party_1.title) - expect(page).to have_content(@viewing_party_2.title) - end - it "has a link that takes you to a discover page" do - click_on "Discover Movies" do + it 'has a link that takes you to a discover page' do + click_on 'Discover Movies' do expect(current_path).to eq("/users/#{@user_1.id}/discover") end end + it 'has a section that lists viewing parties with a link to the movie show page' do + save_and_open_page + + within("##{@viewing_party_1.id}") do + expect(page).to have_content(@viewing_party_1.title) + expect(page).to have_link('Top Gun') + expect(page).to have_content(@viewing_party_1.start_time) + expect(page).to have_content(@user_1.name) + expect(page).to have_content("Host: #{@user_2.name}") + end + within("##{@viewing_party_2.id}") do + expect(page).to have_content(@viewing_party_2.title) + expect(page).to have_link('Hereditary') + expect(page).to have_content(@viewing_party_2.start_time) + expect(page).to have_content(@user_2.name) + expect(page).to have_content("Host: #{@user_1.name}") + end + end end -end \ No newline at end of file +end diff --git a/spec/features/welcome/index_spec.rb b/spec/features/welcome/index_spec.rb index e5f24f7f50..b5bde41afd 100644 --- a/spec/features/welcome/index_spec.rb +++ b/spec/features/welcome/index_spec.rb @@ -7,8 +7,8 @@ @user_2 = User.create!(name: 'Christian', email: 'christian@gmail.com') @user_3 = User.create!(name: 'Fake', email: 'fake@gmail.com') - @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22') - @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46') + @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22', host: @user_2.id) + @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46', host: @user_1.id) @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) From 6fd3c20acc2576efecfd765cc20fa32aad6e094f Mon Sep 17 00:00:00 2001 From: cemccabe <46434166+cemccabe@users.noreply.github.com> Date: Wed, 1 Feb 2023 15:45:38 -0700 Subject: [PATCH 07/14] Complete US8 --- Gemfile | 2 +- Gemfile.lock | 6 ++++++ app/controllers/users_controller.rb | 28 ++++++++++++++-------------- app/models/user.rb | 10 ++++++++++ app/views/users/show.html.erb | 4 ++++ spec/features/users/show_spec.rb | 3 +-- 6 files changed, 36 insertions(+), 17 deletions(-) diff --git a/Gemfile b/Gemfile index 9d321739f8..b8a2d0ac21 100644 --- a/Gemfile +++ b/Gemfile @@ -33,7 +33,7 @@ gem 'jbuilder', '~> 2.5' # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.1.0', require: false - +gem 'faraday' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'pry' diff --git a/Gemfile.lock b/Gemfile.lock index f4baedabbc..a0bb196d85 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,6 +74,10 @@ GEM docile (1.4.0) erubi (1.12.0) execjs (2.8.1) + faraday (2.7.4) + faraday-net_http (>= 2.0, < 3.1) + ruby2_keywords (>= 0.0.4) + faraday-net_http (3.0.2) ffi (1.15.5) figaro (1.2.0) thor (>= 0.14.0, < 2) @@ -199,6 +203,7 @@ GEM rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) ruby-progressbar (1.11.0) + ruby2_keywords (0.0.5) ruby_dep (1.5.0) sass (3.7.4) sass-listen (~> 4.0.0) @@ -254,6 +259,7 @@ DEPENDENCIES bootsnap (>= 1.1.0) capybara coffee-rails (~> 4.2) + faraday figaro jbuilder (~> 2.5) launchy diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 95e33f5ae1..5eec428ee3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,17 +1,17 @@ class UsersController < ApplicationController - def index - @users = User.all - end - def show - @user = User.find(params[:id]) - - end - def new + def index + @users = User.all + end - end - def create - user = User.create!(name: params[:name], email: params[:email]) - redirect_to "/users/#{user.id}" - end - + def show + @user = User.find(params[:id]) + end + + def new + end + + def create + user = User.create!(name: params[:name], email: params[:email]) + redirect_to "/users/#{user.id}" + end end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index 0d9442a344..5540a73c89 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,14 @@ class User < ApplicationRecord has_many :viewing_party_users has_many :viewing_parties, through: :viewing_party_users + + def self.poster(title) + conn = Faraday.new(url: "https://api.themoviedb.org") do |faraday| + faraday.params['api_key'] = ENV['tmdb_api'] + end + response = conn.get("/3/search/movie?api_key=17774d224d9d374cf775b5850c113b88&query=#{title}") + data = JSON.parse(response.body, symbolize_names: true) + + data[:results][0][:poster_path] #"/62HCnUTziyWcpDaBO2i1DX17ljH.jpg" + end end \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index e87a11af37..7b660e2b62 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -6,6 +6,10 @@ <% @user.viewing_parties.each do |vp| %>
> + + + <%= image_tag "https://image.tmdb.org/t/p/w500#{User.poster(vp.title)}", size: "200x300" %> +
<%= link_to "#{vp.title}", "/viewing_parties/#{vp.id}", method: :get, local: true %>

Start time: <%= vp.start_time %>

<% if @user.id == vp.host %> diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb index bb6bcec5c4..29ffb05515 100644 --- a/spec/features/users/show_spec.rb +++ b/spec/features/users/show_spec.rb @@ -33,8 +33,6 @@ end end it 'has a section that lists viewing parties with a link to the movie show page' do - save_and_open_page - within("##{@viewing_party_1.id}") do expect(page).to have_content(@viewing_party_1.title) expect(page).to have_link('Top Gun') @@ -48,6 +46,7 @@ expect(page).to have_content(@viewing_party_2.start_time) expect(page).to have_content(@user_2.name) expect(page).to have_content("Host: #{@user_1.name}") + save_and_open_page end end end From b3cce7847622c759201f63ea3e648100c2c538c3 Mon Sep 17 00:00:00 2001 From: cemccabe <46434166+cemccabe@users.noreply.github.com> Date: Thu, 2 Feb 2023 13:45:55 -0700 Subject: [PATCH 08/14] Create movies services and fascade for API call; create movies controller and index view; update routes --- app/controllers/movies_controller.rb | 5 +++ app/services/movies_service.rb | 11 ++++++ app/views/discover/index.html.erb | 13 ++++++ app/views/movies/index.html.erb | 1 + config/routes.rb | 3 +- spec/features/users/discover/index_spec.rb | 46 ++++++++++++++++++++++ 6 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 app/controllers/movies_controller.rb create mode 100644 app/services/movies_service.rb create mode 100644 app/views/movies/index.html.erb create mode 100644 spec/features/users/discover/index_spec.rb diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb new file mode 100644 index 0000000000..d8a7ea921c --- /dev/null +++ b/app/controllers/movies_controller.rb @@ -0,0 +1,5 @@ +class MoviesController < ApplicationController + def index + + end +end \ No newline at end of file diff --git a/app/services/movies_service.rb b/app/services/movies_service.rb new file mode 100644 index 0000000000..8075dcd8e6 --- /dev/null +++ b/app/services/movies_service.rb @@ -0,0 +1,11 @@ +class MoviesService + def self.conn + conn = Faraday.new(url: "https://api.themoviedb.org") do |faraday| + faraday.params['api_key'] = ENV['tmdb_api'] + end + end + + def self.parse_json(response) + JSON.parse(response.body, symbolize_names: true) + end +end \ No newline at end of file diff --git a/app/views/discover/index.html.erb b/app/views/discover/index.html.erb index e69de29bb2..000427e2e2 100644 --- a/app/views/discover/index.html.erb +++ b/app/views/discover/index.html.erb @@ -0,0 +1,13 @@ +

Discover Index Page

+ +<%= form_with url: movies_path, method: :get, local: true do |f| %> + <%= f.submit 'Discover Top Rated Movies' %> +<% end %> +
+<%= form_with url: movies_path, method: :get, local: true do |f| %> + <%= f.label :search, 'Search' %> + <%= f.text_field :search %> + <%= f.submit 'Search by Movie Title' %> +<% end %> + + diff --git a/app/views/movies/index.html.erb b/app/views/movies/index.html.erb new file mode 100644 index 0000000000..7f7c73751d --- /dev/null +++ b/app/views/movies/index.html.erb @@ -0,0 +1 @@ +

Movies

\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f32385191c..9a092635ff 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,5 +4,6 @@ resources :users, only: [:index, :new, :create, :show] do resources :discover, only: [:index] end - resources :viewing_parties, only: [:show] + resources :viewing_parties, only: [:show] + resources :movies, only: [:index] end diff --git a/spec/features/users/discover/index_spec.rb b/spec/features/users/discover/index_spec.rb new file mode 100644 index 0000000000..c49f9b43ee --- /dev/null +++ b/spec/features/users/discover/index_spec.rb @@ -0,0 +1,46 @@ +require 'rails_helper' + +RSpec.describe 'Users discover index' do + before(:each) do + @user_1 = User.create!(name: 'William', email: 'william@gmail.com') + @user_2 = User.create!(name: 'Christian', email: 'christian@gmail.com') + @user_3 = User.create!(name: 'Fake', email: 'fake@gmail.com') + + @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22', host: @user_2.id) + @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46', host: @user_1.id) + + @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) + @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) + + visit user_discover_index_path(@user_1) + end + + it 'has a button to discover top rated movies' do + expect(page).to have_button('Discover Top Rated Movies') + save_and_open_page + end + + it 'has a text field to enter keyword(s) to search by movie title' do + expect(page).to have_field('Search') + end + + it 'has a button to search by movie title' do + expect(page).to have_button('Search by Movie Title') + end + + describe 'when user clicks on Top Rated Movies' do + it 'redirects to the movies results page' do + click_button('Discover Top Rated Movies') + expect(current_path).to eq(movies_path) + end + end + + describe 'when user clicks on search button' do + it 'redirects to the movies results page' do + fill_in 'Search', with: 'Top Gun' + click_button('Search by Movie Title') + expect(current_path).to eq(movies_path) + expect(page).to have_content('Top Gun') + end + end +end \ No newline at end of file From 68ead7c234e6005c870bc232e95c181d13b9131e Mon Sep 17 00:00:00 2001 From: cemccabe <46434166+cemccabe@users.noreply.github.com> Date: Thu, 2 Feb 2023 15:07:34 -0700 Subject: [PATCH 09/14] Update controllers and show pages; Pass all tests; Complete US9 --- app/controllers/movies_controller.rb | 10 +++++++++- app/fascades/movies_fascade.rb | 22 ++++++++++++++++++++++ app/poros/movie.rb | 8 ++++++++ app/services/movies_service.rb | 10 ++++++++++ app/views/movies/index.html.erb | 7 ++++++- app/views/users/show.html.erb | 2 +- spec/features/users/discover/index_spec.rb | 3 +-- spec/features/users/show_spec.rb | 1 - 8 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 app/fascades/movies_fascade.rb create mode 100644 app/poros/movie.rb diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index d8a7ea921c..aa51e3b742 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,5 +1,13 @@ class MoviesController < ApplicationController def index - + if params[:commit] == 'Search by Movie Title' + @movies = MoviesFascade.movie_data(params[:search]) + @title = params[:commit] + end + + if params[:commit] == 'Discover Top Rated Movies' + @movies = MoviesFascade.top_rated + @title = params[:commit] + end end end \ No newline at end of file diff --git a/app/fascades/movies_fascade.rb b/app/fascades/movies_fascade.rb new file mode 100644 index 0000000000..4ba6bea792 --- /dev/null +++ b/app/fascades/movies_fascade.rb @@ -0,0 +1,22 @@ +class MoviesFascade + def self.poster(title) + response = MoviesService.movie_data(title) + response[:results][0][:poster_path] + end + + def self.movie_data(title) + response = MoviesService.movie_data(title) + results = response[:results][0..19] + results.map do |data| + Movie.new(data) + end + end + + def self.top_rated + response = MoviesService.top_rated + results = response[:results][0..19] + results.map do |data| + Movie.new(data) + end + end +end \ No newline at end of file diff --git a/app/poros/movie.rb b/app/poros/movie.rb new file mode 100644 index 0000000000..effd8e2abd --- /dev/null +++ b/app/poros/movie.rb @@ -0,0 +1,8 @@ +class Movie + attr_reader :title, :vote_average + + def initialize(attributes) + @title = attributes[:title] + @vote_average = attributes[:vote_average] + end +end \ No newline at end of file diff --git a/app/services/movies_service.rb b/app/services/movies_service.rb index 8075dcd8e6..d31f4da2bb 100644 --- a/app/services/movies_service.rb +++ b/app/services/movies_service.rb @@ -8,4 +8,14 @@ def self.conn def self.parse_json(response) JSON.parse(response.body, symbolize_names: true) end + + def self.movie_data(title) + response = conn.get("/3/search/movie?query=#{title}") + parse_json(response) + end + + def self.top_rated + response = conn.get("/3/movie/top_rated") + parse_json(response) + end end \ No newline at end of file diff --git a/app/views/movies/index.html.erb b/app/views/movies/index.html.erb index 7f7c73751d..e346624b41 100644 --- a/app/views/movies/index.html.erb +++ b/app/views/movies/index.html.erb @@ -1 +1,6 @@ -

Movies

\ No newline at end of file +

<%= @title %>

+<% @movies.each do |movie| %> +

Title: <%= movie.title %>

+

Rating: <%= movie.vote_average %>

+
+<% end %> \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 7b660e2b62..8bd5de33cd 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -8,7 +8,7 @@
> - <%= image_tag "https://image.tmdb.org/t/p/w500#{User.poster(vp.title)}", size: "200x300" %> + <%= image_tag "https://image.tmdb.org/t/p/w500#{MoviesFascade.poster(vp.title)}", size: "200x300" %>
<%= link_to "#{vp.title}", "/viewing_parties/#{vp.id}", method: :get, local: true %>

Start time: <%= vp.start_time %>

diff --git a/spec/features/users/discover/index_spec.rb b/spec/features/users/discover/index_spec.rb index c49f9b43ee..02bbce561f 100644 --- a/spec/features/users/discover/index_spec.rb +++ b/spec/features/users/discover/index_spec.rb @@ -17,7 +17,6 @@ it 'has a button to discover top rated movies' do expect(page).to have_button('Discover Top Rated Movies') - save_and_open_page end it 'has a text field to enter keyword(s) to search by movie title' do @@ -37,7 +36,7 @@ describe 'when user clicks on search button' do it 'redirects to the movies results page' do - fill_in 'Search', with: 'Top Gun' + fill_in :search, with: 'Top Gun' click_button('Search by Movie Title') expect(current_path).to eq(movies_path) expect(page).to have_content('Top Gun') diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb index 29ffb05515..5fb4f319df 100644 --- a/spec/features/users/show_spec.rb +++ b/spec/features/users/show_spec.rb @@ -46,7 +46,6 @@ expect(page).to have_content(@viewing_party_2.start_time) expect(page).to have_content(@user_2.name) expect(page).to have_content("Host: #{@user_1.name}") - save_and_open_page end end end From cc56fb8c3d5854712127bc63de07769a752b59c9 Mon Sep 17 00:00:00 2001 From: William Lampke Date: Thu, 2 Feb 2023 19:06:29 -0500 Subject: [PATCH 10/14] add apis and views for 10 --- app/controllers/movies_controller.rb | 7 ++++++- app/fascades/movies_fascade.rb | 12 ++++++++++++ app/poros/movie.rb | 6 +++++- app/services/movies_service.rb | 12 ++++++++++++ app/views/discover/index.html.erb | 4 ++-- app/views/movies/index.html.erb | 3 ++- app/views/movies/show.html.erb | 18 ++++++++++++++++++ config/routes.rb | 2 +- spec/features/users/discover/index_spec.rb | 19 +++++++++++++++++-- 9 files changed, 75 insertions(+), 8 deletions(-) create mode 100644 app/views/movies/show.html.erb diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index aa51e3b742..37db589cf0 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,5 +1,6 @@ class MoviesController < ApplicationController - def index + def index + @user = params[:user_id] if params[:commit] == 'Search by Movie Title' @movies = MoviesFascade.movie_data(params[:search]) @title = params[:commit] @@ -10,4 +11,8 @@ def index @title = params[:commit] end end + def show + @movie = MoviesFascade.find(params[:id]) + + end end \ No newline at end of file diff --git a/app/fascades/movies_fascade.rb b/app/fascades/movies_fascade.rb index 4ba6bea792..3174c2288f 100644 --- a/app/fascades/movies_fascade.rb +++ b/app/fascades/movies_fascade.rb @@ -19,4 +19,16 @@ def self.top_rated Movie.new(data) end end + def self.find(id) + response = MoviesService.find(id) + Movie.new(response) + end + def self.cast(id) + response = MoviesService.cast(id) + response[:cast][0..9] + end + def self.reviews(id) + response = MoviesService.reviews(id) + results = response[:results] + end end \ No newline at end of file diff --git a/app/poros/movie.rb b/app/poros/movie.rb index effd8e2abd..046cdef037 100644 --- a/app/poros/movie.rb +++ b/app/poros/movie.rb @@ -1,8 +1,12 @@ class Movie - attr_reader :title, :vote_average + attr_reader :movie_id, :title, :vote_average, :runtime, :genres, :overview def initialize(attributes) + @movie_id = attributes[:id] @title = attributes[:title] @vote_average = attributes[:vote_average] + @runtime = attributes[:runtime] + @genres = attributes[:genres] + @overview = attributes[:overview] end end \ No newline at end of file diff --git a/app/services/movies_service.rb b/app/services/movies_service.rb index d31f4da2bb..5c31f4f284 100644 --- a/app/services/movies_service.rb +++ b/app/services/movies_service.rb @@ -18,4 +18,16 @@ def self.top_rated response = conn.get("/3/movie/top_rated") parse_json(response) end + def self.find(id) + response = conn.get("/3/movie/#{id}") + parse_json(response) + end + def self.cast(id) + response = conn.get("/3/movie/#{id}/credits") + parse_json(response) + end + def self.reviews(id) + response = conn.get("/3/movie/#{id}/reviews") + parse_json(response) + end end \ No newline at end of file diff --git a/app/views/discover/index.html.erb b/app/views/discover/index.html.erb index 000427e2e2..b6afd7da82 100644 --- a/app/views/discover/index.html.erb +++ b/app/views/discover/index.html.erb @@ -1,10 +1,10 @@

Discover Index Page

-<%= form_with url: movies_path, method: :get, local: true do |f| %> +<%= form_with url: user_movies_path, method: :get, local: true do |f| %> <%= f.submit 'Discover Top Rated Movies' %> <% end %>
-<%= form_with url: movies_path, method: :get, local: true do |f| %> +<%= form_with url: user_movies_path, method: :get, local: true do |f| %> <%= f.label :search, 'Search' %> <%= f.text_field :search %> <%= f.submit 'Search by Movie Title' %> diff --git a/app/views/movies/index.html.erb b/app/views/movies/index.html.erb index e346624b41..14e6863f41 100644 --- a/app/views/movies/index.html.erb +++ b/app/views/movies/index.html.erb @@ -1,6 +1,7 @@

<%= @title %>

<% @movies.each do |movie| %> -

Title: <%= movie.title %>

+ + <%= link_to "#{movie.title}", "/users/#{@user}/movies/#{movie.movie_id}", method: :get, local: true %>

Rating: <%= movie.vote_average %>


<% end %> \ No newline at end of file diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb new file mode 100644 index 0000000000..7ab643be67 --- /dev/null +++ b/app/views/movies/show.html.erb @@ -0,0 +1,18 @@ +

<%= @movie.title %>

+

Average: <%= @movie.vote_average %>

+

Runtime(Minutes): <%= @movie.runtime %>

+

Summary: <%= @movie.overview %>

+
Genres:
+<% @movie.genres.each do |genre| %> +

<%= genre[:name] %>

+<% end %> +
+
Cast:
+<% MoviesFascade.cast(@movie.movie_id).each do |castmember| %> +

<%= "#{castmember[:name]}, as #{castmember[:character]}" %>

+<% end %> +
Total Reviews: <%= MoviesFascade.reviews(@movie.movie_id).length %>
+<% MoviesFascade.reviews(@movie.movie_id).each do |review| %> +

Reviewer: <%= review[:author_details][:username] %>

+

Review: <%= review[:content] %>

+<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 9a092635ff..97354e6d88 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,7 @@ get "/register", to: "users#new" resources :users, only: [:index, :new, :create, :show] do resources :discover, only: [:index] + resources :movies, only: [:index, :show] end resources :viewing_parties, only: [:show] - resources :movies, only: [:index] end diff --git a/spec/features/users/discover/index_spec.rb b/spec/features/users/discover/index_spec.rb index 02bbce561f..4614b7f1a2 100644 --- a/spec/features/users/discover/index_spec.rb +++ b/spec/features/users/discover/index_spec.rb @@ -30,7 +30,6 @@ describe 'when user clicks on Top Rated Movies' do it 'redirects to the movies results page' do click_button('Discover Top Rated Movies') - expect(current_path).to eq(movies_path) end end @@ -38,8 +37,24 @@ it 'redirects to the movies results page' do fill_in :search, with: 'Top Gun' click_button('Search by Movie Title') - expect(current_path).to eq(movies_path) expect(page).to have_content('Top Gun') end end + describe 'when user clicks on search button' do + it 'links to movie show page' do + click_button('Discover Top Rated Movies') + click_on "The Godfather" + expect(page).to have_content("The Godfather") + expect(page).to have_content("8.715") + expect(page).to have_content("175") + expect(page).to have_content("Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.") + expect(page).to have_content("Drama") + expect(page).to have_content("Crime") + + expect(page).to have_content("Marlon Brando, as Don Vito Corleone") + expect(page).to have_content("Al Pacino, as Don Michael Corleone") + expect(page).to have_content("Reviewer: futuretv") + expect(page).to have_content("Reviewer: crastana") + end + end end \ No newline at end of file From 6c72e48ef222165d80171a94b96fbad47ff4bdc4 Mon Sep 17 00:00:00 2001 From: cemccabe <46434166+cemccabe@users.noreply.github.com> Date: Fri, 3 Feb 2023 11:44:21 -0700 Subject: [PATCH 11/14] Update routes for new ViewingParty; update views; update tests; complete US11 --- app/controllers/viewing_parties_controller.rb | 26 ++++++++++++ app/models/user.rb | 16 +++---- app/views/viewing_parties/new.html.erb | 22 ++++++++++ app/views/viewing_parties/show.html.erb | 5 +++ config/routes.rb | 5 ++- spec/features/viewing_parties/show_spec.rb | 42 +++++++++++++++++++ 6 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 app/controllers/viewing_parties_controller.rb create mode 100644 app/views/viewing_parties/new.html.erb create mode 100644 app/views/viewing_parties/show.html.erb create mode 100644 spec/features/viewing_parties/show_spec.rb diff --git a/app/controllers/viewing_parties_controller.rb b/app/controllers/viewing_parties_controller.rb new file mode 100644 index 0000000000..fd1e2e0cd8 --- /dev/null +++ b/app/controllers/viewing_parties_controller.rb @@ -0,0 +1,26 @@ +class ViewingPartiesController < ApplicationController + def show + @user = User.find(params[:user_id]) + @vp = ViewingParty.find(params[:id]) + end + + def new + @movie = MoviesFascade.find(params[:movie_id]) + @user = User.find(params[:user_id]) + @all_users = User.all + end + + def create + @movie = MoviesFascade.find(params[:movie_id]) + @user = User.find(params[:user_id]) + time = params["time(4i)"] + ":" + params["time(5i)"] + vp = ViewingParty.create!(title: @movie.title, duration: params[:duration], start_time: time, host: @user.id) + @all_users = User.all + @all_users.each do |user| + if params[user.name.to_sym] == "1" + ViewingPartyUser.create!(viewing_party_id: vp.id, user_id: user.id) + end + end + redirect_to "/users/#{@user.id}/movies/#{@movie.movie_id}/viewing_parties/#{vp.id}" + end +end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index 5540a73c89..338eee94ac 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,13 +2,13 @@ class User < ApplicationRecord has_many :viewing_party_users has_many :viewing_parties, through: :viewing_party_users - def self.poster(title) - conn = Faraday.new(url: "https://api.themoviedb.org") do |faraday| - faraday.params['api_key'] = ENV['tmdb_api'] - end - response = conn.get("/3/search/movie?api_key=17774d224d9d374cf775b5850c113b88&query=#{title}") - data = JSON.parse(response.body, symbolize_names: true) + # def self.poster(title) + # conn = Faraday.new(url: "https://api.themoviedb.org") do |faraday| + # faraday.params['api_key'] = ENV['tmdb_api'] + # end + # response = conn.get("/3/search/movie?api_key=17774d224d9d374cf775b5850c113b88&query=#{title}") + # data = JSON.parse(response.body, symbolize_names: true) - data[:results][0][:poster_path] #"/62HCnUTziyWcpDaBO2i1DX17ljH.jpg" - end + # data[:results][0][:poster_path] #"/62HCnUTziyWcpDaBO2i1DX17ljH.jpg" + # end end \ No newline at end of file diff --git a/app/views/viewing_parties/new.html.erb b/app/views/viewing_parties/new.html.erb new file mode 100644 index 0000000000..b01c0c49e0 --- /dev/null +++ b/app/views/viewing_parties/new.html.erb @@ -0,0 +1,22 @@ +

<%= @movie.title %>

+ +<%= form_with url: "/users/#{@user.id}/movies/#{@movie.movie_id}/viewing_parties", method: :post, local: true do |f| %> + <%= f.label :duration %> + <%= f.number_field :duration, value: @movie.runtime %> +
+ <%= f.label :date %> + <%= f.date_select :date, :order => [:day, :month, :year] %> +
+ <%= f.label :time %> + <%= f.time_select :time %> +
+

Add your friends to this viewing party:

+ <% @all_users.each do |user| %> + <% if user.name != @user.name %> + <%= f.label user.name %> + <%= f.check_box user.name %> + <% end %> + <% end %> +
+ <%= f.submit "Create Viewing Party" %> +<% end %> diff --git a/app/views/viewing_parties/show.html.erb b/app/views/viewing_parties/show.html.erb new file mode 100644 index 0000000000..4e3b7cd99e --- /dev/null +++ b/app/views/viewing_parties/show.html.erb @@ -0,0 +1,5 @@ +

<%= @vp.title %> Viewing Party

+ +

Duration: <%= @vp.duration %>

+

Start time: <%= @vp.start_time %>

+

Host: <%= @user.name %>

\ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 97354e6d88..50222e9dd2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,7 +3,8 @@ get "/register", to: "users#new" resources :users, only: [:index, :new, :create, :show] do resources :discover, only: [:index] - resources :movies, only: [:index, :show] + resources :movies, only: [:index, :show] do + resources :viewing_parties, only: [:show, :new, :create] + end end - resources :viewing_parties, only: [:show] end diff --git a/spec/features/viewing_parties/show_spec.rb b/spec/features/viewing_parties/show_spec.rb new file mode 100644 index 0000000000..92ecf9749d --- /dev/null +++ b/spec/features/viewing_parties/show_spec.rb @@ -0,0 +1,42 @@ +require 'rails_helper' + +RSpec.describe 'New and show viewing party page' do + before(:each) do + @user_1 = User.create!(name: 'William', email: 'william@gmail.com') + @user_2 = User.create!(name: 'Christian', email: 'christian@gmail.com') + @user_3 = User.create!(name: 'Fake', email: 'fake@gmail.com') + + @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22', host: @user_2.id) + @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46', host: @user_1.id) + + @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) + @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) + + @viewing_party_user_3 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_2.id) + @viewing_party_user_4 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_2.id) + + @movie = MoviesFascade.find(238) + + + # visit new_user_movie_viewing_party_path(@user_1) + visit "/users/#{@user_1.id}/movies/#{@movie.movie_id}/viewing_parties/new" + # /users/:user_id/movies/:movie_id/viewing_parties/new(.:format) + + end + + it 'displays name of movie title rendered above a form' do + expect(page).to have_content(@movie.title) + expect(page).to_not have_content(@user_1.name) + expect(page).to have_field('Duration', with: @movie.runtime) + expect(page).to have_content('Date') + expect(page).to have_content('Time') + page.check('Christian') + expect(page).to have_field('Christian', checked: true) + click_on 'Create Viewing Party' + expect(page).to have_content('Duration') + expect(page).to have_content('Start time') + expect(page).to have_content(@user_1.name) + visit "/users/#{@user_2.id}" + expect(page).to have_content('The Godfather') + end +end \ No newline at end of file From 4ab740ede68ba4d691b077120180e24e899107b0 Mon Sep 17 00:00:00 2001 From: William Lampke Date: Fri, 3 Feb 2023 13:51:12 -0500 Subject: [PATCH 12/14] re format all files --- app/controllers/discover_controller.rb | 6 ++-- app/controllers/movies_controller.rb | 8 ++--- app/controllers/users_controller.rb | 11 ++++--- app/controllers/viewing_parties_controller.rb | 10 +++---- app/controllers/welcome_controller.rb | 2 +- app/fascades/movies_fascade.rb | 5 +++- app/models/user.rb | 9 ------ app/poros/movie.rb | 2 +- app/services/movies_service.rb | 9 ++++-- spec/features/users/discover/index_spec.rb | 30 +++++++++---------- spec/features/users/index_spec.rb | 27 ++++++++--------- spec/features/viewing_parties/show_spec.rb | 4 +-- spec/features/welcome/index_spec.rb | 5 ++-- 13 files changed, 58 insertions(+), 70 deletions(-) diff --git a/app/controllers/discover_controller.rb b/app/controllers/discover_controller.rb index 12862295a6..86ba410154 100644 --- a/app/controllers/discover_controller.rb +++ b/app/controllers/discover_controller.rb @@ -1,5 +1,3 @@ class DiscoverController < ApplicationController - def index - - end -end \ No newline at end of file + def index; end +end diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index 37db589cf0..ac51a2eb0d 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -1,5 +1,5 @@ class MoviesController < ApplicationController - def index + def index @user = params[:user_id] if params[:commit] == 'Search by Movie Title' @movies = MoviesFascade.movie_data(params[:search]) @@ -11,8 +11,8 @@ def index @title = params[:commit] end end - def show + + def show @movie = MoviesFascade.find(params[:id]) - end -end \ No newline at end of file +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5eec428ee3..475fcb2929 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,17 +1,16 @@ class UsersController < ApplicationController - def index - @users = User.all + def index + @users = User.all end def show @user = User.find(params[:id]) end - def new - end + def new; end def create - user = User.create!(name: params[:name], email: params[:email]) + user = User.create!(name: params[:name], email: params[:email]) redirect_to "/users/#{user.id}" end -end \ No newline at end of file +end diff --git a/app/controllers/viewing_parties_controller.rb b/app/controllers/viewing_parties_controller.rb index fd1e2e0cd8..9799fcc669 100644 --- a/app/controllers/viewing_parties_controller.rb +++ b/app/controllers/viewing_parties_controller.rb @@ -9,18 +9,16 @@ def new @user = User.find(params[:user_id]) @all_users = User.all end - + def create @movie = MoviesFascade.find(params[:movie_id]) @user = User.find(params[:user_id]) - time = params["time(4i)"] + ":" + params["time(5i)"] + time = params['time(4i)'] + ':' + params['time(5i)'] vp = ViewingParty.create!(title: @movie.title, duration: params[:duration], start_time: time, host: @user.id) @all_users = User.all @all_users.each do |user| - if params[user.name.to_sym] == "1" - ViewingPartyUser.create!(viewing_party_id: vp.id, user_id: user.id) - end + ViewingPartyUser.create!(viewing_party_id: vp.id, user_id: user.id) if params[user.name.to_sym] == '1' end redirect_to "/users/#{@user.id}/movies/#{@movie.movie_id}/viewing_parties/#{vp.id}" end -end \ No newline at end of file +end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 756fe86914..ab4d827961 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -2,4 +2,4 @@ class WelcomeController < ApplicationController def index @users = User.all end -end \ No newline at end of file +end diff --git a/app/fascades/movies_fascade.rb b/app/fascades/movies_fascade.rb index 3174c2288f..a35cfd6763 100644 --- a/app/fascades/movies_fascade.rb +++ b/app/fascades/movies_fascade.rb @@ -19,16 +19,19 @@ def self.top_rated Movie.new(data) end end + def self.find(id) response = MoviesService.find(id) Movie.new(response) end + def self.cast(id) response = MoviesService.cast(id) response[:cast][0..9] end + def self.reviews(id) response = MoviesService.reviews(id) results = response[:results] end -end \ No newline at end of file +end diff --git a/app/models/user.rb b/app/models/user.rb index 338eee94ac..8eb4c2ade9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,13 +2,4 @@ class User < ApplicationRecord has_many :viewing_party_users has_many :viewing_parties, through: :viewing_party_users - # def self.poster(title) - # conn = Faraday.new(url: "https://api.themoviedb.org") do |faraday| - # faraday.params['api_key'] = ENV['tmdb_api'] - # end - # response = conn.get("/3/search/movie?api_key=17774d224d9d374cf775b5850c113b88&query=#{title}") - # data = JSON.parse(response.body, symbolize_names: true) - - # data[:results][0][:poster_path] #"/62HCnUTziyWcpDaBO2i1DX17ljH.jpg" - # end end \ No newline at end of file diff --git a/app/poros/movie.rb b/app/poros/movie.rb index 046cdef037..3b783fce81 100644 --- a/app/poros/movie.rb +++ b/app/poros/movie.rb @@ -9,4 +9,4 @@ def initialize(attributes) @genres = attributes[:genres] @overview = attributes[:overview] end -end \ No newline at end of file +end diff --git a/app/services/movies_service.rb b/app/services/movies_service.rb index 5c31f4f284..ffb44ddc08 100644 --- a/app/services/movies_service.rb +++ b/app/services/movies_service.rb @@ -1,6 +1,6 @@ class MoviesService def self.conn - conn = Faraday.new(url: "https://api.themoviedb.org") do |faraday| + conn = Faraday.new(url: 'https://api.themoviedb.org') do |faraday| faraday.params['api_key'] = ENV['tmdb_api'] end end @@ -15,19 +15,22 @@ def self.movie_data(title) end def self.top_rated - response = conn.get("/3/movie/top_rated") + response = conn.get('/3/movie/top_rated') parse_json(response) end + def self.find(id) response = conn.get("/3/movie/#{id}") parse_json(response) end + def self.cast(id) response = conn.get("/3/movie/#{id}/credits") parse_json(response) end + def self.reviews(id) response = conn.get("/3/movie/#{id}/reviews") parse_json(response) end -end \ No newline at end of file +end diff --git a/spec/features/users/discover/index_spec.rb b/spec/features/users/discover/index_spec.rb index 4614b7f1a2..249edeacb1 100644 --- a/spec/features/users/discover/index_spec.rb +++ b/spec/features/users/discover/index_spec.rb @@ -8,10 +8,10 @@ @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22', host: @user_2.id) @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46', host: @user_1.id) - + @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) - + visit user_discover_index_path(@user_1) end @@ -43,18 +43,18 @@ describe 'when user clicks on search button' do it 'links to movie show page' do click_button('Discover Top Rated Movies') - click_on "The Godfather" - expect(page).to have_content("The Godfather") - expect(page).to have_content("8.715") - expect(page).to have_content("175") - expect(page).to have_content("Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.") - expect(page).to have_content("Drama") - expect(page).to have_content("Crime") - - expect(page).to have_content("Marlon Brando, as Don Vito Corleone") - expect(page).to have_content("Al Pacino, as Don Michael Corleone") - expect(page).to have_content("Reviewer: futuretv") - expect(page).to have_content("Reviewer: crastana") + click_on 'The Godfather' + expect(page).to have_content('The Godfather') + expect(page).to have_content('8.715') + expect(page).to have_content('175') + expect(page).to have_content('Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.') + expect(page).to have_content('Drama') + expect(page).to have_content('Crime') + + expect(page).to have_content('Marlon Brando, as Don Vito Corleone') + expect(page).to have_content('Al Pacino, as Don Michael Corleone') + expect(page).to have_content('Reviewer: futuretv') + expect(page).to have_content('Reviewer: crastana') end end -end \ No newline at end of file +end diff --git a/spec/features/users/index_spec.rb b/spec/features/users/index_spec.rb index 56045231ab..d11d0030fe 100644 --- a/spec/features/users/index_spec.rb +++ b/spec/features/users/index_spec.rb @@ -1,17 +1,17 @@ require 'rails_helper' RSpec.describe 'User index spec' do - before(:each) do - @user_1 = User.create!(name: 'William', email: 'william@gmail.com') - @user_2 = User.create!(name: 'Christian', email: 'christian@gmail.com') - @user_3 = User.create!(name: 'Fake', email: 'fake@gmail.com') + before(:each) do + @user_1 = User.create!(name: 'William', email: 'william@gmail.com') + @user_2 = User.create!(name: 'Christian', email: 'christian@gmail.com') + @user_3 = User.create!(name: 'Fake', email: 'fake@gmail.com') - @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22', host: @user_2.id) - @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46', host: @user_1.id) - - @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) - @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) - end + @viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22', host: @user_2.id) + @viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46', host: @user_1.id) + + @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) + @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) + end describe 'User Register' do it "The form should include: -Name @@ -19,11 +19,10 @@ -Register Button Once the user registers they should be taken to a dashboard page '/users/:id', where :id is the id for the user that was just created." do visit register_path - fill_in :name, with: "Bob" - fill_in :email, with: "Bob@gmail.com" - click_on "Submit" + fill_in :name, with: 'Bob' + fill_in :email, with: 'Bob@gmail.com' + click_on 'Submit' expect(page).to have_content("Bob's Dashboard") - end end end diff --git a/spec/features/viewing_parties/show_spec.rb b/spec/features/viewing_parties/show_spec.rb index 92ecf9749d..44e6e54d9d 100644 --- a/spec/features/viewing_parties/show_spec.rb +++ b/spec/features/viewing_parties/show_spec.rb @@ -17,11 +17,9 @@ @movie = MoviesFascade.find(238) - # visit new_user_movie_viewing_party_path(@user_1) visit "/users/#{@user_1.id}/movies/#{@movie.movie_id}/viewing_parties/new" # /users/:user_id/movies/:movie_id/viewing_parties/new(.:format) - end it 'displays name of movie title rendered above a form' do @@ -39,4 +37,4 @@ visit "/users/#{@user_2.id}" expect(page).to have_content('The Godfather') end -end \ No newline at end of file +end diff --git a/spec/features/welcome/index_spec.rb b/spec/features/welcome/index_spec.rb index b5bde41afd..5e379ac001 100644 --- a/spec/features/welcome/index_spec.rb +++ b/spec/features/welcome/index_spec.rb @@ -12,7 +12,7 @@ @viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) @viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) - + visit '/' end @@ -35,5 +35,4 @@ expect(page).to have_content('Home') end end - -end \ No newline at end of file +end From 2f2ee6bfed3e7a2e320e310c56a85cfc6959f47f Mon Sep 17 00:00:00 2001 From: cemccabe <46434166+cemccabe@users.noreply.github.com> Date: Fri, 3 Feb 2023 13:50:00 -0700 Subject: [PATCH 13/14] Create api tests and fixtures --- Gemfile | 1 + spec/features/users/discover/index_spec.rb | 14 + spec/fixtures/godfather_response.json | 75 ++++ spec/fixtures/top_gun_response.json | 372 +++++++++++++++++++ spec/fixtures/top_rated_godfather.json | 396 +++++++++++++++++++++ spec/fixtures/top_rated_response.json | 396 +++++++++++++++++++++ spec/spec_helper.rb | 1 + 7 files changed, 1255 insertions(+) create mode 100644 spec/fixtures/godfather_response.json create mode 100644 spec/fixtures/top_gun_response.json create mode 100644 spec/fixtures/top_rated_godfather.json create mode 100644 spec/fixtures/top_rated_response.json diff --git a/Gemfile b/Gemfile index b8a2d0ac21..852f9019ed 100644 --- a/Gemfile +++ b/Gemfile @@ -54,6 +54,7 @@ group :test do gem 'simplecov' gem 'shoulda-matchers' gem 'launchy' + # gem 'webmock' end diff --git a/spec/features/users/discover/index_spec.rb b/spec/features/users/discover/index_spec.rb index 249edeacb1..40820fe77e 100644 --- a/spec/features/users/discover/index_spec.rb +++ b/spec/features/users/discover/index_spec.rb @@ -29,20 +29,34 @@ describe 'when user clicks on Top Rated Movies' do it 'redirects to the movies results page' do + # stub_request(:get, "https://api.themoviedb.org/3/movie/top_rated?api_key=17774d224d9d374cf775b5850c113b88"). + # to_return(status: 200, body: File.read('spec/fixtures/top_rated_response.json'), headers: {}) + click_button('Discover Top Rated Movies') end end describe 'when user clicks on search button' do it 'redirects to the movies results page' do + # stub_request(:get, "https://api.themoviedb.org/3/search/movie?api_key=17774d224d9d374cf775b5850c113b88&query=Top%20Gun"). + # to_return(status: 200, body: File.read('spec/fixtures/top_gun_response.json'), headers: {}) + fill_in :search, with: 'Top Gun' click_button('Search by Movie Title') expect(page).to have_content('Top Gun') end end + describe 'when user clicks on search button' do it 'links to movie show page' do + # stub_request(:get, "https://api.themoviedb.org/3/movie/top_rated?api_key=17774d224d9d374cf775b5850c113b88"). + # to_return(status: 200, body: File.read('spec/fixtures/top_rated_godfather.json'), headers: {}) + click_button('Discover Top Rated Movies') + + # stub_request(:get, "https://api.themoviedb.org/3/movie/238/credits?api_key=17774d224d9d374cf775b5850c113b88"). + # to_return(status: 200, body: File.read('spec/fixtures/godfather_response.json'), headers: {}) + click_on 'The Godfather' expect(page).to have_content('The Godfather') expect(page).to have_content('8.715') diff --git a/spec/fixtures/godfather_response.json b/spec/fixtures/godfather_response.json new file mode 100644 index 0000000000..ed4d32c515 --- /dev/null +++ b/spec/fixtures/godfather_response.json @@ -0,0 +1,75 @@ +{ + "adult": false, + "backdrop_path": "/tmU7GeKVybMWFButWEGl2M4GeiP.jpg", + "belongs_to_collection": { + "id": 230, + "name": "The Godfather Collection", + "poster_path": "/9Baumh5J9N1nJUYzNkm0xsgjpwY.jpg", + "backdrop_path": "/3WZTxpgscsmoUk81TuECXdFOD0R.jpg" + }, + "budget": 6000000, + "genres": [ + { + "id": 18, + "name": "Drama" + }, + { + "id": 80, + "name": "Crime" + } + ], + "homepage": "http://www.thegodfather.com/", + "id": 238, + "imdb_id": "tt0068646", + "original_language": "en", + "original_title": "The Godfather", + "overview": "Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.", + "popularity": 90.094, + "poster_path": "/3bhkrj58Vtu7enYsRolD1fZdja1.jpg", + "production_companies": [ + { + "id": 4, + "logo_path": "/gz66EfNoYPqHTYI4q9UEN4CbHRc.png", + "name": "Paramount", + "origin_country": "US" + }, + { + "id": 10211, + "logo_path": null, + "name": "Alfran Productions", + "origin_country": "US" + } + ], + "production_countries": [ + { + "iso_3166_1": "US", + "name": "United States of America" + } + ], + "release_date": "1972-03-14", + "revenue": 245066411, + "runtime": 175, + "spoken_languages": [ + { + "english_name": "English", + "iso_639_1": "en", + "name": "English" + }, + { + "english_name": "Italian", + "iso_639_1": "it", + "name": "Italiano" + }, + { + "english_name": "Latin", + "iso_639_1": "la", + "name": "Latin" + } + ], + "status": "Released", + "tagline": "An offer you can't refuse.", + "title": "The Godfather", + "video": false, + "vote_average": 8.715, + "vote_count": 17406 +} \ No newline at end of file diff --git a/spec/fixtures/top_gun_response.json b/spec/fixtures/top_gun_response.json new file mode 100644 index 0000000000..5a61dc02fe --- /dev/null +++ b/spec/fixtures/top_gun_response.json @@ -0,0 +1,372 @@ +{ + "page": 1, + "results": [ + { + "adult": false, + "backdrop_path": "/AaV1YIdWKnjAIAOe8UUKBFm327v.jpg", + "genre_ids": [ + 28, + 18 + ], + "id": 361743, + "original_language": "en", + "original_title": "Top Gun: Maverick", + "overview": "After more than thirty years of service as one of the Navy’s top aviators, and dodging the advancement in rank that would ground him, Pete “Maverick” Mitchell finds himself training a detachment of TOP GUN graduates for a specialized mission the likes of which no living pilot has ever seen.", + "popularity": 374.687, + "poster_path": "/62HCnUTziyWcpDaBO2i1DX17ljH.jpg", + "release_date": "2022-05-24", + "title": "Top Gun: Maverick", + "video": false, + "vote_average": 8.3, + "vote_count": 5899 + }, + { + "adult": false, + "backdrop_path": "/jILeJ60zPpIjjJHGSmIeY4eO30t.jpg", + "genre_ids": [ + 28, + 18 + ], + "id": 744, + "original_language": "en", + "original_title": "Top Gun", + "overview": "For Lieutenant Pete 'Maverick' Mitchell and his friend and co-pilot Nick 'Goose' Bradshaw, being accepted into an elite training school for fighter pilots is a dream come true. But a tragedy, as well as personal demons, will threaten Pete's dreams of becoming an ace pilot.", + "popularity": 113.897, + "poster_path": "/xUuHj3CgmZQ9P2cMaqQs4J0d4Zc.jpg", + "release_date": "1986-05-16", + "title": "Top Gun", + "video": false, + "vote_average": 7, + "vote_count": 7029 + }, + { + "adult": false, + "backdrop_path": "/l1GmkC9EJLDVRt8RxT64cet6QUQ.jpg", + "genre_ids": [ + 99, + 10770 + ], + "id": 1076135, + "original_language": "fr", + "original_title": "Le Phénomène Top Gun Maverick", + "overview": "36 years after the release of the first \"Top Gun\", this sequel has been eagerly awaited by fans around the world. Didier Allouch talks about the success of the film in France and around the world.", + "popularity": 8.502, + "poster_path": "/4t4GS16zOkdewJzeRZZwy3m7Y76.jpg", + "release_date": "2022-12-23", + "title": "The Top Gun Maverick Phenomenon", + "video": false, + "vote_average": 0, + "vote_count": 0 + }, + { + "adult": false, + "backdrop_path": "/uRokRYuqQZf5v1JJERKhKTmJXLn.jpg", + "genre_ids": [ + 28, + 35, + 99 + ], + "id": 984430, + "original_language": "en", + "original_title": "James Corden's Top Gun Training with Tom Cruise", + "overview": "When \"Top Gun: Maverick\" star Tom Cruise calls you up to hang out for the day, you say yes. And for James Corden, that meant having Tom pilot you in two different fighter planes, pushing the limits of gravity and James's stomach.", + "popularity": 19.828, + "poster_path": "/e2EILRtu7b6qu4TuwU7BpyHop68.jpg", + "release_date": "2022-06-01", + "title": "James Corden's Top Gun Training with Tom Cruise", + "video": false, + "vote_average": 5.8, + "vote_count": 13 + }, + { + "adult": false, + "backdrop_path": "/6KmDXXNVlbtZVCNQgcWGZeJ5DtS.jpg", + "genre_ids": [ + 99 + ], + "id": 978444, + "original_language": "fr", + "original_title": "Top Gun : les coulisses du grand retour", + "overview": "", + "popularity": 13.966, + "poster_path": "/pSs9HbhK5rvHDKlH5YcLTSrPzih.jpg", + "release_date": "2022-05-19", + "title": "Top Gun : les coulisses du grand retour", + "video": false, + "vote_average": 6.8, + "vote_count": 4 + }, + { + "adult": false, + "backdrop_path": null, + "genre_ids": [ + 99 + ], + "id": 747321, + "original_language": "en", + "original_title": "On Your Six: Thirty Years of Top Gun", + "overview": "A five-part documentary from 2016, chronicling the legacy of Top Gun.", + "popularity": 11.945, + "poster_path": "/zG78aJ6dnh7s23t4UR25I71FNd6.jpg", + "release_date": "2020-05-19", + "title": "On Your Six: Thirty Years of Top Gun", + "video": false, + "vote_average": 2, + "vote_count": 1 + }, + { + "adult": false, + "backdrop_path": "/uwOGuf5q0xxUVEfMCy4ooU1S02M.jpg", + "genre_ids": [ + 37 + ], + "id": 243655, + "original_language": "pt", + "original_title": "Top Gun", + "overview": "A gunslinger returns to his hometown to warn of an impending outlaw gang attack, but he's met with hatred and fear for his previous killings.", + "popularity": 1.678, + "poster_path": "/A4bwWlc6AgWL1cl9LS05pSKdNT7.jpg", + "release_date": "1955-12-01", + "title": "Top Gun", + "video": false, + "vote_average": 5.8, + "vote_count": 4 + }, + { + "adult": false, + "backdrop_path": "/yp46os3Gf5qOkpDv7rZtxSlP78N.jpg", + "genre_ids": [ + 99 + ], + "id": 520091, + "original_language": "fr", + "original_title": "TOP GUN 2002", + "overview": "", + "popularity": 1.306, + "poster_path": "/2lUHMJDIhdeTSUbGFtbzgDEUJ1C.jpg", + "release_date": "2002-07-23", + "title": "TOP GUN 2002", + "video": false, + "vote_average": 5.5, + "vote_count": 2 + }, + { + "adult": false, + "backdrop_path": "/84Ig8eo770TgXDNBsn4hEgwpgqc.jpg", + "genre_ids": [ + 99 + ], + "id": 976632, + "original_language": "en", + "original_title": "The Real Top Gun", + "overview": "The story of real mavericks in the Navy’s Top Gun aerial combat school. Action sequences from Hollywood and actual footage from Navy fighters in combat help explore the history of the school and the impact of naval aviation on the world.", + "popularity": 1.416, + "poster_path": "/3YrxKZowAPgbphzaLEfQzfIQg8A.jpg", + "release_date": "2022-05-22", + "title": "The Real Top Gun", + "video": false, + "vote_average": 4.5, + "vote_count": 2 + }, + { + "adult": false, + "backdrop_path": null, + "genre_ids": [ + 99 + ], + "id": 573425, + "original_language": "en", + "original_title": "Combat in the Air - Top Gun", + "overview": "", + "popularity": 1.2, + "poster_path": "/whZNNhnaWWP972rArTYtSVPtSjA.jpg", + "release_date": "1997-04-01", + "title": "Combat in the Air - Top Gun", + "video": false, + "vote_average": 2, + "vote_count": 1 + }, + { + "adult": false, + "backdrop_path": null, + "genre_ids": [], + "id": 229690, + "original_language": "pt", + "original_title": "Top Gun - Mission Norge", + "overview": "", + "popularity": 0.666, + "poster_path": null, + "release_date": "2008-01-01", + "title": "Top Gun - Mission Norge", + "video": false, + "vote_average": 0, + "vote_count": 0 + }, + { + "adult": false, + "backdrop_path": null, + "genre_ids": [ + 99 + ], + "id": 777254, + "original_language": "no", + "original_title": "Top Gun - Oppdrag Norge", + "overview": "", + "popularity": 0.6, + "poster_path": null, + "release_date": "2008-12-14", + "title": "Top Gun - Oppdrag Norge", + "video": false, + "vote_average": 0, + "vote_count": 0 + }, + { + "adult": false, + "backdrop_path": null, + "genre_ids": [ + 99 + ], + "id": 1022047, + "original_language": "en", + "original_title": "Danger Zone: The Making of Top Gun", + "overview": "A comprehensive 6-part documentary on the making of \"Top Gun\" featuring all-new interviews with the cast and crew. Available on Disc 2 of the \"Top Gun\" 2-Disc Special Collector's Edition DVD.", + "popularity": 1.41, + "poster_path": "/fhjM1vsPfjIzHsIC2GE1w5RcfCP.jpg", + "release_date": "2004-05-10", + "title": "Danger Zone: The Making of Top Gun", + "video": false, + "vote_average": 0, + "vote_count": 0 + }, + { + "adult": false, + "backdrop_path": null, + "genre_ids": [ + 99 + ], + "id": 368986, + "original_language": "en", + "original_title": "Top Gun Over Moscow", + "overview": "Nova visits Russia for Nova: Top Gun Over Moscow, a thorough look at the sleekest and most powerful Russian jets. In a word, they are tough. These jets are engineered quite differently from their American counterparts. They function well in adverse conditions, able to take off from open dirt fields, and their continuous operation doesn't depend on regular maintenance. The U.S. jet is finely tuned, requiring more frequent upkeep, but definitely having a high-tech edge, particularly in the areas of radar and missile guidance. Interviews with pilots reveal a very different outlook between the two countries on training goals.", + "popularity": 0.6, + "poster_path": null, + "release_date": "2006-10-23", + "title": "Top Gun Over Moscow", + "video": true, + "vote_average": 0, + "vote_count": 0 + }, + { + "adult": false, + "backdrop_path": null, + "genre_ids": [], + "id": 754461, + "original_language": "en", + "original_title": "Top Gun Jets II", + "overview": "You'll be on board with the world famous Thunderbirds in a spectacular behind-the-scenes demonstration of action, timing, and skill. Experience the heart-stopping starburst maneuver as you become part of the precision teamwork and professionalism that is the United States Air Force. Prepare for the aerial survival training with the ground and flight crews of \"Red Flag.\" You meet a \"bandit\" in the solitude of space over the Nevada desert and become \"combat ready.\" And, find yourself in the cockpit of the U.S. Air Force's premier fighter -- the incredible F-16 Falcon. You will \"Sour Like an Eagle\" after an adrenalin-generating \"scramble\" in your F-15. Thrill to mach-plus speed and experience the strain of high-G forces as you claim air superiority and execute the \"kill.\" Find out how the men and women in Air Force blue \"keep-em flyin'\".", + "popularity": 0.6, + "poster_path": "/6sqFUHPgccPEiEQIlWLBKAO304G.jpg", + "release_date": "", + "title": "Top Gun Jets II", + "video": true, + "vote_average": 0, + "vote_count": 0 + }, + { + "adult": false, + "backdrop_path": null, + "genre_ids": [ + 10402, + 35, + 28 + ], + "id": 1062763, + "original_language": "en", + "original_title": "A Very Top Gun Christmas: A Musical Parody", + "overview": "The North Pole is under attack, and it’s up to Maverick and his elite squad of Top Guns to save the day in this musical parody of 2022’s highest grossing film.", + "popularity": 1.03, + "poster_path": "/funKoLJmx5Lst8Scr1QWqbkCNjU.jpg", + "release_date": "2022-12-14", + "title": "A Very Top Gun Christmas: A Musical Parody", + "video": false, + "vote_average": 0, + "vote_count": 0 + }, + { + "adult": false, + "backdrop_path": "/gV2wSIlNMIUxEArKYrTF2NX4tjb.jpg", + "genre_ids": [ + 99 + ], + "id": 834027, + "original_language": "en", + "original_title": "Val", + "overview": "For over 40 years Val Kilmer, one of Hollywood’s most mercurial and/or misunderstood actors has been documenting his own life and craft through film and video. He has amassed thousands of hours of footage, from 16mm home movies made with his brothers, to time spent in iconic roles for blockbuster movies like Top Gun, The Doors, Tombstone, and Batman Forever. This raw, wildly original and unflinching documentary reveals a life lived to extremes and a heart-filled, sometimes hilarious look at what it means to be an artist and a complex man.", + "popularity": 11.448, + "poster_path": "/vWJKmfmjpkFeTbUGep6t7w5TexA.jpg", + "release_date": "2021-07-23", + "title": "Val", + "video": false, + "vote_average": 7, + "vote_count": 106 + }, + { + "adult": false, + "backdrop_path": "/kjRFf4mbBQZ3NDwF3MM1eRKqZfB.jpg", + "genre_ids": [ + 28 + ], + "id": 714351, + "original_language": "en", + "original_title": "Top Gunner", + "overview": "Recent graduates of a secluded U.S. Air Force base must protect a gene-editing bioweapon from the Russian military—who are desperate to seize the deadly viral agent at any cost.", + "popularity": 8.577, + "poster_path": "/w3pYxiYHcPlEIW44RYdQgNQESvE.jpg", + "release_date": "2020-06-23", + "title": "Top Gunner", + "video": false, + "vote_average": 5.8, + "vote_count": 104 + }, + { + "adult": false, + "backdrop_path": "/wQjx0spZDP6ZwYdjQjNKeljbAvQ.jpg", + "genre_ids": [ + 28, + 35 + ], + "id": 95094, + "original_language": "en", + "original_title": "No. 1 of the Secret Service", + "overview": "No. 1 is fearless, irrestible, and licensed to kill. No. 1 is assigned to capture a madman killing international financiers. Before getting the bad guy, No. 1 encounters mercenaries from the evil organization K.R.A.S.H. (Killing, Rape, Arson, Slaughter, and Hit).", + "popularity": 1.964, + "poster_path": "/vKBNaS5LxidxeXYzaLyHSbFIgrT.jpg", + "release_date": "1978-04-01", + "title": "No. 1 of the Secret Service", + "video": false, + "vote_average": 4.7, + "vote_count": 6 + }, + { + "adult": false, + "backdrop_path": "/s9hW1DHfgy5ppK1fTUJuMKh4YFK.jpg", + "genre_ids": [ + 28, + 53 + ], + "id": 980083, + "original_language": "en", + "original_title": "Top Gunner: Danger Zone", + "overview": "An airliner filled with 800 passengers is forced to fly fast and low, above farmlands, suburbs and skyscraper-packed cities or the tons of explosives aboard will detonate. When an elite unit of US Air Force fighter jets is sent to provide escort, they find themselves facing a squadron of unidentifiable warplanes which ignites a deadly air battle that threatens to destroy all life above and below.", + "popularity": 4.48, + "poster_path": "/29UCk1nvPzn2XubLk5rKDMlHBRu.jpg", + "release_date": "2022-05-20", + "title": "Top Gunner: Danger Zone", + "video": false, + "vote_average": 3.7, + "vote_count": 7 + } + ], + "total_pages": 2, + "total_results": 27 +} \ No newline at end of file diff --git a/spec/fixtures/top_rated_godfather.json b/spec/fixtures/top_rated_godfather.json new file mode 100644 index 0000000000..8070b20d18 --- /dev/null +++ b/spec/fixtures/top_rated_godfather.json @@ -0,0 +1,396 @@ +{ + "page": 1, + "results": [ + { + "adult": false, + "backdrop_path": "/tmU7GeKVybMWFButWEGl2M4GeiP.jpg", + "genre_ids": [ + 18, + 80 + ], + "id": 238, + "original_language": "en", + "original_title": "The Godfather", + "overview": "Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.", + "popularity": 90.094, + "poster_path": "/3bhkrj58Vtu7enYsRolD1fZdja1.jpg", + "release_date": "1972-03-14", + "title": "The Godfather", + "video": false, + "vote_average": 8.7, + "vote_count": 17402 + }, + { + "adult": false, + "backdrop_path": "/wPU78OPN4BYEgWYdXyg0phMee64.jpg", + "genre_ids": [ + 18, + 80 + ], + "id": 278, + "original_language": "en", + "original_title": "The Shawshank Redemption", + "overview": "Framed in the 1940s for the double murder of his wife and her lover, upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where he puts his accounting skills to work for an amoral warden. During his long stretch in prison, Dufresne comes to be admired by the other inmates -- including an older prisoner named Red -- for his integrity and unquenchable sense of hope.", + "popularity": 100.339, + "poster_path": "/hBcY0fE9pfXzvVaY4GKarweriG2.jpg", + "release_date": "1994-09-23", + "title": "The Shawshank Redemption", + "video": false, + "vote_average": 8.7, + "vote_count": 23196 + }, + { + "adult": false, + "backdrop_path": "/kGzFbGhp99zva6oZODW5atUtnqi.jpg", + "genre_ids": [ + 18, + 80 + ], + "id": 240, + "original_language": "en", + "original_title": "The Godfather Part II", + "overview": "In the continuing saga of the Corleone crime family, a young Vito Corleone grows up in Sicily and in 1910s New York. In the 1950s, Michael Corleone attempts to expand the family business into Las Vegas, Hollywood and Cuba.", + "popularity": 60.985, + "poster_path": "/hek3koDUyRQk7FIhPXsa6mT2Zc3.jpg", + "release_date": "1974-12-20", + "title": "The Godfather Part II", + "video": false, + "vote_average": 8.6, + "vote_count": 10537 + }, + { + "adult": false, + "backdrop_path": "/zb6fM1CX41D9rF9hdgclu0peUmy.jpg", + "genre_ids": [ + 18, + 36, + 10752 + ], + "id": 424, + "original_language": "en", + "original_title": "Schindler's List", + "overview": "The true story of how businessman Oskar Schindler saved over a thousand Jewish lives from the Nazis while they worked as slaves in his factory during World War II.", + "popularity": 52.414, + "poster_path": "/sF1U4EUQS8YHUYjNl3pMGNIQyr0.jpg", + "release_date": "1993-12-15", + "title": "Schindler's List", + "video": false, + "vote_average": 8.6, + "vote_count": 13711 + }, + { + "adult": false, + "backdrop_path": "/vI3aUGTuRRdM7J78KIdW98LdxE5.jpg", + "genre_ids": [ + 35, + 18, + 10749 + ], + "id": 19404, + "original_language": "hi", + "original_title": "दिलवाले दुल्हनिया ले जायेंगे", + "overview": "Raj is a rich, carefree, happy-go-lucky second generation NRI. Simran is the daughter of Chaudhary Baldev Singh, who in spite of being an NRI is very strict about adherence to Indian values. Simran has left for India to be married to her childhood fiancé. Raj leaves for India with a mission at his hands, to claim his lady love under the noses of her whole family. Thus begins a saga.", + "popularity": 31.418, + "poster_path": "/2CAL2433ZeIihfX1Hb2139CX0pW.jpg", + "release_date": "1995-10-19", + "title": "Dilwale Dulhania Le Jayenge", + "video": false, + "vote_average": 8.6, + "vote_count": 4043 + }, + { + "adult": false, + "backdrop_path": "/faXT8V80JRhnArTAeYXz0Eutpv9.jpg", + "genre_ids": [ + 16, + 12, + 35, + 10751, + 14 + ], + "id": 315162, + "original_language": "en", + "original_title": "Puss in Boots: The Last Wish", + "overview": "Puss in Boots discovers that his passion for adventure has taken its toll: He has burned through eight of his nine lives, leaving him with only one life left. Puss sets out on an epic journey to find the mythical Last Wish and restore his nine lives.", + "popularity": 4239.37, + "poster_path": "/kuf6dutpsT0vSVehic3EZIqkOBt.jpg", + "release_date": "2022-12-07", + "title": "Puss in Boots: The Last Wish", + "video": false, + "vote_average": 8.6, + "vote_count": 3130 + }, + { + "adult": false, + "backdrop_path": "/Ab8mkHmkYADjU7wQiOkia9BzGvS.jpg", + "genre_ids": [ + 16, + 10751, + 14 + ], + "id": 129, + "original_language": "ja", + "original_title": "千と千尋の神隠し", + "overview": "A young girl, Chihiro, becomes trapped in a strange new world of spirits. When her parents undergo a mysterious transformation, she must call upon the courage she never knew she had to free her family.", + "popularity": 80.123, + "poster_path": "/39wmItIWsg5sZMyRUHLkWBcuVCM.jpg", + "release_date": "2002-09-20", + "title": "Spirited Away", + "video": false, + "vote_average": 8.5, + "vote_count": 13886 + }, + { + "adult": false, + "backdrop_path": "/qqHQsStV6exghCM7zbObuYBiYxw.jpg", + "genre_ids": [ + 18 + ], + "id": 389, + "original_language": "en", + "original_title": "12 Angry Men", + "overview": "The defense and the prosecution have rested and the jury is filing into the jury room to decide if a young Spanish-American is guilty or innocent of murdering his father. What begins as an open and shut case soon becomes a mini-drama of each of the jurors' prejudices and preconceptions about the trial, the accused, and each other.", + "popularity": 30.317, + "poster_path": "/ppd84D2i9W8jXmsyInGyihiSyqz.jpg", + "release_date": "1957-04-10", + "title": "12 Angry Men", + "video": false, + "vote_average": 8.5, + "vote_count": 7005 + }, + { + "adult": false, + "backdrop_path": "/dIWwZW7dJJtqC6CgWzYkNVKIUm8.jpg", + "genre_ids": [ + 10749, + 16, + 18 + ], + "id": 372058, + "original_language": "ja", + "original_title": "君の名は。", + "overview": "High schoolers Mitsuha and Taki are complete strangers living separate lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki’s body, and he in hers. This bizarre occurrence continues to happen randomly, and the two must adjust their lives around each other.", + "popularity": 97.602, + "poster_path": "/q719jXXEzOoYaps6babgKnONONX.jpg", + "release_date": "2016-08-26", + "title": "Your Name.", + "video": false, + "vote_average": 8.5, + "vote_count": 9458 + }, + { + "adult": false, + "backdrop_path": "/2MBBuXBE26AjRRTmj8poSFHLhhS.jpg", + "genre_ids": [ + 35, + 53, + 18 + ], + "id": 496243, + "original_language": "ko", + "original_title": "기생충", + "overview": "All unemployed, Ki-taek's family takes peculiar interest in the wealthy and glamorous Parks for their livelihood until they get entangled in an unexpected incident.", + "popularity": 59.797, + "poster_path": "/7IiTTgloJzvGI1TAYymCfbfl3vT.jpg", + "release_date": "2019-05-30", + "title": "Parasite", + "video": false, + "vote_average": 8.5, + "vote_count": 15180 + }, + { + "adult": false, + "backdrop_path": "/l6hQWH9eDksNJNiXWYRkWqikOdu.jpg", + "genre_ids": [ + 14, + 18, + 80 + ], + "id": 497, + "original_language": "en", + "original_title": "The Green Mile", + "overview": "A supernatural tale set on death row in a Southern prison, where gentle giant John Coffey possesses the mysterious power to heal people's ailments. When the cell block's head guard, Paul Edgecomb, recognizes Coffey's miraculous gift, he tries desperately to help stave off the condemned man's execution.", + "popularity": 106.922, + "poster_path": "/velWPhVMQeQKcxggNEU8YmIo52R.jpg", + "release_date": "1999-12-10", + "title": "The Green Mile", + "video": false, + "vote_average": 8.5, + "vote_count": 14986 + }, + { + "adult": false, + "backdrop_path": "/pbEkjhdfP7yuDcMB78YEZwgD4IN.jpg", + "genre_ids": [ + 18, + 28, + 80, + 53 + ], + "id": 155, + "original_language": "en", + "original_title": "The Dark Knight", + "overview": "Batman raises the stakes in his war on crime. With the help of Lt. Jim Gordon and District Attorney Harvey Dent, Batman sets out to dismantle the remaining criminal organizations that plague the streets. The partnership proves to be effective, but they soon find themselves prey to a reign of chaos unleashed by a rising criminal mastermind known to the terrified citizens of Gotham as the Joker.", + "popularity": 74.7, + "poster_path": "/qJ2tW6WMUDux911r6m7haRef0WH.jpg", + "release_date": "2008-07-14", + "title": "The Dark Knight", + "video": false, + "vote_average": 8.5, + "vote_count": 29096 + }, + { + "adult": false, + "backdrop_path": "/suaEOtk1N1sgg2MTM7oZd2cfVp3.jpg", + "genre_ids": [ + 53, + 80 + ], + "id": 680, + "original_language": "en", + "original_title": "Pulp Fiction", + "overview": "A burger-loving hit man, his philosophical partner, a drug-addled gangster's moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their adventures unfurl in three stories that ingeniously trip back and forth in time.", + "popularity": 71.153, + "poster_path": "/fIE3lAGcZDV1G6XM5KmuWnNsPp1.jpg", + "release_date": "1994-09-10", + "title": "Pulp Fiction", + "video": false, + "vote_average": 8.5, + "vote_count": 24574 + }, + { + "adult": false, + "backdrop_path": "/eoCSp75lxatmIa6aGqfnzwtbttd.jpg", + "genre_ids": [ + 37 + ], + "id": 429, + "original_language": "it", + "original_title": "Il buono, il brutto, il cattivo", + "overview": "While the Civil War rages on between the Union and the Confederacy, three men – a quiet loner, a ruthless hitman, and a Mexican bandit – comb the American Southwest in search of a strongbox containing $200,000 in stolen gold.", + "popularity": 58.897, + "poster_path": "/bX2xnavhMYjWDoZp1VM6VnU1xwe.jpg", + "release_date": "1966-12-23", + "title": "The Good, the Bad and the Ugly", + "video": false, + "vote_average": 8.5, + "vote_count": 7176 + }, + { + "adult": false, + "backdrop_path": "/3h1JZGDhZ8nzxdgvkxha0qBqi05.jpg", + "genre_ids": [ + 35, + 18, + 10749 + ], + "id": 13, + "original_language": "en", + "original_title": "Forrest Gump", + "overview": "A man with a low IQ has accomplished great things in his life and been present during significant historic events—in each case, far exceeding what anyone imagined he could do. But despite all he has achieved, his one true love eludes him.", + "popularity": 67.775, + "poster_path": "/arw2vcBveWOVZr6pxd9XTd1TdQa.jpg", + "release_date": "1994-06-23", + "title": "Forrest Gump", + "video": false, + "vote_average": 8.5, + "vote_count": 24074 + }, + { + "adult": false, + "backdrop_path": "/3RMLbSEXOn1CzLoNT7xFeLfdxhq.jpg", + "genre_ids": [ + 10749, + 16 + ], + "id": 372754, + "original_language": "ja", + "original_title": "同級生", + "overview": "Rihito Sajo, an honor student with a perfect score on the entrance exam and Hikaru Kusakabe, in a band and popular among girls, would have never crossed paths. Until one day they started talking at the practice for their school’s upcoming chorus festival. After school, the two meet regularly, as Hikaru helps Rihito to improve his singing skills. While they listen to each other’s voice and harmonize, their hearts start to beat together.", + "popularity": 9.567, + "poster_path": "/cIfRCA5wEvj9tApca4UDUagQEiM.jpg", + "release_date": "2016-02-20", + "title": "Dou kyu sei – Classmates", + "video": false, + "vote_average": 8.5, + "vote_count": 289 + }, + { + "adult": false, + "backdrop_path": "/w2uGvCpMtvRqZg6waC1hvLyZoJa.jpg", + "genre_ids": [ + 10749 + ], + "id": 696374, + "original_language": "en", + "original_title": "Gabriel's Inferno", + "overview": "An intriguing and sinful exploration of seduction, forbidden love, and redemption, Gabriel's Inferno is a captivating and wildly passionate tale of one man's escape from his own personal hell as he tries to earn the impossible--forgiveness and love.", + "popularity": 14.282, + "poster_path": "/oyG9TL7FcRP4EZ9Vid6uKzwdndz.jpg", + "release_date": "2020-05-29", + "title": "Gabriel's Inferno", + "video": false, + "vote_average": 8.5, + "vote_count": 2322 + }, + { + "adult": false, + "backdrop_path": "/lXhgCODAbBXL5buk9yEmTpOoOgR.jpg", + "genre_ids": [ + 12, + 14, + 28 + ], + "id": 122, + "original_language": "en", + "original_title": "The Lord of the Rings: The Return of the King", + "overview": "Aragorn is revealed as the heir to the ancient kings as he, Gandalf and the other members of the broken fellowship struggle to save Gondor from Sauron's forces. Meanwhile, Frodo and Sam take the ring closer to the heart of Mordor, the dark lord's realm.", + "popularity": 78.719, + "poster_path": "/rCzpDGLbOoPwLjy3OAm5NUPOTrC.jpg", + "release_date": "2003-12-01", + "title": "The Lord of the Rings: The Return of the King", + "video": false, + "vote_average": 8.5, + "vote_count": 21021 + }, + { + "adult": false, + "backdrop_path": "/sw7mordbZxgITU877yTpZCud90M.jpg", + "genre_ids": [ + 18, + 80 + ], + "id": 769, + "original_language": "en", + "original_title": "GoodFellas", + "overview": "The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid who is adopted by neighbourhood gangsters at an early age and climbs the ranks of a Mafia family under the guidance of Jimmy Conway.", + "popularity": 43.077, + "poster_path": "/aKuFiU82s5ISJpGZp7YkIr3kCUd.jpg", + "release_date": "1990-09-12", + "title": "GoodFellas", + "video": false, + "vote_average": 8.5, + "vote_count": 10943 + }, + { + "adult": false, + "backdrop_path": "/jtAI6OJIWLWiRItNSZoWjrsUtmi.jpg", + "genre_ids": [ + 10749 + ], + "id": 724089, + "original_language": "en", + "original_title": "Gabriel's Inferno: Part II", + "overview": "Professor Gabriel Emerson finally learns the truth about Julia Mitchell's identity, but his realization comes a moment too late. Julia is done waiting for the well-respected Dante specialist to remember her and wants nothing more to do with him. Can Gabriel win back her heart before she finds love in another's arms?", + "popularity": 16.385, + "poster_path": "/x5o8cLZfEXMoZczTYWLrUo1P7UJ.jpg", + "release_date": "2020-07-31", + "title": "Gabriel's Inferno: Part II", + "video": false, + "vote_average": 8.5, + "vote_count": 1459 + } + ], + "total_pages": 539, + "total_results": 10768 +} \ No newline at end of file diff --git a/spec/fixtures/top_rated_response.json b/spec/fixtures/top_rated_response.json new file mode 100644 index 0000000000..8070b20d18 --- /dev/null +++ b/spec/fixtures/top_rated_response.json @@ -0,0 +1,396 @@ +{ + "page": 1, + "results": [ + { + "adult": false, + "backdrop_path": "/tmU7GeKVybMWFButWEGl2M4GeiP.jpg", + "genre_ids": [ + 18, + 80 + ], + "id": 238, + "original_language": "en", + "original_title": "The Godfather", + "overview": "Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.", + "popularity": 90.094, + "poster_path": "/3bhkrj58Vtu7enYsRolD1fZdja1.jpg", + "release_date": "1972-03-14", + "title": "The Godfather", + "video": false, + "vote_average": 8.7, + "vote_count": 17402 + }, + { + "adult": false, + "backdrop_path": "/wPU78OPN4BYEgWYdXyg0phMee64.jpg", + "genre_ids": [ + 18, + 80 + ], + "id": 278, + "original_language": "en", + "original_title": "The Shawshank Redemption", + "overview": "Framed in the 1940s for the double murder of his wife and her lover, upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where he puts his accounting skills to work for an amoral warden. During his long stretch in prison, Dufresne comes to be admired by the other inmates -- including an older prisoner named Red -- for his integrity and unquenchable sense of hope.", + "popularity": 100.339, + "poster_path": "/hBcY0fE9pfXzvVaY4GKarweriG2.jpg", + "release_date": "1994-09-23", + "title": "The Shawshank Redemption", + "video": false, + "vote_average": 8.7, + "vote_count": 23196 + }, + { + "adult": false, + "backdrop_path": "/kGzFbGhp99zva6oZODW5atUtnqi.jpg", + "genre_ids": [ + 18, + 80 + ], + "id": 240, + "original_language": "en", + "original_title": "The Godfather Part II", + "overview": "In the continuing saga of the Corleone crime family, a young Vito Corleone grows up in Sicily and in 1910s New York. In the 1950s, Michael Corleone attempts to expand the family business into Las Vegas, Hollywood and Cuba.", + "popularity": 60.985, + "poster_path": "/hek3koDUyRQk7FIhPXsa6mT2Zc3.jpg", + "release_date": "1974-12-20", + "title": "The Godfather Part II", + "video": false, + "vote_average": 8.6, + "vote_count": 10537 + }, + { + "adult": false, + "backdrop_path": "/zb6fM1CX41D9rF9hdgclu0peUmy.jpg", + "genre_ids": [ + 18, + 36, + 10752 + ], + "id": 424, + "original_language": "en", + "original_title": "Schindler's List", + "overview": "The true story of how businessman Oskar Schindler saved over a thousand Jewish lives from the Nazis while they worked as slaves in his factory during World War II.", + "popularity": 52.414, + "poster_path": "/sF1U4EUQS8YHUYjNl3pMGNIQyr0.jpg", + "release_date": "1993-12-15", + "title": "Schindler's List", + "video": false, + "vote_average": 8.6, + "vote_count": 13711 + }, + { + "adult": false, + "backdrop_path": "/vI3aUGTuRRdM7J78KIdW98LdxE5.jpg", + "genre_ids": [ + 35, + 18, + 10749 + ], + "id": 19404, + "original_language": "hi", + "original_title": "दिलवाले दुल्हनिया ले जायेंगे", + "overview": "Raj is a rich, carefree, happy-go-lucky second generation NRI. Simran is the daughter of Chaudhary Baldev Singh, who in spite of being an NRI is very strict about adherence to Indian values. Simran has left for India to be married to her childhood fiancé. Raj leaves for India with a mission at his hands, to claim his lady love under the noses of her whole family. Thus begins a saga.", + "popularity": 31.418, + "poster_path": "/2CAL2433ZeIihfX1Hb2139CX0pW.jpg", + "release_date": "1995-10-19", + "title": "Dilwale Dulhania Le Jayenge", + "video": false, + "vote_average": 8.6, + "vote_count": 4043 + }, + { + "adult": false, + "backdrop_path": "/faXT8V80JRhnArTAeYXz0Eutpv9.jpg", + "genre_ids": [ + 16, + 12, + 35, + 10751, + 14 + ], + "id": 315162, + "original_language": "en", + "original_title": "Puss in Boots: The Last Wish", + "overview": "Puss in Boots discovers that his passion for adventure has taken its toll: He has burned through eight of his nine lives, leaving him with only one life left. Puss sets out on an epic journey to find the mythical Last Wish and restore his nine lives.", + "popularity": 4239.37, + "poster_path": "/kuf6dutpsT0vSVehic3EZIqkOBt.jpg", + "release_date": "2022-12-07", + "title": "Puss in Boots: The Last Wish", + "video": false, + "vote_average": 8.6, + "vote_count": 3130 + }, + { + "adult": false, + "backdrop_path": "/Ab8mkHmkYADjU7wQiOkia9BzGvS.jpg", + "genre_ids": [ + 16, + 10751, + 14 + ], + "id": 129, + "original_language": "ja", + "original_title": "千と千尋の神隠し", + "overview": "A young girl, Chihiro, becomes trapped in a strange new world of spirits. When her parents undergo a mysterious transformation, she must call upon the courage she never knew she had to free her family.", + "popularity": 80.123, + "poster_path": "/39wmItIWsg5sZMyRUHLkWBcuVCM.jpg", + "release_date": "2002-09-20", + "title": "Spirited Away", + "video": false, + "vote_average": 8.5, + "vote_count": 13886 + }, + { + "adult": false, + "backdrop_path": "/qqHQsStV6exghCM7zbObuYBiYxw.jpg", + "genre_ids": [ + 18 + ], + "id": 389, + "original_language": "en", + "original_title": "12 Angry Men", + "overview": "The defense and the prosecution have rested and the jury is filing into the jury room to decide if a young Spanish-American is guilty or innocent of murdering his father. What begins as an open and shut case soon becomes a mini-drama of each of the jurors' prejudices and preconceptions about the trial, the accused, and each other.", + "popularity": 30.317, + "poster_path": "/ppd84D2i9W8jXmsyInGyihiSyqz.jpg", + "release_date": "1957-04-10", + "title": "12 Angry Men", + "video": false, + "vote_average": 8.5, + "vote_count": 7005 + }, + { + "adult": false, + "backdrop_path": "/dIWwZW7dJJtqC6CgWzYkNVKIUm8.jpg", + "genre_ids": [ + 10749, + 16, + 18 + ], + "id": 372058, + "original_language": "ja", + "original_title": "君の名は。", + "overview": "High schoolers Mitsuha and Taki are complete strangers living separate lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki’s body, and he in hers. This bizarre occurrence continues to happen randomly, and the two must adjust their lives around each other.", + "popularity": 97.602, + "poster_path": "/q719jXXEzOoYaps6babgKnONONX.jpg", + "release_date": "2016-08-26", + "title": "Your Name.", + "video": false, + "vote_average": 8.5, + "vote_count": 9458 + }, + { + "adult": false, + "backdrop_path": "/2MBBuXBE26AjRRTmj8poSFHLhhS.jpg", + "genre_ids": [ + 35, + 53, + 18 + ], + "id": 496243, + "original_language": "ko", + "original_title": "기생충", + "overview": "All unemployed, Ki-taek's family takes peculiar interest in the wealthy and glamorous Parks for their livelihood until they get entangled in an unexpected incident.", + "popularity": 59.797, + "poster_path": "/7IiTTgloJzvGI1TAYymCfbfl3vT.jpg", + "release_date": "2019-05-30", + "title": "Parasite", + "video": false, + "vote_average": 8.5, + "vote_count": 15180 + }, + { + "adult": false, + "backdrop_path": "/l6hQWH9eDksNJNiXWYRkWqikOdu.jpg", + "genre_ids": [ + 14, + 18, + 80 + ], + "id": 497, + "original_language": "en", + "original_title": "The Green Mile", + "overview": "A supernatural tale set on death row in a Southern prison, where gentle giant John Coffey possesses the mysterious power to heal people's ailments. When the cell block's head guard, Paul Edgecomb, recognizes Coffey's miraculous gift, he tries desperately to help stave off the condemned man's execution.", + "popularity": 106.922, + "poster_path": "/velWPhVMQeQKcxggNEU8YmIo52R.jpg", + "release_date": "1999-12-10", + "title": "The Green Mile", + "video": false, + "vote_average": 8.5, + "vote_count": 14986 + }, + { + "adult": false, + "backdrop_path": "/pbEkjhdfP7yuDcMB78YEZwgD4IN.jpg", + "genre_ids": [ + 18, + 28, + 80, + 53 + ], + "id": 155, + "original_language": "en", + "original_title": "The Dark Knight", + "overview": "Batman raises the stakes in his war on crime. With the help of Lt. Jim Gordon and District Attorney Harvey Dent, Batman sets out to dismantle the remaining criminal organizations that plague the streets. The partnership proves to be effective, but they soon find themselves prey to a reign of chaos unleashed by a rising criminal mastermind known to the terrified citizens of Gotham as the Joker.", + "popularity": 74.7, + "poster_path": "/qJ2tW6WMUDux911r6m7haRef0WH.jpg", + "release_date": "2008-07-14", + "title": "The Dark Knight", + "video": false, + "vote_average": 8.5, + "vote_count": 29096 + }, + { + "adult": false, + "backdrop_path": "/suaEOtk1N1sgg2MTM7oZd2cfVp3.jpg", + "genre_ids": [ + 53, + 80 + ], + "id": 680, + "original_language": "en", + "original_title": "Pulp Fiction", + "overview": "A burger-loving hit man, his philosophical partner, a drug-addled gangster's moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their adventures unfurl in three stories that ingeniously trip back and forth in time.", + "popularity": 71.153, + "poster_path": "/fIE3lAGcZDV1G6XM5KmuWnNsPp1.jpg", + "release_date": "1994-09-10", + "title": "Pulp Fiction", + "video": false, + "vote_average": 8.5, + "vote_count": 24574 + }, + { + "adult": false, + "backdrop_path": "/eoCSp75lxatmIa6aGqfnzwtbttd.jpg", + "genre_ids": [ + 37 + ], + "id": 429, + "original_language": "it", + "original_title": "Il buono, il brutto, il cattivo", + "overview": "While the Civil War rages on between the Union and the Confederacy, three men – a quiet loner, a ruthless hitman, and a Mexican bandit – comb the American Southwest in search of a strongbox containing $200,000 in stolen gold.", + "popularity": 58.897, + "poster_path": "/bX2xnavhMYjWDoZp1VM6VnU1xwe.jpg", + "release_date": "1966-12-23", + "title": "The Good, the Bad and the Ugly", + "video": false, + "vote_average": 8.5, + "vote_count": 7176 + }, + { + "adult": false, + "backdrop_path": "/3h1JZGDhZ8nzxdgvkxha0qBqi05.jpg", + "genre_ids": [ + 35, + 18, + 10749 + ], + "id": 13, + "original_language": "en", + "original_title": "Forrest Gump", + "overview": "A man with a low IQ has accomplished great things in his life and been present during significant historic events—in each case, far exceeding what anyone imagined he could do. But despite all he has achieved, his one true love eludes him.", + "popularity": 67.775, + "poster_path": "/arw2vcBveWOVZr6pxd9XTd1TdQa.jpg", + "release_date": "1994-06-23", + "title": "Forrest Gump", + "video": false, + "vote_average": 8.5, + "vote_count": 24074 + }, + { + "adult": false, + "backdrop_path": "/3RMLbSEXOn1CzLoNT7xFeLfdxhq.jpg", + "genre_ids": [ + 10749, + 16 + ], + "id": 372754, + "original_language": "ja", + "original_title": "同級生", + "overview": "Rihito Sajo, an honor student with a perfect score on the entrance exam and Hikaru Kusakabe, in a band and popular among girls, would have never crossed paths. Until one day they started talking at the practice for their school’s upcoming chorus festival. After school, the two meet regularly, as Hikaru helps Rihito to improve his singing skills. While they listen to each other’s voice and harmonize, their hearts start to beat together.", + "popularity": 9.567, + "poster_path": "/cIfRCA5wEvj9tApca4UDUagQEiM.jpg", + "release_date": "2016-02-20", + "title": "Dou kyu sei – Classmates", + "video": false, + "vote_average": 8.5, + "vote_count": 289 + }, + { + "adult": false, + "backdrop_path": "/w2uGvCpMtvRqZg6waC1hvLyZoJa.jpg", + "genre_ids": [ + 10749 + ], + "id": 696374, + "original_language": "en", + "original_title": "Gabriel's Inferno", + "overview": "An intriguing and sinful exploration of seduction, forbidden love, and redemption, Gabriel's Inferno is a captivating and wildly passionate tale of one man's escape from his own personal hell as he tries to earn the impossible--forgiveness and love.", + "popularity": 14.282, + "poster_path": "/oyG9TL7FcRP4EZ9Vid6uKzwdndz.jpg", + "release_date": "2020-05-29", + "title": "Gabriel's Inferno", + "video": false, + "vote_average": 8.5, + "vote_count": 2322 + }, + { + "adult": false, + "backdrop_path": "/lXhgCODAbBXL5buk9yEmTpOoOgR.jpg", + "genre_ids": [ + 12, + 14, + 28 + ], + "id": 122, + "original_language": "en", + "original_title": "The Lord of the Rings: The Return of the King", + "overview": "Aragorn is revealed as the heir to the ancient kings as he, Gandalf and the other members of the broken fellowship struggle to save Gondor from Sauron's forces. Meanwhile, Frodo and Sam take the ring closer to the heart of Mordor, the dark lord's realm.", + "popularity": 78.719, + "poster_path": "/rCzpDGLbOoPwLjy3OAm5NUPOTrC.jpg", + "release_date": "2003-12-01", + "title": "The Lord of the Rings: The Return of the King", + "video": false, + "vote_average": 8.5, + "vote_count": 21021 + }, + { + "adult": false, + "backdrop_path": "/sw7mordbZxgITU877yTpZCud90M.jpg", + "genre_ids": [ + 18, + 80 + ], + "id": 769, + "original_language": "en", + "original_title": "GoodFellas", + "overview": "The true story of Henry Hill, a half-Irish, half-Sicilian Brooklyn kid who is adopted by neighbourhood gangsters at an early age and climbs the ranks of a Mafia family under the guidance of Jimmy Conway.", + "popularity": 43.077, + "poster_path": "/aKuFiU82s5ISJpGZp7YkIr3kCUd.jpg", + "release_date": "1990-09-12", + "title": "GoodFellas", + "video": false, + "vote_average": 8.5, + "vote_count": 10943 + }, + { + "adult": false, + "backdrop_path": "/jtAI6OJIWLWiRItNSZoWjrsUtmi.jpg", + "genre_ids": [ + 10749 + ], + "id": 724089, + "original_language": "en", + "original_title": "Gabriel's Inferno: Part II", + "overview": "Professor Gabriel Emerson finally learns the truth about Julia Mitchell's identity, but his realization comes a moment too late. Julia is done waiting for the well-respected Dante specialist to remember her and wants nothing more to do with him. Can Gabriel win back her heart before she finds love in another's arms?", + "popularity": 16.385, + "poster_path": "/x5o8cLZfEXMoZczTYWLrUo1P7UJ.jpg", + "release_date": "2020-07-31", + "title": "Gabriel's Inferno: Part II", + "video": false, + "vote_average": 8.5, + "vote_count": 1459 + } + ], + "total_pages": 539, + "total_results": 10768 +} \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1d8f63c286..163dbe5f21 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,7 @@ # it. # require 'simplecov' +# require 'webmock/rspec' SimpleCov.start 'rails' SimpleCov.add_filter ['spec', 'config'] # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration From 575a3bb8f775a76ac3f4e19866e18096dd3de2f4 Mon Sep 17 00:00:00 2001 From: William Lampke Date: Fri, 3 Feb 2023 16:37:29 -0500 Subject: [PATCH 14/14] final changes --- Gemfile | 1 + app/controllers/movies_controller.rb | 2 ++ app/controllers/viewing_parties_controller.rb | 6 +++++- app/views/movies/show.html.erb | 1 + app/views/users/index.html.erb | 2 +- app/views/users/show.html.erb | 1 - db/seeds.rb | 12 ++++++++++++ 7 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index b8a2d0ac21..8bc21e077a 100644 --- a/Gemfile +++ b/Gemfile @@ -54,6 +54,7 @@ group :test do gem 'simplecov' gem 'shoulda-matchers' gem 'launchy' + end diff --git a/app/controllers/movies_controller.rb b/app/controllers/movies_controller.rb index ac51a2eb0d..d2c32ab585 100644 --- a/app/controllers/movies_controller.rb +++ b/app/controllers/movies_controller.rb @@ -13,6 +13,8 @@ def index end def show + @user = params[:user_id] + @movie = MoviesFascade.find(params[:id]) end end diff --git a/app/controllers/viewing_parties_controller.rb b/app/controllers/viewing_parties_controller.rb index 9799fcc669..d6c82be4c9 100644 --- a/app/controllers/viewing_parties_controller.rb +++ b/app/controllers/viewing_parties_controller.rb @@ -15,9 +15,13 @@ def create @user = User.find(params[:user_id]) time = params['time(4i)'] + ':' + params['time(5i)'] vp = ViewingParty.create!(title: @movie.title, duration: params[:duration], start_time: time, host: @user.id) + ViewingPartyUser.create!(viewing_party_id: vp.id, user_id: @user.id) @all_users = User.all @all_users.each do |user| - ViewingPartyUser.create!(viewing_party_id: vp.id, user_id: user.id) if params[user.name.to_sym] == '1' + if params[user.name.to_sym] == '1' + ViewingPartyUser.create!(viewing_party_id: vp.id, user_id: user.id) + + end end redirect_to "/users/#{@user.id}/movies/#{@movie.movie_id}/viewing_parties/#{vp.id}" end diff --git a/app/views/movies/show.html.erb b/app/views/movies/show.html.erb index 7ab643be67..e6532ed5bb 100644 --- a/app/views/movies/show.html.erb +++ b/app/views/movies/show.html.erb @@ -6,6 +6,7 @@ <% @movie.genres.each do |genre| %>

<%= genre[:name] %>

<% end %> +<%= link_to "Create a Viewing Party for this movie", "/users/#{@user.to_i}/movies/#{@movie.movie_id}/viewing_parties/new", method: :get, local: true %>
Cast:
<% MoviesFascade.cast(@movie.movie_id).each do |castmember| %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index a6e1573f1e..c69132e7c6 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -1,5 +1,5 @@ <% @users.each do |user| %>
    -
  • <%= "Name: #{user.name}" %>
  • +
  • <%= link_to "Name: #{user.name}", "/users/#{user.id}", method: :get, local: true %>
<% end %> \ No newline at end of file diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 8bd5de33cd..f2e9205a8a 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -3,7 +3,6 @@ <%= form_with url: "/users/#{@user.id}/discover", method: :get, local: true do |f| %> <%= f.submit 'Discover Movies' %> <% end %> - <% @user.viewing_parties.each do |vp| %>
> diff --git a/db/seeds.rb b/db/seeds.rb index 1beea2accd..c1a5ded363 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,15 @@ # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first) +@user_1 = User.create!(name: 'William', email: 'william@gmail.com') +@user_2 = User.create!(name: 'Christian', email: 'christian@gmail.com') +@user_3 = User.create!(name: 'Fake', email: 'fake@gmail.com') + +@viewing_party_1 = ViewingParty.create!(title: 'Top Gun', duration: 120, start_time: '14:22', host: @user_2.id) +@viewing_party_2 = ViewingParty.create!(title: 'Hereditary', duration: 111, start_time: '09:46', host: @user_1.id) + +@viewing_party_user_1 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_1.id) +@viewing_party_user_2 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_1.id) + +@viewing_party_user_3 = ViewingPartyUser.create!(user_id: @user_1.id, viewing_party_id: @viewing_party_2.id) +@viewing_party_user_4 = ViewingPartyUser.create!(user_id: @user_2.id, viewing_party_id: @viewing_party_2.id)