Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
79cceb3
Update some rubocop rules
zakariaf Apr 18, 2022
fac5866
Add rack-cors gem to handle AJAX calls
zakariaf Apr 17, 2022
de17156
Add cors configs to allow requests from any origin on any resource
zakariaf Apr 17, 2022
23d268d
Fix rubocop errors
zakariaf Apr 17, 2022
f6a96d1
Add devise gem
zakariaf Apr 17, 2022
8645edb
Install devise configs
zakariaf Apr 17, 2022
1125547
Set navigational_formats empty array as we want to use it for api
zakariaf Apr 17, 2022
fc284a7
defined default url options
zakariaf Apr 17, 2022
ebfe841
Define User model using Devise
zakariaf Apr 17, 2022
1855cc0
Add devise-jwt gem
zakariaf Apr 17, 2022
4017c45
Define JWT secret key
zakariaf Apr 17, 2022
acc34e4
Exclude schema.rb from rubocop config
zakariaf Apr 17, 2022
eb6f2bf
Use Allowlist for revocation strategy
zakariaf Apr 17, 2022
6528040
Use json format as default for devise routes
zakariaf Apr 17, 2022
6ea4b47
Add RSpec JsonHelper to parse the body of the response
zakariaf Apr 18, 2022
bbd4f96
Turn off request forgery protection as we want to use the app like an…
zakariaf Apr 18, 2022
cab57fd
expose Authorization header which will be used to dispatch and receiv…
zakariaf Apr 18, 2022
93e95c9
Dispatch/Revoke JWT tokens by calling login/logout endpoints
zakariaf Apr 18, 2022
f7df475
Modify expiration_time to 1 day
zakariaf Apr 18, 2022
5f49c2c
Define RegistrationsController
zakariaf Apr 18, 2022
f923e13
Define session controller
zakariaf Apr 18, 2022
310238d
Define AuthenticationHelper
zakariaf Apr 18, 2022
17c5df5
Add SessionsController specs
zakariaf Apr 18, 2022
c8dbae9
Add frozen_string_literal to all files
zakariaf Apr 18, 2022
806dd34
Define .env.test file for github jobs
zakariaf Apr 18, 2022
49f103c
Rename the github workflow to CI and add rspec job
zakariaf Apr 18, 2022
7f9c96e
Update README.md file
zakariaf Apr 18, 2022
620b3bf
Add a test to check confirmation password
zakariaf Apr 18, 2022
343012a
Update README.md file
zakariaf Apr 18, 2022
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
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# export RAILS_ENV=development

## Host
export DEFAULT_HOST=example.com

## Puma
# export PORT=3000
# export PIDFILE=tmp/pids/server.pid
Expand Down Expand Up @@ -30,3 +33,7 @@ export POSTGRES_DB=baseapp
## Sidekiq web
# export SIDEKIQ_WEB_USERNAME=sidekiq-web-dashboard
# export SIDEKIQ_WEB_PASSWORD=sidekiq-web-123

## Secret keys
# You can use `rake secret` command to generate a secret key
export DEVISE_JWT_SECRET_KEY=my-jwt-secret-key
25 changes: 25 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

## Host
export DEFAULT_HOST=localhost

## Postgres
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres
export POSTGRES_DB=baseapp_test

## Redis URL
# export REDIS_URL=redis://redis:6379/1
# export REDIS_CHANNEL_PREFIX=baseapp

## Action cable
# export ACTION_CABLE_URL=ws://localhost:28080
# export ACTION_CABLE_ALLOWED_REQUEST_ORIGINS=http:\/\/localhost*
# Examples:
# http:\/\/localhost*
# http:\/\/example.*,https:\/\/example.*

## Secret keys
# You can use `rake secret` command to generate a secret key
export DEVISE_JWT_SECRET_KEY=bad60161405df79d927357174573d3ef5f8e1086786e9102cdd39d490cab0d7307150d08f8fa9b3e2ef32031a61df7516c8b44a1c0456d8d98b3a32f17aa439
81 changes: 81 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
linter:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.2 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x

- name: Install Yarn
run: |
npm install yarn
yarn --version
yarn install

- name: Prepare environment
run: |
bundle exec overcommit --sign
bundle exec overcommit --sign pre-commit

- name: Run all checks
run: SKIP=AuthorName,AuthorEmail bundle exec overcommit --run

rspec:
runs-on: ubuntu-latest
env:
RAILS_ENV: test
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options:
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports:
- 6379:6379
options: --entrypoint redis-server

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.2 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically

- name: Install dependent libraries
run: sudo apt-get install libpq-dev

- name: Create DB
run: |
bundle exec rails db:reset

- name: Run tests
run: bundle exec rspec
39 changes: 0 additions & 39 deletions .github/workflows/lint.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ yarn-error.log*
# Ignore env files
.env*
!.env.example
!.env.test

