Downcase subdomains and domains when given as user input.
This commit is contained in:
parent
e413373858
commit
7260f36be7
@ -37,9 +37,13 @@ module Locomotive
|
|||||||
|
|
||||||
module InstanceMethods
|
module InstanceMethods
|
||||||
|
|
||||||
|
def subdomain=(subdomain)
|
||||||
|
super(subdomain.try(:downcase))
|
||||||
|
end
|
||||||
|
|
||||||
def domains=(array)
|
def domains=(array)
|
||||||
array.reject!(&:blank?)
|
array.reject!(&:blank?)
|
||||||
array = [] if array.blank?; super(array)
|
array = [] if array.blank?; super(array.map(&:downcase))
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_subdomain_to_domains
|
def add_subdomain_to_domains
|
||||||
@ -84,4 +88,4 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Locomotive::Extensions::Site::SubdomainDomains do
|
||||||
|
describe '#subdomain=' do
|
||||||
|
let(:site) { Locomotive::Site.new }
|
||||||
|
|
||||||
|
it 'downcases the subdomain' do
|
||||||
|
site.subdomain = 'MiXeDCaSe'
|
||||||
|
|
||||||
|
site.subdomain.should == 'mixedcase'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#domains=' do
|
||||||
|
let(:site) { Locomotive::Site.new }
|
||||||
|
|
||||||
|
it 'downcases the domains' do
|
||||||
|
site.domains = ['FIRST.com', 'second.com', 'THIRD.com']
|
||||||
|
|
||||||
|
site.domains.should == ['first.com', 'second.com', 'third.com']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user