Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eric Belongea & John O'Leary #91

Open
wants to merge 95 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
ea24cb9
Add a PR request template
EricBelongea Nov 27, 2023
48e93e3
Merge pull request #1 from EricBelongea/feature/setup
Captainlearyo Nov 27, 2023
cbab649
This will add gems to the Gemfile
EricBelongea Nov 27, 2023
36a710b
Add gem and database setup.
EricBelongea Nov 27, 2023
4096b63
Merge pull request #2 from EricBelongea/feature/setup
Captainlearyo Nov 27, 2023
ed34381
Add controllers, models, tests, and views.
EricBelongea Nov 28, 2023
4892dad
Add models, controllers, tests, and more.
EricBelongea Nov 28, 2023
4e69c2f
Merge pull request #3 from EricBelongea/feature/landing_page
Captainlearyo Nov 28, 2023
fdbdfca
complete landing page
Captainlearyo Nov 28, 2023
097e459
Merge pull request #4 from EricBelongea/landing_page
EricBelongea Nov 28, 2023
461750b
complete user registration page
Captainlearyo Nov 28, 2023
41eb94c
Update new.html.erb
EricBelongea Nov 28, 2023
78ea79f
Merge pull request #5 from EricBelongea/user_registration_page
EricBelongea Nov 28, 2023
5bcd37d
Try to add coverage to gitignore
EricBelongea Nov 28, 2023
bdc95e2
Try number two for coverage ignore
EricBelongea Nov 28, 2023
677c9a4
Add coverage
EricBelongea Nov 28, 2023
f2bf42c
Adding coverage pt2
EricBelongea Nov 28, 2023
dad35d6
Untrack coverage file
EricBelongea Nov 28, 2023
f41d718
Buff happy path testing for landing page and user registration
EricBelongea Nov 28, 2023
06b5cd5
data base built out
Captainlearyo Nov 28, 2023
a2f44fa
Add a flash[:alert] is user doesn't fill in name or email
EricBelongea Nov 28, 2023
b824bbc
Add sad path testing for user creation
EricBelongea Nov 28, 2023
09ef2e7
Buff testing for user new_spec and create testing for user show_spec
EricBelongea Nov 28, 2023
f0432e8
Merge pull request #6 from EricBelongea/user_parties
EricBelongea Nov 28, 2023
251bf80
Sets up shoulda-matchers create model validation testing
EricBelongea Nov 28, 2023
fb710c8
Adding git ignore to merge pull down
EricBelongea Nov 28, 2023
e209702
Remove cached coverage
EricBelongea Nov 28, 2023
92e9c0d
Merge branch 'main' into refactor/edge_case
EricBelongea Nov 28, 2023
a0cd836
Start of database issues
EricBelongea Nov 29, 2023
214c1bd
Add new error message if duplicate email
EricBelongea Nov 29, 2023
7f57e54
Create table, setup validations, and relationships
EricBelongea Nov 29, 2023
f37cf7d
Add relation and validation testing
EricBelongea Nov 29, 2023
5b9c346
Add function behind discover movie button from user dashboard
EricBelongea Nov 29, 2023
1b389ae
Add webmock and vcr gems
EricBelongea Nov 29, 2023
fb502c1
Merge pull request #7 from EricBelongea/refactor/edge_case
Captainlearyo Nov 29, 2023
7a80720
Fixes webmocks
EricBelongea Nov 29, 2023
c640667
Update users_controller.rb
EricBelongea Nov 29, 2023
ed0e439
Merge pull request #8 from EricBelongea/refactor/edge_case
Captainlearyo Nov 29, 2023
e1b3ef5
list_user_parties
Captainlearyo Nov 29, 2023
f182801
Merge branch 'main' of github.com:EricBelongea/viewing_party_lite_7 i…
Captainlearyo Nov 29, 2023
d8ccc24
list parties
Captainlearyo Nov 29, 2023
bd14ad9
Merge pull request #9 from EricBelongea/list_user_parties
EricBelongea Nov 29, 2023
1897213
complete service and facade
Captainlearyo Nov 29, 2023
a3ea0d6
Merge pull request #10 from EricBelongea/service_facade_setup
EricBelongea Nov 29, 2023
831f021
Change name of discover controller to movies
EricBelongea Nov 29, 2023
bc5956f
Redo routing and config for new controller
EricBelongea Nov 29, 2023
9122b48
Movies#index is now functional
EricBelongea Nov 29, 2023
0ab5fcc
Fix test in regards to change in routing
EricBelongea Nov 29, 2023
9a599f0
Create creds
EricBelongea Nov 29, 2023
705d176
Make the movie poro
EricBelongea Nov 29, 2023
b4f3812
Top rated movies are return via button
EricBelongea Nov 29, 2023
5d7b998
tested service
Captainlearyo Nov 29, 2023
3c6e9ca
Search for movies by title
EricBelongea Nov 29, 2023
74195a4
Something went wrong with encryption
EricBelongea Nov 29, 2023
64dfa9e
Merge branch 'main' into feature/7_user_story
EricBelongea Nov 29, 2023
5e9dd29
Merge main onto branch
EricBelongea Nov 29, 2023
bfd6c37
Adds some testing
EricBelongea Nov 29, 2023
e42e747
This adds what we technically need for US8
EricBelongea Nov 30, 2023
6cc227a
Merge pull request #11 from EricBelongea/feature/7_user_story
Captainlearyo Nov 30, 2023
61473df
save
EricBelongea Nov 30, 2023
6761aec
Add links and setup routing for next user story
EricBelongea Nov 30, 2023
a6025c4
Merge pull request #12 from EricBelongea/feature/8_user_stroy
Captainlearyo Nov 30, 2023
2b40123
Create new branch with folders to test
EricBelongea Nov 30, 2023
018204f
Add facade and service testing for top_rated and searched_movies
EricBelongea Nov 30, 2023
4a7e934
Add poro testing
EricBelongea Nov 30, 2023
b8bb492
Add feature testing for API calls
EricBelongea Nov 30, 2023
b56abf2
Add sad path testing when user searches for movies
EricBelongea Nov 30, 2023
db534c6
Clean up commented notes to self
EricBelongea Nov 30, 2023
cc4c2c0
Merge pull request #13 from EricBelongea/ref/testing
Captainlearyo Nov 30, 2023
c3ec8e5
story 9 complete
Captainlearyo Dec 1, 2023
5f98cf9
Merge branch 'main' into story_9
Captainlearyo Dec 1, 2023
cb73fe5
Merge pull request #14 from EricBelongea/story_9
EricBelongea Dec 1, 2023
f5561d7
Readd encrytion
EricBelongea Dec 1, 2023
f2c6928
viewing parties
Captainlearyo Dec 1, 2023
a3651d2
Merge pull request #15 from EricBelongea/story_9_fix
EricBelongea Dec 1, 2023
7f8386f
Merge branch 'main' of github.com:EricBelongea/viewing_party_lite_7
EricBelongea Dec 1, 2023
56c7042
Adds a route and controller
EricBelongea Dec 1, 2023
a98f0f0
Merge branch 'main' into feature/10_user_story
EricBelongea Dec 1, 2023
247156a
Setup routing and controller
EricBelongea Dec 1, 2023
cb79124
errors
EricBelongea Dec 1, 2023
97e6f3f
Starts on party creation
EricBelongea Dec 1, 2023
b782ed7
Progress on party#create action
EricBelongea Dec 1, 2023
ed9354f
Found the typo for movid_id
EricBelongea Dec 1, 2023
7f3ab87
Dream driving create action
EricBelongea Dec 1, 2023
41eedb1
Removes tests
EricBelongea Dec 1, 2023
f3459b5
Merge pull request #16 from EricBelongea/feature/10_user_story
Captainlearyo Dec 1, 2023
34b6c1d
partial stroy 11
Captainlearyo Dec 1, 2023
3e80a5c
Merge pull request #17 from EricBelongea/story_11
EricBelongea Dec 1, 2023
252ad05
Add movie runtime to display so a user explicity knows how long the m…
EricBelongea Dec 1, 2023
3035346
story 11 complete
Captainlearyo Dec 1, 2023
30b1c42
story 11 tested
Captainlearyo Dec 1, 2023
9315029
Builds on feature testing for party creation
EricBelongea Dec 1, 2023
a220f98
Merge pull request #18 from EricBelongea/ref/testing_sad_paths
Captainlearyo Dec 1, 2023
2910a2e
Merge pull request #19 from EricBelongea/story_11
EricBelongea Dec 1, 2023
d361764
expanded testing
Captainlearyo Dec 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@

