stationed 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +20 -0
- data/README.md +136 -0
- data/Rakefile +27 -0
- data/app/helpers/crud_link_helper.rb +22 -0
- data/app/helpers/page_title_helper.rb +107 -0
- data/lib/generators/stationed/templates_generator.rb +24 -0
- data/lib/stationed/app_builder.rb +13 -0
- data/lib/stationed/crud_tag.rb +70 -0
- data/lib/stationed/engine.rb +8 -0
- data/lib/stationed/generators/app_generator.rb +52 -0
- data/lib/stationed/generators/plugins/capybara.rb +12 -0
- data/lib/stationed/generators/plugins/capybara_webkit.rb +14 -0
- data/lib/stationed/generators/plugins/database_cleaner.rb +13 -0
- data/lib/stationed/generators/plugins/devise.rb +43 -0
- data/lib/stationed/generators/plugins/draper.rb +14 -0
- data/lib/stationed/generators/plugins/factory_girl.rb +14 -0
- data/lib/stationed/generators/plugins/flashes.rb +12 -0
- data/lib/stationed/generators/plugins/foreman.rb +15 -0
- data/lib/stationed/generators/plugins/generators.rb +12 -0
- data/lib/stationed/generators/plugins/guard.rb +26 -0
- data/lib/stationed/generators/plugins/haml.rb +12 -0
- data/lib/stationed/generators/plugins/i18n_spec.rb +13 -0
- data/lib/stationed/generators/plugins/kaminari.rb +18 -0
- data/lib/stationed/generators/plugins/layout.rb +13 -0
- data/lib/stationed/generators/plugins/normalize.rb +12 -0
- data/lib/stationed/generators/plugins/pry.rb +19 -0
- data/lib/stationed/generators/plugins/pundit.rb +20 -0
- data/lib/stationed/generators/plugins/rack_deflater.rb +17 -0
- data/lib/stationed/generators/plugins/responders.rb +28 -0
- data/lib/stationed/generators/plugins/rspec.rb +21 -0
- data/lib/stationed/generators/plugins/rubocop.rb +14 -0
- data/lib/stationed/generators/plugins/simple_form.rb +32 -0
- data/lib/stationed/generators/plugins/simple_form_inputs.rb +13 -0
- data/lib/stationed/generators/plugins/spring.rb +13 -0
- data/lib/stationed/generators/plugins/stationed.rb +12 -0
- data/lib/stationed/generators/plugins/strong_parameters.rb +18 -0
- data/lib/stationed/generators/plugins/styles.rb +24 -0
- data/lib/stationed/generators/plugins/turbolinks.rb +13 -0
- data/lib/stationed/generators/plugins/webmock.rb +13 -0
- data/lib/stationed/generators/plugins/wiki.rb +20 -0
- data/lib/stationed/generators/plugins/yard.rb +14 -0
- data/lib/stationed/generators/plugins.rb +10 -0
- data/lib/stationed/generators/templates/Deployment.md +3 -0
- data/lib/stationed/generators/templates/Home.md +8 -0
- data/lib/stationed/generators/templates/Procfile +1 -0
- data/lib/stationed/generators/templates/README.md.erb +42 -0
- data/lib/stationed/generators/templates/Services.md +3 -0
- data/lib/stationed/generators/templates/Setup.md +58 -0
- data/lib/stationed/generators/templates/Testing.md +3 -0
- data/lib/stationed/generators/templates/application.html.haml +11 -0
- data/lib/stationed/generators/templates/application.scss +6 -0
- data/lib/stationed/generators/templates/application_decorator.rb +23 -0
- data/lib/stationed/generators/templates/application_responder.rb +6 -0
- data/lib/stationed/generators/templates/authorization.rb +11 -0
- data/lib/stationed/generators/templates/capybara_webkit.rb +1 -0
- data/lib/stationed/generators/templates/database_cleaner.rb +19 -0
- data/lib/stationed/generators/templates/devise.rb +3 -0
- data/lib/stationed/generators/templates/env.erb +3 -0
- data/lib/stationed/generators/templates/factories_spec.rb +10 -0
- data/lib/stationed/generators/templates/factory_girl.rb +3 -0
- data/lib/stationed/generators/templates/flashes.html.haml +5 -0
- data/lib/stationed/generators/templates/generators.rb +11 -0
- data/lib/stationed/generators/templates/gollum.rake +5 -0
- data/lib/stationed/generators/templates/gollum.rb +5 -0
- data/lib/stationed/generators/templates/i18n_spec.rb +10 -0
- data/lib/stationed/generators/templates/layout.scss +3 -0
- data/lib/stationed/generators/templates/normalize.css +425 -0
- data/lib/stationed/generators/templates/paginating_decorator.rb +7 -0
- data/lib/stationed/generators/templates/pundit.rb +1 -0
- data/lib/stationed/generators/templates/rubocop.rake +5 -0
- data/lib/stationed/generators/templates/rubocop.yml +38 -0
- data/lib/stationed/generators/templates/select2_input.rb +14 -0
- data/lib/stationed/generators/templates/simple_form.rb +65 -0
- data/lib/stationed/generators/templates/simplecov +6 -0
- data/lib/stationed/generators/templates/spec_helper.rb +27 -0
- data/lib/stationed/generators/templates/spring.rb +1 -0
- data/lib/stationed/generators/templates/static_input.rb +11 -0
- data/lib/stationed/generators/templates/webmock.rb +1 -0
- data/lib/stationed/generators/templates/yardopts +7 -0
- data/lib/stationed/version.rb +3 -0
- data/lib/stationed.rb +4 -0
- data/lib/tasks/stationed_tasks.rake +4 -0
- data/lib/templates/haml/scaffold/_form.html.haml +11 -0
- data/lib/templates/haml/scaffold/edit.html.haml +2 -0
- data/lib/templates/haml/scaffold/index.html.haml +24 -0
- data/lib/templates/haml/scaffold/new.html.haml +2 -0
- data/lib/templates/haml/scaffold/show.html.haml +9 -0
- data/lib/templates/rails/scaffold_controller/controller.rb +64 -0
- data/lib/templates/rspec/integration/request_spec.rb +10 -0
- data/lib/templates/rspec/model/model_spec.rb +6 -0
- data/lib/templates/rspec/scaffold/controller_spec.rb +224 -0
- data/lib/templates/rspec/scaffold/edit_spec.rb +20 -0
- data/lib/templates/rspec/scaffold/index_spec.rb +20 -0
- data/lib/templates/rspec/scaffold/new_spec.rb +20 -0
- data/lib/templates/rspec/scaffold/routing_spec.rb +17 -0
- data/lib/templates/rspec/scaffold/show_spec.rb +14 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +1418 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/helpers/crud_link_helper_spec.rb +88 -0
- data/spec/helpers/page_title_helper_spec.rb +83 -0
- data/spec/spec_helper.rb +14 -0
- metadata +261 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Kaminari
|
5
|
+
def finish_template
|
6
|
+
gem 'kaminari'
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def run_bundle
|
11
|
+
super
|
12
|
+
generate 'kaminari:config'
|
13
|
+
generate 'kaminari:views default'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Layout
|
5
|
+
def finish_template
|
6
|
+
remove_file 'app/views/layouts/application.html.haml'
|
7
|
+
copy_file 'application.html.haml', 'app/views/layouts/application.html.haml'
|
8
|
+
super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Pry
|
5
|
+
def finish_template
|
6
|
+
gem_group :development, :test do
|
7
|
+
gem 'pry-rails'
|
8
|
+
gem 'pry-byebug'
|
9
|
+
gem 'pry-stack_explorer'
|
10
|
+
gem 'better_errors'
|
11
|
+
gem 'binding_of_caller'
|
12
|
+
end
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Pundit
|
5
|
+
def finish_template
|
6
|
+
gem 'pundit'
|
7
|
+
copy_file 'pundit.rb', 'spec/support/pundit.rb'
|
8
|
+
copy_file 'authorization.rb', 'app/controllers/concerns/authorization.rb'
|
9
|
+
inject_into_class 'app/controllers/application_controller.rb', 'ApplicationController', "\n include Authorization\n\n"
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def run_bundle
|
14
|
+
super
|
15
|
+
generate 'pundit:install'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module RackDeflater
|
5
|
+
def finish_template
|
6
|
+
environment nil, env: :production do
|
7
|
+
<<-RUBY
|
8
|
+
# Enable deflate / gzip compression of controller-generated responses
|
9
|
+
config.middleware.use Rack::Deflater
|
10
|
+
RUBY
|
11
|
+
end
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Responders
|
5
|
+
def finish_template
|
6
|
+
gem 'responders'
|
7
|
+
copy_file 'application_responder.rb', 'lib/application_responder.rb'
|
8
|
+
|
9
|
+
inject_into_class 'app/controllers/application_controller.rb', 'ApplicationController' do
|
10
|
+
<<-RUBY
|
11
|
+
self.responder = ApplicationResponder
|
12
|
+
respond_to :html
|
13
|
+
|
14
|
+
RUBY
|
15
|
+
end
|
16
|
+
|
17
|
+
application do
|
18
|
+
<<-RUBY
|
19
|
+
# Enable auto-loading from ./lib
|
20
|
+
config.autoload_paths << Rails.root.join('lib')
|
21
|
+
RUBY
|
22
|
+
end
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Rspec
|
5
|
+
def finish_template
|
6
|
+
gem 'simplecov', group: :test
|
7
|
+
gem 'rspec-rails', group: [:development, :test]
|
8
|
+
copy_file 'simplecov', '.simplecov'
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def run_bundle
|
13
|
+
super
|
14
|
+
generate 'rspec:install'
|
15
|
+
remove_file 'spec/spec_helper.rb'
|
16
|
+
copy_file 'spec_helper.rb', 'spec/spec_helper.rb'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Rubocop
|
5
|
+
def finish_template
|
6
|
+
gem 'rubocop', group: :development
|
7
|
+
copy_file 'rubocop.rake', 'lib/tasks/rubocop.rake'
|
8
|
+
copy_file 'rubocop.yml', '.rubocop.yml'
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module SimpleForm
|
5
|
+
def finish_template
|
6
|
+
gem 'simple_form'
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def run_bundle
|
11
|
+
super
|
12
|
+
generate 'simple_form:install'
|
13
|
+
remove_file 'config/initializers/simple_form.rb'
|
14
|
+
copy_file 'simple_form.rb', 'config/initializers/simple_form.rb'
|
15
|
+
application do
|
16
|
+
<<-RUBY
|
17
|
+
# Remove Rails' default error wrapper tags and rely solely on SimpleForm
|
18
|
+
# and its generated markup.
|
19
|
+
config.action_view.field_error_proc = lambda do |html_tag, instance|
|
20
|
+
html_tag.html_safe
|
21
|
+
end
|
22
|
+
|
23
|
+
# Always use SimpleForm for forms without needing the simple_form_for
|
24
|
+
# helper.
|
25
|
+
config.action_view.default_form_builder = SimpleForm::FormBuilder
|
26
|
+
RUBY
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module SimpleFormInputs
|
5
|
+
def finish_template
|
6
|
+
copy_file 'static_input.rb', 'app/inputs/static_input.rb'
|
7
|
+
copy_file 'select2_input.rb', 'app/inputs/select2_input.rb'
|
8
|
+
super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module StrongParameters
|
5
|
+
def finish_template
|
6
|
+
environment nil, env: :development do
|
7
|
+
<<-RUBY
|
8
|
+
# Raise an ActionController::UnpermittedParameters exception when
|
9
|
+
# a parameter is not explcitly permitted but is passed anyway.
|
10
|
+
config.action_controller.action_on_unpermitted_parameters = :raise
|
11
|
+
RUBY
|
12
|
+
end
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Styles
|
5
|
+
def finish_template
|
6
|
+
gem 'bourbon'
|
7
|
+
gem 'neat'
|
8
|
+
gem 'bitters'
|
9
|
+
remove_file 'app/assets/stylesheets/application.css'
|
10
|
+
copy_file 'application.scss', 'app/assets/stylesheets/application.scss'
|
11
|
+
copy_file 'layout.scss', 'app/assets/stylesheets/_layout.scss'
|
12
|
+
super
|
13
|
+
end
|
14
|
+
|
15
|
+
def run_bundle
|
16
|
+
super
|
17
|
+
run 'bitters install'
|
18
|
+
FileUtils.mv 'bitters', 'app/assets/stylesheets/bitters'
|
19
|
+
gsub_file 'app/assets/stylesheets/bitters/_bitters.scss', %r{// @import}, '@import'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Turbolinks
|
5
|
+
def finish_template
|
6
|
+
gsub_file 'Gemfile', /^gem 'turbolinks'.*\n/, ''
|
7
|
+
gsub_file 'app/assets/javascripts/application.js', %r{//= require turbolinks\n}, ''
|
8
|
+
super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Wiki
|
5
|
+
def finish_template
|
6
|
+
gem 'gollum', require: 'gollum/app', group: [:development]
|
7
|
+
route "mount Precious::App => '/wiki' if defined?(Precious)"
|
8
|
+
copy_file 'Home.md', 'doc/wiki/Home.md'
|
9
|
+
copy_file 'Setup.md', 'doc/wiki/Setup.md'
|
10
|
+
copy_file 'Testing.md', 'doc/wiki/Testing.md'
|
11
|
+
copy_file 'Services.md', 'doc/wiki/Services.md'
|
12
|
+
copy_file 'Deployment.md', 'doc/wiki/Deployment.md'
|
13
|
+
copy_file 'gollum.rake', 'lib/tasks/gollum.rake'
|
14
|
+
copy_file 'gollum.rb', 'config/initializers/gollum.rb'
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Stationed
|
2
|
+
module Generators
|
3
|
+
module Plugins
|
4
|
+
module Yard
|
5
|
+
def finish_template
|
6
|
+
gem 'yard', require: false, group: :doc
|
7
|
+
gem 'kramdown', require: false, group: :doc
|
8
|
+
copy_file 'yardopts', '.yardopts'
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
web: bin/thin start --port $PORT --environment $RAILS_ENV
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# <%= app_name %>
|
2
|
+
|
3
|
+
Provide a brief description of the purpose of this application.
|
4
|
+
|
5
|
+
## Setup instructions
|
6
|
+
|
7
|
+
This application requires a working installation of Ruby and Rubygems on your
|
8
|
+
system, along with a functioning database such as SQLite or PostgreSQL. Install
|
9
|
+
Ruby gem dependencies using Bundler.
|
10
|
+
|
11
|
+
For full instructions, see [doc/wiki/Setup.md](doc/wiki/Setup.md).
|
12
|
+
|
13
|
+
## Documentation
|
14
|
+
|
15
|
+
### Wiki
|
16
|
+
|
17
|
+
The application-specific Wiki is stored in `doc/wiki` and contains anything
|
18
|
+
need to know to work with this project. You can view and edit the wiki in a
|
19
|
+
web-based application using the [Gollum][]
|
20
|
+
project.
|
21
|
+
|
22
|
+
### API docs
|
23
|
+
|
24
|
+
You can generate API documentation for this project with the following Rake
|
25
|
+
task:
|
26
|
+
|
27
|
+
% bin/rake doc:yard
|
28
|
+
|
29
|
+
Documentation will be output in HTML format in `doc/app`. To also generate API
|
30
|
+
docs for the Rails framework, use:
|
31
|
+
|
32
|
+
% bin/rake doc:api
|
33
|
+
|
34
|
+
Further usage guides for the Rails framework can be generated using this task:
|
35
|
+
|
36
|
+
% bin/rake doc:guides
|
37
|
+
|
38
|
+
## Authors
|
39
|
+
|
40
|
+
* Your Name <name@email.com>
|
41
|
+
|
42
|
+
[Gollum]: https://github.com/gollum/gollum
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Setup instructions
|
2
|
+
|
3
|
+
This page will guide you through setting up the application.
|
4
|
+
|
5
|
+
## 1. Get the code
|
6
|
+
|
7
|
+
First, make sure you have the repository checked out:
|
8
|
+
|
9
|
+
% git clone path/to/repo.git
|
10
|
+
|
11
|
+
## 2. System dependencies
|
12
|
+
|
13
|
+
As this is a Ruby on Rails application, your system will need both Ruby and
|
14
|
+
Rubygems installed. Ensure that it is:
|
15
|
+
|
16
|
+
% ruby --version
|
17
|
+
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
|
18
|
+
% gem --version
|
19
|
+
2.2.2
|
20
|
+
|
21
|
+
If you don't have Ruby installed yet, using
|
22
|
+
{Rbenv}[https://github.com/sstephenson/rbenv] or {rvm}[http://rvm.io] is
|
23
|
+
recommeded to install it.
|
24
|
+
|
25
|
+
Once you've got Ruby set up, install {Bundler}[http://bundler.io] to install
|
26
|
+
further dependencies.
|
27
|
+
|
28
|
+
% gem install bundler
|
29
|
+
% bundle install
|
30
|
+
|
31
|
+
## 3. Database configuration
|
32
|
+
|
33
|
+
Once Bundler has installed all required Ruby gems, you can go ahead and setup
|
34
|
+
your database. You will need to specify your database connection details in
|
35
|
+
`config/database.yml`. There is a template for you to customize in
|
36
|
+
`config/database.yml.example`.
|
37
|
+
|
38
|
+
## 4. Application configuration
|
39
|
+
|
40
|
+
The application further depends on a couple of environment variables. These are
|
41
|
+
read from `.env`. There is a template file `env.example` for you to customize.
|
42
|
+
Create your personal `.env` file and make sure to fill in the blanks.
|
43
|
+
|
44
|
+
## 5. Database setup
|
45
|
+
|
46
|
+
Once all your settings are done, you can create your database, load the schema
|
47
|
+
and any seed data with Rake:
|
48
|
+
|
49
|
+
% bin/rake db:setup
|
50
|
+
|
51
|
+
## 6. Launch web server
|
52
|
+
|
53
|
+
Now you can start a new Rails server to browse through the application:
|
54
|
+
|
55
|
+
% bin/rails server
|
56
|
+
|
57
|
+
The application should now be accessible at
|
58
|
+
[http://localhost:3000](http://localhost:3000).
|
@@ -0,0 +1,11 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html{ lang: 'en' }
|
3
|
+
%head
|
4
|
+
%meta{ charset: 'utf-8' }
|
5
|
+
%meta{ name: 'viewport', content: 'width=device-width, initial-scale=1.0' }
|
6
|
+
%title= page_title
|
7
|
+
= stylesheet_link_tag 'application'
|
8
|
+
= csrf_meta_tags
|
9
|
+
%body
|
10
|
+
= yield
|
11
|
+
= javascript_include_tag 'application'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class ApplicationDecorator < Draper::Decorator
|
2
|
+
# Always use our custom PaginatingDecorator to decorate ActiveRelation
|
3
|
+
# objects so we can properly delegate Kaminari's pagination extensions.
|
4
|
+
def self.collection_decorator_class
|
5
|
+
PaginatingDecorator
|
6
|
+
end
|
7
|
+
|
8
|
+
# Override Haml's default object notation to use the class name
|
9
|
+
# it would have used had an object not been decorated.
|
10
|
+
#
|
11
|
+
# This removes the need for markup like:
|
12
|
+
#
|
13
|
+
# %div[person.person]
|
14
|
+
# ...
|
15
|
+
#
|
16
|
+
# Instead allowing:
|
17
|
+
#
|
18
|
+
# %div[person]
|
19
|
+
# ...
|
20
|
+
def haml_object_ref
|
21
|
+
model.class.to_s.underscore
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# Base responder for our application, that uses the Responders gem to mix in
|
2
|
+
# extra functinoality into Rails' default Responder.
|
3
|
+
class ApplicationResponder < ActionController::Responder
|
4
|
+
include Responders::FlashResponder
|
5
|
+
include Responders::HttpCacheResponder
|
6
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Controller concern for authorization using Pundit. This ensures that actions
|
2
|
+
# properly use Pundit's authorization hooks (`authorize` and `policy_scope`).
|
3
|
+
module Authorization
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include Pundit
|
6
|
+
|
7
|
+
included do
|
8
|
+
after_action :verify_authorized, except: :index
|
9
|
+
after_action :verify_policy_scoped, only: :index
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Capybara.javascript_driver = :webkit
|
@@ -0,0 +1,19 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.before(:suite) do
|
3
|
+
DatabaseCleaner.strategy = :transaction
|
4
|
+
DatabaseCleaner.clean_with(:truncation)
|
5
|
+
end
|
6
|
+
|
7
|
+
config.before(:each) do
|
8
|
+
if example.metadata[:js]
|
9
|
+
DatabaseCleaner.strategy = :truncation
|
10
|
+
else
|
11
|
+
DatabaseCleaner.strategy = :transaction
|
12
|
+
DatabaseCleaner.start
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
config.after(:each) do
|
17
|
+
DatabaseCleaner.clean
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'factories' do
|
4
|
+
FactoryGirl.factories.map(&:name).each do |factory_name|
|
5
|
+
specify "#{factory_name} factory is valid", :factory do
|
6
|
+
factory = build(factory_name)
|
7
|
+
expect(factory).to be_valid if factory.respond_to?(:valid?)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Rails.application.config.generators do |g|
|
2
|
+
g.template_engine :haml
|
3
|
+
g.test_framework :rspec, fixture: true, fixture_replacement: :factory_girl
|
4
|
+
g.view_specs true
|
5
|
+
g.helper_specs false
|
6
|
+
g.helper false
|
7
|
+
g.javascripts false
|
8
|
+
g.stylesheets false
|
9
|
+
g.fixture_replacement :factory_girl, dir: 'spec/factories'
|
10
|
+
g.assets false
|
11
|
+
end
|