Example Rails 5 app using Google OAuth2
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
bin Lint updates, integrate rubocop with spec tests May 17, 2018
config
db
lib/tasks
public Start Rails project code Apr 15, 2017
spec
vendor/assets Start Rails project code Apr 15, 2017
.dockerignore
.gitignore Use figaro to load environment variables Apr 15, 2017
.rubocop
.rubocop.yml Removed unnecessary .rubocop_todo.yml May 19, 2018
.ruby-gemset
.travis.yml
Dockerfile
Gemfile Upgraded dependency versions Jan 5, 2019
Gemfile.lock Upgraded dependency versions Jan 5, 2019
LICENSE
README.md Updated dependency versions and README May 18, 2018
Rakefile
config.ru
docker-compose.yml
rails5googleoauth2.sublime-project
runAppLocally.sh
runTestsInNewContainers.sh
waitForContainerSetup.sh

README.md

Rails5_GoogleOAuth2

Build Status

This is an example Rails 5 application which uses Google OAuth2 for user authentication.

Technology stack

Ruby 2.4, Rails 5.1, PostgreSQL 9.6, Docker

System dependencies

Docker. That's it.

There's no need to pre-install Ruby, since the docker-compose script sets up all dependencies in self-contained Docker containers.

Configuration

Create a local config/local_env.yml and populate its variables (see https://github.com/zquestz/omniauth-google-oauth2).

GOOGLE_CLIENT_ID: 'Enter the Google client id for your project'
GOOGLE_CLIENT_SECRET: 'Enter the Google client secret for your project'

Note that Google OAuth requires verification of website ownership before it will accept Google authentication requests. See https://developers.google.com/identity/protocols/OAuth2 for the latest instructions on how to verify your website.

How to run the app locally (port 3000)

./runAppLocally.sh

How to run tests in a self-contained run

./runTestsInNewContainers.sh

This sets up Docker containers, runs tests, then tears down the containers.

How to run tests on-demand

  • ./runAppLocally.sh (in a separate terminal)
  • docker-compose run -e "RAILS_ENV=test" web rake db:migrate
  • All tests: docker-compose run -e "RAILS_ENV=test" web bundle exec rake spec
  • Specific test: docker-compose run -e "RAILS_ENV=test" web rspec spec/path/to/spec.rb
  • Lint code analysis: docker-compose run -e "RAILS_ENV=test" web rubocop

You can use this approach to continually test during development.

License

Rails5_GoogleOAuth2 is released under the MIT License.