corrected tests for conference domains service
This commit is contained in:
parent
33c5ab9938
commit
686c0a41dc
3 changed files with 33 additions and 33 deletions
|
|
@ -1,6 +1,9 @@
|
|||
require 'resolv'
|
||||
|
||||
class ConferenceDomainsService
|
||||
def initialize(params)
|
||||
@conference = params[:conference]
|
||||
def initialize(conference, resolver = Resolv::DNS.new)
|
||||
@conference = conference
|
||||
@resolver = resolver
|
||||
end
|
||||
|
||||
##
|
||||
|
|
@ -11,16 +14,7 @@ class ConferenceDomainsService
|
|||
# * +true+ -> If the custom domain has a CNAME record for the hosted version
|
||||
# * +false+ -> If the custom domain does not have a CNAME record for the hosted version
|
||||
def check_custom_domain
|
||||
require 'resolv'
|
||||
unless ENV['OSEM_HOSTNAME'].nil?
|
||||
cname_record = Resolv::DNS.new.getresources(@conference.custom_domain, Resolv::DNS::Resource::IN::CNAME)
|
||||
if cname_record.present?
|
||||
return ENV['OSEM_HOSTNAME'] == cname_record.first.name.to_s
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
'--feature disabled--'
|
||||
cname_record = @resolver.getresources(@conference.custom_domain, Resolv::DNS::Resource::IN::CNAME)
|
||||
cname_record.present? ? ENV['OSEM_HOSTNAME'] == cname_record.name.to_s : false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,14 +17,15 @@
|
|||
%td
|
||||
= @conference.custom_domain
|
||||
%td
|
||||
- ck_domain = ConferenceDomainsService.new(conference: @conference).check_custom_domain
|
||||
- if ck_domain == true
|
||||
%span.glyphicon.glyphicon-ok
|
||||
- elsif ck_domain == false
|
||||
%span.glyphicon.glyphicon-remove
|
||||
- if ENV['OSEM_HOSTNAME'].present?
|
||||
- ck_domain = ConferenceDomainsService.new(@conference).check_custom_domain
|
||||
- if ck_domain
|
||||
%span.glyphicon.glyphicon-ok
|
||||
- else
|
||||
%span.glyphicon.glyphicon-remove
|
||||
- else
|
||||
%i
|
||||
= ck_domain
|
||||
feature disabled
|
||||
%td
|
||||
.btn-group
|
||||
= link_to 'Edit', admin_conference_conference_domains_edit_path(@conference.short_title),
|
||||
|
|
@ -67,7 +68,7 @@
|
|||
Pick a domain you want to host your conference on from a domain registrar or register it with a domain registrar.
|
||||
%li
|
||||
Add your own domain name to OSEM
|
||||
= link_to 'here', admin_conference_conference_domains_edit_path(id: @conference.short_title)
|
||||
= link_to 'here', admin_conference_conference_domains_edit_path(@conference.short_title)
|
||||
%li
|
||||
The last step is adding a CNAME record in your registrar’s DNS Settings.
|
||||
Different registrars have different ways of adding a CNAME record.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue