Sha256: c029e8e828e0b08d721dd2573fd1d98fbaab97a680165cf6453b97f0b953f6ea

Contents?: true

Size: 1.18 KB

Versions: 13

Compression:

Stored size: 1.18 KB

Contents

require 'test_helper'

module Guts
  class OptionTest < ActiveSupport::TestCase
    test 'should not create without key' do
      option = Option.new
      
      assert_not option.save
    end
    
    test 'should create option' do
      option       = Option.new
      option.key   = 'one_key'
      option.value = 'To rule them all'
      
      assert_equal true, option.save
    end
    
    test 'should normalize key name' do
      option       = Option.new
      option.key   = 'One key!'
      
      option_two     = Option.new
      option_two.key = 'one_key_two'
      
      assert_equal 'one_key', option.key
      assert_equal 'one_key_two', option_two.key
    end
    
    test 'should not create with key less than three characters' do
      option     = Option.new
      option.key = 'xy'
      
      assert_not option.save
    end
    
    test 'should be trackable' do
      assert_equal true, Option.methods.include?(:trackable)
    end
    
    test 'should find by key using helper method' do
      assert_instance_of Option, Option.for_key(:test_key)
    end
    
    test 'option should be multisite compatible' do
      assert Option.all.to_sql.include?('site_id')
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
guts-1.4.0 test/models/guts/option_test.rb
guts-1.3.6 test/models/guts/option_test.rb
guts-1.3.5 test/models/guts/option_test.rb
guts-1.3.4 test/models/guts/option_test.rb
guts-1.3.3 test/models/guts/option_test.rb
guts-1.3.2 test/models/guts/option_test.rb
guts-1.3.1 test/models/guts/option_test.rb
guts-1.3.0 test/models/guts/option_test.rb
guts-1.2.2 test/models/guts/option_test.rb
guts-1.2.1 test/models/guts/option_test.rb
guts-1.2.0 test/models/guts/option_test.rb
guts-1.1.1 test/models/guts/option_test.rb
guts-1.1.0 test/models/guts/option_test.rb