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

Vcr #131

Open
wants to merge 136 commits into
base: main
Choose a base branch
from
Open

Vcr #131

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
3de11a6
Create pull_request_template.md
Caleb1991 Jul 5, 2021
7bcf0b2
Merge pull request #20 from Caleb1991/Caleb1991-patch-1
JoannaCoPo Jul 6, 2021
d43d46d
Add rubocop to gemfile
Caleb1991 Jul 6, 2021
5f0a693
Delete gemfile.lock
Caleb1991 Jul 6, 2021
683b22e
bundle install
Caleb1991 Jul 6, 2021
a7a79d4
Update Travid yml file
Caleb1991 Jul 6, 2021
bd151d7
Merge pull request #22 from Caleb1991/gemfile_update_2
JoannaCoPo Jul 6, 2021
0280a59
Add schema diagram
JoannaCoPo Jul 6, 2021
3c70f47
Fix file path
JoannaCoPo Jul 6, 2021
fcbc63e
Fix file path
JoannaCoPo Jul 6, 2021
73e6a78
Update README.md
JoannaCoPo Jul 6, 2021
667cbac
Update README.md
JoannaCoPo Jul 6, 2021
0075cfe
Merge pull request #23 from Caleb1991/schema
Caleb1991 Jul 6, 2021
0aa0447
Create user table
Caleb1991 Jul 6, 2021
cbce4b0
Merge pull request #24 from Caleb1991/registration_page
JoannaCoPo Jul 6, 2021
fd633c3
Change ruby v to 2.7.2
JoannaCoPo Jul 6, 2021
8acec1c
TDD welcome page
JoannaCoPo Jul 6, 2021
c98ba4b
Add route for welcome index
JoannaCoPo Jul 6, 2021
d5e9751
Create welcome controller
JoannaCoPo Jul 6, 2021
438d857
Add shoulda matchers
JoannaCoPo Jul 6, 2021
32a8176
Add model test for user
JoannaCoPo Jul 6, 2021
ae7d4cd
Add validations and has_secure_password to User
JoannaCoPo Jul 6, 2021
b7eb363
Add view functionality
JoannaCoPo Jul 6, 2021
ce21baa
Create functionality for registration page, and test for edge cases o…
Caleb1991 Jul 7, 2021
d6e7bab
Correct Rubocop warnings
Caleb1991 Jul 7, 2021
18a47f4
Merge pull request #25 from Caleb1991/registration_form
JoannaCoPo Jul 7, 2021
1c78556
Create migrations for User Friendships, Viewing Parties, and Attendees
Caleb1991 Jul 7, 2021
95fbfaf
Merge pull request #26 from Caleb1991/migrations
JoannaCoPo Jul 7, 2021
d6b78b6
Save work
JoannaCoPo Jul 8, 2021
1d7ce00
Define current_user helper in application controller
JoannaCoPo Jul 8, 2021
56910a7
Add user status functionality
JoannaCoPo Jul 8, 2021
56f35c5
Add login and registration paths
JoannaCoPo Jul 8, 2021
4c20fc5
Create login sesssions controller with create action
JoannaCoPo Jul 8, 2021
87eb974
Add user controller with empty create action
JoannaCoPo Jul 8, 2021
5eac100
Create new view for sessions
JoannaCoPo Jul 8, 2021
c1939d6
Clean up test file
JoannaCoPo Jul 8, 2021
24bec77
Merge branch 'main' into welcome_page
Caleb1991 Jul 8, 2021
c3fb36f
Merge pull request #27 from Caleb1991/welcome_page
Caleb1991 Jul 8, 2021
807890c
Remove second instance of shoulda-matchers
Caleb1991 Jul 8, 2021
6c3f87a
Change button_to to link_to
JoannaCoPo Jul 8, 2021
07fee50
Change redirect route to root path
JoannaCoPo Jul 8, 2021
987b8bd
Create dashboard template
Caleb1991 Jul 8, 2021
ea78669
Add login form
JoannaCoPo Jul 8, 2021
75352e0
Change registration button to link
JoannaCoPo Jul 8, 2021
cce341b
Fix assertions
JoannaCoPo Jul 9, 2021
d2eccc2
Run migrations for remaining tables
JoannaCoPo Jul 9, 2021
bc7c400
Fix all relevent button assertions to link
JoannaCoPo Jul 9, 2021
42ad682
Test correct login credentials
JoannaCoPo Jul 9, 2021
0f45ab3
Add action and route for logout
JoannaCoPo Jul 9, 2021
0ec22ff
Test for invalid login attempt
JoannaCoPo Jul 9, 2021
c5b1bcd
Merge pull request #28 from Caleb1991/dashboard
JoannaCoPo Jul 9, 2021
7fb2b49
Merge pull request #29 from Caleb1991/welcome_page
Caleb1991 Jul 9, 2021
74e3032
Models with relationships
JoannaCoPo Jul 10, 2021
53641a7
Create model test for attendee
JoannaCoPo Jul 10, 2021
cbbdd7e
Add relationships for ViewingParty
JoannaCoPo Jul 10, 2021
199201d
Create model test for ViewingParty
JoannaCoPo Jul 10, 2021
36949e7
Create UserFriendships functionality as well as tests. In addition ad…
Caleb1991 Jul 10, 2021
a2ce772
Merge pull request #30 from Caleb1991/user_friendships
JoannaCoPo Jul 10, 2021
ddae3fb
Add tests for viewing party sections
JoannaCoPo Jul 10, 2021
a0db7a0
Add movie show page path
JoannaCoPo Jul 10, 2021
73c353e
Merge
JoannaCoPo Jul 10, 2021
dd92846
Merge
JoannaCoPo Jul 10, 2021
808e628
Edit all revleant models and tests to change ViewingParty to Party
JoannaCoPo Jul 10, 2021
0261082
Active record for user invites
JoannaCoPo Jul 11, 2021
1fece75
Work on functionality for parties intbvited to
JoannaCoPo Jul 11, 2021
e710b14
Comment out show action; revisit
JoannaCoPo Jul 11, 2021
d12dc68
Remove white space
JoannaCoPo Jul 11, 2021
862bbaf
Add movie_title attribute for viewing parties
JoannaCoPo Jul 11, 2021
37015b4
Create tests for viewing party sections
JoannaCoPo Jul 11, 2021
80aafc9
Add functionality for viewing party sections
JoannaCoPo Jul 11, 2021
aa56fce
Merge pull request #31 from Caleb1991/viewing_parties
Caleb1991 Jul 12, 2021
35cd045
Address some rubocop violations
Caleb1991 Jul 12, 2021
3d1fe20
Merge pull request #32 from Caleb1991/rubocop
JoannaCoPo Jul 12, 2021
a77a4be
Add figaro gem, update travis yml file
Caleb1991 Jul 13, 2021
e4d08b4
Update Travis
Caleb1991 Jul 13, 2021
d7fb592
Update Travis again
Caleb1991 Jul 13, 2021
6f000e0
Add bundle install and bundle update to Travis script
Caleb1991 Jul 13, 2021
9166018
Remove bundle update from Travis
Caleb1991 Jul 13, 2021
739b05d
Update README.md
Caleb1991 Jul 13, 2021
7d9f725
Update usernames to include link to given user's GitHub
Caleb1991 Jul 13, 2021
63927b7
Layout template for API consumption
Caleb1991 Jul 13, 2021
25585cd
Merge pull request #35 from Caleb1991/API
JoannaCoPo Jul 13, 2021
3232cb7
Set up Faraday connection and JSON parsing
JoannaCoPo Jul 13, 2021
92ca12f
General setup for api consumption and testing
JoannaCoPo Jul 13, 2021
aa2f02d
Install testing gems
JoannaCoPo Jul 13, 2021
757b902
Prepare stubs for api testing
JoannaCoPo Jul 13, 2021
29d89ea
Add movie search and plan top rated
JoannaCoPo Jul 13, 2021
168699c
Bring in three endpoints for API for movie details page
Caleb1991 Jul 13, 2021
962add5
Merge pull request #36 from Caleb1991/movie_details
JoannaCoPo Jul 13, 2021
2a47b91
Merge partner progress
JoannaCoPo Jul 13, 2021
4a22eb2
Slight refactor on Movie poros, as well as APIServices
Caleb1991 Jul 13, 2021
fe2b35a
adds api key to gitignore
JoannaCoPo Jul 13, 2021
1ee6b87
Update gitignore
JoannaCoPo Jul 13, 2021
313c25b
Comment out gem temporarily
JoannaCoPo Jul 13, 2021
7f710c6
Temp tests
JoannaCoPo Jul 13, 2021
22ad0fe
migrate movie search helpers to movie_facade
JoannaCoPo Jul 13, 2021
2c65fb0
Add create_movie_objects helper
JoannaCoPo Jul 13, 2021
45c03fa
Create poros directt with film_standard class
JoannaCoPo Jul 13, 2021
69255f0
Add search params to search_by_movie
JoannaCoPo Jul 13, 2021
3ee8329
Add index routes for discover and movies
JoannaCoPo Jul 13, 2021
e5c53db
Create initial test for discover index page
JoannaCoPo Jul 13, 2021
b3b9035
Add movies spec directory
JoannaCoPo Jul 13, 2021
f2722e5
Add index view for discover page
JoannaCoPo Jul 13, 2021
712749e
Create movies index page
JoannaCoPo Jul 14, 2021
6b279a6
Create discover controller
JoannaCoPo Jul 14, 2021
b791135
Fix typo in forms
JoannaCoPo Jul 14, 2021
41ba7f1
Fix test typos; test passing
JoannaCoPo Jul 14, 2021
f98cfad
Improve naming
JoannaCoPo Jul 14, 2021
b66726d
Merge pull request #37 from Caleb1991/movie_details_refactor
JoannaCoPo Jul 14, 2021
dc1e6a6
Merge refactor
JoannaCoPo Jul 14, 2021
2cf8c01
Fix instance variable
JoannaCoPo Jul 14, 2021
cb87b24
Fix routing for sessions login
JoannaCoPo Jul 14, 2021
13360e5
Uncomment out show action
JoannaCoPo Jul 14, 2021
23301ca
Fix syntax issue
JoannaCoPo Jul 14, 2021
40dcd3d
Fix order syntax in top_rated
JoannaCoPo Jul 14, 2021
c38e1ef
Fix typo in index action
JoannaCoPo Jul 14, 2021
9a3fedb
Update text field specification
JoannaCoPo Jul 14, 2021
2ce6b5d
Add spacing
JoannaCoPo Jul 14, 2021
a740cfc
Add line break
JoannaCoPo Jul 14, 2021
cd896ac
Create movies index spec
JoannaCoPo Jul 14, 2021
f35872e
Debug tests
JoannaCoPo Jul 14, 2021
4668426
Merge pull request #38 from Caleb1991/api_movie_search
Caleb1991 Jul 14, 2021
9e33845
Update poros file, start work on new party
Caleb1991 Jul 14, 2021
f7bc154
Add some more functionality to new viewing party, currently incomplete
Caleb1991 Jul 14, 2021
2ebd2a8
Merge branch 'main' into movie_details_refactor
Caleb1991 Jul 14, 2021
bf76537
Merge pull request #39 from Caleb1991/movie_details_refactor
JoannaCoPo Jul 14, 2021
ba919e5
Add logout functionality
JoannaCoPo Jul 14, 2021
96305c3
Cleanup tests
JoannaCoPo Jul 14, 2021
c482949
Merge pull request #40 from Caleb1991/jo_refactor
Caleb1991 Jul 14, 2021
e07ee3e
Minor refactors to make for better user experience, redirecting to us…
Caleb1991 Jul 14, 2021
7aa0ff1
Merge pull request #41 from Caleb1991/minor_refactor
Caleb1991 Jul 15, 2021
7582bff
Vcr setup
JoannaCoPo Jul 15, 2021
2b9f279
Add a few tests for facade
JoannaCoPo Jul 15, 2021
dc2b3a5
Include setup for webmock attempt
JoannaCoPo Jul 15, 2021
bce0f23
Include setup for webmock attempt
JoannaCoPo Jul 15, 2021
cfbb4db
Final test refactor
JoannaCoPo Jul 15, 2021
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 @@ -18,3 +18,6 @@

