Giter VIP home page Giter VIP logo

brownfield-of-dreams's Introduction

Brownfield Of Dreams

This is the base repo for a brownfield project used at Turing for Backend Mod 3.

Project Spec and Evaluation Rubric: https://github.com/turingschool-examples/brownfield-of-dreams

Project Board

Students will continue to build on the existing code base using the cards within the following Github Project: https://github.com/turingschool-examples/brownfield-of-dreams/projects/1

Learning Goals and Labels

The cards are labeled in a way that correspond to learning goals or to specific areas you might personally want to focus on.

Cards should be completed from top to bottom in the To Do column. Cards labeled good first issue are good as filler work and will allow you to practice common Rails skills.

About the Project

This is a Ruby on Rails application used to organize YouTube content used for online learning. Each tutorial is a playlist of video segments. Within the application an admin is able to create tags for each tutorial in the database. A visitor or registered user can then filter tutorials based on these tags.

A visitor is able to see all of the content on the application but in order to bookmark a segment they will need to register. Once registered a user can bookmark any of the segments in a tutorial page.

Local Setup

Clone down the repo

$ git clone

Install the gem packages

$ bundle install

Install node packages for stimulus

$ brew install node
$ brew install yarn
$ yarn

Set up the database

$ rails db:create
$ rails db:migrate
$ rails db:seed

Youtube API

This project makes use of the Youtube API.

First, obtain an API key by following steps 1 - 3 in this guide for the "Before you Start" section. When creating new credentials, make sure you choose the "API Key" option. Make sure that you follow the step to enable the Youtube Data API. Your API key will not work without that step.

Once you have obtained an API key and enabled the API:

  1. Run bundle exec figaro install
  2. This will create the file config/application.yml. Open that file.
  3. Append the following to that file: YOUTUBE_API_KEY: <your api key>, replacing <your api key> with the api key you just obtained.

Test Suite

You can run the test suite with:

$ bundle exec rspec

If set up correctly, and assuming you have internet access and the Youtube API is functioning correctly, you should have all passing tests.

Technologies

Versions

  • Ruby 2.4.1
  • Rails 5.2.0

brownfield-of-dreams's People

Contributors

tywestlie avatar margoflewelling avatar jmejia avatar dionew1 avatar danmoran-pro avatar brianzanti avatar dependabot[bot] avatar

Forkers

danmoran-pro

brownfield-of-dreams's Issues

Email invitations

Background: We want to be able to enter a user's Github handle and send them an email invite to our app. You'll use the Github API to retrieve the email address of the invitee.

As a registered user
When I visit /dashboard
And I click "Send an Invite"
Then I should be on /invite

And when I fill in "Github Handle" with <A VALID GITHUB HANDLE>
And I click on "Send Invite"
Then I should be on /dashboard
And I should see a message that says "Successfully sent invite!" (if the user has an email address associated with their github account)
Or I should see a message that says "The Github user you selected doesn't have an email address associated with their account."

The email should read as follows

Hello <INVITEE_NAME_AS_IT_APPEARS_ON_GITHUB>,

<INVITER_NAME_AS_IT_APPEARS_ON_GITHUB> has invited you to join <YOUR_APP_NAME>. You can create an account <here (should be a link to /signup)>.

Import YouTube playlist

Currently tutorials can be created by manually entering information and then manually entering videos one by one.

The playlist importer should take a playlist_id which relates to a youtube playlist and import all of the videos and associate them with a tutorial.

As an admin
When I visit '/admin/tutorials/new'
Then I should see a link for 'Import YouTube Playlist'
When I click 'Import YouTube Playlist'
Then I should see a form

And when I fill in 'Playlist ID' with a valid ID
Then I should be on '/admin/dashboard'
And I should see a flash message that says 'Successfully created tutorial. View it here.'
And 'View it here' should be a link to '/tutorials/:id'
And when I click on 'View it here'
Then I should be on '/tutorials/:id'
And I should see all videos from the YouTube playlist
And the order should be the same as it was on YouTube
  • Retain the original sequence from YouTube
  • Creates a video record for each video in the playlist and stores the youtube id.
  • Associates each video stored in the DB is associated with a tutorial. (validate presence of tutorial id)
  • Can import a playlist with more than 50 videos

User Dashboard: Github Repositories

Details: A user exists in the database. They have a Github token stored. Generate a token here for testing and development: https://github.com/settings/tokens

