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:
parent
41c991384a
commit
457247da8e
38 changed files with 607 additions and 90 deletions
|
@ -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
|
||||
|
||||
|
|
36
test/controllers/tags/deletions_controller_test.rb
Normal file
36
test/controllers/tags/deletions_controller_test.rb
Normal 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
|
42
test/controllers/tags_controller_test.rb
Normal file
42
test/controllers/tags_controller_test.rb
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue