aboutsummaryrefslogtreecommitdiff
path: root/test/models/tag_test.rb
blob: dafb8e477d896c03745868d4cc8c2219bac25ea0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# frozen_string_literal: true

require 'test_helper'

class TagTest < ActiveSupport::TestCase
  test 'name is present and unique' do
    tag = Tag.new
    assert_raise(ActiveRecord::RecordInvalid) { tag.save! }

    tag = Tag.new(name: tags(:tag1).name)
    assert_raise(ActiveRecord::RecordInvalid) { tag.save! }

    tag.name = 'another'
    assert_difference('Tag.count') { tag.save! }
  end
end