Browse Source

updates

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
0345f80786
  1. BIN
      app/assets/images/arrow.png
  2. BIN
      app/assets/images/bgd.jpg
  3. BIN
      app/assets/images/boxbar-background.png
  4. BIN
      app/assets/images/button-background-active.png
  5. BIN
      app/assets/images/button-background.png
  6. BIN
      app/assets/images/messages/error.png
  7. BIN
      app/assets/images/messages/notice.png
  8. BIN
      app/assets/images/messages/warning.png
  9. 2
      app/assets/stylesheets/application.css
  10. 1
      app/assets/stylesheets/marketing.css.scss
  11. 438
      app/assets/stylesheets/theme/default.css
  12. 5
      app/controllers/application_controller.rb
  13. 4
      app/controllers/domains_controller.rb
  14. 43
      app/controllers/mxes_controller.rb
  15. 10
      app/controllers/ns_controller.rb
  16. 29
      app/controllers/records_controller.rb
  17. 9
      app/controllers/soas_controller.rb
  18. 5
      app/helpers/application_helper.rb
  19. 2
      app/helpers/mxes_helper.rb
  20. 14
      app/models/domain.rb
  21. 13
      app/models/mx.rb
  22. 2
      app/models/ns.rb
  23. 3
      app/models/record.rb
  24. 2
      app/models/soa.rb
  25. 2
      app/views/fragments/_top.html.erb
  26. 2
      app/views/layouts/application.html.erb
  27. 2
      app/views/layouts/errors.html.erb
  28. 2
      app/views/layouts/marketing.html.erb
  29. 13
      app/views/records/_list_record_columns.html.erb
  30. 4
      config/routes.rb
  31. 3
      config/settings.yml
  32. 157
      spec/controllers/mxes_controller_spec.rb
  33. 15
      spec/helpers/mxes_helper_spec.rb
  34. 11
      spec/requests/mxes_spec.rb
  35. 35
      spec/routing/mxes_routing_spec.rb
  36. 15
      spec/views/mxes/edit.html.erb_spec.rb
  37. 14
      spec/views/mxes/index.html.erb_spec.rb
  38. 15
      spec/views/mxes/new.html.erb_spec.rb
  39. 11
      spec/views/mxes/show.html.erb_spec.rb

BIN
app/assets/images/arrow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

BIN
app/assets/images/bgd.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
app/assets/images/boxbar-background.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
app/assets/images/button-background-active.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
app/assets/images/button-background.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

BIN
app/assets/images/messages/error.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

BIN
app/assets/images/messages/notice.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 604 B

BIN
app/assets/images/messages/warning.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 B

2
app/assets/stylesheets/application.css

@ -4,7 +4,7 @@
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require normalize
*= require theme/base
*= require web-app-theme/themes/default/style.css
*= require theme/default
*= require marketing
*= require active_scaffold
*= require overrides

1
app/assets/stylesheets/marketing.css.scss

