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

Kyle Ledin and Samuel Cox Viewing Party Lite #202

Open
wants to merge 50 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
c076fd2
Create migrations and schema
sambcox Jan 30, 2023
f128eb7
Create relationships and validations as well as tests
sambcox Jan 31, 2023
af3a6b3
Merge pull request #13 from sambcox/Schema_and_relationships
Kledin85 Jan 31, 2023
34516ca
Adjust schema to reflect conversation in class
sambcox Jan 31, 2023
71b08d4
Create test suite
sambcox Jan 31, 2023
64eb5c5
Fix when column in validations for viewing parties
sambcox Jan 31, 2023
ef5239d
Add landing page
sambcox Jan 31, 2023
26b1bd9
Merge pull request #14 from sambcox/Landing_Page
Kledin85 Jan 31, 2023
ade5d15
Create new user and user show pages
sambcox Jan 31, 2023
228dbf2
Merge pull request #15 from sambcox/User_Creation
Kledin85 Jan 31, 2023
af6515c
Add user discover controller
sambcox Jan 31, 2023
980a1f2
Merge pull request #16 from sambcox/User_Creation
Kledin85 Jan 31, 2023
f290be2
Delete coverage directory
sambcox Jan 31, 2023
97e5505
movie discover page
Kledin85 Jan 31, 2023
718f751
Merge pull request #17 from sambcox/KL_discover
sambcox Jan 31, 2023
083b0b2
Get api calls working correctly and test with webmock
sambcox Feb 1, 2023
23d3d4e
Make testing of api calls more robust
sambcox Feb 1, 2023
e99e396
Merge pull request #18 from sambcox/Movie_Return_Page
Kledin85 Feb 1, 2023
5003616
Add sad path for movie search if nothing is inputted
sambcox Feb 1, 2023
f3b39b3
Create blank movie show page
sambcox Feb 1, 2023
9874307
Add movie information to movie show page
sambcox Feb 1, 2023
0c4382c
Add cast to movie show page
sambcox Feb 1, 2023
7ef4321
Add reviews to movie show page
sambcox Feb 1, 2023
097ebae
Add review count to movies show
sambcox Feb 1, 2023
ade9556
Merge pull request #19 from sambcox/Movies_Show
Kledin85 Feb 1, 2023
4a8aa6c
edit migrations
Kledin85 Feb 1, 2023
921aaae
viewing party
Kledin85 Feb 1, 2023
d8f9362
working on getting new viewing parties form link
Kledin85 Feb 2, 2023
e655d25
Allow form with model to work correctly and refactor for services and…
sambcox Feb 2, 2023
b54fe0a
Create custom duration validator
sambcox Feb 3, 2023
1d2c7cf
Allow user show page to display all viewing parties
sambcox Feb 3, 2023
5e2c05c
Merge pull request #20 from sambcox/KL_new_viewing_party
Kledin85 Feb 3, 2023
a1849a3
Add test t make sure new viewing party displays the correct informati…
Kledin85 Feb 3, 2023
6538b81
Adds sad path testing to viewing parties new spec
Kledin85 Feb 3, 2023
58e91dc
covers sad path testing
Kledin85 Feb 3, 2023
dac7771
writes test for poros
Kledin85 Feb 3, 2023
3b1d026
Add bootstrap to style
sambcox Feb 3, 2023
fadb1c0
Have test written for services, poros, and facades
Kledin85 Feb 3, 2023
90a8feb
Merge pull request #21 from sambcox/BootStrap
Kledin85 Feb 3, 2023
a0aba4e
Merge branch 'main' into KL_revamp_test
sambcox Feb 3, 2023
ddd9792
Merge pull request #22 from sambcox/KL_revamp_test
sambcox Feb 3, 2023
9e3865a
Adjust expectations in failing tests due to changes in view structure
sambcox Feb 3, 2023
482b4c1
Finish final tests
sambcox Feb 3, 2023
c4ee0dd
Merge pull request #23 from sambcox/Final_Tests
Kledin85 Feb 3, 2023
f768608
Adhere to rubocop principles
sambcox Feb 3, 2023
29eb27e
Merge pull request #24 from sambcox/Rubocop
Kledin85 Feb 3, 2023
ed12809
Add auth functionality
sambcox Feb 13, 2023
91a9ea1
Merge pull request #25 from sambcox/Auth
sambcox Feb 13, 2023
a801490
Add session functionality
sambcox Feb 15, 2023
45605a4
Merge pull request #26 from sambcox/Sessions
sambcox Feb 15, 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@

