build: 🔧 default url_options host added
simplecov added, docker-compose updated, test_helper updated
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
RAILS_ENV=development
|
||||
HOST=0.0.0.0
|
||||
PORT=3000
|
||||
HOSTNAME=0.0.0.0
|
||||
RAILS_PORT=3000
|
||||
DATABASE_URL=postgres://user:user_12345@db:5432/url_shortener
|
||||
|
||||
@@ -25,3 +25,6 @@
|
||||
|
||||
# Ignore master key for decrypting credentials and more.
|
||||
/config/master.key
|
||||
|
||||
# Ignore coverage reports
|
||||
/coverage/*
|
||||
|
||||
@@ -10,7 +10,7 @@ gem 'rails', '~> 5.2.6'
|
||||
# Use postgresql as the database for Active Record
|
||||
gem 'pg', '>= 0.18', '< 2.0'
|
||||
# Use Puma as the app server
|
||||
gem 'puma', '~> 3.11'
|
||||
gem 'puma', '~> 4.3.8'
|
||||
# Use SCSS for stylesheets
|
||||
gem 'sass-rails', '~> 5.0'
|
||||
# Use Uglifier as compressor for JavaScript assets
|
||||
@@ -57,7 +57,9 @@ group :test do
|
||||
gem 'capybara', '>= 2.15'
|
||||
gem 'selenium-webdriver'
|
||||
# Easy installation and use of chromedriver to run system tests with Chrome
|
||||
gem 'chromedriver-helper'
|
||||
gem 'webdrivers'
|
||||
# SimpleCov is a code coverage analysis tool for Ruby
|
||||
gem 'simplecov'
|
||||
end
|
||||
|
||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||
|
||||
+18
-10
@@ -44,8 +44,6 @@ GEM
|
||||
tzinfo (~> 1.1)
|
||||
addressable (2.7.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
archive-zip (0.12.0)
|
||||
io-like (~> 0.3.0)
|
||||
arel (9.0.0)
|
||||
bindex (0.8.1)
|
||||
bootsnap (1.7.5)
|
||||
@@ -61,9 +59,6 @@ GEM
|
||||
regexp_parser (>= 1.5, < 3.0)
|
||||
xpath (~> 3.2)
|
||||
childprocess (3.0.0)
|
||||
chromedriver-helper (2.1.1)
|
||||
archive-zip (~> 0.10)
|
||||
nokogiri (~> 1.8)
|
||||
coffee-rails (4.2.2)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0)
|
||||
@@ -73,6 +68,7 @@ GEM
|
||||
coffee-script-source (1.12.2)
|
||||
concurrent-ruby (1.1.9)
|
||||
crass (1.0.6)
|
||||
docile (1.4.0)
|
||||
erubi (1.10.0)
|
||||
execjs (2.8.1)
|
||||
ffi (1.15.1)
|
||||
@@ -83,7 +79,6 @@ GEM
|
||||
activesupport (>= 4.2.0)
|
||||
i18n (1.8.10)
|
||||
concurrent-ruby (~> 1.0)
|
||||
io-like (0.3.1)
|
||||
jbuilder (2.11.2)
|
||||
activesupport (>= 5.0.0)
|
||||
listen (3.1.5)
|
||||
@@ -117,8 +112,10 @@ GEM
|
||||
pg (1.2.3-x64-mingw32)
|
||||
pg (1.2.3-x86-mingw32)
|
||||
public_suffix (4.0.6)
|
||||
puma (3.12.6)
|
||||
puma (3.12.6-java)
|
||||
puma (4.3.8)
|
||||
nio4r (~> 2.0)
|
||||
puma (4.3.8-java)
|
||||
nio4r (~> 2.0)
|
||||
racc (1.5.2)
|
||||
racc (1.5.2-java)
|
||||
rack (2.2.3)
|
||||
@@ -169,6 +166,12 @@ GEM
|
||||
selenium-webdriver (3.142.7)
|
||||
childprocess (>= 0.5, < 4.0)
|
||||
rubyzip (>= 1.2.2)
|
||||
simplecov (0.21.2)
|
||||
docile (~> 1.1)
|
||||
simplecov-html (~> 0.11)
|
||||
simplecov_json_formatter (~> 0.1)
|
||||
simplecov-html (0.12.3)
|
||||
simplecov_json_formatter (0.1.3)
|
||||
spring (2.1.1)
|
||||
spring-watcher-listen (2.0.1)
|
||||
listen (>= 2.7, < 4.0)
|
||||
@@ -198,6 +201,10 @@ GEM
|
||||
activemodel (>= 5.0)
|
||||
bindex (>= 0.4.0)
|
||||
railties (>= 5.0)
|
||||
webdrivers (4.6.0)
|
||||
nokogiri (~> 1.6)
|
||||
rubyzip (>= 1.3.0)
|
||||
selenium-webdriver (>= 3.0, < 4.0)
|
||||
websocket-driver (0.7.5)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-driver (0.7.5-java)
|
||||
@@ -217,21 +224,22 @@ DEPENDENCIES
|
||||
bootsnap (>= 1.1.0)
|
||||
byebug
|
||||
capybara (>= 2.15)
|
||||
chromedriver-helper
|
||||
coffee-rails (~> 4.2)
|
||||
jbuilder (~> 2.5)
|
||||
listen (>= 3.0.5, < 3.2)
|
||||
pg (>= 0.18, < 2.0)
|
||||
puma (~> 3.11)
|
||||
puma (~> 4.3.8)
|
||||
rails (~> 5.2.6)
|
||||
sass-rails (~> 5.0)
|
||||
selenium-webdriver
|
||||
simplecov
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
turbolinks (~> 5)
|
||||
tzinfo-data
|
||||
uglifier (>= 1.3.0)
|
||||
web-console (>= 3.3.0)
|
||||
webdrivers
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.6.6p146
|
||||
|
||||
@@ -1,5 +1,34 @@
|
||||
# URL shortener
|
||||
|
||||
## How to run
|
||||
|
||||
### Development
|
||||
- Setup
|
||||
```bash
|
||||
docker-compose up -d
|
||||
docker-compose run --rm app bundle exec rails db:migrate
|
||||
docker-compose stop
|
||||
```
|
||||
- Run
|
||||
```bash
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
### Testing
|
||||
- Run database in background
|
||||
```bash
|
||||
docker-compose -f docker-compose.test.yml up -d db
|
||||
```
|
||||
- Run tests
|
||||
```bash
|
||||
docker-compose -f docker-compose.test.yml run --rm app bundle exec rails test
|
||||
```
|
||||
|
||||
### Rubocop
|
||||
```bash
|
||||
docker-compose run --rm app rubocop
|
||||
```
|
||||
|
||||
## TODO
|
||||
- [x] Create link model (make sure to create a index for the slug and click counter)
|
||||
- [x] Generate unique slug
|
||||
|
||||
@@ -60,4 +60,6 @@ Rails.application.configure do
|
||||
# Use an evented file watcher to asynchronously detect changes in source code,
|
||||
# routes, locales, etc. This feature depends on the listen gem.
|
||||
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
|
||||
Rails.application.routes.default_url_options[:host] = "#{ENV['HOSTNAME']}:#{ENV['RAILS_PORT']}"
|
||||
end
|
||||
|
||||
@@ -93,4 +93,6 @@ Rails.application.configure do
|
||||
|
||||
# Do not dump schema after migrations.
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
|
||||
Rails.application.routes.default_url_options[:host] = "#{ENV['HOSTNAME']}:#{ENV['RAILS_PORT']}"
|
||||
end
|
||||
|
||||
@@ -45,4 +45,5 @@ Rails.application.configure do
|
||||
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
Rails.application.routes.default_url_options[:host] = "#{ENV['HOSTNAME']}:#{ENV['RAILS_PORT']}"
|
||||
end
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
db:
|
||||
image: postgres:12.5-alpine
|
||||
volumes:
|
||||
- test_db_data:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_USER: user
|
||||
POSTGRES_PASSWORD: user_12345
|
||||
POSTGRES_DB: test_url_shortener
|
||||
ports:
|
||||
- 5432:5432
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.dev
|
||||
volumes:
|
||||
- .:/usr/src/app
|
||||
- gem_cache:/usr/local/bundle/gems
|
||||
command: bundle exec rails test
|
||||
tty: true
|
||||
environment:
|
||||
RAILS_ENV: test
|
||||
HOSTNAME: 0.0.0.0
|
||||
PORT: 3000
|
||||
DATABASE_URL: postgres://user:user_12345@db:5432/test_url_shortener
|
||||
depends_on:
|
||||
- db
|
||||
volumes:
|
||||
gem_cache:
|
||||
test_db_data:
|
||||
+1
-1
@@ -18,7 +18,7 @@ services:
|
||||
volumes:
|
||||
- .:/usr/src/app
|
||||
- gem_cache:/usr/local/bundle/gems
|
||||
command: bundle exec rails s -p 3000 -b '0.0.0.0'
|
||||
command: bundle exec rails s
|
||||
stdin_open: true
|
||||
tty: true
|
||||
env_file: .env.dev
|
||||
|
||||
@@ -4,6 +4,16 @@ ENV['RAILS_ENV'] ||= 'test'
|
||||
require_relative '../config/environment'
|
||||
require 'rails/test_help'
|
||||
|
||||
if ENV['RAILS_ENV'] == 'test'
|
||||
require 'simplecov'
|
||||
SimpleCov.start 'rails' do
|
||||
add_filter "/app/channels"
|
||||
add_filter "/app/mailers"
|
||||
add_filter "/app/jobs"
|
||||
end
|
||||
puts 'required simplecov'
|
||||
end
|
||||
|
||||
module ActiveSupport
|
||||
class TestCase
|
||||
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
||||
|
||||
Reference in New Issue
Block a user