diff --git a/app/models/locomotive/extensions/site/subdomain_domains.rb b/app/models/locomotive/extensions/site/subdomain_domains.rb index 46f1df2a..71963b5f 100644 --- a/app/models/locomotive/extensions/site/subdomain_domains.rb +++ b/app/models/locomotive/extensions/site/subdomain_domains.rb @@ -37,9 +37,13 @@ module Locomotive module InstanceMethods + def subdomain=(subdomain) + super(subdomain.try(:downcase)) + end + def domains=(array) array.reject!(&:blank?) - array = [] if array.blank?; super(array) + array = [] if array.blank?; super(array.map(&:downcase)) end def add_subdomain_to_domains @@ -84,4 +88,4 @@ module Locomotive end end end -end \ No newline at end of file +end diff --git a/spec/models/locomotive/extensions/site/subdomain_domains_spec.rb b/spec/models/locomotive/extensions/site/subdomain_domains_spec.rb new file mode 100644 index 00000000..f9fb33e4 --- /dev/null +++ b/spec/models/locomotive/extensions/site/subdomain_domains_spec.rb @@ -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