# Ignore master key for decrypting credentials and more.
/config/master.key

coverage/
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
6 changes: 6 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,14 @@ gem "bootsnap", require: false

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"
gem "faraday"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "pry"
gem "shoulda-matchers"
gem "orderly"

end

group :development do
Expand All @@ -70,4 +74,6 @@ group :test do
gem "capybara"
gem "launchy"
gem "simplecov"
gem "webmock"
gem "vcr"
end
29 changes: 29 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ GEM
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.2.0)
bindex (0.8.1)
bootsnap (1.16.0)
msgpack (~> 1.2)
Expand All @@ -84,13 +85,21 @@ GEM
xpath (~> 3.2)
coderay (1.1.3)
concurrent-ruby (1.2.2)
crack (0.4.5)
rexml
crass (1.0.6)
date (3.3.3)
diff-lcs (1.5.0)
docile (1.4.0)
erubi (1.12.0)
faraday (2.7.12)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
globalid (1.1.0)
activesupport (>= 5.0)
hashdiff (1.0.1)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
importmap-rails (1.2.1)
Expand Down Expand Up @@ -131,6 +140,9 @@ GEM
racc (~> 1.4)
nokogiri (1.15.2-x86_64-darwin)
racc (~> 1.4)
orderly (0.1.1)
capybara (>= 1.1)
rspec (>= 2.14)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
Expand Down Expand Up @@ -178,6 +190,10 @@ GEM
rake (13.0.6)
regexp_parser (2.8.1)
rexml (3.2.5)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
Expand Down Expand Up @@ -213,6 +229,9 @@ GEM
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
shoulda-matchers (5.3.0)
activesupport (>= 5.2.0)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand All @@ -237,11 +256,16 @@ GEM
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
vcr (6.2.0)
web-console (4.2.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webmock (3.19.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand All @@ -256,21 +280,26 @@ PLATFORMS
DEPENDENCIES
bootsnap
capybara
faraday
importmap-rails
jbuilder
launchy
orderly
pg (~> 1.1)
pry
puma (~> 5.0)
rails (~> 7.0.4, >= 7.0.4.2)
rspec-rails
rubocop-rails
shoulda-matchers
simplecov
sprockets-rails
stimulus-rails
turbo-rails
tzinfo-data
vcr
web-console
webmock

RUBY VERSION
ruby 3.2.2p53
Expand Down
23 changes: 23 additions & 0 deletions app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class MoviesController < ApplicationController
def index
end

def search
@movies = if params[:q] == "top_rated"
MovieFacade.top_rated
else
if params[:q].blank?
flash[:alert] = "Please enter a Movie title"
redirect_back(fallback_location: "/users/#{params[:id]}/discover")
else
MovieFacade.searched_movies(params[:q])
end
end
end

def show
@data = MovieFacade.movie_details(params[:movie_id])
@data2 = MovieFacade.movie_cast(params[:movie_id])
@data3 = MovieFacade.movie_reviews(params[:movie_id])
end
end
48 changes: 48 additions & 0 deletions app/controllers/parties_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class PartiesController < ApplicationController
def new
@user = User.find(params[:user_id])
@movie = MovieFacade.movie_details(params[:movie_id])
@users = User.all
end

def create
movie = find_movie
user_host = User.find(params[:user_id])

if params[:duration].to_i < movie[:runtime]
flash[:alert] = "Party must be as long or longer than movie"
redirect_back(fallback_location: "/users/#{params[:user_id]}/movies/#{movie[:id]}/new")
elsif params[:name].blank? || params[:date].blank?
flash[:alert] = "Please fill in all fields"
redirect_back(fallback_location: "/users/#{params[:user_id]}/movies/#{movie[:id]}/new")
else
@party = Party.new({
movie_id: params[:movie_id],
movie_title: movie[:title],
duration: params[:duration],
date: params[:date],
start_time: format_time(params["start_time(4i)"], params["start_time(5i)"]),
name: params[:name]
})
if @party.save
UserParty.create(user_id: user_host.id, party_id: @party.id, host: true)

User.all.each do |user|
next if user == user_host
UserParty.create(user_id: user.id, party_id: @party.id, host: false) if params[user.name] == "1"
end
redirect_to user_path(params[:user_id])
end
end
end

private

def find_movie
MovieFacade.movie_details(params[:movie_id])
end

def format_time(hour, min)
"#{hour}:#{min}"
end
end
35 changes: 35 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
class UsersController < ApplicationController

def show
@user = User.find(params[:id])
@movies = @user.list_parties
end

def new
@user = User.create(user_params)
end

def create
@user = User.new(user_params)

if @user.name.blank? || @user.email.blank?
flash[:alert] = 'Name or Email cannot be blank'
redirect_back(fallback_location: new_user_path)
else
begin
@user.save!
redirect_to user_path(@user.id)
rescue ActiveRecord::RecordNotUnique => e
if e.message.include?('email')
flash[:alert] = 'Email is already taken. Please choose a different one.'
end
redirect_back(fallback_location: new_user_path)
end
end
end

private
def user_params
params.permit(:name, :email)
end
end
5 changes: 5 additions & 0 deletions app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class WelcomeController < ApplicationController
def index
@users = User.all
end
end
27 changes: 27 additions & 0 deletions app/facade/movie_facade.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class MovieFacade
def self.top_rated
json_response = MovieService.top_rated[:results]
@results = json_response.map do |movie|
Movie.new(movie)
end.first(20)
end

def self.searched_movies(searched_term)
json_response = MovieService.searched_movies(searched_term)
json_response[:results].map do |movie|
Movie.new(movie)
end.first(20)
end

def self.movie_details(id)
MovieService.movie_details(id)
end

def self.movie_cast(id)
MovieService.movie_cast(id)
end

def self.movie_reviews(id)
MovieService.movie_reviews(id)
end
end
16 changes: 16 additions & 0 deletions app/models/party.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Party < ApplicationRecord
validates :movie_id, presence: true
validates :movie_title, presence: true
validates :duration, presence: true
validates :date, presence: true
validates :start_time, presence: true
validates :name, presence: true

has_many :user_parties
has_many :users, through: :user_parties

def get_host_name
host_party = user_parties.includes(:user).find { |party| party.host == true }
host_party.user.name if host_party.present?
end
end
16 changes: 16 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class User < ApplicationRecord
validates :name, presence: true
validates :email, presence: true

has_many :user_parties
has_many :parties, through: :user_parties


def list_parties
movies = []
parties.uniq.each do |party|
movies << MovieFacade.movie_details(party.movie_id)
end
movies
end
end
10 changes: 10 additions & 0 deletions app/models/user_party.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class UserParty < ApplicationRecord
belongs_to :user
belongs_to :party


def get_user_name
user = User.find_by_id(self.user_id)
user.present? ? user.name : "Unknown User"
end
end
26 changes: 26 additions & 0 deletions app/poros/movie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Movie
attr_reader :backdrop_path, :genres, :id, :overview,
:popularity, :poster_path, :release_date, :title,
:vote_average, :vote_count, :runtime

def initialize(data)
@backdrop_path = data[:backdrop_path]
@genres = data[:genres]
@id = data[:id]
@overview = data[:overview]
@popularity = data[:popularity]
@poster_path = data[:poster_path]
@release_date = data[:release_date]
@title = data[:title]
@vote_average = data[:vote_average]
@vote_count = data[:vote_count]
@runtime = data[:runtime]
end

def self.runtime_in_min(data)
runtime_minutes = data[:runtime].to_i
hours = runtime_minutes / 60
minutes = runtime_minutes % 60
"#{hours} hours #{minutes} minutes"
end
end
32 changes: 32 additions & 0 deletions app/services/movie_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class MovieService
def self.conn
Faraday.new(url: "https://api.themoviedb.org") do |faraday|
faraday.params['api_key'] = Rails.application.credentials.tmdb[:key]
end
end

def self.get_url(url)
response = conn.get(url)
JSON.parse(response.body, symbolize_names: true)
end

def self.top_rated
get_url('/3/movie/top_rated')
end

def self.searched_movies(search_term)
get_url("/3/search/movie?query=#{search_term}")
end

def self.movie_details(id)
get_url("/3/movie/#{id}")
end

def self.movie_cast(id)
get_url("/3/movie/#{id}/credits")
end

def self.movie_reviews(id)
get_url("/3/movie/#{id}/reviews")
end
end
Loading