diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..ef3dc668a8 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# Contributing + +We ♥ contributors! By participating in this project, you agree to abide by the +Ruby for Good [code of conduct]. + +[code of conduct]: https://github.com/rubyforgood/code-of-conduct + +Here are the basic steps to submit a pull request. Make sure that you're working +on an [open issue]–if the relevant issue doesn't exist, open it! + +[open issue]: https://github.com/rubyforgood/diaper/issues + +1. Claim an issue on [our issue tracker][open issue] by assigning it to yourself + (core team member) or commenting. If the issue doesn't exist yet, open it. + +2. Fork the repo. + +3. Run `./bin/setup`. + +4. Run the tests. We only take pull requests with passing tests, and it's great + to know that you have a clean slate: `bundle exec rake` + +5. Add a test for your change. If you are adding functionality or fixing a + bug, you should add a test! + +6. Make the test pass. + +7. Push to your fork and submit a pull request. Include the issue number + (ex. `Resolves #1`) in the PR description. + +At this point you're waiting on us–we'll try to respond to your PR quickly. +We may suggest some changes or improvements or alternatives. + +Some things that will increase the chance that your pull request is accepted: + +* Use Rails idioms and helpers +* Include tests that fail without your code, and pass with it +* Update the documentation, the surrounding one, examples elsewhere, guides, + whatever is affected by your contribution diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000000..3215f0137b --- /dev/null +++ b/Guardfile @@ -0,0 +1,70 @@ +# A sample Guardfile +# More info at https://github.com/guard/guard#readme + +## Uncomment and set this to only include directories you want to watch +# directories %w(app lib config test spec features) \ +# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")} + +## Note: if you are using the `directories` clause above and you are not +## watching the project directory ('.'), then you will want to move +## the Guardfile to a watched dir and symlink it back, e.g. +# +# $ mkdir config +# $ mv Guardfile config/ +# $ ln -s config/Guardfile . +# +# and, you'll have to watch "config/Guardfile" instead of "Guardfile" + +# Note: The cmd option is now required due to the increasing number of ways +# rspec may be run, below are examples of the most common uses. +# * bundler: 'bundle exec rspec' +# * bundler binstubs: 'bin/rspec' +# * spring: 'bin/rspec' (This will use spring if running and you have +# installed the spring binstubs per the docs) +# * zeus: 'zeus rspec' (requires the server to be started separately) +# * 'just' rspec: 'rspec' + +guard :rspec, cmd: "bundle exec rspec" do + require "guard/rspec/dsl" + dsl = Guard::RSpec::Dsl.new(self) + + # Feel free to open issues for suggestions and improvements + + # RSpec files + rspec = dsl.rspec + watch(rspec.spec_helper) { rspec.spec_dir } + watch(rspec.spec_support) { rspec.spec_dir } + watch(rspec.spec_files) + + # Ruby files + ruby = dsl.ruby + dsl.watch_spec_files_for(ruby.lib_files) + + # Rails files + rails = dsl.rails(view_extensions: %w(erb haml slim)) + dsl.watch_spec_files_for(rails.app_files) + dsl.watch_spec_files_for(rails.views) + + watch(rails.controllers) do |m| + [ + rspec.spec.call("routing/#{m[1]}_routing"), + rspec.spec.call("controllers/#{m[1]}_controller"), + rspec.spec.call("acceptance/#{m[1]}") + ] + end + + # Rails config changes + watch(rails.spec_helper) { rspec.spec_dir } + watch(rails.routes) { "#{rspec.spec_dir}/routing" } + watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" } + + # Capybara features specs + watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") } + watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") } + + # Turnip features and steps + watch(%r{^spec/acceptance/(.+)\.feature$}) + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m| + Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance" + end +end diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..460d20c4f1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Ruby for Good + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 7db80e4ca1..c89ba0b5ed 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,25 @@ # README -This README would normally document whatever steps are necessary to get the -application up and running. +[![Build Status](https://travis-ci.org/rubyforgood/pdx_diaper.svg?branch=master)](https://travis-ci.org/rubyforgood/pdx_diaper) -Things you may want to cover: +## Ruby Version +This app uses Ruby version 2.3.0, indicated in `/.ruby-version`, which will be auto-selected if you use a Ruby versioning manager like `rvm` or `rbenv`. -* Ruby version +## Database Configuration +*Note: The app currently uses SQLite3 for dev/test, but should be reconfigured to work as below, using PG.* -* System dependencies +This app uses PostgreSQL for all environments. When you first clone this app, you will need to create a `.env` file in the root of the application, and populate it with: -* Configuration +``` +DEV_DB_USERNAME=dev_username +DEV_DB_PASSWORD=dev_password +TEST_DB_USERNAME=test_username +TEST_DB_PASSWORD=test_password +``` -* Database creation +You'll also need to create the `dev` and `test` databases, the app is expecting them to be named `diaper_development` and `diaper_test`, respectively. -* Database initialization +## Contributing +Please feel free to contribute! While we welcome all contributions to this app, pull-requests that address outstanding Issues *and* have appropriate test coverage for them will be strongly prioritized. In particular, addressing issues that are tagged with the next milestone should be prioritized higher. -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... +Standard Github community processes apply -- fork the repo, make your changes, submit a pull-request with your change. Please indicate which issue it addresses in your pull-request title. diff --git a/config/initializers/prawn.rb b/config/initializers/prawn.rb new file mode 100644 index 0000000000..d799e5a5a5 --- /dev/null +++ b/config/initializers/prawn.rb @@ -0,0 +1,5 @@ +PrawnRails.config do |config| + config.page_layout = :portrait + config.page_size = "A4" + config.skip_page_creation = false +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 763f006f54..12f2fd5910 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -5,6 +5,8 @@ abort("The Rails environment is running in production mode!") if Rails.env.production? require 'spec_helper' require 'rspec/rails' +require 'capybara/rails' + # Add additional requires below this line. Rails is not loaded until this point! # Requires supporting ruby files with custom matchers and macros, etc, in @@ -33,10 +35,27 @@ # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false # instead of true. - config.use_transactional_fixtures = true + config.use_transactional_fixtures = false # Make FactoryGirl easier. config.include FactoryGirl::Syntax::Methods + + # Preparatifyication + config.before(:suite) do + DatabaseCleaner.clean_with(:truncation) + DatabaseCleaner.strategy = :transaction + DatabaseCleaner.clean + FactoryGirl.lint + end + + config.before(:each) do + DatabaseCleaner.start + end + + config.after(:each) do + DatabaseCleaner.clean + end + # RSpec Rails can automatically mix in different behaviours to your tests # based on their file location, for example enabling you to call `get` and diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8f698be460..f01134ef75 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -49,7 +49,7 @@ # The settings below are suggested to provide a good initial experience # with RSpec, but feel free to customize to your heart's content. -=begin + # This allows you to limit a spec run to individual examples or groups # you care about by tagging them with `:focus` metadata. When nothing # is tagged with `:focus`, all examples get run. RSpec also provides @@ -57,6 +57,7 @@ # metadata: `fit`, `fdescribe` and `fcontext`, respectively. config.filter_run_when_matching :focus +=begin # Allows RSpec to persist some state between runs in order to support # the `--only-failures` and `--next-failure` CLI options. We recommend # you configure your source control system to ignore this file. @@ -68,7 +69,7 @@ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode config.disable_monkey_patching! - +=end # Many RSpec users commonly either run the entire suite or an individual # file, and it's useful to allow more verbose output when running an # individual spec file. @@ -78,7 +79,8 @@ # (e.g. via a command-line flag). config.default_formatter = 'doc' end - + +=begin # Print the 10 slowest examples and example groups at the # end of the spec run, to help surface which specs are running # particularly slow.