Sha256: 920dc822cad7a5903692733ea76f9dd2648645e44d36cc54c04fa43f38da9571

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

describe "ActiveRecord::Base" do
  before(:each) do
    class User < ActiveRecord::Base
      attr_accessor :subdomain
    end
  end

  it "should have validates_subdomain_format_of which runs SubdomainRoutes.valid_subdomain? against the attributes" do
    User.validates_subdomain_format_of :subdomain
    SubdomainRoutes.should_receive(:valid_subdomain?).with("mholling").and_return(true)
    User.new(:subdomain => "mholling").should be_valid
    SubdomainRoutes.should_receive(:valid_subdomain?).with("mholling").and_return(nil)
    User.new(:subdomain => "mholling").should_not be_valid
  end
  
  it "should have validates_subdomain_not_reserved which checks the attributes against the fixed-subdomain routes" do
    User.validates_subdomain_not_reserved :subdomain
    reserved = [ "", "www", "support", "admin" ]
    map_subdomain(*reserved) { |map| map.resource :home }
    reserved.each do |subdomain|
      User.new(:subdomain => subdomain).should_not be_valid
    end
    [ "mholling", "edmondst", "2girls1cup" ].each do |subdomain|
      User.new(:subdomain => subdomain).should be_valid
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ghazel-subdomain_routes-0.3.1.2 spec/validations_spec.rb
ghazel-subdomain_routes-0.3.1.1 spec/validations_spec.rb