@ -19,6 +19,7 @@
padding: 0 30px 30px;
h2 {
font-size: 25px;
margin-top: 0;
}
p {
font-size: 18px;

438
app/assets/stylesheets/theme/default.css

@ -0,0 +1,438 @@
body {
color: #111111;
background: #c4c4c4 url("images/bgd.jpg");
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
h1, h2, h3 {
color: #111111;
font-weight: normal;
font-family: Cambria, Georgia, serif;
}
a:link, a:visited, a:hover, a:active {
color: #111111;
}
a {
-moz-outline: none;
}
hr {
background: #dddddd;
color: #dddddd;
}
#header {
height: 80px;
background-color: #333333;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.25), 0 1px 1px rgba(255, 255, 255, 0.3);
-moz-box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.25), 0 1px 1px rgba(255, 255, 255, 0.3);
-webkit-box-shadow: inset 0 -5px 10px rgba(0, 0, 0, 0.25), 0 1px 1px rgba(255, 255, 255, 0.3);
}
#header h1 {
padding: 15px 5px;
float: left;
font-size: 40px;
font-style: normal;
text-transform: normal;
letter-spacing: -1px;
line-height: 1.2em;
color: white;
}
#header h1 a:link, #header h1 a:active, #header h1 a:hover, #header h1 a:visited {
color: white;
}
#main {
width: 77%;
float: left;
}
#main .block {
padding-top: 0px;
background-color: white;
text-shadow: 0 1px 0 white;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.3);
}
#main .block .content {
padding-top: 1px;
}
#main .block .content .inner {
padding: 0 15px 15px;
}
#main .block .content h2 {
margin-left: 15px;
font-size: 22px;
text-transform: normal;
letter-spacing: -1px;
line-height: 1.2em;
}
#main .block .content p {
font-size: 13px;
font-style: normal;
font-weight: normal;
text-transform: normal;
letter-spacing: normal;
line-height: 1.45em;
}
#main-navigation {
padding-top: 30px;
width: auto;
}
#main-navigation ul li {
padding-left: 20px;
margin-right: 0;
}
#main-navigation ul li a:link, #main-navigation ul li a:visited, #main-navigation ul li a:hover, #main-navigation ul li a:active {
padding: 8px 0;
text-decoration: none;
color: #eeeeee;
}
#main-navigation ul li.active a:link, #main-navigation ul li.active a:visited, #main-navigation ul li.active a:hover, #main-navigation ul li.active a:active {
color: #a4a4a4;
}
.secondary-navigation {
background: #e0e0e0 url("images/boxbar-background.png") top;
border-bottom-width: 0px;
-moz-border-radius-topleft: 6px;
-webkit-border-top-left-radius: 6px;
border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-webkit-border-top-right-radius: 6px;
border-top-right-radius: 6px;
}
.secondary-navigation li.first a, .secondary-navigation ul li.first {
-moz-border-radius-topleft: 6px;
-webkit-border-top-left-radius: 6px;
border-top-left-radius: 6px;
}
.secondary-navigation ul li a:link, .secondary-navigation ul li a:visited, .secondary-navigation ul li a:hover, .secondary-navigation ul li a:active {
text-decoration: none;
color: #111111;
}
.secondary-navigation ul li.text {
padding: 10px 15px;
color: #818171;
}
.secondary-navigation ul li.active {
background-color: white;
}
.secondary-navigation ul li.active a:hover {
background-color: white;
}
#user-navigation {
top: 33px;
right: 10px;
color: #eeeeee;
font-size: 14px;
}
#user-navigation ul li a:link, #user-navigation ul li a:visited, #user-navigation ul li a:hover, #user-navigation ul li a:active {
text-decoration: none;
color: #eeeeee;
}
#user-navigation ul li a:active img {
margin-top: 1px;
}
#user-navigation ul li, .secondary-navigation ul li {
float: left;
}
#footer {
color: #261f1f;
text-shadow: none;
}
#footer .block {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
background: none;
}
#footer p {
margin: 0;
padding: 0;
text-align: center;
}
#sidebar {
width: 20%;
float: right;
}
#sidebar .block {
padding-top: 2px;
padding-bottom: 2px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}
#sidebar .block h4 {
font-weight: normal;
font-family: helvetica, arial, sans-serif;
}
#sidebar .notice {
color: white;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
background-color: rgba(0, 0, 0, 0.3);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(rgba(0, 0, 0, 0.15)), to(rgba(0, 0, 0, 0)));
background-image: -moz-linear-gradient(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0));
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 1px rgba(255, 255, 255, 0.3);
-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 1px rgba(255, 255, 255, 0.3);
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 1px rgba(255, 255, 255, 0.3);
}
#sidebar .warning {
padding-left: 10px;
padding-right: 10px;
color: #222222;
background: #ffef4e;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.1);
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.1);
border: 1px solid rgba(0, 0, 0, 0.3);
}
#sidebar h3 {
padding-left: 25px;
color: #111111;
border-bottom: 1px solid #261f1f;
}
#sidebar ul li {
background-position: 0 11px;
background-repeat: no-repeat;
background-image: url("images/arrow.png");
border-bottom: 1px dashed #777777;
list-style-type: none;
}
#sidebar ul li a {
margin-left: 10px;
text-decoration: none;
text-shadow: 0 1px 0 white;
}
#sidebar ul li.active a {
color: #a4a4a4;
}
.control {
float: right;
margin-right: 9px;
margin-top: 11px;
}
.pagination a, .pagination span {
border: 1px solid #c3c4ba;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
margin-right: 5px;
padding: 6px;
min-width: 15px;
text-align: center;
background: #dddddd;
background-image: url("images/button-background.png");
color: #111111;
}
.pagination a:hover {
border: 1px solid #818171;
-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}
.pagination span.current {
background: #261f1f;
color: white;
border: 1px solid #261f1f;
}
.pagination a:active {
background-image: url("images/button-background-active.png");
outline: none;
}
.table th {
background: #eaeaea;
color: #222222;
font-weight: normal;
}
.table th.last {
min-width: 90px;
}
.table td {
border-bottom: 1px solid #eaeaea;
}
.table td.last {
padding-top: 0px;
padding-bottom: 0px;
}
.table tr.even {
background: #f8f8f8;
}
.form label.label {
font-family: helvetica, arial, sans-serif;
font-weight: normal;
color: #666666;
}
.form input.text_field, .form textarea.text_area {
width: 100%;
border: 1px solid #dddddd;
-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}
.form input.button {
background: #dddddd;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
border: 1px solid #c1c1c1;
padding: 2px 5px;
cursor: pointer;
color: #111111;
font-weight: bold;
font-size: 11px;
}
.form input.button:hover {
border: 1px solid #666666;
}
.form .description {
font-style: italic;
color: #8c8c8c;
font-size: 0.9em;
}
.form .navform a {
color: #cc0000;
}
.flash .message {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
text-align: center;
margin: 0 auto 15px;
color: white;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.flash .message p {
margin: 8px;
}
.flash .error, .flash .error-list {
border: 1px solid #993624;
background: #cc4831 url("images/messages/error.png") no-repeat 10px center;
}
.flash .warning {
border: 1px solid #bb9004;
background: #f9c006 url("images/messages/warning.png") no-repeat 10px center;
}
.flash .notice {
color: #28485e;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
border: 1px solid #8a9daa;
background: #b8d1e2 url("images/messages/notice.png") no-repeat 10px center;
}
.flash .error-list {
text-align: left;
}
.flash .error-list h2 {
font-size: 16px;
text-align: center;
}
.flash .error-list ul {
padding-left: 22px;
line-height: 18px;
list-style-type: square;
margin-bottom: 15px;
}
ul.list li {
border-bottom-color: #dddddd;
border-bottom-width: 1px;
border-bottom-style: solid;
}
ul.list li .item .avatar {
border-color: #dddddd;
border-width: 1px;
border-style: solid;
padding: 2px;
}
#box {
width: 480px;
}
#box .block {
background: white;
text-shadow: 0 1px 0 white;
box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.3);
-webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.3);
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
}
#box .block h2 {
background: #261f1f;
color: white;
text-shadow: none;
-moz-border-radius-topleft: 6px;
-webkit-border-top-left-radius: 6px;
border-top-left-radius: 6px;
-moz-border-radius-topright: 6px;
-webkit-border-top-right-radius: 6px;
border-top-right-radius: 6px;
}
a.button, button.button {
background: #edeeed url("images/button-background.png") top;
border: 1px solid #c3c4ba;
font-family: helvetica, arial, sans-serif;
font-weight: normal;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}
a.button:link, a.button:visited, a.button:hover, a.button:active, button.button:link, button.button:visited, button.button:hover, button.button:active {
font-weight: normal;
background: #edeeed url("images/button-background.png") top;
}
a.button:active, button.button:active {
background: #eaeaea url("images/button-background-active.png") top;
outline: none;
margin-top: 1px;
margin-bottom: -1px;
}
.form div.left {
width: 10%;
float: left;
}
.form div.right {
width: 85%;
float: right;
}
.login div.left, .signup div div.left {
width: 21%;
float: left;
}
.login div.right, .signup div div.right {
width: 74%;
float: right;
}

