Sha256: c6b8337b062f08dc79f149f6bdfbf4a9e3651f9630ccc3d89ab7a55d71f786c4

Contents?: true

Size: 1.22 KB

Versions: 16

Compression:

Stored size: 1.22 KB

Contents

require 'test_helper'

module Adminpanel
  class SectionTest < ActiveSupport::TestCase

    def test_telephone_validations
      set_telephone
      assert @telephone.valid?

      @telephone.update_attribute(:description, '1' * 9)
      assert @telephone.invalid?

      @telephone.update_attribute(:description, '1' * 11)
      assert @telephone.invalid?

      @telephone.update_attribute(:description, '01-2-3-4-5')
      assert @telephone.invalid?

      @telephone.update_attribute(:description, '')
      assert @telephone.valid?
    end

    def test_default_scope
      assert_equal(
        Adminpanel::Section.all.to_sql,
        Adminpanel::Section.reorder('').order(:order => :asc).to_sql
      )
    end

  protected
    def set_telephone
      @telephone = Adminpanel::Section.new(
        name: 'Telefono',
        key: 'phone',
        has_description: false,
        description: '1234567890',
        page: 'home',
        has_image: false
      )
    end

    def set_description
      @description = Adminpanel::Section.new(
        name: 'Inicio',
        key: 'greeting',
        has_description: true,
        description: 'lorem ipsum dolor sit amec',
        page: 'home',
        has_image: false
      )
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
adminpanel-3.2.1 test/models/adminpanel/section_test.rb
adminpanel-3.2.0 test/models/adminpanel/section_test.rb
adminpanel-3.1.0 test/models/adminpanel/section_test.rb
adminpanel-3.0.0 test/models/adminpanel/section_test.rb
adminpanel-2.6.1 test/models/adminpanel/section_test.rb
adminpanel-2.6.0 test/models/adminpanel/section_test.rb
adminpanel-2.5.5 test/models/adminpanel/section_test.rb
adminpanel-2.5.4 test/models/adminpanel/section_test.rb
adminpanel-2.5.3 test/models/adminpanel/section_test.rb
adminpanel-2.5.2 test/models/adminpanel/section_test.rb
adminpanel-2.5.1 test/models/adminpanel/section_test.rb
adminpanel-2.5.0 test/models/adminpanel/section_test.rb
adminpanel-2.4.3 test/models/adminpanel/section_test.rb
adminpanel-2.4.2 test/models/adminpanel/section_test.rb
adminpanel-2.4.1 test/models/adminpanel/section_test.rb
adminpanel-2.4.0 test/models/adminpanel/section_test.rb