8000 Bootstrap by dominicsayers · Pull Request #2 · dominicsayers/rails-template · GitHub
[go: up one dir, main page]

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3212c0b
Configure CircleCI
dominicsayers May 17, 2018
717e0d6
Leverage app's module name for configuration
dominicsayers Jul 27, 2018
f83f6cd
Add README.md
dominicsayers May 16, 2018
59a1a8f
Add Devise
dominicsayers May 21, 2018
1ef378d
`rails generate devise:install`
dominicsayers Jun 17, 2018
0f8b3af
Configure Devise
dominicsayers May 21, 2018
7626b55
Static pages
dominicsayers Jun 19, 2018
40997b3
Add authentication page components
dominicsayers Jun 19, 2018
8b3e212
Manually require helpers
dominicsayers Sep 7, 2018
84150a3
Add routing helper for specs
dominicsayers Aug 5, 2018
d02b541
Add Account model
dominicsayers Jul 17, 2018
3b99a8c
`rails g scaffold_controller Account --skip`
dominicsayers Nov 2, 2019
b4a8e8a
`bin/rubocop --auto-correct`
dominicsayers Jul 17, 2018
5a8e2df
Fix remaining Rubocop offences
dominicsayers Jul 17, 2018
4a53d72
Fix generated specs so they pass
dominicsayers Jul 17, 2018
8f2d91f
Limit accounts access to logged-in users
dominicsayers Jul 27, 2018
9b3072c
Allow user to navigate to accounts
dominicsayers Sep 5, 2018
aa0f666
Add fields to views
dominicsayers Aug 18, 2018
f8f965b
Add reserved_subdomain gem
dominicsayers Jul 11, 2018
cf94cc4
Add examples to accounts/edit
dominicsayers Sep 7, 2018
6fecc3e
Nothing yet to test in Accounts
dominicsayers Sep 7, 2018
771b7bf
AccountsHelper isn't needed
dominicsayers Sep 7, 2018
53d8448
Add routing constraint definitions
dominicsayers Jul 11, 2018
3ef6f94
Subdomain routing
dominicsayers Jul 15, 2018
6cc2130
Make accounts_controller_spec do real work
dominicsayers Sep 7, 2018
800ea3f
Add basic request spec
dominicsayers Sep 29, 2018
d0d6ff4
Add Bootstrap
dominicsayers May 21, 2018
19ed80b
Configure Bootstrap
dominicsayers May 21, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
8000
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions .circleci/config.yml
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
version: 2

docker_image: &docker_image
image: circleci/ruby:latest-node-browsers

restore_repo: &restore_repo
restore_cache:
keys:
- v1-repo-{{ .Branch }}-{{ .Revision }}
- v1-repo-{{ .Branch }}
- v1-repo

restore_bundle: &restore_bundle
restore_cache:
keys:
- v1-bundle-{{ checksum "Gemfile.lock" }}-{{ checksum "yarn.lock" }}
- v1-bundle

jobs:
checkout_code:
docker:
- <<: *docker_image
steps:
- *restore_repo
- checkout
- save_cache:
key: v1-repo-{{ .Branch }}-{{ .Revision }}
paths:
- .

bundle:
docker:
- <<: *docker_image
environment:
BUNDLE_SILENCE_ROOT_WARNING: "true"
RAILS_ENV: test
NODE_ENV: test
steps:
- *restore_repo
- checkout
- *restore_bundle
- run: gem update bundler
- run: bundle config set path 'vendor/bundle'
- run: bundle install --jobs=4 --retry=3
- run: yarn install
- run: bin/rails webpacker:compile
- save_cache:
key: v1-bundle-{{ checksum "Gemfile.lock" }}-{{ checksum "yarn.lock" }}
paths:
- vendor/bundle
- public/packs-test

rubocop:
docker:
- <<: *docker_image
steps:
- *restore_repo
- *restore_bundle
- run: gem update bundler
- run: bundle config set path 'vendor/bundle'
- run: bundle check
- run: bin/rubocop

rspec:
docker:
- <<: *docker_image
environment:
PGHOST: 127.0.0.1
PGUSER: postgres
RAILS_ENV: test
NODE_ENV: test
- image: circleci/postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
steps:
- *restore_repo
- *restore_bundle
- run: gem update bundler
- run: bundle config set path 'vendor/bundle'
- run: bundle check
- run: dockerize -wait tcp://127.0.0.1:5432 -timeout 120s
- run: bundle exec rake db:create
- run: bundle exec rake db:schema:load
- run:
command: |
mkdir /tmp/test-results
bundle exec rspec \
--format RspecJunitFormatter \
--out /tmp/test-results/rspec.xml \
--format progress \
$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
- store_test_results:
path: /tmp/test-results
- store_artifacts:
path: /tmp/test-results
destination: test-results

workflows:
version: 2
main:
jobs:
- checkout_code
- bundle:
requires:
- checkout_code
- rubocop:
requires:
10BC8 - bundle
- rspec:
requires:
- bundle
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
APP_HOST=localhost
DEVISE_MAILER_SENDER=admin@example.com
DEVISE_PEPPER=insecure: use a generated secret in production
DEVISE_SECRET_KEY=insecure: use a generated secret in production
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ gem 'jbuilder', '~> 2.7'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