5
app/controllers/application_controller.rb

@ -13,4 +13,9 @@ class ApplicationController < ActionController::Base
render :template => 'errors/access_denied', :layout => 'errors'
end
protected
def ensure_nested_under_domain
raise CanCan::AccessDenied, "not found" unless nested? and nested_parent_record.is_a?(Domain)
end
end

4
app/controllers/domains_controller.rb

@ -5,8 +5,11 @@ class DomainsController < ApplicationController
conf.list.columns = [:name, :soa_record, :ns_records, :records]
conf.create.columns = [:name, :soa_record, :ns_records]
conf.update.columns = [:name, :soa_record, :ns_records]
conf.columns[:name].description = 'yourdomain.com'
conf.columns[:ns_records].show_blank_record = false
conf.actions.exclude :show
conf.list.sorting = { :name => :asc }
conf.create.link.label = "Add Domain"
conf.columns[:records].label = 'All Records'
end
@ -25,6 +28,7 @@ class DomainsController < ApplicationController
def after_create_save(record)
session[:sample_ns] = nil
@record.reload
end
def sample_ns

43
app/controllers/mxes_controller.rb

@ -0,0 +1,43 @@
class MxesController < ApplicationController
active_scaffold :mx do |conf|
conf.list.columns = [:name, :type, :content, :ttl, :prio, :change_date]
conf.create.columns = [:name, :content, :ttl, :prio]
conf.update.columns = [:name, :content, :ttl, :prio]
conf.columns[:content].label = 'MX'
conf.columns[:name].description = 'Ex: mail or mx etc'
conf.columns[:change_date].list_ui = :timestamp
conf.actions.exclude :show
end
before_filter :ensure_nested_under_domain
protected
def do_new
super
@record.prio ||= begin
maximum = nested_parent_record.mx_records.maximum(:prio)
maximum.nil? ? Settings.default_prio : maximum + 10
end
end
# override to use :mx_records instead of :records assoc
def beginning_of_chain
if nested? && nested.association && nested.association.collection? && nested.association.name == :records
nested.parent_scope.mx_records
else
super
end
end
# override, we make our own sti logic
def new_model
model = beginning_of_chain
model.new
end
# override to close create form after success
def render_parent?
nested_singular_association? # || params[:parent_sti]
end
end