A future story will implement generating these tokens dynamically but that isn't necessary here.

As a logged in user
When I visit /dashboard
Then I should see a section for "Github"
And under that section I should see a list of 5 repositories with the name of each Repo linking to the repo on Github

User Dashboard: Friendships

Details: We want to create friendships between users with accounts in our database. Long term we want to make video recommendations based on what friends are bookmarking. This card should not include the recommendation logic. That's coming in a different user story.

Background: A user (Josh) exists in the system with a Github token. The user has two followers on Github. One follower (Dione) also has an account within our database. The other follower (Mike) does not have an account in our system. If a follower or following has an account in our system we want to include a link next to their name to allow us to add as a friend.

In this case Dione would have an Add as Friend link next to her name. Mike would not have the link next to his name.

Tips: No need to work on edge cases during your spike. You'll want to research self referential has_many through. Here's a good starting point to understand the concept: http://blog.hasmanythrough.com/2007/10/30/self-referential-has-many-through. You'll probably need to do more googling but that's part of the fun ;)

  • Links show up next to followers that have accounts in our system.
  • Links show up next to followings that have accounts in our database.
  • Links do not show up next to followers or followings if they are not in our database.
  • There's a section on the dashboard that shows all of the users that I have friended
  • Edge Case: Make sure this fails gracefully. If you open up a POST route to create a friendship, be sure to catch the scenario where someone sends an invalid user id. Send a flash message alerting them of the error.

Deploy

Deploy your application to Heroku.

In addition to the normal deployment, you will also need to setup your Youtube api key manually for your Heroku production environment.

Setup Continuous Integration

Set up continuous integration using Travis CI

  1. Go to https://travis-ci.org/ and set up your account
  2. Add this project to your repositories. You can do this from the main dashboard page by clicking the plus button next to My Repositories
  3. Configure your YOUTUBE_API_KEY environment variable for your travis environment. You can find configuration for environment variables by selecting your repository from the travis dashboard and clicking More Options -> Settings.
  4. Configure deployment to Heroku by filling in the api_key and app variables in the .travis.yml file. Use this guide as a reference.

You can test that your travis set up is working by pushing a commit to your repository. You should see a build triggered from the Travis dashboard. When the build is complete, you should see the change automatically deployed to Heroku.

User Dashboard: Github Followers

๐Ÿš” ๐Ÿ‘ฎโ€โ™€๏ธ ๐Ÿ‘ฎโ€โ™€๏ธ ๐Ÿ‘ฎโ€โ™€๏ธ
DO NOT START THIS STORY UNLESS THE STORY REFERENCED BELOW HAS BEEN COMPLETED BY BOTH IN YOUR PAIR.

You should pair on story "User Dashboard: Github Repositories" and deploy it prior to working on this one.

Continue this process for all stories labeled spike first. You will learn more this way and produce better code.

๐Ÿš“ ๐Ÿ’จ ๐Ÿ‘ฎ ๐Ÿ‘ฎ ๐Ÿ‘ฎ

Details: A user exists in the database. They have a Github token stored. Generate a token here for testing and development: https://github.com/settings/tokens

A future story will implement generating these tokens dynamically but that isn't necessary here.

No need to hit the endpoint for followings. A future story will address this.

As a logged in user
When I visit /dashboard
Then I should see a section for "Github"
And under that section I should see another section titled "Followers"
And I should see list of all followers with their handles linking to their Github profile

API endpoint documentation
https://developer.github.com/v3/users/followers/

  • API call uses authenticated call: /user/followers instead of /users/:username/followers
  • No hashes in the view.
  • Uses objects in the view to represent the followers.

User Dashboard: Github Following

๐Ÿ‘‡ ๐Ÿ‘‡ ๐Ÿ‘‡ ๐Ÿ‘‡
REMINDER: Don't start this story until you and your partner pair on and deploy the previous user story.
โ˜๏ธ โ˜๏ธ โ˜๏ธ โ˜๏ธ

Details: A user exists in the database. They have a Github token stored. Generate a token here for testing and development: https://github.com/settings/tokens

A future story will implement generating these tokens dynamically but that isn't necessary here.

As a logged in user
When I visit /dashboard
Then I should see a section for "Github"
And under that section I should see another section titled "Following"
And I should see list of users I follow with their handles linking to their Github profile