# Vite Ruby
/public/vite
Expand Down
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AllCops:
Exclude:
- "lib/**/*"
- "bin/**/*"
- "db/schema.rb"

Metrics/BlockLength:
IgnoredMethods:
Expand All @@ -24,3 +25,9 @@ Metrics/BlockLength:
- draw
- configure
- group

Style/Documentation:
Enabled: false

RSpec/MultipleMemoizedHelpers:
Max: 10
24 changes: 16 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ gem 'redis', '~> 4.0'
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: %i( mingw mswin x64_mingw jruby )
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false
Expand Down Expand Up @@ -56,6 +56,14 @@ gem 'jsonapi.rb'
# Simple, efficient background processing for Ruby
gem 'sidekiq'

# provides support for Cross-Origin Resource Sharing (CORS)
gem 'rack-cors'

# a flexible authentication solution
gem 'devise'
# a devise extension which uses JWT tokens for user authentication
gem 'devise-jwt'

# Linting
gem 'brakeman'
gem 'bundler-audit'
Expand All @@ -65,11 +73,11 @@ gem 'overcommit'

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem 'debug', platforms: %i( mri mingw x64_mingw )
gem 'rspec-rails', '~> 5.0.0'
gem 'annotate'
gem 'pry'
gem 'debug', platforms: %i[mri mingw x64_mingw]
gem 'dotenv-rails'
gem 'pry'
gem 'rspec-rails', '~> 5.0.0'
gem 'rubocop', require: false
gem 'rubocop-performance'
gem 'rubocop-rails', require: false
Expand All @@ -90,12 +98,12 @@ end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem 'capybara'
gem 'database_cleaner-active_record'
gem 'factory_bot_rails'
gem 'faker'
# RSpec matchers for JSON API.
gem 'jsonapi-rspec'
gem 'selenium-webdriver'
gem 'webdrivers'
gem 'factory_bot_rails'
gem 'faker'
gem 'database_cleaner-active_record'
gem 'simplecov', require: false
gem 'webdrivers'
end
37 changes: 37 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ GEM
activerecord (>= 3.2, < 8.0)
rake (>= 10.4, < 14.0)
ast (2.4.2)
bcrypt (3.1.17)
bindex (0.8.1)
bootsnap (1.11.1)
msgpack (~> 1.2)
Expand Down Expand Up @@ -102,14 +103,33 @@ GEM
debug (1.5.0)
irb (>= 1.3.6)
reline (>= 0.2.7)
devise (4.8.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise-jwt (0.9.0)
devise (~> 4.0)
warden-jwt_auth (~> 0.6)
diff-lcs (1.5.0)
digest (3.1.0)
docile (1.4.0)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
dry-auto_inject (0.9.0)
dry-container (>= 0.3.4)
dry-cli (0.7.0)
dry-configurable (0.14.0)
concurrent-ruby (~> 1.0)
dry-core (~> 0.6)
dry-container (0.9.0)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.13, >= 0.13.0)
dry-core (0.7.1)
concurrent-ruby (~> 1.0)
erubi (1.10.0)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -143,6 +163,7 @@ GEM
jsonapi.rb (2.0.0)
jsonapi-serializer
rack
jwt (2.3.0)
license_finder (7.0.1)
bundler
rubyzip (>= 1, < 3)
Expand Down Expand Up @@ -180,6 +201,7 @@ GEM
racc (~> 1.4)
nokogiri (1.13.4-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
overcommit (0.58.0)
childprocess (>= 0.6.3, < 5)
iniparse (~> 1.4)
Expand All @@ -198,6 +220,8 @@ GEM
nio4r (~> 2.0)
racc (1.6.0)
rack (2.2.3)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-proxy (0.7.2)
rack
rack-test (1.1.0)
Expand Down Expand Up @@ -234,6 +258,9 @@ GEM
regexp_parser (2.3.0)
reline (0.3.1)
io-console (~> 0.5)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
Expand Down Expand Up @@ -312,6 +339,13 @@ GEM
dry-cli (~> 0.7.0)
rack-proxy (~> 0.6, >= 0.6.1)
zeitwerk (~> 2.2)
warden (1.2.9)
rack (>= 2.0.9)
warden-jwt_auth (0.6.0)
dry-auto_inject (~> 0.8)
dry-configurable (~> 0.13)
jwt (~> 2.1)
warden (~> 1.2)
web-console (4.2.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand Down Expand Up @@ -343,6 +377,8 @@ DEPENDENCIES
capybara
database_cleaner-active_record
debug
devise
devise-jwt
dotenv-rails
factory_bot_rails
faker
Expand All @@ -358,6 +394,7 @@ DEPENDENCIES
pg (~> 1.1)
pry
puma (~> 5.0)
rack-cors
rails (~> 7.0.2.3)
redis (~> 4.0)
rspec-rails (~> 5.0.0)
Expand Down
Loading