10
app/controllers/ns_controller.rb

@ -1,15 +1,11 @@
class NsController < ApplicationController
active_scaffold :ns do |conf|
conf.columns = [:name, :content, :ttl]
conf.list.columns = [:name, :type, :content, :ttl, :prio, :change_date]
conf.create.columns = [:content, :ttl]
conf.update.columns = [:content, :ttl]
conf.columns[:content].label = 'NS'
conf.columns[:change_date].list_ui = :timestamp
conf.actions.exclude :show
end
protected
def beginning_of_chain
super.readonly(false)
end
before_filter :ensure_nested_under_domain
end

29
app/controllers/records_controller.rb

@ -1,18 +1,25 @@
class RecordsController < ApplicationController
# override so SOA's cannot be created by themselves
def self._add_sti_create_links
new_action_link = active_scaffold_config.action_links.collection['new']
unless new_action_link.nil? || active_scaffold_config.sti_children.empty?
active_scaffold_config.action_links.collection.delete('new')
sti_children = active_scaffold_config.sti_children - [:SOA]
sti_children.each do |child|
new_sti_link = Marshal.load(Marshal.dump(new_action_link)) # deep clone
new_sti_link.label = child.to_s.camelize.constantize.model_name.human
new_sti_link.parameters = {:parent_sti => controller_path}
new_sti_link.controller = Proc.new { active_scaffold_controller_for(child.to_s.camelize.constantize).controller_path }
active_scaffold_config.action_links.collection.create.add(new_sti_link)
end
end
end
active_scaffold :record do |conf|
conf.sti_children = [:SOA, :NS]
conf.sti_children = [:SOA, :NS, :MX]
conf.columns = [:name, :type, :content, :ttl, :prio, :change_date]
conf.columns[:change_date].list_ui = :timestamp
conf.actions.exclude :show
end
before_filter :ensure_nested_under_domain
protected
def beginning_of_chain
super.readonly(false)
end
def ensure_nested_under_domain
raise CanCan::AccessDenied, "not found" unless nested? and nested_parent_record.is_a?(Domain)
end
end

