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

Letter opener web gem added for review apps #59

Merged
merged 6 commits into from
Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ APP_BASE_URL="<Replace with app url>"
DATABASE_URL="postgres://root:password@localhost/miru_web?encoding=utf8&pool=5&timeout=5000"

# Mailer Configuration
EMAIL_DELIVERY_METHOD='letter_opener'
MAILER_SENDER="info@miru.saeloun.com"

# SendGrid Email Configuration
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ gem "sass-rails"
gem "dotenv-rails"
gem "foreman"

# Letter opener can be configured to avoid sending sending actual emails whenever required.
gem "letter_opener_web"

group :development, :test do
# See https://edgeguides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", ">= 1.0.0", platforms: %i[mri mingw x64_mingw]
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ GEM
addressable (~> 2.7)
letter_opener (1.7.0)
launchy (~> 2.2)
letter_opener_web (2.0.0)
actionmailer (>= 5.2)
letter_opener (~> 1.7)
railties (>= 5.2)
rexml
loofah (2.13.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand All @@ -149,6 +154,8 @@ GEM
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
nokogiri (1.12.5-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.21.0)
parser (3.0.3.2)
Expand Down Expand Up @@ -319,6 +326,7 @@ DEPENDENCIES
foreman
jbuilder (~> 2.11)
letter_opener
letter_opener_web
pg
puma (~> 5.0)
rack-mini-profiler (>= 2.3.3)
Expand Down
45 changes: 37 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,64 @@ Saeloun timetracking application.

### Installation

* Step 1: Clone repo to local
- Step 1: Clone repo to local

```
git clone https://github.com/saeloun/miru-web.git
```
* Step 2: Install ruby 3.0.3

- Step 2: Install ruby 3.0.3

```
rvm install $(cat .ruby-version)
```
* Step 3: Install Node 16.4.2

- Step 3: Install Node 16.4.2

```
nvm install $(cat .nvmrc)
```
* Step 4: Install Postgres

- Step 4: Install Postgres

```
brew install postgresql
```
* Step 5: Install gem

- Step 5: Install gem

```
bundle install
```
* Step 6: Install node packages

- Step 6: Install node packages

```
yarn install
```
* Step 7: Setup ENV's

- Step 7: Setup ENV's

```
cp .env.example .env
```
* Step 8: Running app in local

- Step 8: Running app in local

```
foreman start -f Procfile.dev
```

### To receive the emails in non-production apps.

Go to `/sent_emails` for accessing the emails.

## Testing in Review apps

### User Test credentials

| Role | Email | Password |
| -------- | ------------------- | -------- |
| Owner | vipul@example.com | password |
| Admin | supriya@example.com | password |
| Employee | akhil@example.com | password |
14 changes: 14 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
"plan": "heroku-postgresql:hobby-dev"
}
],
"env": {
"MAILER_SENDER": {
"description": "The email address to use as the sender",
"value": "miru-review@saeloun.com"
},
"EMAIL_DELIVERY_METHOD": {
"description": "The email delivery method to use",
"value": "letter_opener_web"
},
"JWT_SECRET_KEY": {
"description": "The secret key for the JWT",
"value": "fc68556be046e0972ccd4608d10aa36f01adf7fd9eeae05c792308f973be79c055f0a72f8b76cd5aa0740622d263a93c2b3f6e51ad2873afda81e6a0724884c2"
}
},
"buildpacks": [
{
"url": "heroku/nodejs"
Expand Down
4 changes: 4 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ class Application < Rails::Application
end

config.react.server_renderer_extensions = ["jsx", "js", "tsx", "ts"]

if email_delivery_method = ENV["EMAIL_DELIVERY_METHOD"]
config.action_mailer.delivery_method = email_delivery_method.to_sym
end
end
end
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
# config.active_record.shard_resolver = ->(request) { Tenant.find_by!(host: request.host).shard }

# Action Mailer Configuration
host = ENV.fetch("APP_BASE_URL", "localhost")
host = ENV.fetch("APP_BASE_URL", "#{ENV["HEROKU_APP_NAME"] + ".herokuapp.com"}")
config.action_mailer.default_url_options = { host: host }
config.action_mailer.asset_host = host
end
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@
root to: "application#redirect_path"
resources :dashboard, only: [:index]
resources :time_trackings, only: [:index], path: "time-tracking"

# For opening the email in the web browser in non production environments
if ENV["EMAIL_DELIVERY_METHOD"] == "letter_opener_web"
mount LetterOpenerWeb::Engine, at: "/sent_emails"
end
end
10 changes: 10 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# frozen_string_literal: true

# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
# Character.create(name: "Luke", movie: movies.first)

# Create Owner user
User.create(first_name: "Vipul", last_name: "A M", email: "vipul@example.com", password: "password", password_confirmation: "password", role: "owner", confirmed_at: DateTime.now)

# Create Admin user
User.create(first_name: "Supriya", last_name: "Agarwal", email: "supriya@example.com", password: "password", password_confirmation: "password", role: "admin", confirmed_at: DateTime.now)

# Create Employee User
User.create(first_name: "Akhil", last_name: "G Krishnan", email: "akhil@example.com", password: "password", password_confirmation: "password", role: "employee", confirmed_at: DateTime.now)