mirror of
https://github.com/neocities/neocities.git
synced 2025-08-05 09:11:28 +02:00
tests for tagging, eliminate dupes, script to unify tags
This commit is contained in:
parent
5cb988b3e7
commit
f5814226a6
3 changed files with 68 additions and 1 deletions
|
@ -9,5 +9,24 @@ describe Tag do
|
|||
Tag.create_unless_exists tag_name.upcase
|
||||
Tag.filter(name: tag_name).count.must_equal 1
|
||||
end
|
||||
|
||||
it 'prohibits junk tags' do
|
||||
Tag.where(name: '').delete
|
||||
tag = Tag.create_unless_exists ''
|
||||
Tag.where(name: '').count.must_equal 0
|
||||
end
|
||||
|
||||
it 'strips tags' do
|
||||
name = SecureRandom.hex(4)+' '
|
||||
Tag.create_unless_exists name
|
||||
|
||||
Tag[name: name.strip].wont_be_nil
|
||||
end
|
||||
|
||||
it 'does not duplicate' do
|
||||
name = SecureRandom.hex(4).upcase
|
||||
2.times { Tag.create_unless_exists name }
|
||||
Tag.where(name: name.downcase).count.must_equal 1
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue