Sha256: 67b3526493cb4416bce1ba16b3450a6564ec0680e7ae6265afe240193ede298a

Contents?: true

Size: 851 Bytes

Versions: 7

Compression:

Stored size: 851 Bytes

Contents

require 'test_helper'

class TitleTest < ActiveSupport::TestCase
  test "length of name" do
    title = Title.new(name: '', post: posts(:published))
    assert !title.save
    assert title.errors.has_key?(:base)

    title.name = 'a'
    assert title.save, title.errors.full_messages.to_sentence
  end

  test "uniqueness" do
    persisted = titles(:draft)
    title = Title.new(name: persisted.name, post: posts(:published))
    assert !title.save, title.errors.full_messages.to_a
    assert title.errors.has_key?(:uniqueness), title.errors.full_messages.to_a
  end

  test "editing only possible when it's a draft" do
    title = titles(:draft)
    title.name = "Changing it."
    assert title.save, title.errors.full_messages.to_sentence

    title = titles(:published_history)
    title.name = "Shouldn't change"
    assert !title.save
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ecrire-0.31.2 test/editor/models/title_test.rb
ecrire-0.31.1 test/editor/models/title_test.rb
ecrire-0.31.0 test/editor/models/title_test.rb
ecrire-0.30.3 test/editor/models/title_test.rb
ecrire-0.30.2 test/editor/models/title_test.rb
ecrire-0.30.1 test/editor/models/title_test.rb
ecrire-0.30.0 test/editor/models/title_test.rb