API endpoint documentation
https://developer.github.com/v3/users/followers/#list-users-followed-by-another-user

  • API call uses authenticated call
  • No hashes in the view.
  • Uses objects in the view to represent the Github users.

Hide 'classroom content' from non-logged in users.

Currently all tutorials are visible to anyone. We want to make tutorials marked as "classroom content" viewable only if the user is logged in.

The tutorials table has a boolean column for classroom that should be used for this story.

Admin: New Tutorial

When I visit '/admin/tutorials/new'
And I fill in 'title' with a meaningful name
And I fill in 'description' with a some content
And I fill in 'thumbnail' with a valid YouTube thumbnail
And I click on 'Save'
Then I should be on '/tutorials/{NEW_TUTORIAL_ID}'
And I should see a flash message that says "Successfully created tutorial."

  • Sad path accounted for

RuboCop

You will use use RuboCop to enforce style guidelines. The evaluation rubric at the end project will use it to measure code quality.

RuboCop will be installed when you bundle. Simply run bundle exec rubocop from the command line. You should have about 10 violations as you start the project. Fix these violations first. Make sure that you continue to use RuboCop throughout the project to pick up on style violations as you go. DO NOT wait until the end to fix a giant pile of RuboCop errors.

As you work through the project, you may find some of the RuboCop complaints difficult to decipher. Reference the Cops documentation and the Rails Cops documentation for more information.

Please reach out to your instructors if you find any style violations that you believe should not be enforced. Ask your instructors before editing .rubocop.yml

Bookmarking doesn't reload page

Background: When a user bookmarks a video the page reloads which means if they were watching a video, the video starts over making for a frustrating user experience. We can use JavaScript to make a POST request to /api/v1/bookmarks.

This story should make a fetch call to an internal API.

The app currently uses Stimulus JS and there are already examples of how to make a fetch call to an internal API. Review that code and use it as a template.

Delete videos when deleting a Tutorial

Background: Currently deleting a Tutorial will leave all of the videos in the database, meaning they will be referencing a tutorial that doesn't exist.

Use ActiveRecords dependent destroy functionality to fix this.

User Dashboard: Bookmarks

Background: Ability to bookmark is already built out. This story should display things that are already bookmarked. Bookmarking occurs in UserVideosController#create if you want to explore the model relationships.

As a logged in user
When I visit '/dashboard'
Then I should see a list of all bookmarked segments under the Bookmarked Segments section
And they should be organized by which tutorial they are a part of
And the videos should be ordered by their position
  • Only makes one query to the database (no n+1 queries)
  • Avoids loading all videos into memory

User Email activation

As a guest user
When I visit "/"
And I click "Register"
Then I should be on "/register"
And when I fill in an email address (required)
And I fill in first name (required)
And I fill in last name (required)
And I fill in password and password confirmation (required)
And I click submit
Then I should be redirected to "/dashboard"
And I should see a message that says "Logged in as <SOME_NAME>"
And I should see a message that says "This account has not yet been activated. Please check your email."
Background: The registration process above will trigger this story

As a non-activated user
When I check my email for the registration email
I should see a message that says "Visit here to activate your account."
And when I click on that link
Then I should be taken to a page that says "Thank you! Your account is now activated."

And when I visit "/dashboard"
Then I should see "Status: Active"

User Dashboard: Github OAuth

Details: We want a user to have the option to connect their Github account and retrieve a user specific token automatically.

As a user
When I visit /dashboard
Then I should see a link that is styled like a button that says "Connect to Github"
And when I click on "Connect to Github"
Then I should go through the OAuth process
And I should be redirected to /dashboard
And I should see all of the content from the previous Github stories (repos, followers, and following)

Tips: Testing this is tricky. Don't worry about testing during the spike. In fact, TDD'ing this is really tricky if you've never done it before. Get a working implementation first even when you are pairing and backfill a test. You should not try to fill out the form and click buttons on Github in your tests. Omniauth gives us a special way to test this. Use these docs as a starting point: https://github.com/omniauth/omniauth/wiki/Integration-Testing

  • Uses Omniauth Github (does not hand roll the OAuth handshake)
  • Tests the handshake using Omniauth Mock Auth (see above tips section).

Make Bookmark display message if user is not logged in

GET /tutorials/:id

Currently the Bookmark link will redirect to the login page and stop the video from playing which leads to a rather jarring experience.

Let's display a message that says "User must login to bookmark videos." A tooltip or flash notice could be good options?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.