Browse Source

CLDC-3894 add some local dev setup documentation (#2996)

* add some local dev setup documentation

* debugging docs

* Mention rails console user creation

* include file location

* remove trailing whitespace

* refactor rubymine docs

* prettier

* fix rubocop safety level description

---------

Co-authored-by: Carolyn <carolyn.barker@softwire.com>
pull/3017/head
carolynbarker 7 days ago committed by GitHub
parent
commit
e0df29d4bd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 21
      .run/core.run.xml
  2. 50
      docs/setup.md

21
.run/core.run.xml

@ -0,0 +1,21 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="core" type="RailsRunConfigurationType" factoryName="Rails">
<module name="submit-social-housing-lettings-and-sales-data" />
<predefined_log_file enabled="true" id="RUBY_RAILS_SERVER" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
<EXTENSION ID="BundlerRunConfigurationExtension" BUNDLE_MODE="AUTO" bundleExecEnabled="true" />
<EXTENSION ID="org.jetbrains.plugins.ruby.rails.run.RailsRunConfigurationExtension" SCRATCH_USE_RAILS_RUNNER="false" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="SCRIPT_ARGS" VALUE="" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="PORT" VALUE="3000" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="IP" VALUE="127.0.0.1" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="DUMMY_APP" VALUE="test/dummy" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="RAILS_SERVER_TYPE" VALUE="default" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="ENVIRONMENT_TYPE" VALUE="development" />
<RAILS_SERVER_CONFIG_SETTINGS_ID NAME="LAUNCH_JS" VALUE="false" />
<method v="2" />
</configuration>
</component>

50
docs/setup.md

@ -147,6 +147,9 @@ Also ensure you have firefox installed
bundle exec rake db:seed
```
5. For Ordinance Survey related functionality, such as using the UPRN, you will need to set `OS_DATA_KEY` in your .env file. This key is shared across the team and can be found in AWS Secrets Manager.
6. For email functionality, you will need a GOV.UK Notify API key, which is individual to you. Ask an existing team member to invite you to the "CORE Helpdesk" Notify service. Once invited, sign in and go to "API integration" to generate an API key, and set this as `GOVUK_NOTIFY_API_KEY` in your .env file.
## Running Locally
### Application
@ -183,18 +186,63 @@ Development mode will target the latest versions of Chrome, Firefox and Safari f
The Rails server will start on <http://localhost:3000>.
To sign in locally, you can use any username and password from your local database. The seed task in `seeds.rb` creates users in various roles all with the password `REVIEW_APP_USER_PASSWORD` from your .env file (which has default value `password`).
To create any other users, you can edit the seed commands, or run similar commands in the rails console.
You can also insert a new user row using SQL, but you will need to generate a correctly encrypted password. You can find the value to use for encrypted password which corresponds to the password `YOURPASSWORDHERE` using `User.new(:password => [YOURPASSWORDHERE]).encrypted_password`.
### Debugging
Add the line `binding.pry` to the code to pause the execution of the code at that line and open a powerful interactive console for debugging.
More details on Pry are available at <https://pry.github.io/> .
RubyMine also offers built-in debugging functionality, with the ability to manage breakpoints in the IDE.
To use this:
- To run the app with debugger: select the "core" Rails run configuration for the project in the top right, then click the bug icon to run with the debugger attached
- To run tests with debugger: use the arrows in the margin of spec files beside a section or an individual test
- To run anything else with debugger: go to `Run > Edit Configurations` and add the task you want to debug - options include Rails, Rake, Rspec, Ruby
Click a line number to place a breakpoint. Right click a breakpoint for advanced options on when to trigger and what to log. You can view all breakpoints, toggle them and configure them from the `View Breakpoints...` menu.
When the running code reaches a breakpoint, the debugger pauses execution and the debug panel can be used to:
- View the call stack and the values of variables in the current scope
- Evaluate and watch expressions
- Step through the code line by line
- Mute all breakpoints, resume, restart, etc
More details on debugging in RubyMine can be found at <https://www.jetbrains.com/help/ruby/debugging-code.html> .
### Tests
```bash
bundle exec rspec
```
Or to run individual tests / files use your IDE
To run a specific folder use
```bash
bundle exec rspec ./spec/folder
```
To run individual files use
```bash
bundle exec rspec ./spec/path/to/file.rb
```
or run individual files/tests from your IDE
### Feature toggles
Feature toggles can be found in `app/services/feature_toggle.rb`
### Formatting
- `yarn prettier . --write` for scss, yml, md, and json files
- `yarn standard --fix` for js files
- `bundle exec rubocop -a` to autocorrect safe autocorrectable rubocop offenses in ruby files
- `bundle exec rubocop -A` to autocorrect all autocorrectable rubocop offenses in ruby files - both safe and unsafe
### Linting

Loading…
Cancel
Save