Page MenuHomeGRNET

No OneTemporary

File Metadata

Created
Mon, Nov 25, 8:18 AM
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 3b17d27..38e4c7e 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -1,48 +1,48 @@
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery.min
//= require jquery_ujs
//= require bootstrap.min
//= require typeahead.bundle.min
//= require_tree .
$(function() {
- // Show priority on MX record only
+ // Show priority on MX/SRV record only
$('#record_type').change(function() {
- if ($(this).val() == 'MX') {
+ if ($(this).val() == 'MX' || $(this).val() == 'SRV') {
$('#record_prio').parents('div.form-group').removeClass('hidden');
} else {
$('#record_prio').parents('div.form-group').addClass('hidden');
}
});
var searchMembersGroup = $('#js-search-member').data('group');
var searchMembers = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: '/groups/' + searchMembersGroup + '/search_member.json?q=%QUERY',
wildcard: '%QUERY'
}
});
$('#js-search-member').typeahead({
hint: true,
minLength: 2
}, {
name: 'members',
display: 'email',
source: searchMembers
});
});
diff --git a/app/models/srv.rb b/app/models/srv.rb
new file mode 100644
index 0000000..0219c20
--- /dev/null
+++ b/app/models/srv.rb
@@ -0,0 +1,8 @@
+class SRV < Record
+ validates :content, presence: true
+ validates :prio, presence: true, prio: true
+
+ def supports_prio?
+ true
+ end
+end
diff --git a/test/factories/srv.rb b/test/factories/srv.rb
new file mode 100644
index 0000000..fae9109
--- /dev/null
+++ b/test/factories/srv.rb
@@ -0,0 +1,8 @@
+FactoryGirl.define do
+ factory :srv, class: 'SRV' do
+ domain
+ name '_service._proto.name.'
+ prio 10
+ content 'weight port target.'
+ end
+end
diff --git a/test/models/srv_test.rb b/test/models/srv_test.rb
new file mode 100644
index 0000000..4695d0f
--- /dev/null
+++ b/test/models/srv_test.rb
@@ -0,0 +1,41 @@
+require 'test_helper'
+
+class SRVTest < ActiveSupport::TestCase
+
+ test 'saves' do
+ rec = build(:srv)
+ rec.valid?
+ assert_empty rec.errors
+ assert rec.save
+ end
+
+ test 'supports prio' do
+ rec = build(:srv)
+ assert rec.supports_prio?, 'supports prio'
+ end
+
+ [
+ 0,
+ 10,
+ 65_535,
+ ].each { |prio|
+ test "valid prio #{prio}" do
+ rec = build(:srv, prio: prio)
+ rec.valid?
+ assert_empty rec.errors[:prio], "#{prio} should be valid!"
+ end
+ }
+
+ [
+ -10,
+ 65_535 + 1,
+ 'str',
+ ].each { |prio|
+ test "invalid prio #{prio}" do
+ rec = build(:srv, prio: prio)
+ rec.valid?
+ assert_not_empty rec.errors[:prio], "#{prio} should be invalid!"
+ end
+ }
+
+end

Event Timeline