aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/lint_test.rb
blob: 99f8eff5d87fca00b91eb4f53b90d0527f079cba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require "cases/helper"

class LintTest < ActiveModel::TestCase
  include ActiveModel::Lint::Tests

  class CompliantModel
    extend ActiveModel::Naming

    def to_model
      self
    end

    def to_key
      new_record? ? nil : [id]
    end

    def to_param
      return nil if to_key.nil?
      # some default for CPKs, real implementations will differ
      to_key.length > 1 ? to_key.join('-') : to_key.first.to_s
    end

    def valid?()      true end
    def new_record?() true end
    def destroyed?()  true end

    def errors
      obj = Object.new
      def obj.[](key)         [] end
      def obj.full_messages() [] end
      obj
    end
  end

  def setup
    @model = CompliantModel.new
  end
end