diff --git a/config/initializers/xsd.rb b/config/initializers/xsd.rb index a02fe2dae1..12a8af78a4 100644 --- a/config/initializers/xsd.rb +++ b/config/initializers/xsd.rb @@ -1,2 +1,2 @@ require 'application_service' -require 'xsd/util' +require 'xsd/schema' diff --git a/lib/xsd/util.rb b/lib/xsd/schema.rb similarity index 82% rename from lib/xsd/util.rb rename to lib/xsd/schema.rb index 196175cbee..12a0cd6d94 100644 --- a/lib/xsd/util.rb +++ b/lib/xsd/schema.rb @@ -1,6 +1,7 @@ module Xsd - class Util < ApplicationService + class Schema < ApplicationService SCHEMA_PATH = 'lib/schemas/'.freeze + BASE_URL = 'https://epp.tld.ee/schema/'.freeze attr_reader :xsd_schemas, :for_prefix @@ -10,8 +11,13 @@ def initialize(params) @xsd_schemas = Dir.entries(schema_path).select { |f| File.file? File.join(schema_path, f) } end + def self.filename(*args, &block) + new(*args, &block).call + end + def call - latest(for_prefix) + filename = latest(for_prefix) + BASE_URL + filename end private diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index 59a8ddf776..b8fd851be5 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -14,10 +14,10 @@ def test_illegal_chars_in_dns_key request_xml = <<-XML - + - + #{name} #{registrant.code} @@ -31,7 +31,7 @@ def test_illegal_chars_in_dns_key #{pub_key} - + #{'test' * 2000} diff --git a/test/lib/xsd_schema/xsd_schema_test.rb b/test/lib/xsd_schema/xsd_schema_test.rb new file mode 100644 index 0000000000..0d3e30103b --- /dev/null +++ b/test/lib/xsd_schema/xsd_schema_test.rb @@ -0,0 +1,21 @@ +require 'test_helper' +require 'xsd/schema' + +class XsdSchemaTest < ActiveSupport::TestCase + def setup + @schema_path = 'test/fixtures/files/schemas' + super + end + + def test_single_part_name + filename = Xsd::Schema.filename(schema_path: @schema_path, for_prefix: 'abcde') + + assert_equal Xsd::Schema::BASE_URL + 'abcde-1.2.xsd', filename + end + + def test_double_part_name + filename = Xsd::Schema.filename(schema_path: @schema_path, for_prefix: 'abcde-fghij') + + assert_equal Xsd::Schema::BASE_URL + 'abcde-fghij-1.3.xsd', filename + end +end diff --git a/test/lib/xsd_util/xsd_util_test.rb b/test/lib/xsd_util/xsd_util_test.rb deleted file mode 100644 index d2d70a68f8..0000000000 --- a/test/lib/xsd_util/xsd_util_test.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'test_helper' -require 'xsd/util' - -class XsdUtilTest < ActiveSupport::TestCase - def test_single_part_name - version = Xsd::Util.call(schema_path: 'test/fixtures/files/schemas', for_prefix: 'abcde') - - assert_equal 'abcde-1.2.xsd', version - end - - def test_double_part_name - version = Xsd::Util.call(schema_path: 'test/fixtures/files/schemas', for_prefix: 'abcde-fghij') - - assert_equal 'abcde-fghij-1.3.xsd', version - end -end