gem 'bootstrap'
gem 'devise'
gem 'dotenv-rails'
gem 'jquery-rails'
gem 'reserved_subdomain'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand All @@ -51,3 +55,7 @@ group :development do
gem 'spring-commands-rspec'
gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
gem 'rspec_junit_formatter'
end
33 changes: 33 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,33 @@ GEM
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
ast (2.4.1)
autoprefixer-rails (9.7.6)
execjs
bcrypt (3.1.13)
bindex (0.8.1)
bootsnap (1.4.6)
msgpack (~> 1.0)
bootstrap (4.5.0)
autoprefixer-rails (>= 9.1.0)
popper_js (>= 1.14.3, < 2)
sassc-rails (>= 2.0.0)
builder (3.2.4)
byebug (11.1.3)
concurrent-ruby (1.1.6)
crass (1.0.6)
devise (4.7.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.3)
dotenv (2.7.5)
dotenv-rails (2.7.5)
dotenv (= 2.7.5)
railties (>= 3.2, < 6.1)
erubi (1.9.0)
execjs (2.7.0)
factory_bot (5.2.0)
activesupport (>= 4.2.0)
factory_bot_rails (5.2.0)
Expand All @@ -82,6 +96,10 @@ GEM
concurrent-ruby (~> 1.0)
jbuilder (2.10.0)
activesupport (>= 5.0.0)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand All @@ -101,10 +119,12 @@ GEM
nio4r (2.5.2)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
parallel (1.19.1)
parser (2.7.1.3)
ast (~> 2.4.0)
pg (1.2.3)
popper_js (1.16.0)
puma (4.3.5)
nio4r (~> 2.0)
rack (2.2.2)
Expand Down Expand Up @@ -148,6 +168,10 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (1.7.1)
reserved_subdomain (0.0.4)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.4)
rspec-core (3.9.2)
rspec-support (~> 3.9.3)
Expand All @@ -166,6 +190,8 @@ GEM
rspec-mocks (~> 3.9)
rspec-support (~> 3.9)
rspec-support (3.9.3)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.85.1)
parallel (~> 1.10)
parser (>= 2.7.0.1)
Expand Down Expand Up @@ -216,6 +242,8 @@ GEM
tzinfo (1.2.7)
thread_safe (~> 0.1)
unicode-display_width (1.7.0)
warden (1.2.8)
rack (>= 2.0.6)
web-console (4.0.2)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -235,16 +263,21 @@ PLATFORMS

DEPENDENCIES
bootsnap (>= 1.4.2)
bootstrap
byebug
devise
dotenv-rails
factory_bot_rails
jbuilder (~> 2.7)
jquery-rails
listen (~> 3.2)
pg (>= 0.18, < 2.0)
puma (~> 4.1)
rails (~> 6.0.3, >= 6.0.3.1)
rails-controller-testing
reserved_subdomain
rspec-rails
rspec_junit_formatter
rubocop-rails
rubocop-rspec
sass-rails (>= 6)
Expand Down
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
# README
# rails-template

This README would normally document whatever steps are necessary to get the
application up and running.
A template for a modern Rails app

Things you may want to cover:
## Design goals

* Ruby version
1. Support good practice for development and devops
1. Allow users to register and verify an account
1. Templated UI

* System dependencies
## Installation

* Configuration
[Install Yarn](https://yarnpkg.com/lang/en/docs/install)

* Database creation
### Debian / Ubuntu

* Database initialization
1. `sudo apt-get install libpq-dev`
1. `bundle install`

* How to run the test suite
### RedHat / CentOS

* Services (job queues, cache servers, search engines, etc.)
1. `sudo yum install postgresql-devel`
1. `bundle install`

* Deployment instructions
### MacOS

* ...
1. `brew install postgresql`
1. `bundle install`

## Notes

### Credentials

The credentials file only contains `secret_key_base`. Other secrets and configuration settings are managed with environment variables.
19 changes: 19 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's
// vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require jquery3
//= require popper
//= require bootstrap
//= require_tree .
15 changes: 0 additions & 15 deletions app/assets/stylesheets/application.css

This file was deleted.

2 changes: 2 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Custom bootstrap variables must be set or imported *before* bootstrap.
@import "bootstrap";
27 changes: 27 additions & 0 deletions app/constraints/subdomain_constraints.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

module SubdomainConstraints
NON_ACCOUNT_SUBDOMAINS = %w[admin www].freeze

# Routing constraint
class Account
def self.matches?(request)
module_parent.could_be_account?(request.subdomain)
end
end

# Routing constraint
class NotAccount
def self.matches?(request)
!module_parent.could_be_account?(request.subdomain)
end
end

module_function

def could_be_account?(subdomain)
return false if subdomain.blank?

!NON_ACCOUNT_SUBDOMAINS.include? subdomain
end
end
Loading
0