Skip to content
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

Bugfix: Ensure credit_count is tested correctly #20654

Conversation

codeandclay
Copy link

Closes #20653

Credit uses counter culture to create and populate columns. The code currently populates these columns explicitly. However, not populating the credits_count columns should cause tests to fail. It doesn't.

The credits test subjects are set up with:

let(:user_credits) { create_list(:credit, 2, user: user) }
let(:org_credits) { create_list(:credit, 1, organization: organization) }

However, these are not tested. They do not point to the correct user or organisation.

Using let!, eager loads these associations and creates the necessary credits, and references the lazily loaded user and organization subjects.

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Added/updated tests?

We encourage you to keep the code coverage percentage at 80% and above.

@codeandclay codeandclay requested a review from a team as a code owner February 19, 2024 19:27
@codeandclay codeandclay requested review from lightalloy and maestromac and removed request for a team February 19, 2024 19:27
Copy link
Contributor

Thank you for opening this PR! We appreciate you!

For all pull requests coming from third-party forks we will need to
review the PR before we can process it through our CI pipelines.

A Forem Team member will review this contribution and get back to
you as soon as possible!

Copy link
Contributor

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

@codeandclay codeandclay marked this pull request as draft February 19, 2024 19:32
depfu bot and others added 3 commits February 19, 2024 19:52
Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
Co-authored-by: Mac Siri <mac@forem.com>
Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
Fixes forem#20653

Credit uses counter culture to create and populate columns. The code currently populates these columns explicitly. However, not populating the credits_count columns should cause tests to fail. It doesn't.

The credits test subjects are set up with:

```
let(:user_credits) { create_list(:credit, 2, user: user) }
let(:org_credits) { create_list(:credit, 1, organization: organization) }
```

However, these are not tested. They do not point to the correct `user` or `organisation`.

Using `let!`, eager loads these associations and creates the necessary credits, and references the lazily loaded `user` and `organization` subjects.
@codeandclay codeandclay force-pushed the codeandclay/fix-ineffective-credit-spec-tests-20653 branch from a892424 to 675d6df Compare February 19, 2024 19:52
@codeandclay
Copy link
Author

Need to sign CLA first and ensure branch is up to date. Easier to do if I start again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

credit_spec tests for #credit_count are ineffective and do not fail when expected to
1 participant