You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement Block Management Interface with Search and Unblock Features
- Added `rails-controller-testing` gem for enhanced controller testing.
- Updated `PersonBlocksController` to include search functionality for blocked users and display blocking timestamps.
- Created views for managing blocked users, including index and new block forms.
- Implemented AJAX responses for blocking and unblocking users with Turbo Streams.
- Enhanced policies to manage user permissions for blocking actions.
- Added acceptance criteria documentation for the Block Management Interface.
- Developed comprehensive controller specs to ensure functionality and edge cases are covered.
@@ -12,32 +12,36 @@ Instructions for GitHub Copilot and other automated contributors working in this
12
12
13
13
## Setup
14
14
- Environment runs a setup script that installs Ruby 3.4.4, Node 20, Postgres + PostGIS, and ES7, then prepares databases.
15
+
-**Docker Environment**: All commands requiring database access must use `bin/dc-run` to execute within the containerized environment.
16
+
-**Dummy App Commands**: Use `bin/dc-run-dummy` for Rails commands that need the dummy app context (e.g., `bin/dc-run-dummy rails console`, `bin/dc-run-dummy rails db:migrate`).
15
17
- Databases:
16
18
- development: `community_engine_development`
17
19
- test: `community_engine_test`
18
20
- Use `DATABASE_URL` to connect (overrides fallback host in `config/database.yml`).
-**For reflection-based features**: Create concerns with `included_in_models` class methods for safe dynamic class resolution
50
-
-**Post-generation security check**: Run `bundle exec brakeman --quiet --no-pager -c UnsafeReflection,SQL,CrossSiteScripting` after major code changes
54
+
-**Post-generation security check**: Run `bin/dc-run bundle exec brakeman --quiet --no-pager -c UnsafeReflection,SQL,CrossSiteScripting` after major code changes
51
55
52
56
## Conventions
53
57
- Make incremental changes with passing tests.
54
-
-**Security first**: Run `bundle exec brakeman --quiet --no-pager` before committing code changes.
58
+
-**Security first**: Run `bin/dc-run bundle exec brakeman --quiet --no-pager` before committing code changes.
55
59
-**Test every change**: Generate RSpec tests for all code modifications, including models, controllers, mailers, jobs, and JavaScript.
56
60
-**Test coverage requirements**: All new features, bug fixes, and refactors must include comprehensive test coverage.
57
61
- Avoid introducing new external services in tests; stub where possible.
@@ -156,14 +160,14 @@ We use the `i18n-tasks` gem to ensure all translation keys are present, normaliz
156
160
157
161
## Example Commands
158
162
```bash
159
-
i18n-tasks normalize
160
-
i18n-tasks missing
161
-
i18n-tasks add-missing
162
-
i18n-tasks health
163
+
bin/dc-run i18n-tasks normalize
164
+
bin/dc-run i18n-tasks missing
165
+
bin/dc-run i18n-tasks add-missing
166
+
bin/dc-run i18n-tasks health
163
167
```
164
168
165
169
## CI Note
166
-
- The i18n GitHub Action installs dev/test gem groups to make `i18n-tasks` available. Locally, you can mirror CI with `bin/i18n`, which sets `BUNDLE_WITH=development:test` automatically.
170
+
- The i18n GitHub Action installs dev/test gem groups to make `i18n-tasks` available. Locally, you can mirror CI with `bin/dc-run bin/i18n`, which sets `BUNDLE_WITH=development:test` automatically.
167
171
168
172
See `.github/instructions/i18n-mobility.instructions.md` for additional translation rules.
169
173
@@ -205,6 +209,22 @@ For every implementation plan, create acceptance criteria covering relevant stak
205
209
-**Test all layers**: models (validations, associations, methods), controllers (actions, authorization), services, mailers, jobs, and view components.
206
210
-**JavaScript/Stimulus testing**: Include feature specs that exercise dynamic behaviors like form interactions and AJAX updates.
207
211
212
+
## Test Environment Requirements
213
+
-**Host Platform Configuration**: All controller, request, and feature tests MUST configure the host platform/community before testing.
214
+
-**Use `configure_host_platform`**: Call this helper method in a `before` block for any test that makes HTTP requests or tests authentication/authorization.
215
+
-**DeviseSessionHelpers**: Include this module and use authentication helpers like `login('[email protected]', 'password')` for authenticated tests.
216
+
-**Platform Setup Pattern**:
217
+
```ruby
218
+
RSpec.describe BetterTogether::SomeControllerdo
219
+
before do
220
+
configure_host_platform # Creates host platform with community
### Critical Testing Pattern: Request Specs vs Controller Specs
342
+
- **Project Standard**: All tests use request specs (`type: :request`) for consistency with Rails engine routing
343
+
- **Exception Handling**: Controller specs (`type: :controller`) require special URL helper configuration in Rails engines
344
+
- **Why This Matters**: Request specs handle Rails engine routing automatically through the full HTTP stack, while controller specs test in isolation and need explicit configuration
345
+
- **Debugging Indicator**: If you see `default_url_options` errors only in one spec while others pass, check if it's a controller spec in a request spec codebase
346
+
347
+
### Rails Engine URL Helper Configuration
348
+
- **Problem**: Controller specs in Rails engines throw `default_url_options` errors that request specs don't encounter
349
+
- **Root Cause**: Engines need special URL helper setup for controller specs but not request specs
350
+
- **Solution Patterns**:
351
+
```ruby
352
+
# For controller spec assertions, use pattern matching instead of path helpers:
353
+
expect(response.location).to include('/person_blocks') # Good
354
+
expect(response).to redirect_to(person_blocks_path) # Problematic in controller specs
-**Special Cases**: If controller specs are needed, prepare for URL helper configuration complexity
390
+
-**Debugging Approach**: When testing errors occur in only one spec, compare its type and setup to working specs
391
+
392
+
## Docker Environment Usage
393
+
-**All database-dependent commands must use `bin/dc-run`**: This includes tests, generators, and any command that connects to PostgreSQL, Redis, or Elasticsearch
394
+
-**Dummy app commands use `bin/dc-run-dummy`**: For Rails commands that need the dummy app context (console, migrations specific to dummy app)
395
+
-**Examples of commands requiring `bin/dc-run`**:
396
+
- Tests: `bin/dc-run bundle exec rspec`
397
+
- Generators: `bin/dc-run rails generate model User`
398
+
- Brakeman: `bin/dc-run bundle exec brakeman`
399
+
- RuboCop: `bin/dc-run bundle exec rubocop`
400
+
-**Examples of commands requiring `bin/dc-run-dummy`**:
0 commit comments