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

Tommy Takahashi and Sam Tran #93

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
17a73b1
Create pull_request_template.md
ttakahashi1591 Nov 27, 2023
fa8767d
Add faker gem
ttakahashi1591 Nov 27, 2023
08d02f5
Add factory-bot and shoulda-matchers gems as well completing SimpleCo…
ttakahashi1591 Nov 28, 2023
7bd53ff
Merge pull request #12 from ttakahashi1591/gems_setup
Sykogst Nov 28, 2023
74f1419
Setup db, models, and tests
Sykogst Nov 28, 2023
b273254
Merge pull request #13 from ttakahashi1591/db/setup
ttakahashi1591 Nov 28, 2023
671ae8c
test: Add User dashboard spec and user user factory
ttakahashi1591 Nov 28, 2023
307e0f4
Add User Resources with Show in routes
ttakahashi1591 Nov 28, 2023
e87ab60
feat: Add UsersController and Show method
ttakahashi1591 Nov 28, 2023
0643e1d
feat: Add view for user show page and display User name on Dashboard
ttakahashi1591 Nov 28, 2023
a05344a
test: Build out spec test for the Discover Movies button on the Users…
ttakahashi1591 Nov 28, 2023
a5e9748
Write tests for welcome index, landing page
Sykogst Nov 28, 2023
6f6206f
feat: Add Button to Discover Movies Index page on the User Show page
ttakahashi1591 Nov 28, 2023
e29d504
Add view, add route for /register (new user), and user resources
Sykogst Nov 28, 2023
b907a54
Update route prefix, add to view
Sykogst Nov 28, 2023
dc1f571
feat: Complete User Dashboard Page with the last addition of a sectio…
ttakahashi1591 Nov 28, 2023
341c9ab
fix: Remove rubocop-rails gem
ttakahashi1591 Nov 28, 2023
857f65f
Add links to show pages for each user
Sykogst Nov 28, 2023
8aed483
Add Home link to route back to landing
Sykogst Nov 28, 2023
da47d6f
Merge pull request #15 from ttakahashi1591/feat/landing-page
ttakahashi1591 Nov 28, 2023
32cb993
refactor: Remove parties variable to keep only one instatiated variable
ttakahashi1591 Nov 28, 2023
3c0a704
Merge branch 'main' into user_dashboard_page
Sykogst Nov 28, 2023
1743a10
Merge pull request #14 from ttakahashi1591/user_dashboard_page
Sykogst Nov 28, 2023
f85775c
Write preliminary tests for new user creation page
Sykogst Nov 29, 2023
266eb6e
Add new view, controller action
Sykogst Nov 29, 2023
06c0cc0
Write tests for add valid user, update view form, add create action t…
Sykogst Nov 29, 2023
6196e42
Update controller and view to have flash message for successful add o…
Sykogst Nov 29, 2023
3d3ecac
Add sad path testing for duplicate email, missing fields, invalid ema…
Sykogst Nov 29, 2023
5ce78ef
Make routes more restful
Sykogst Nov 29, 2023
e5bb169
Refactor root path
Sykogst Nov 29, 2023
e77ffe1
Clean up extra returns in specs
Sykogst Nov 29, 2023
be9f68c
Merge pull request #16 from ttakahashi1591/feat/user-registration
ttakahashi1591 Nov 29, 2023
f9dd751
Write test for search by movie title and add route
Sykogst Nov 29, 2023
c906c01
Add links to view for searched titles, start test for top20
Sykogst Nov 29, 2023
ac4f4fc
Refactor test to use webmock/vcr
Sykogst Nov 29, 2023
fed5a40
Refactor, services, facades, poros
Sykogst Nov 29, 2023
d4b2491
Add top rated 20 filter functionality
Sykogst Nov 29, 2023
ba1e10d
Remove old fixtures
Sykogst Nov 29, 2023
aae43c7
Merge pull request #17 from ttakahashi1591/feat/discover-movies
ttakahashi1591 Nov 29, 2023
a273816
Add proper link route, add average vote to top 20 filter
Sykogst Nov 30, 2023
a0358b4
Add functionality and test for search results page
Sykogst Nov 30, 2023
0a9c884
Remove extra returns
Sykogst Nov 30, 2023
90d9569
Add within blocks and id to view to increase test robustness
Sykogst Nov 30, 2023
d396993
Merge pull request #18 from ttakahashi1591/feat/movie-results
ttakahashi1591 Nov 30, 2023
27f6bf6
feat: Add Movie Show spec, start Movie Show view and build out Movies…
ttakahashi1591 Nov 30, 2023
a8aae00
feat: Add find_by(id) method to get to the movie_id endpoint
ttakahashi1591 Nov 30, 2023
a06be65
Attempt to get Create a Party button routing to work
ttakahashi1591 Nov 30, 2023
b4b3dd5
fix: Still need to figure out why I can't recieve the information fro…
ttakahashi1591 Nov 30, 2023
1f98233
feat: Add Average Rating and start setting up runtime for the view
ttakahashi1591 Nov 30, 2023
b25cb0b
feat: Add cast memebers
ttakahashi1591 Nov 30, 2023
f420aec
test: Add MoviesService spec test
ttakahashi1591 Nov 30, 2023
724e963
test: Add moviesfacade and moviesservice tests and started on Movie p…
ttakahashi1591 Dec 1, 2023
2641414
test: Complete Movie Poro testing
ttakahashi1591 Dec 1, 2023
3c5fb6f
test: Add ApplicationService spec test
ttakahashi1591 Dec 1, 2023
d39ba08
Merge pull request #19 from ttakahashi1591/movie_details_page
Sykogst Dec 1, 2023
98df111
Write preliminary tests for new page, rename routes and controllers
Sykogst Dec 1, 2023
8faece3
Add form to create new viewing party, test, view, controller, update …
Sykogst Dec 1, 2023
f32df55
Remove old comment
Sykogst Dec 1, 2023
ad95ab6
Merge pull request #21 from ttakahashi1591/feat/new-party
ttakahashi1591 Dec 1, 2023
94fe598
feat: Complete Dashboard Viewing Parties
ttakahashi1591 Dec 2, 2023
398ddb3
Merge pull request #22 from ttakahashi1591/dashboard_viewing_parties
Sykogst Dec 2, 2023
9bff9b6
Rename #create_parties to #create_user_parties, rename key/value elem…
Sykogst Dec 2, 2023
e117ff4
Refactor to change to #actor_details(data) and #review_details(data)…
Sykogst Dec 2, 2023
a8ee26e
add return
Sykogst Dec 2, 2023
c253121
Merge pull request #23 from ttakahashi1591/refactor/misc
ttakahashi1591 Dec 2, 2023
f286d1e
test: Remove commented out code in viewing_party new spec
ttakahashi1591 Dec 2, 2023
e3dd007
feat: Add password_digest migration to User table
ttakahashi1591 Dec 11, 2023
b323662
Complete User Story 1: Registration (w/ Authentication) Happy Path
ttakahashi1591 Dec 11, 2023
1e20e38
Merge pull request #24 from ttakahashi1591/register_with_authenticati…
ttakahashi1591 Dec 11, 2023
960315e
Complete User Story 2: Registration (w/ Authentication) Sad Path
ttakahashi1591 Dec 11, 2023
b53ebec
Merge pull request #25 from ttakahashi1591/registration_with_authenti…
ttakahashi1591 Dec 11, 2023
4749ccb
feat: Add check in User Create method to ensure email is downcase
ttakahashi1591 Dec 11, 2023
40b24ad
Complete User Story 3: Logging In Happy Path
ttakahashi1591 Dec 11, 2023
42eeb0e
Merge pull request #26 from ttakahashi1591/logging_in_happy_path
ttakahashi1591 Dec 12, 2023
ca17da9
Complete User Sotry 4: Logging In Sad Path
ttakahashi1591 Dec 12, 2023
a65416f
Merge pull request #27 from ttakahashi1591/logging_in_sad_path
ttakahashi1591 Dec 12, 2023
b0dacbb
Add Sessions and memoization of current user to support with less req…
ttakahashi1591 Dec 12, 2023
d82fedb
Merge pull request #28 from ttakahashi1591/lets_get_fancy_with_a_help…
ttakahashi1591 Dec 12, 2023
4031187
feat: Add sessions to User Create and Login methods
ttakahashi1591 Dec 12, 2023
a8edd68
feat: Complete Task 2: Log out a user
ttakahashi1591 Dec 12, 2023
345129b
Merge pull request #29 from ttakahashi1591/log_out_a_user
ttakahashi1591 Dec 12, 2023
1d3423c
feat: Complete Task 3: User Story 1
ttakahashi1591 Dec 12, 2023
9c550ef
Merge pull request #30 from ttakahashi1591/3task_1us_authorization
ttakahashi1591 Dec 12, 2023
60cf8f4
feat: Complete Task 5: User Story 3, going back to complete the previ…
ttakahashi1591 Dec 12, 2023
3a7e5b0
feat: Complete Task 4: User Story 2
ttakahashi1591 Dec 13, 2023
9573e67
Merge pull request #31 from ttakahashi1591/4task_2us_authorization
ttakahashi1591 Dec 13, 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
11 changes: 9 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ gem "jbuilder"
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"
gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
Expand All @@ -48,6 +48,8 @@ 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"
Expand All @@ -62,12 +64,17 @@ group :development do

