Skip to content

Latest commit

 

History

History
137 lines (94 loc) · 4.72 KB

setup.md

File metadata and controls

137 lines (94 loc) · 4.72 KB

App Setup

Dependencies

  • Ruby 2.2.3
  • PostgreSQL 9.x
  • Elasticsearch 1.5+
  • A MyUSA account
  • An SMTP server (production mode only)

Installation

C2 is a fairly typical Rails application, so the setup is straightforward:

  1. Run

    git clone https://github.com/18F/C2.git
    cd C2
    
    # Will print "DONE" if successful. NOTE: This will delete any existing records in your C2 database and add a few seed records.
    ./script/bootstrap
  2. Per the Twelve-Factor guidelines, all necessary configuration should be possible through environment variables. (See .env.example for the full list.)

    Your configuration will go in the .env file. Create it by copying .env.example:

    cp .env.example .env
  3. Register an application on MyUSA.

    • Give the application a Name that gives MyUSA admins a good idea of what it is and who set it up; e.g. Janet's laptop C2
    • Set the Url field to the URL for your setup. If you're running the app locally, the default URL is http://localhost:3000/
    • Set the Redirect uri field to [your_C2_url]/auth/myusa/callback . For example, with the default URL: http://localhost:3000/auth/myusa/callback
    • In the "Select the API Scopes..." section, select:
      • Email Address
      • First Name
      • Last Name
    • By default, new applications on MyUSA have a status of Private, which means that only the MyUSA user who registered the app can log in. If you need other people to log into your C2 setup, then your app will need a status of Public. (This matters for staging servers more than local development, so you probably don't need to worry about it.)

    Since Public apps need to be approved by MyUSA admins before they're usable, it's best to leave the status as Private when setting up, then change it to Public later.

  4. Once you've registered the application, MyUSA will give you two consumer key strings for saving: the Public Key and Secret Key. Add these to your .env, setting MYUSA_KEY to the Public Key and MYUSA_SECRET to the Secret Key.

Troubleshooting

Can't create or connect to database

  • Check that PostgreSQL is running
  • Set the DATABASE_URL variable in .env to match your setup

Can't create or connect to Elasticsearch

  • Check that Elasticsearch is running (default is localhost:9200)
  • Set the ES_URL variable in .env to match your setup

If 'foreman' command not found, you may be using rbenv. If so, run the following...

rbenv rehash
gem install foreman

MyUSA won't let other users log in

This is likely because your MyUSA app registration is marked Private. To get Public status, go to your developer applications list and click Request Public Access; this will send a message to the MyUSA admins. (If your application's status hasn't changed after one business day, try mailing the MyUSA team; if you're an 18F employee, ask in the #myusa Slack channel.)

Starting the application

./script/start
open http://localhost:3000

Populating with data

Once you've authed locally, there will be a user record associated with your email address. There won't be much for you to see until your client slug is set, so find your user record and set it to ncr:

bin/rails c
user = User.find_by(email_address: '[email protected]')
user.update(client_slug: 'ncr')

Now you will see the link to create a new work order locally.

If you'd like to seed your dashboard with work orders, you can run this rake task:

bin/rake populate:ncr:for_user[[email protected]]

Now you should see 25 pending purchase requests at http://localhost:3000/proposals.

Viewing the mailers

As emails are sent, they will be visible at http://localhost:3000/letter_opener.

If you are working on an email mailer/template, you can view all of them at http://localhost:3000/rails/mailers.

Running tests

PhantomJS

You will need to install PhantomJS and have it in your PATH. This is used for javascript and interface testing.

Running the entire suite once

./bin/rake

Running tests as corresponding files are changed

bundle exec guard

Checking for security vulnerabilities

gem install brakeman
brakeman

or just visit the project on Gemnasium.

Re-indexing search

rake search:import NPROCS=2 FORCE=y