forked from ontoportal/ontologies_api
-
Notifications
You must be signed in to change notification settings - Fork 12
Refactor/tests stability and minitest style #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alexskr
merged 17 commits into
feature/user-admin-endpoints
from
refactor/tests-stability-and-minitest-style
Nov 7, 2025
Merged
Refactor/tests stability and minitest style #198
alexskr
merged 17 commits into
feature/user-admin-endpoints
from
refactor/tests-stability-and-minitest-style
Nov 7, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Ontology Admin Endpoints for Logs and Submission Management
…ests Replace non-idiomatic assertions with Minitest equivalents: - assert(x == y) -> assert_equal - .eql?() -> assert_equal - assert !x.empty? -> assert_operator x.length, :>, 0 - submissions.all? -> submissions.each for better error messages Extract repeated contact validation into helper method to reduce duplication. Fix intermittent test failures by sorting array keys before comparison to handle non-deterministic ordering. refs #197
- Replace class variables (@@) with class instance variables using accessors - Add attr_accessor definitions for shared test state - Modernize assertions to Minitest style (assert_equal, assert_includes, assert_nil) - Improve code formatting and readability
…dition - Replace random .sample(3) with deterministic .first(3) - Use dynamic assertion for keep_ids count instead of hardcoded value - Capture process_id before use for clarity - Simplify polling loop condition to check only for 'done' or 'errors' - Clean up assertion message formatting for consistency
…n/deletion - Replace `assert 201, ...` with `assert_equal 201, ...` to properly compare response status. - Add GET checks after slice creation to confirm the new slice exists. - Remove redundant manual reset of LinkedData.settings.enable_security. - Update DELETE test to expect 204 (No Content) instead of 201. - Add GET checks after deletion to verify the slice was actually removed.
- Add explicit flunk when status_payload contains 'errors' to prevent false positives from incomplete or invalid responses - Ensure test fails immediately on backend error instead of silently skipping assertions
Restore LinkedData.settings.enable_slices to its original value after tests.
…com:ncbo/ontologies_api into refactor/tests-stability-and-minitest-style
… user helpers This change refactors `TestOntologySubmissionsController` to eliminate suite-level globals and class-variable state in favor of per-test setup and shared helpers: - Replace `before_suite` + `@@acronym`/`@@name`/`@@file_params` with per-test `setup` that generates a unique ontology acronym and creates an ontology administered by a shared test user. - Introduce a suite-local `USERNAME = "test_user"` and use `ensure_user(USERNAME)` to guarantee the user exists without races. - Normalize assertion style: - Use `assert_equal(expected, actual, message)` with parentheses - Remove `msg=` pseudo-named args - Add `.sort` where appropriate when comparing unordered keys - Replace direct references to `@@acronym`/`@@name` with instance vars (`@acronym`, `@name`). New helper methods (in the base test class) used by this suite: - `create_user(username, email:, password:)` — always creates a user - `ensure_user(username, email:, password:)` — idempotently finds or creates - `delete_user(username)` — removes a user if present Notes: - `delete_ontologies_and_submissions` now runs in `setup` to guarantee a clean slate per test. `after_all` also cleans up the shared user via `delete_user(USERNAME)`. If the extra cleanup proves redundant, we can drop `before_all`/`after_all` and keep only the per-test cleanup.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/user-admin-endpoints #198 +/- ##
================================================================
+ Coverage 72.86% 73.46% +0.60%
================================================================
Files 63 63
Lines 3376 3377 +1
================================================================
+ Hits 2460 2481 +21
+ Misses 916 896 -20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issue:
Summary
This PR focuses primarily on stabilizing and refactoring tests in
test_ontology_submissions_controller,as part of ongoing work for the user-admin-endpoints feature.It introduces more deterministic behavior, modernizes assertions to idiomatic Minitest style, and removes shared suite-level state that was causing nondeterministic failures.
Note: This is not comprehensive — only the most failure-prone areas were addressed in this pass. Additional test suites will be refactored in follow-up PRs.
Key Improvements