test: add MaterialCategory and BuyerCategory model tests + BuyerCategory factory#5
Open
test: add MaterialCategory and BuyerCategory model tests + BuyerCategory factory#5
Conversation
Both Oroshi::MaterialCategory and Oroshi::BuyerCategory had no model tests despite being core classification models used throughout the wholesale order system. MaterialCategory (11 tests): - Valid with valid attributes - Name presence validation - Activatable concern: nil active invalid, false active valid - Activatable scopes: active/inactive filtering - has_many :materials association - dependent: :destroy behaviour verified with a created material BuyerCategory (8 tests): - Valid with valid attributes - Name, symbol, color presence validations - default_scope orders by created_at ascending - has_many :buyers and :buyer_buyer_categories associations - Persistence sanity check Also adds test/factories/oroshi/buyer_categories_factory.rb (missing factory referenced in system tests but never defined as a standalone factory file).
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
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.
What
Adds model tests for two untested classification models (Oroshi::MaterialCategory and Oroshi::BuyerCategory), plus a missing factory for BuyerCategory.
Why
These models are used throughout the order system for classifying buyers and packaging materials, but neither had dedicated unit tests. BuyerCategory also lacked a FactoryBot factory despite being referenced in system tests.
36 oroshi models exist; only 22 had model tests. This closes two gaps.
Changes
test/factories/oroshi/buyer_categories_factory.rb (new)
BuyerCategory factory with FFaker-generated name, symbol, and hex color — follows the same pattern as the existing oroshi_buyer factory.
test/models/oroshi/material_category_test.rb (11 tests)
test/models/oroshi/buyer_category_test.rb (8 tests)
Risks
Low — no model logic changes, no migrations. All tests use FactoryBot build/create with the dummy app's test database.