Skip to content

Commit 38d86fb

Browse files
Merge pull request #1879 from basecamp/scope-tags
Scope tags by account
2 parents 6847c00 + 4a30663 commit 38d86fb

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

app/models/card/taggable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Card::Taggable
99
end
1010

1111
def toggle_tag_with(title)
12-
tag = Tag.find_or_create_by!(title: title)
12+
tag = account.tags.find_or_create_by!(title: title)
1313

1414
transaction do
1515
if tagged_with?(tag)

test/models/card/taggable_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@ class Card::TaggableTest < ActiveSupport::TestCase
1616
@card.toggle_tag_with "ruby"
1717
end
1818
end
19+
20+
test "scope tags by account" do
21+
assert_difference -> { Tag.count }, 2 do
22+
cards(:logo).toggle_tag_with "ruby"
23+
cards(:paycheck).toggle_tag_with "ruby"
24+
end
25+
26+
assert_not_equal cards(:logo).tags.last, cards(:paycheck).tags.last
27+
end
1928
end

0 commit comments

Comments
 (0)