Sha256: b57eff5d25e29d14f73ae575f0739135a8b349c13fe6025d693bf0a46a538609

Contents?: true

Size: 1.54 KB

Versions: 6

Compression:

Stored size: 1.54 KB

Contents

require 'test_helper'

class SiteTest < ActiveSupport::TestCase

  def test_does_not_allow_duplicate_names
    Factory(:site, :domain => "test.com")
    @site = Factory.build(:site, :domain => "test.com")
    assert !@site.valid?
    assert_has_error_on @site, :domain, "has already been taken"
  end

  def test_remove_www_from_front_when_saving
    @site = Factory(:site, :domain => "www.test.com")
    assert_equal "test.com", @site.domain
  end
  
  def test_should_remove_www_from_front_when_saving_preserving_sub_domains
    @site = Factory(:site, :domain => "www.foo.test.com")
    assert_equal "foo.test.com", @site.domain
  end
  
  def test_should_not_remove_sub_domain_from_domain_when_saving
    @site = Factory(:site, :domain => "foo.test.com")
    assert_equal "foo.test.com", @site.domain
  end
  
  def test_should_make_the_first_the_default
    @first = Factory(:site)
    @second = Factory(:site)
    assert @first.the_default?
    assert !@second.the_default?
  end
  
  def test_change_the_default
    @first = Factory(:site, :the_default=>false)
    @second = Factory(:site, :the_default => true)
    reset(:first, :second)
    assert !@first.the_default?
    assert @second.the_default?
  end
  
  def test_find_by_domain
    @default =     @first = Factory(:site, :the_default=>true)
    @example = Factory(:site, :domain => "test.com")
    assert_equal @example, Cms::Site.find_by_domain("test.com")
    assert_equal @example, Cms::Site.find_by_domain("www.test.com")
    assert_equal @default, Cms::Site.find_by_domain("whatever.com")
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
browsercms-3.4.2 test/unit/models/site_test.rb
browsercms-3.4.2.rc1 test/unit/models/site_test.rb
browsercms-3.4.1 test/unit/models/site_test.rb
browsercms-3.4.0 test/unit/models/site_test.rb
browsercms-3.4.0.rc2 test/unit/models/site_test.rb
browsercms-3.4.0.rc1 test/unit/models/site_test.rb