9
app/controllers/soas_controller.rb

@ -1,14 +1,9 @@
class SoasController < ApplicationController
active_scaffold :soa do |conf|
conf.columns = [:name, :primary_ns, :contact, :ttl]
conf.list.columns = [:name, :type, :content, :ttl, :prio, :change_date]
conf.create.columns = [:contact, :ttl]
conf.update.columns = [:contact, :ttl]
conf.columns[:change_date].list_ui = :timestamp
conf.actions.exclude :delete, :show
end
protected
def beginning_of_chain
super.readonly(false)
end
end

5
app/helpers/application_helper.rb

@ -14,4 +14,9 @@ module ApplicationHelper
end
end
def active_scaffold_column_timestamp(column, record)
value = record.send(column.name)
value.nil? ? nil : Time.at(value)
end
end

2
app/helpers/mxes_helper.rb

@ -0,0 +1,2 @@
module MxesHelper
end

14
app/models/domain.rb

@ -30,19 +30,13 @@ class Domain < ActiveRecord::Base
def setup(email, sample_ns)
build_soa_record
soa = soa_record
soa.contact ||= email
ns_records.build
ns_records.build
ns_records.build
ns1, ns2 = ns_records
soa = soa_record
ns1.content = sample_ns.first
ns1.ttl ||= Settings.default_ttl
ns2.content = sample_ns.second
ns2.ttl ||= Settings.default_ttl
soa.contact ||= email
soa.ttl ||= Settings.default_ttl
end
end

13
app/models/mx.rb

@ -7,9 +7,14 @@
# Obtained from http://www.zytrax.com/books/dns/ch8/mx.html
#
class MX < Record
validates :prio,
:numericality => {:greater_than_or_equal_to => 0, :less_than_or_equal_to => 65535, :only_integer => true}
validates :prio, :numericality => {
:greater_than_or_equal_to => 0,
:less_than_or_equal_to => 65535,
:only_integer => true
}
validates :content, :presence => true, :hostname => true
def supports_prio?; true end
def supports_priority?; true end
end
Mx = MX

2
app/models/ns.rb

@ -22,6 +22,8 @@
class NS < Record
validates :content, :presence => true, :hostname => true
def to_label; "#{content}" end
end
Ns = NS

3
app/models/record.rb

@ -16,6 +16,9 @@ class Record < ActiveRecord::Base
before_validation :prepare_name!
before_save :update_change_date
after_save :update_soa_serial
after_initialize do
self.ttl ||= Settings.default_ttl
end
# By default records don't support priorities.
# Those who do can overwrite this in their own classes.

2
app/models/soa.rb

@ -58,7 +58,7 @@ class SOA < Record
save
end
def to_label; "#{type} #{primary_ns} #{contact}" end
def to_label; "#{primary_ns} #{contact}" end
private

2
app/views/fragments/_top.html.erb

@ -1,6 +1,6 @@
<div id="header">
<div class="header-inner">
<h1><a href="/">Simple DNS</a></h1>
<h1><a href="/">Entry DNS</a></h1>
<div id="main-navigation">
<ul class="wat-cf">
<% if user_signed_in? %>

2
app/views/layouts/application.html.erb

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Simple DNS</title>
<title>Entry DNS</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tag %>

2
app/views/layouts/errors.html.erb

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Simple DNS</title>
<title>Entry DNS</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tag %>

2
app/views/layouts/marketing.html.erb

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Simple DNS</title>
<title>Entry DNS</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tag %>

13
app/views/records/_list_record_columns.html.erb

