1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 07:39:39 +02:00

Create tagging system (#792)

* Repro

* Fix

* Update signage

* Create tagging system

* Add tags to transaction imports

* Build tagging UI

* Cleanup

* More cleanup
This commit is contained in:
Zach Gollwitzer 2024-05-23 08:09:33 -04:00 committed by GitHub
parent 41c991384a
commit 457247da8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 607 additions and 90 deletions

View file

@ -6,7 +6,10 @@ class ImportsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in @user = users(:family_admin)
@empty_import = imports(:empty_import)
@loaded_import = imports(:loaded_import)
@loaded_import = @empty_import.dup
@loaded_import.update! raw_csv_str: valid_csv_str
@completed_import = imports(:completed_import)
end

View file

@ -0,0 +1,36 @@
require "test_helper"
class Tags::DeletionsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in @user = users(:family_admin)
@user_tags = @user.family.tags
@tag = tags(:hawaii_trip)
end
test "should get new" do
get new_tag_deletion_url(@tag)
assert_response :success
end
test "create with replacement" do
replacement_tag = tags(:trips)
affected_transaction_count = @tag.transactions.count
assert affected_transaction_count > 0
assert_difference -> { Tag.count } => -1, -> { replacement_tag.transactions.count } => affected_transaction_count do
post tag_deletions_url(@tag), params: { replacement_tag_id: replacement_tag.id }
end
end
test "create without replacement" do
affected_transactions = @tag.transactions
assert affected_transactions.count > 0
assert_difference -> { Tag.count } => -1, -> { Tagging.count } => affected_transactions.count * -1 do
post tag_deletions_url(@tag)
end
end
end

View file

@ -0,0 +1,42 @@
require "test_helper"
class TagsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in @user = users(:family_admin)
end
test "should get index" do
get tags_url
assert_response :success
@user.family.tags.each do |tag|
assert_select "#" + dom_id(tag), count: 1
end
end
test "should get new" do
get new_tag_url
assert_response :success
end
test "should create tag" do
assert_difference("Tag.count") do
post tags_url, params: { tag: { name: "Test Tag" } }
end
assert_redirected_to tags_url
assert_equal "Tag created", flash[:notice]
end
test "should get edit" do
get edit_tag_url(tags.first)
assert_response :success
end
test "should update tag" do
patch tag_url(tags.first), params: { tag: { name: "Test Tag" } }
assert_redirected_to tags_url
assert_equal "Tag updated", flash[:notice]
end
end