Encapsulate tagging as a taggable domain method

Tag scope control should not float around in the controller
This commit is contained in:
David Heinemeier Hansson
2024-10-19 20:14:59 -07:00
parent c00dcd8c66
commit b1f5498914
3 changed files with 31 additions and 10 deletions
+25
View File
@@ -0,0 +1,25 @@
require "test_helper"
class TagsControllerTest < ActionDispatch::IntegrationTest
setup do
sign_in_as :kevin
end
test "create with existing tag" do
assert_no_difference -> { accounts(:"37s").tags.count } do
post bucket_bubble_tags_url(buckets(:writebook), bubbles(:logo)), params: { tag: { title: "Web" } }
end
assert_redirected_to bubbles(:logo)
end
test "create with new tag" do
assert_difference -> { accounts(:"37s").tags.count }, +1 do
post bucket_bubble_tags_url(buckets(:writebook), bubbles(:logo)), params: { tag: { title: "Horizons" } }
end
assert_redirected_to bubbles(:logo)
assert bubbles(:logo).tags.pluck(:title).include?("Horizons")
end
end