Viewing party is an application which allows users to search for popular movies, view details and reviews of movies and invite friends to a scheduled party to watch the movie. It consumes The MovieDB API (https://developers.themoviedb.org/) to provide reviews and up to date info about movies.
Our database structure links users to friends and to viewing party events, with events being linked to a movie and other users who have been invited to attend that event.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
You will need to install the mailcatcher gem locally in order to test the email functionality in the app.
`gem install mailcatcher`
-
Fork and clone the repo
-
Install the gem package
bundle install
-
Create the database
rails db:create
-
Migrate the existing Schema
rails db:migrate
Optional: Seed the datebase
rails db:seed
-
Add MovieDB API Key locally (See API section for details.)
Note: This app uses The MovieDB API to support most of it's functionality. Most tests will not pass and most parts of the app will not work without an API key added.
-
Run tests (See Runing the tests](#running-the-tests) section for more details)
bundle exec RSpec
-
Start localhostserver
rails s
-
Access localhost server in browser
localhost:3000
- All tests: insert
bundle exec rspec
in your terminal. feature
tests only: insertbundle exec rspec spec/features
in your terminal.model
tests only: insertbundle exec rspec spec/models
in your terminal.
Below are two examples of a happy and sad path when trying to log in.
it 'I am taken to my dashboard after a successful login' do
fill_in :email, with: @user1.email
fill_in :password, with: @user1.password
click_button "Log In"
expect(current_path).to eq(dashboard_path)
expect(page).to have_content("Welcome #{@user1.username}!")
end
it 'I see an error for an unsuccessful login' do
fill_in :email, with: @user1.email
fill_in :password, with: "wrong password"
click_on "Log In"
expect(current_path).to eq(root_path)
expect(page).to have_content("Invalid Credentials!")
end
- We used
RuboCop
- static code analyzer and code formatter - Steps to install RuboCop
Inspecting 22 files
.....C................
Offenses:
app/controllers/sessions_controller.rb:6:3: C: Metrics/MethodLength: Method has too many lines. [11/10]
def create ...
^^^^^^^^^^
22 files inspected, 1 offense detected
- Create with directory that contains rails app
heroku create
- If you are unsure which stack to use, read this article
- Verify remote is running
git config --list | grep heroku
- Deploy code - never push anything but main branch
git push heroku main
- If no errors, migrate database
heroku run rails db:migrate
- Assign one dyno running the app
heroku ps:scale web=1
- Check the state of app's dyno
heroku ps
- Oopen the app in brower
heroku open
heroku apps:destroy
heroku pg:reset DATABASE
heroku run rails db:migrate
heroku run rails db:seed
There is currently one API being used in this application, The Movie DB. In order to consume this API and correctly use this application, you must follow these steps:
-
Sign up for MovieDB - Go to the MovieDB homepage and click Join TMDb. - Set up a new account, confirm your email, and redirect your browser back to the homepage.
-
Once you are logged in and on the homepage, access your profile settings. - You can do this by clicking the icon with your first initial on the top right of the screen(If you haven't set up a profile picture yet).
-
Navigate to the API tab within settings
-
Request a new API key and fill out the forms provided - This might take 24 hours to process as the only one who can approve this key is the sight's true admin.
-
Once you have your key, copy and paste your Bearer Access Token into a new
YML
file in theconfig
folder of your application, along with an assigned variable. -
Within your
application.rb
file inconfig
, add this within the classApplication
:config.before_configuration do env_file = File.join(Rails.root, 'config', 'local_env.yml') YAML.load(File.open(env_file)).each do |key, value| ENV[key.to_s] = value end if File.exists?(env_file) end
-
Now, you have added the bearer token to your application! You are now open to accessing this API using your own designed service. If you would prefer to use the default service, please refer to the
movie_service.rb
file withinapps/services
to find the correct actions. ``` -
You have successfully implemented the MovieDB API! To find the correct endpoints you would like to access, use This URL.