mirror of
https://github.com/we-promise/sure.git
synced 2026-08-05 00:22:17 +00:00
Add test coverage for category hierarchy and account search
Model-level:
- Category::GroupTest (new): for() grouping and the new select_options
helper (order + indent labels).
- CategoryTest: alphabetically_by_hierarchy scope ordering.
- Rule::ConditionFilter::TransactionCategoryTest (new)
- Rule::ActionExecutor::SetTransactionCategoryTest (new)
- Import::CategoryMappingTest (new): grouping + 'Add as new category'
still prepends correctly.
Controller/integration-level (asserting actual rendered HTML order):
- SplitsControllerTest: category combobox data-value ordering.
- Transactions::CategorizesControllerTest: bulk-categorize <select>
option ordering.
- TransactionsControllerTest:
- search filter checkbox ordering (q[categories][])
- new-transaction DS::Select category ordering (via trigger id +
ancestor traversal)
- new-transaction account select renders a search box
All new/modified test files verified with 'ruby -c' (syntax) and
cross-checked fixture names, family scoping, route helpers, and field
names against the actual fixtures/routes/views. Ruby/Bundler network
access to rubygems.org is unavailable in this sandbox, so the suite
itself has not been executed — run 'bin/rails test' before merging.
This commit is contained in:
25
test/models/import/category_mapping_test.rb
Normal file
25
test/models/import/category_mapping_test.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require "test_helper"
|
||||
|
||||
class Import::CategoryMappingTest < ActiveSupport::TestCase
|
||||
setup do
|
||||
@mapping = import_mappings(:one)
|
||||
end
|
||||
|
||||
test "selectable_values groups subcategories immediately after their parent" do
|
||||
options = @mapping.selectable_values
|
||||
|
||||
parent_index = options.index { |_label, id| id == categories(:food_and_drink).id }
|
||||
child_index = options.index { |_label, id| id == categories(:subcategory).id }
|
||||
|
||||
assert_not_nil parent_index
|
||||
assert_not_nil child_index
|
||||
assert_equal parent_index + 1, child_index
|
||||
end
|
||||
|
||||
test "selectable_values still prepends 'Add as new category' when key is present" do
|
||||
options = @mapping.selectable_values
|
||||
|
||||
assert_equal "Add as new category", options.first.first
|
||||
assert_equal Import::Mapping::CREATE_NEW_KEY, options.first.last
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user