@ -1,13 +0,0 @@
<% columns.each do |column| %>
<% authorized = record.authorized_for?(:crud_type => :read, :column => column.name) -%>
<% column_value = authorized ? get_column_value(record, column) : active_scaffold_config.list.empty_field_text -%>
<td class="<%= column_class(column, column_value, record) %>" >
<% if column.name == :change_date %>
<% column_value = Time.at(record.change_date) unless record.change_date.nil? # TODO: localize ? %>
<%= authorized ? render_list_column(column_value, column, record) : column_value %>
<% else %>
<%= authorized ? render_list_column(column_value, column, record) : column_value %>
<% end %>
</td>
<% end -%>

4
config/routes.rb

@ -17,6 +17,10 @@ Simpledns::Application.routes.draw do
resources :ns do
as_routes
end
resources :mxes do
as_routes
end
get '/dashboard', :to => 'dashboard#index', :as => :dashboard
root :to => 'home#index'

3
config/settings.yml

@ -5,4 +5,5 @@ ns:
- ns1.ourdomain.com
- ns2.ourdomain.com
- ns3.ourdomain.com
- ns4.ourdomain.com
- ns4.ourdomain.com
default_prio: 10

157
spec/controllers/mxes_controller_spec.rb

@ -0,0 +1,157 @@
require 'spec_helper'
# This spec was generated by rspec-rails when you ran the scaffold generator.
# It demonstrates how one might use RSpec to specify the controller code that
# was generated by Rails when you ran the scaffold generator.
#
# It assumes that the implementation code is generated by the rails scaffold
# generator. If you are using any extension libraries to generate different
# controller code, this generated spec may or may not pass.
#
# It only uses APIs available in rails and/or rspec-rails. There are a number
# of tools you can use to make these specs even more expressive, but we're
# sticking to rails and rspec-rails APIs to keep things simple and stable.
#
# Compared to earlier versions of this generator, there is very limited use of
# stubs and message expectations in this spec. Stubs are only used when there
# is no simpler way to get a handle on the object needed for the example.
# Message expectations are only used when there is no simpler way to specify
# that an instance is receiving a specific message.
describe MxesController do
# This should return the minimal set of attributes required to create a valid
# Mx. As you add validations to Mx, be sure to
# update the return value of this method accordingly.
def valid_attributes
{}
end
describe "GET index" do
it "assigns all mxes as @mxes" do
mx = Mx.create! valid_attributes
get :index
assigns(:mxes).should eq([mx])
end
end
describe "GET show" do
it "assigns the requested mx as @mx" do
mx = Mx.create! valid_attributes
get :show, :id => mx.id.to_s
assigns(:mx).should eq(mx)
end
end
describe "GET new" do
it "assigns a new mx as @mx" do
get :new
assigns(:mx).should be_a_new(Mx)
end
end
describe "GET edit" do
it "assigns the requested mx as @mx" do
mx = Mx.create! valid_attributes
get :edit, :id => mx.id.to_s
assigns(:mx).should eq(mx)
end
end
describe "POST create" do
describe "with valid params" do
it "creates a new Mx" do
expect {
post :create, :mx => valid_attributes
}.to change(Mx, :count).by(1)
end
it "assigns a newly created mx as @mx" do
post :create, :mx => valid_attributes
assigns(:mx).should be_a(Mx)
assigns(:mx).should be_persisted
end
it "redirects to the created mx" do
post :create, :mx => valid_attributes
response.should redirect_to(Mx.last)
end
end
describe "with invalid params" do
it "assigns a newly created but unsaved mx as @mx" do
# Trigger the behavior that occurs when invalid params are submitted
Mx.any_instance.stub(:save).and_return(false)
post :create, :mx => {}
assigns(:mx).should be_a_new(Mx)
end
it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
Mx.any_instance.stub(:save).and_return(false)
post :create, :mx => {}
response.should render_template("new")
end
end
end
describe "PUT update" do
describe "with valid params" do
it "updates the requested mx" do
mx = Mx.create! valid_attributes
# Assuming there are no other mxes in the database, this
# specifies that the Mx created on the previous line
# receives the :update_attributes message with whatever params are
# submitted in the request.
Mx.any_instance.should_receive(:update_attributes).with({'these' => 'params'})
put :update, :id => mx.id, :mx => {'these' => 'params'}
end
it "assigns the requested mx as @mx" do
mx = Mx.create! valid_attributes
put :update, :id => mx.id, :mx => valid_attributes
assigns(:mx).should eq(mx)
end
it "redirects to the mx" do
mx = Mx.create! valid_attributes
put :update, :id => mx.id, :mx => valid_attributes
response.should redirect_to(mx)
end
end
describe "with invalid params" do
it "assigns the mx as @mx" do
mx = Mx.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Mx.any_instance.stub(:save).and_return(false)
put :update, :id => mx.id.to_s, :mx => {}
assigns(:mx).should eq(mx)
end
it "re-renders the 'edit' template" do
mx = Mx.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Mx.any_instance.stub(:save).and_return(false)
put :update, :id => mx.id.to_s, :mx => {}
response.should render_template("edit")
end
end
end
describe "DELETE destroy" do
it "destroys the requested mx" do
mx = Mx.create! valid_attributes
expect {
delete :destroy, :id => mx.id.to_s
}.to change(Mx, :count).by(-1)
end
it "redirects to the mxes list" do
mx = Mx.create! valid_attributes
delete :destroy, :id => mx.id.to_s
response.should redirect_to(mxes_url)
end
end
end

