mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 14:31:25 +00:00
* fix: locale-dependent category duplication bug * fix: use family locale for investment contributions category to prevent duplicates and handle legacy data * Remove v* tag trigger from flutter-build to fix double-runs publish.yml already calls flutter-build via workflow_call on v* tags, so the direct push trigger was causing duplicate workflow runs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Refactor mobile release asset flow * fix: category uniqueness and workflow issues * fix: fix test issue * fix: solve test issue * fix: resolve legacy problem * fix: solve lint test issue * fix: revert unrelated changes --------- Co-authored-by: Juan José Mata <juanjo.mata@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
44 lines
1.4 KiB
Ruby
44 lines
1.4 KiB
Ruby
require "test_helper"
|
|
|
|
class CategoryTest < ActiveSupport::TestCase
|
|
def setup
|
|
@family = families(:dylan_family)
|
|
end
|
|
|
|
test "replacing and destroying" do
|
|
transactions = categories(:food_and_drink).transactions.to_a
|
|
|
|
categories(:food_and_drink).replace_and_destroy!(categories(:income))
|
|
|
|
assert_equal categories(:income), transactions.map { |t| t.reload.category }.uniq.first
|
|
end
|
|
|
|
test "replacing with nil should nullify the category" do
|
|
transactions = categories(:food_and_drink).transactions.to_a
|
|
|
|
categories(:food_and_drink).replace_and_destroy!(nil)
|
|
|
|
assert_nil transactions.map { |t| t.reload.category }.uniq.first
|
|
end
|
|
|
|
test "subcategory can only be one level deep" do
|
|
category = categories(:subcategory)
|
|
|
|
error = assert_raises(ActiveRecord::RecordInvalid) do
|
|
category.subcategories.create!(name: "Invalid category", family: @family)
|
|
end
|
|
|
|
assert_equal "Validation failed: Parent can't have more than 2 levels of subcategories", error.message
|
|
end
|
|
|
|
test "all_investment_contributions_names returns all locale variants" do
|
|
names = Category.all_investment_contributions_names
|
|
|
|
assert_includes names, "Investment Contributions" # English
|
|
assert_includes names, "Contributions aux investissements" # French
|
|
assert_includes names, "Investeringsbijdragen" # Dutch
|
|
assert names.all? { |name| name.is_a?(String) }
|
|
assert_equal names, names.uniq # No duplicates
|
|
end
|
|
end
|