# Speed up commands on slow machines / big apps [https://github.com/rails/spring]
# gem "spring"
gem "rubocop-rails"
# gem "rubocop-rails"
end

group :test do
gem "rspec-rails"
gem "capybara"
gem "launchy"
gem "simplecov"
gem "faker"
gem "factory_bot_rails"
gem "shoulda-matchers"
gem "webmock"
gem "vcr"
end
62 changes: 33 additions & 29 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ GEM
tzinfo (~> 2.0)
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
base64 (0.2.0)
bcrypt (3.1.20)
bindex (0.8.1)
bootsnap (1.16.0)
msgpack (~> 1.2)
Expand All @@ -84,13 +85,28 @@ 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)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
faker (3.2.2)
i18n (>= 1.8.11, < 2)
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 All @@ -99,8 +115,6 @@ GEM
jbuilder (2.11.5)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
launchy (2.5.2)
addressable (~> 2.8)
loofah (2.21.3)
Expand Down Expand Up @@ -131,10 +145,6 @@ GEM
racc (~> 1.4)
nokogiri (1.15.2-x86_64-darwin)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pg (1.5.3)
pry (0.14.2)
coderay (~> 1.1)
Expand Down Expand Up @@ -174,10 +184,9 @@ GEM
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.8.1)
rexml (3.2.5)
rexml (3.2.6)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
Expand All @@ -195,24 +204,9 @@ GEM
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-support (3.12.1)
rubocop (1.54.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-rails (2.20.2)
activesupport (>= 4.2.0)
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 @@ -236,12 +230,16 @@ GEM
railties (>= 6.0.0)
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 @@ -254,8 +252,12 @@ PLATFORMS
x86_64-darwin-21

DEPENDENCIES
bcrypt (~> 3.1.7)
bootsnap
capybara
factory_bot_rails
faker
faraday
importmap-rails
jbuilder
launchy
Expand All @@ -264,13 +266,15 @@ DEPENDENCIES
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
11 changes: 11 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
class ApplicationController < ActionController::Base
helper_method :current_user

def current_user
@_current_user ||= User.find(session[:user_id]) if session[:user_id]
end

private

def error_message(errors)
errors.full_messages.join(', ')
end
end
5 changes: 5 additions & 0 deletions app/controllers/discover_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class DiscoverController < ApplicationController
def index

end
end
16 changes: 16 additions & 0 deletions app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class MoviesController < ApplicationController
def index
@user = User.find(params[:user_id])
if params[:top]
@movies_facade = MoviesFacade.new.top_rated
else
@movies_facade = MoviesFacade.new.search(params[:query])
end
end

def show
@user = User.find(params[:user_id])

@movie_facade = MoviesFacade.new.find_movie(params[:id])
end
end
55 changes: 55 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class UsersController < ApplicationController

def new
end

def create
params[:email] = params[:email].downcase
user = User.new(user_params)
if user.save
session[:user_id] = user.id
flash[:success] = 'Successfully Added New User'
redirect_to user_path(user)
else
flash[:error] = "#{error_message(user.errors)}"
redirect_to register_user_path
end
end

def show
if session[:user_id]
@user = User.find(params[:id])
else
flash[:error] = 'You must log in to view the dashboard'
redirect_to root_path
end
end

def login_form
end

def login
params[:email] = params[:email].downcase
user = User.find_by(email: params[:email])
if user && user.authenticate(params[:password])
session[:user_id] = user.id
flash[:success] = "Welcome, #{user.name}!"
redirect_to user_path(user)
else
flash[:error] = "Sorry, your credentials are bad."
render :login_form
end
end

def log_out
session[:user_id] = nil
flash[:success] = "You've been logged out!"
redirect_to root_path
end

private

def user_params
params.permit(:name, :email, :password, :password_confirmation)
end
end
30 changes: 30 additions & 0 deletions app/controllers/viewing_party_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class ViewingPartyController < ApplicationController
def new
@user = User.find(params[:user_id])
@movie_facade = MoviesFacade.new.find_movie(params[:movie_id])
end

def create
if params[:duration].to_i >= params[:movie_duration].to_i
create_user_parties
redirect_to user_path(params[:user_id])
else
flash[:alert] = "Not enough time"
redirect_to "/users/#{params[:user_id]}/movies/#{params[:movie_id]}/viewing_party/new"
end
end

private

def create_user_parties
party = Party.create(movie_id: params[:movie_id], movie_title: params[:title], start_time: params[:start_time], date: params[:date], image_path: params[:image], duration: params[:duration])
UserParty.create!(user_id: params[:user_id], party_id: party.id, host: true)

params[:invitees].each do |user_id, checkbox_value|
if checkbox_value == "1"
UserParty.create!(user_id: user_id.to_i, party_id: party.id, host: false)
end
end
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
30 changes: 30 additions & 0 deletions app/facades/movies_facade.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class MoviesFacade
def search(keyword)
service = MoviesService.new

data = service.movie_search(keyword)

data[:results].map do |data|
Movie.new(data)
end
end

def top_rated
service = MoviesService.new

data = service.top_rated_20

data[:results].map do |data|
Movie.new(data)
end
end

def find_movie(movie_id)
movie_data = MoviesService.new.movie(movie_id)
cast_data = MoviesService.new.cast(movie_id)
review_data = MoviesService.new.reviews(movie_id)

combined_data = movie_data.merge(cast_data).merge(review_data)
Movie.new(combined_data)
end
end
34 changes: 34 additions & 0 deletions app/models/party.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class Party < ApplicationRecord
validates :movie_id, presence: true, numericality: true

has_many :user_parties
has_many :users, through: :user_parties

def date_and_time
parsed_date = Date.parse(self.date)
formatted_date = parsed_date.strftime("%B%e, %Y")
"#{formatted_date} #{self.start_time}"
end

def host?(user)
host = UserParty.find_by_sql(
"select user_parties.host from user_parties
inner join parties on user_parties.party_id = parties.id
where parties.id = #{self.id}
and user_parties.user_id = #{user.id};"
).first.host

return "Hosting" if host
return "Invited" if !host
end

def attendees
Party.find_by_sql(
"select users.name from users
inner join user_parties on user_parties.user_id = users.id
inner join parties on user_parties.party_id = parties.id
where parties.id = #{self.id}
and user_parties.host = false"
)
end
end
Loading