Skip to content

For Developers: Development Setup

Alex Kiessling edited this page Oct 17, 2023 · 2 revisions

RMD is a Ruby on Rails application, so the usual suspects here are:

  • Ruby
  • Gem (via Bundler)
  • PostGRES
  • NodeJS

Dependencies

Homebrew

You will need this to install things like PostGRES, phantomjs, and any other specialized executables, and development libraries for related gems need by the application.

To install, go to: https://brew.sh/

Ruby

Install the version specified in .ruby-version

There are a number of different version managers you can use:

NodeJS

Install the version specified in .node-version

Options include:

Setup

Configuration Files

Copy default settings into your local overrides

cp config/settings.yml config/settings.local.yml

Running Tests

Run the tests

bundle install
bundle exec rake db:create db:migrate
bundle exec rspec

Local Development

Using vault, obtain the current client id and secret keys. If you have vault configured via command line, you can do this with

vault kv get secret/app/rmd/local

You can also visit https://vault.dsrd.libraries.psu.edu:8200

Note the values for client_id and client_secret and update your settings.local.yml file

development:                                                                                                               
  client_secret: [client_secret]                                                                    
  client_id: [client_id]                                                                       
  oauth_app_url: https://login.microsoftonline.com/                                                                     
  oauth_token_url: /7cf48d45-3ddb-4389-a9c1-c115526eb52e/oauth2/v2.0/token                                              
  oauth_authorize_url: /7cf48d45-3ddb-4389-a9c1-c115526eb52e/oauth2/v2.0/authorize 

Your local application should now be configured to authenticate with OAuth, but you will need to create an account for yourself within RMD.

User.create(first_name: [First], last_name: [Last], is_admin: true, penn_state_identifier: [Access ID], webaccess_id: '[Access ID])

Start up the application

yarn install
bundle exec bin/dev

Frontend

Jsbundling-rails is used to bundle assets in the app/javascript directory. After bundling, the bundled manifests are added to app/assets/builds for sprockets to load. Javascripts requiring node modules should be added to the app/javascript directory to be bundled. Other assets should be placed in app/assets to be loaded by sprockets. This results in the application having two entrypoints for styles and javascripts (total of four files): application.js application.css bundle.js bundle.css. Both must be loaded in the layouts. To make the rails server "watch" the app/javascript directory for changes and automatically trigger a re-bundle when changes are detected, run bin/dev instead of rails s. At the time of writing this documentation, rspec-rails does not have a builtin hook to prepare assets with jsbundling for tests. We are invoking the rake task test:prepare in the integration_helper.rb to do this ourselves.