Sha256: b039643853bc4b76b5cd953f62b2dd60e96f6079f536f920eb0f1833dcf620a4

Contents?: true

Size: 1.27 KB

Versions: 5

Compression:

Stored size: 1.27 KB

Contents

require File.expand_path('../../test_helper', File.dirname(__FILE__))

class CmsSiteTest < ActiveSupport::TestCase
  
  def test_fixtures_validity
    Cms::Site.all.each do |site|
      assert site.valid?, site.errors.full_messages.to_s
    end
  end
  
  def test_validation
    site = Cms::Site.new
    assert site.invalid?
    assert_has_errors_on site, [:label, :hostname]
    
    site = Cms::Site.new(:label => 'My Site', :hostname => 'http://my-site.host')
    assert site.invalid?
    assert_has_errors_on site, :hostname
    
    site = Cms::Site.new(:label => 'My Site', :hostname => 'my-site.host')
    assert site.valid?
  end
  
  def test_label_assignment
    site = Cms::Site.new(:hostname => 'my-site.host')
    assert site.valid?
    assert_equal 'my-site.host', site.label
  end
  
  def test_cascading_destroy
    assert_difference 'Cms::Site.count', -1 do
      assert_difference 'Cms::Layout.count', -3 do
        assert_difference 'Cms::Page.count', -2 do
          assert_difference 'Cms::Snippet.count', -1 do
            cms_sites(:default).destroy
          end
        end
      end
    end
  end
  
  def test_options_for_select
    assert_equal 1, Cms::Site.options_for_select.size
    assert_equal 'Default Site (test.host)', Cms::Site.options_for_select[0][0]
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.2.8 test/unit/models/site_test.rb
comfortable_mexican_sofa-1.2.7 test/unit/models/site_test.rb
comfortable_mexican_sofa-1.2.6 test/unit/models/site_test.rb
comfortable_mexican_sofa-1.2.5 test/unit/models/site_test.rb
comfortable_mexican_sofa-1.2.4 test/unit/models/site_test.rb