15
spec/helpers/mxes_helper_spec.rb

@ -0,0 +1,15 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the MxesHelper. For example:
#
# describe MxesHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe MxesHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

11
spec/requests/mxes_spec.rb

@ -0,0 +1,11 @@
require 'spec_helper'
describe "Mxes" do
describe "GET /mxes" do
it "works! (now write some real specs)" do
# Run the generator again with the --webrat flag if you want to use webrat methods/matchers
get mxes_path
response.status.should be(200)
end
end
end

35
spec/routing/mxes_routing_spec.rb

@ -0,0 +1,35 @@
require "spec_helper"
describe MxesController do
describe "routing" do
it "routes to #index" do
get("/mxes").should route_to("mxes#index")
end
it "routes to #new" do
get("/mxes/new").should route_to("mxes#new")
end
it "routes to #show" do
get("/mxes/1").should route_to("mxes#show", :id => "1")
end
it "routes to #edit" do
get("/mxes/1/edit").should route_to("mxes#edit", :id => "1")
end
it "routes to #create" do
post("/mxes").should route_to("mxes#create")
end
it "routes to #update" do
put("/mxes/1").should route_to("mxes#update", :id => "1")
end
it "routes to #destroy" do
delete("/mxes/1").should route_to("mxes#destroy", :id => "1")
end
end
end

15
spec/views/mxes/edit.html.erb_spec.rb

@ -0,0 +1,15 @@
require 'spec_helper'
describe "mxes/edit.html.erb" do
before(:each) do
@mx = assign(:mx, stub_model(Mx))
end
it "renders the edit mx form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", :action => mxes_path(@mx), :method => "post" do
end
end
end

14
spec/views/mxes/index.html.erb_spec.rb

@ -0,0 +1,14 @@
require 'spec_helper'
describe "mxes/index.html.erb" do
before(:each) do
assign(:mxes, [
stub_model(Mx),
stub_model(Mx)
])
end
it "renders a list of mxes" do
render
end
end

15
spec/views/mxes/new.html.erb_spec.rb

@ -0,0 +1,15 @@
require 'spec_helper'
describe "mxes/new.html.erb" do
before(:each) do
assign(:mx, stub_model(Mx).as_new_record)
end
it "renders new mx form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
assert_select "form", :action => mxes_path, :method => "post" do
end
end
end

11
spec/views/mxes/show.html.erb_spec.rb

@ -0,0 +1,11 @@
require 'spec_helper'
describe "mxes/show.html.erb" do
before(:each) do
@mx = assign(:mx, stub_model(Mx))
end
it "renders attributes in <p>" do
render
end
end
Loading…
Cancel
Save