Sha256: a8e21cccfebfd7cc57ad74d08113c74c6e467b8e64a1d52cbea92b193fecb779

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

# This class is only used for testing purposes.
class FakeObject
  include ActiveModel::Validations
  include SerialTranslator

  def self.serialize(*); end

  def self.before_save(*); end

  # Has to be set in this context to test it correctly
  I18n.available_locales = [:en, :de, :'en-GB']

  TRANSLATED_ATTRIBUTES = %w(description title subtitle summary credits imprint)

  serial_translator_for(*TRANSLATED_ATTRIBUTES)

  TRANSLATED_ATTRIBUTES.map {|ta| "#{ta}_translations" }.each do |hash_name|
    attr_accessor hash_name
    define_method("#{hash_name}_will_change!") { changes << hash_name.to_sym }
  end

  def changes
    @changes ||= []
  end

  validates :description, serial_translator_presence: true
  validates :title,       serial_translator_length: { within: 5..25 }
  validates :subtitle,    serial_translator_length: { is: 9,     allow_nil:   true }
  validates :summary,     serial_translator_length: { in: 5..25, allow_blank: true }
  validates :credits,     serial_translator_length: { minimum: 100 }
  validates :imprint,     serial_translator_length: { maximum: 100 }
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
serial_translator-1.1.3 spec/support/fake_object.rb
serial_translator-1.1.0 spec/support/fake_object.rb
serial_translator-1.0.2 spec/support/fake_object.rb
serial_translator-1.0.1 spec/support/fake_object.rb
serial_translator-1.0.0 spec/support/fake_object.rb