Skip to content

Northwestern University Core Facility Management Software (NUCore)

License

Notifications You must be signed in to change notification settings

SquaredLabs/nucore-uconn

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NUcore Open

Open source version of Northwestern University Core Facility Management Software

Note for Forks

As you pull in new features/bug fixes from open, please keep up with the CHANGELOG to see changes that may break your fork and optional/required rake tasks you may want to run.

Quickstart

Welcome to NUcore! This guide will help you get a development environment up and running.

Development within Docker Environment

We recommend running within a docker environment. Benefits:

  • All daemons, processes are running at all times (easier to develop features)

To do this:

  1. Install Docker and Docker Compose
  2. Run ./docker-setup.sh. This sets up your database.yml and secrets.yml files. It also does an intial bundle install.
  3. The output of the previous set is a randomly generated secret. Copy and paste it into your secrets.yml file as the secret_key_base.
  4. This will also finish setting up the database
  5. Seed the database with demo data (optional) docker-compose run app bundle exec rake demo:seed
  6. Run docker-compose up
  7. Open http://localhost:3000

If you seeded the demo data, you can log in with [email protected]/password

Email

We use mailcatcher as an SMTP server and web client. Visit http://localhost:1080.

Useful Commands

  • Rails Console: docker-compose exec app bundle exec rails c
  • Command line in the container: docker-compose exec app bash
  • Running tests: Get a command line in the container and bundle exec rspec

Development locally

It makes a few assumptions:

  1. You write code on a Mac.
  2. You have a running Oracle or MySQL instance with two brand new databases. (Oracle setup instructions here.)
  3. You have the following installed:

Spin it up

  1. Download the project code from Github

    git clone [email protected]:tablexi/nucore-open.git nucore
    
  2. Install dependencies

    cd nucore
    bundle install
    
  3. Configure your databases

    # For oracle, use config/database.yml.oracle.template
    cp config/database.yml.mysql.template config/database.yml
    

    Edit the adapter, database, username, and password settings for both the development and test DBs to match your database instance

  4. Configure your secrets

cp config/secrets.yml.template config/secrets.yml
rake secret
  • Paste the output from rake secret into config/secrets.yml for both development/secret_key_base and test/secret_key_base
  1. Set up databases

    rake db:create
    rake db:schema:load
    rake db:seed
    

Known issue: if you run db:setup or all three in one rake command, the next time you run db:migrate, you will receive a Table 'splits' already exists error. Use the separate commands instead.

  1. Seed your development database

    rake demo:seed
    
  2. Configure your file storage

    By default, files are stored on the local filesystem. If you wish to use Amazon's S3 instead, enable S3 in your environment by updateing the local settings override file such as config/settings/development.local.yml or config/settings/production.local.yml. Uncomment the section under paperclip:

    paperclip:
      aws_access_key_id: <%= ENV.fetch("AWS_ACCESS_KEY", "Your-Key-Here") %>
      aws_secret_access_key: <ENV.fetch("AWS_SECRET_ACCESS_KEY", "Your-Key-Here") %>
      ...
    

    Then add your credentials to the ENV or secrets.yml.

    See migrating_to_s3.md for more info.

  3. Start your server

    bin/rails s
    
  4. Log in

    Visit http://localhost:3000

    demo:seed creates several users with various permissions. All users have the default password of password

    Email/username Role
    [email protected] Admin
    [email protected] PI
    [email protected] Normal User
    [email protected] Facility Staff
    [email protected] Facility Director
  5. Play around! You're running NUcore!

  6. Run delayed_job to support in-browser email previews.

    Run delayed jobs indefinitely in the background:

    ./script/delayed_job start
    

    Or run delayed jobs once for one-off jobs:

    ./script/delayed_job run
    

Test it

NUcore uses Rspec to run tests. Try any of the following from NUcore's root directory.

  • To run all tests (this will take awhile!)

    rake spec
    
  • To run just the model tests

    rake spec:models
    
  • To run just the controller tests

    rake spec:controllers
    

Parallel Tests

You can run specs in parallel during local development using the parallel_tests gem.

  • Create additional databases:

    rake parallel:create
    
  • Run migrations (only needed if building from scratch):

    rake parallel:create
    

    OR

    rake parallel:load_schema
    
  • Copy development schema (repeat after migrations):

     rake parallel:prepare
    
  • Run tests:

    rake parallel:spec
    
  • Example RegEx patterns (ZSH users may require putting rake task in quotes to support args):

     rake parallel:spec[^spec/requests] # every spec file in spec/requests folder
     rake parallel:spec[user]  # run users_controller + user_helper + user specs
     rake parallel:spec['user|instrument']  # run user and product related specs
     rake parallel:spec['spec\/(?!features)'] # run RSpec tests except the tests in spec/features
    

Optional Modules

The following modules are provided as optional features via Rails engines. These are enabled by adding the appropriate engine to your Gemfile (all are on by default). They exist in the vendor/engines directory.

Engine-specific migrations should live in the engine's db/migrate directory and use an engine initializer to add that path to the list of paths Rails checks. If you need to disable an engine, you can undo all of the engine's migrations with the rake engines:db:migrate_down[ENGINE_NAME] task.

Learn more

There are valuable resources in the NUcore's doc directory.

About

Northwestern University Core Facility Management Software (NUCore)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 84.3%
  • Haml 9.8%
  • CoffeeScript 2.3%
  • JavaScript 1.7%
  • SCSS 1.5%
  • HTML 0.4%