-
Notifications
You must be signed in to change notification settings - Fork 13
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
Tests: Improve coverage #455
Merged
Merged
Conversation
This file contains 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
Use "create_and_upload!" instead, wich is an alias.
File: app/helpers/decidim/backup_helper.rb, from 75 to 100%.
File: lib/decidim/translator_configuration_helper.rb, from 77 to 100%.
File: app/services/decidim/action_log_service.rb, from 77 to 100%.
Moved the test files in sub-directories to keep the same structure as the task name
This is a separate commit to keep "rails_migration.rb" as is after its extraction from the Rake task.
It is a duplicate from `decidim-core`
The way it was included in the app (`include` instead of `prepend`) was not overriding the original method. As it does not work with the override (test suite fails), it is removed.
moustachu
approved these changes
Dec 4, 2023
Quentinchampenois
approved these changes
Dec 8, 2023
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.
🎩 Description
Improve tests to reach a global 94% code coverage.
Replaces #454 and #452 (issues with CI not triggering)
📌 Related Issues
No direct related issue
Testing
Run tests and check coverage :)
Tasks
Files under 94% coverage:
lib/tasks/import.rake
102app/jobs/decidim/machine_translation_resource_job.rb
44lib/tasks/migrate.rake
app/services/decidim/s3_sync_service.rb
lib/extends/controllers/decidim/devise/account_controller_extends.rb
app/services/decidim/s3_retention_service.rb
lib/tasks/repair_data.rake
17lib/tasks/db.rake
6lib/active_storage/downloadable.rb
1app/helpers/decidim/backup_helper.rb
1app/services/decidim/action_log_service.rb
3lib/decidim/translator_configuration_helper.rb
2lib/decidim_app/sentry_setup.rb
6app/services/dummy_authorization_handler.rb
lib/decidim/rspec_runner.rb
4lib/decidim_app/decidim_initiatives.rb
3app/services/decidim/database_service.rb
2lib/tasks/decidim_app.rake
2lib/tasks/import.rake
lib/active_storage/downloadable.rb
ActiveStorage::Blob
'sopen
method, inconfig/application.rb
:app/jobs/decidim/machine_translation_resource_job.rb
decidim-core/app/jobs/decidim/machine_translation_resource_job.rb
), tested indecidim-core/spec/jobs/decidim/machine_translation_resource_job_spec.rb
. File was removed from the project.lib/tasks/migrate.rake
RailsMigrations
, maybe)lib/extends/controllers/decidim/devise/account_controller_extends.rb
app/services/decidim/s3_sync_service.rb
#file_list
output may be inconsistent: when a file list empty, the list is created from the backup directory and files are prefixed with the directory name. If the file list is given, no prefix is added.Tests were written to ensure this behavior, but still, it feels weird to me somehow.
app/services/decidim/s3_retention_service.rb
#retention_dates
Could be tested better with timecop gem to have reproducible results#execute
needs proper context and is not yet testeds3_sync_service.rb
. I treated the files as if they were totally different ones (copy-pasted the common tests). A rework of the code of these two classes may be a good idea, with no duplicated tests too.I could have made some shared examples, but I prefer not to yet, as I don't know if the classes should be treated as totally independent.
lib/tasks/repair_data.rake
app/helpers/decidim/backup_helper.rb
Question: What should be the behavior when outside a git repository ? Proposed test replacement:
app/services/dummy_authorization_handler.rb
lib/tasks/decidim_app.rake
decidim_app:setup
is explicitly ignored. Left as-is.EDIT
When comparing the number of files covered (52) vs the ruby files that should be covered (68), we end up with this list:
app/channels/application_cable/channel.rb
: Empty class; 0 direct usage/or reference in the codeapp/channels/application_cable/connection.rb
: Empty class; 0 direct usage/or reference in the codeapp/jobs/backup_job.rb
: referenced insidekick.yml
app/mailers/application_mailer.rb
: 0 direct usage/or reference in the codeapp/models/application_record.rb
: Only used in migrations (which are not tested)app/services/another_dummy_authorization_handler.rb
: 0 direct usage/or reference in the codeapp/services/decidim/osp_authorization_handler.rb
: String reference inconfig/initializers/decidim_verifications.rb
. The tested code may never load the actual class.app/services/decidim/surveys_service.rb
: Used inlib/tasks/db.rake
(L. 32 et 37). My bet is those lines are not coveredapp/services/dummy_authorization_handler.rb
: Used inspec/commands/decidim/verifications/authorize_user_spec.rb
. Weird thing is: I opened that file at some point to decide not to do anythinglib/extends/commands/decidim/admin/create_participatory_space_private_user_extends.rb
: Used to monkey patch a Decidim class. May be never used in the testslib/extends/commands/decidim/admin/impersonate_user_extends.rb
: Used to monkey patch a Decidim class. May be never used in the testslib/extends/queries/decidim/participatory_processes/group_participatory_processes_extends.rb
: Used to monkey patch a Decidim class. May be never used in the testsSimplecov, by default, ignores every files in which the specs don't enter, and there are two possibilities to have a worst coverage, but more accurate: