Skip to content

test: add error test cases for AnnotationCategory - #8177

Open
AngelsandDevsLOL wants to merge 3 commits into
MarkUsProject:masterfrom
AngelsandDevsLOL:test/raise-upload-error-annotations
Open

AngelsandDevsLOL wants to merge 3 commits into
MarkUsProject:masterfrom
AngelsandDevsLOL:test/raise-upload-error-annotations

Conversation

@AngelsandDevsLOL

@AngelsandDevsLOL AngelsandDevsLOL commented Sep 18, 2026

Copy link
Copy Markdown

Proposed Changes

Adds two test cases for AnnotationCategory to cover an error when uploading a CSV in the method, add_by_row. It fails when an instructor tries to add an AnnotationCategory to a course they don't teach. This occurs when the AnnotationText validates the :courses_should_match, which returns false because the creator_id of the text is in a different course than the course for annotation_category_id.

This should let the annotation_category.rb folder achieve 100% coverage.

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality)
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests) X
📦 Dependency update (change that updates a dependency)
📖 Documentation update (change that updates documentation)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the [ ] into a [x] in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • [N/A] I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

Because the AnnotationCategory's add_by_row method calls the AnnotationText's validations, I wasn't sure if I should also be adding test cases for AnnotationText, as well as AnnotationCategory? Or if the test cases should go into AnnotationText instead.

In RubyMine, the compiler is mentioning converting the current row array into '%w' syntax. I didn't accept the change, but I was wondering if it was meant for readability and when you would use it.

I'm confused about exactly what :assignment is. I keep seeing that it's a symbol, but it feels like it represents different things where sometimes it represents the Assignment model/object, other times it's used to define a new variable as in let(:assignment) { create(:assignment) }, or used within other classes (belongs_to :assignment, ...). I've also seen the colon used before methods, such as validates :annotation_category_name, .., which is all really confusing. I'm wondering if there's a better way to understand what the 'symbol' is intuitively, or if it's something I'll eventually understand and learn along the way.

I'm not sure what the difference between describe and context is, since it seems to be used interchangeably.

@coveralls

coveralls commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 35304980534

Coverage increased (+0.006%) to 90.789%

Details

  • Coverage increased (+0.006%) from the base build.
  • Patch coverage: 11 of 11 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 52883
Covered Lines: 49045
Line Coverage: 92.74%
Relevant Branches: 2517
Covered Branches: 1252
Branch Coverage: 49.74%
Branches in Coverage %: Yes
Coverage Strength: 128.2 hits per line

💛 - Coveralls

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.

2 participants