# Ignore master key for decrypting credentials and more.
/config/master.key
/coverage
# Ignore application configuration
/config/application.yml
24 changes: 19 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'bcrypt', '~> 3.1.7'

# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
Expand All @@ -34,25 +34,39 @@ gem 'jbuilder', '~> 2.5'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false

gem 'faraday'

gem 'email_validator'

gem 'bootstrap-sass', '~> 3.2.0'

gem 'jquery-rails'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'figaro'
gem 'pry'
end

group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'rubocop-rails'
gem 'web-console', '>= 3.3.0'
end

group :test do
gem 'rspec-rails'
gem 'capybara'
gem 'database_cleaner'
gem 'factory_bot_rails', '~> 4.0'
gem 'faker'
gem 'launchy'
gem 'orderly'
gem 'rspec-rails'
gem 'shoulda-matchers', '~> 3.1'
gem 'simplecov'
gem 'webmock'
end


# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
57 changes: 57 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ GEM
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0)
ast (2.4.2)
bcrypt (3.1.18)
bindex (0.8.1)
bootsnap (1.9.1)
msgpack (~> 1.0)
bootstrap-sass (3.2.0.4)
sass (~> 3.2)
builder (3.2.4)
capybara (3.36.0)
addressable
Expand All @@ -68,18 +71,46 @@ GEM
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.9)
crack (0.4.5)
rexml
crass (1.0.6)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
database_cleaner-active_record (2.0.1)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
diff-lcs (1.4.4)
docile (1.4.0)
email_validator (2.2.4)
activemodel
erubi (1.10.0)
execjs (2.8.1)
factory_bot (4.11.1)
activesupport (>= 3.0.0)
factory_bot_rails (4.11.1)
factory_bot (~> 4.11.1)
railties (>= 3.0.0)
faker (3.1.0)
i18n (>= 1.8.11, < 2)
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.4)
figaro (1.2.0)
thor (>= 0.14.0, < 2)
globalid (0.5.2)
activesupport (>= 5.0)
hashdiff (1.0.1)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
jbuilder (2.11.3)
activesupport (>= 5.0.0)
jquery-rails (4.5.1)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
launchy (2.5.0)
addressable (~> 2.7)
listen (3.1.5)
Expand All @@ -104,6 +135,9 @@ GEM
racc (~> 1.4)
nokogiri (1.12.5-arm64-darwin)
racc (~> 1.4)
orderly (0.1.1)
capybara (>= 1.1)
rspec (>= 2.14)
parallel (1.21.0)
parser (3.0.2.0)
ast (~> 2.4.1)
Expand Down Expand Up @@ -148,6 +182,10 @@ GEM
ffi (~> 1.0)
regexp_parser (2.1.1)
rexml (3.2.5)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.1)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.1)
Expand Down Expand Up @@ -181,6 +219,7 @@ GEM
rack (>= 1.1)
rubocop (>= 1.7.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)
Expand All @@ -193,6 +232,8 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
shoulda-matchers (3.1.3)
activesupport (>= 4.0.0)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand All @@ -219,6 +260,10 @@ GEM
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webmock (3.18.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 @@ -230,23 +275,35 @@ PLATFORMS
ruby

DEPENDENCIES
bcrypt (~> 3.1.7)
bootsnap (>= 1.1.0)
bootstrap-sass (~> 3.2.0)
capybara
coffee-rails (~> 4.2)
database_cleaner
email_validator
factory_bot_rails (~> 4.0)
faker
faraday
figaro
jbuilder (~> 2.5)
jquery-rails
launchy
listen (>= 3.0.5, < 3.2)
orderly
pg (>= 0.18, < 2.0)
pry
puma (~> 3.11)
rails (~> 5.2.6)
rspec-rails
rubocop-rails
sass-rails (~> 5.0)
shoulda-matchers (~> 3.1)
simplecov
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
webmock

RUBY VERSION
ruby 2.7.4p191
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
//= require rails-ujs
//= require activestorage
//= require_tree .

//= require jquery
//= require bootstrap-sprockets
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
*= require_tree .
*= require_self
*/

@import "bootstrap-sprockets";
@import "bootstrap";
12 changes: 12 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
class ApplicationController < ActionController::Base
helper_method :current_user

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

def validate_user
unless current_user
flash[:error] = ['User must be logged in']
redirect_to root_path
end
end
end
4 changes: 4 additions & 0 deletions app/controllers/discover_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class DiscoverController < ApplicationController
def index
end
end
26 changes: 26 additions & 0 deletions app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class MoviesController < ApplicationController
def index
if params[:q] == 'top rated'

@movies = MovieFacade.find_movies("discover/movie?api_key=#{ENV['movie_api_key']}&language=en-US&sort_by=vote_average.desc&include_adult=false&include_video=false&page=1&vote_count.gte=1000")

elsif params[:commit]

@movies = MovieFacade.find_movies("search/movie?api_key=#{ENV['movie_api_key']}&language=en-US&query=#{params[:title]}&page=1&include_adult=false")

end

if @movies.is_a?(Hash) && (@movies[:success] == false)
flash[:error] = @movies[:errors]
redirect_to discover_index_path
end
end

def show
@movie = MovieFacade.find_movie(params[:id])

@cast = MovieFacade.find_cast(params[:id])

@reviews = MovieFacade.find_reviews(params[:id])
end
end
21 changes: 21 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class SessionsController < ApplicationController
def new

end

def create
user = User.find_by(email: params[:email])
if user&.authenticate(params[:password])
session[:user_id] = user.id
redirect_to user_path(user)
else
flash[:error] = ['Login Failed']
render :new
end
end

def delete
session.clear
redirect_to root_path
end
end
27 changes: 27 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class UsersController < ApplicationController
def new
@user = User.new
end

def create
user = User.new(user_params)

if user.save
session[:user_id] = user.id
redirect_to user_path(user)
else
flash[:error] = user.errors.full_messages
render :new
end
end

def show
validate_user
end

private

def user_params
params.require(:user).permit(:name, :email, :password, :password_confirmation)
end
end
41 changes: 41 additions & 0 deletions app/controllers/viewing_parties_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
class ViewingPartiesController < ApplicationController
def new
@viewing_party = ViewingParty.new
if @user = current_user
@users = @user.all_but_self
@movie = MovieFacade.find_movie(params[:movie_id])
else
flash[:error] = ['User must be logged in']
redirect_to movie_path(params[:movie_id])
end
end

def create
@viewing_party = ViewingParty.new(viewing_party_params)

if @viewing_party.save
redirect_to user_path(@user)
else
flash[:error] = @viewing_party.errors.full_messages
redirect_to new_movie_viewing_party_path(params[:movie_id])
end

create_user_viewing_parties
end

private

def create_user_viewing_parties
UserViewingParty.create({ user_id: current_user.id, viewing_party_id: @viewing_party.id, hosting: true })
params[:viewing_party].each do |key, value|
if value == '1' && key != :movie_id
UserViewingParty.create({ user_id: key, viewing_party_id: @viewing_party.id })
end
end
end

def viewing_party_params
params[:viewing_party][:movie_id] = params[:movie_id]
params.require(:viewing_party).permit(:duration, :start_time, :date, :movie_id)
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
Loading