# Ignore test coverage
/coverage/*

# Ignore application configuration
/config/application.yml
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.7.2
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
language: ruby
rbenv:
- 2.5.3
- 2.7.2
addons:
postgresql: 9.6
script:
- bundle exec rails db:{create,migrate} RAILS_ENV=test
- bundle install
- bundle exec rails db:{drop,create,migrate} RAILS_ENV=test
- bundle exec rspec
deploy:
provider: heroku
api_key:
app:
api_key: ENV['api_key']
app: https://dashboard.heroku.com/apps/secret-waters-04726
run: rails db:migrate
13 changes: 12 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ end

ruby '2.7.2'

gem 'rubocop', require: false
gem 'rails', '5.2.5'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.7'
Expand All @@ -15,24 +16,34 @@ gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'bootsnap'
gem 'jbuilder', '~> 2.5'
gem 'bcrypt', '~> 3.1.7'
gem 'faraday'
gem 'figaro'
gem 'faraday'



group :development, :test do
gem 'pry'
gem 'travis'
# gem 'webmock'
end

group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'rubocop-rails'
gem 'travis'
# gem 'travis'
end

group :test do
gem 'rspec-rails'
gem 'capybara'
gem 'launchy'
gem 'simplecov'
gem 'shoulda-matchers', '~> 4.0'
gem 'webmock'
gem 'vcr'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
60 changes: 43 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ GEM
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.7.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
arel (9.0.0)
ast (2.4.2)
bcrypt (3.1.16)
bindex (0.8.1)
bootsnap (1.7.5)
msgpack (~> 1.0)
Expand All @@ -66,24 +67,36 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.1.8)
concurrent-ruby (1.1.9)
crack (0.4.5)
rexml
crass (1.0.6)
diff-lcs (1.4.4)
docile (1.3.5)
docile (1.4.0)
erubi (1.10.0)
execjs (2.8.0)
faraday (1.4.1)
execjs (2.8.1)
faraday (1.5.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.1.0)
faraday-patron (1.0.0)
faraday_middleware (1.0.0)
faraday (~> 1.0)
ffi (1.15.0)
ffi (1.15.3)
figaro (1.2.0)
thor (>= 0.14.0, < 2)
gh (0.18.0)
activesupport (~> 5.0)
addressable (~> 2.4)
Expand All @@ -94,6 +107,7 @@ GEM
net-http-pipeline
globalid (0.4.2)
activesupport (>= 4.2.0)
hashdiff (1.0.1)
highline (2.0.3)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
Expand All @@ -107,24 +121,22 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.9.1)
loofah (2.10.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.1)
method_source (1.0.0)
mini_mime (1.1.0)
mini_portile2 (2.5.1)
minitest (5.14.4)
msgpack (1.4.2)
multi_json (1.15.0)
multipart-post (2.1.1)
net-http-persistent (2.9.4)
net-http-pipeline (1.0.1)
nio4r (2.5.7)
nokogiri (1.11.3)
mini_portile2 (~> 2.5.0)
nokogiri (1.11.7-x86_64-darwin)
racc (~> 1.4)
parallel (1.20.1)
parser (3.0.1.1)
Expand Down Expand Up @@ -190,18 +202,18 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.2)
rubocop (1.14.0)
rubocop (1.18.2)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.5.0, < 2.0)
rubocop-ast (>= 1.7.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.5.0)
rubocop-ast (1.7.0)
parser (>= 3.0.1.1)
rubocop-rails (2.10.1)
rubocop-rails (2.11.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
Expand All @@ -219,6 +231,8 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
shoulda-matchers (4.5.1)
activesupport (>= 4.2.0)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -248,25 +262,33 @@ GEM
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (2.0.0)
vcr (6.0.0)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webmock (3.13.0)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
websocket (1.2.9)
websocket-driver (0.7.3)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)

PLATFORMS
ruby
x86_64-darwin-20

DEPENDENCIES
bcrypt (~> 3.1.7)
bootsnap
capybara
coffee-rails (~> 4.2)
faraday
figaro
jbuilder (~> 2.5)
launchy
listen (>= 3.0.5, < 3.2)
Expand All @@ -275,16 +297,20 @@ DEPENDENCIES
puma (~> 3.7)
rails (= 5.2.5)
rspec-rails
rubocop
rubocop-rails
sass-rails (~> 5.0)
shoulda-matchers (~> 4.0)
simplecov
travis
tzinfo-data
uglifier (>= 1.3.0)
vcr
web-console (>= 3.3.0)
webmock

RUBY VERSION
ruby 2.7.2p137

BUNDLED WITH
2.1.4
2.2.17
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
<img width="1058" alt="schema" src="https://user-images.githubusercontent.com/75275648/124644758-d73fd700-de4f-11eb-9d76-f1b72be067af.png">
____________________________________________________________________________

# Viewing Party

This is the base repo for the [viewing party project](https://backend.turing.io/module3/projects/viewing_party) used for Turing's Backend Module 3.

### About this Project
### About this Application

Viewing Party is an application that emulates the movie going experience by connecting you with friends that wish to watch the same film. It intuitively displays information for a given film such as; its popularity, the first ten cast members, and reviews for the given film. Create your own party today, or just get invited to one of your friend's parties!

[Link to Deployed Application](https://dashboard.heroku.com/apps/secret-waters-04726)

# Collaborators

Viewing party is an application in which users can explore movie options and create a viewing party event for the user and friend's.
[@JoCoCoPo](https://github.com/JoannaCoPo) - A backend engineering student at Turing School of Software Design, Jo's technical expertise helped guide this project to its completion.

## Local Setup
[@Caleb1991](https://github.com/Caleb1991) - Also a backend student at Turing School of Software Design, Caleb's ability to see the big picture helped bring the project goals into focus.

## Setup and Install Instructions

1. Fork and Clone the repo
2. Install gem packages: `bundle install`
3. Setup the database: `rails db:create`

Viewing Party utilizes the following gems:
Travis CI
Bcrypt
Figaro

Dependencies:
[The Movie Database API](https://www.themoviedb.org/)

## Versions

Expand All @@ -20,3 +38,6 @@ Viewing party is an application in which users can explore movie options and cre
- Rails 5.2.5

Example wireframes to follow are found [here](https://backend.turing.io/module3/projects/viewing_party/wireframes)

## Instructions on Use
Viewing Party requires that a user create an account to access its features. From there, a user may add friends via their homepage, search for movies via the discover page, and host parties of their own, or just join in on a friend's viewing party. Viewing Party utilizes information from the [Movie Databse API](https://www.themoviedb.org/) to connect its users to movie descriptions.
5 changes: 5 additions & 0 deletions app/controllers/API_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class APIController < ApplicationController
def search_get_details
@title = APIFacade.find_movie_title(params[:title])
end
end
7 changes: 7 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
#what is this

helper_method :current_user

def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
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
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
if params['movie_title'] == ''
flash[:error] = 'Field cannot be blank; please try again.'
redirect_to discover_path
elsif params['movie_title']
@movie_search_results = MoviesFacade.search_by_movie_title(params['movie_title'])
else
@top_rated = MoviesFacade.top_rated
end
end

def show
@movie = Movie.new(params[:id])
end
end
20 changes: 20 additions & 0 deletions app/controllers/party_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class PartyController < ApplicationController
def new
@user = User.find(session[:user_id])
@movie = Movie.new(params[:movie_id])
end

def create
@user = User.find(session[:user_id])
@movie = Movie.new(params[:movie_id])
date = "#{params['date(2i)']} #{params['date(3i)']}, #{params['date(1i)']}"

if [email protected]? && params[:duration].to_i >= @movie.runtime_in_minutes
Party.create!(party_host_id: @user.id, movie_title: params[:title], movie_id: params[:movie_id], date: date, duration: params[:duration], start_time: params[:start_time])
redirect_to '/dashboard'
else
flash[:error] = 'One or more of your fields is incorrect'
render :new
end
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
found_user = User.find_by(email: params[:email])
if found_user && found_user.authenticate(params[:password])
session[:user_id] = found_user.id
flash[:success] = "Welcome back, #{found_user.email}!"
# redirect_to root_path
redirect_to dashboard_path
else
flash[:error] = 'Your username or password are incorrect. Please try again.'
redirect_to login_path
end
end

def destroy
session[:user_id] = nil
redirect_to '/'
end
end
17 changes: 17 additions & 0 deletions app/controllers/user_friendships_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class UserFriendshipsController < ApplicationController
def create
user = User.find(session[:user_id])
friend = User.find_by(email: params[:email])

if friend.nil?
flash[:error] = 'That user has not yet registered with this platform.'
redirect_to '/dashboard'
elsif !user.friends.find_by(email: friend.email).nil?
flash[:error] = 'You are already friends with that user'
redirect_to '/dashboard'
elsif
UserFriendship.create(user: user, friend: friend)
redirect_to '/dashboard'
end
end
end
Loading