Browse Source

update deps, fix domain creation, refactor, update AS, simple routes

pull/1/head
Nicolae Claudius 11 years ago
parent
commit
a03f929139
  1. 3
      .rdebugrc
  2. 23
      Gemfile
  3. 87
      Gemfile.lock
  4. 4
      app/models/soa.rb
  5. 21
      app/views/users/domains/_form_association_footer.html.erb
  6. 64
      config/routes.rb
  7. 25
      spec/controllers/users/domains_controller_spec.rb
  8. 2
      spec/models/domain_spec.rb

3
.rdebugrc

@ -0,0 +1,3 @@
et autolist
set autoeval
set autoreload

23
Gemfile

@ -12,34 +12,38 @@ gem 'nilify_blanks', '~> 1.0.2'
gem 'rails_config', '~> 0.3.3'
gem 'rails-settings-cached', '~> 0.3.1'
gem 'active-model-email-validator', '~> 1.0.2'
gem 'mail_form', '~> 1.5.0.rc', github: 'plataformatec/mail_form'
gem 'mail_form', '~> 1.5.0'
gem 'switch_user', '~> 0.9.3'
gem 'simple_form', '~> 3.0.0.rc', github: 'plataformatec/simple_form'
gem 'simple_form', '~> 3.0.0'
gem 'concerned_with', '~> 0.1.0'
gem 'navigasmic', '~> 0.5.6', github: 'jejacks0n/navigasmic',
tag: 'v0.5.6', ref: '1ffe437f279657c6fb87bb4b0215eb723df4ea7a'
gem 'acts_as_nested_interval', '~> 0.1.0'
gem 'seedbank', '~> 0.3.0.pre2', github: 'james2m/seedbank'
gem 'seedbank', '~> 0.3.0'
gem 'unicorn', '~> 4.6.3'
gem 'sass-rails', '~> 4.0.0'
gem 'compass-rails', '~> 2.0.alpha.0'
gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass', branch: '3'
gem 'bootstrap-sass', '~> 3.0.2.1'
gem 'webshims-rails', '~> 1.11.1'
gem 'detect_timezone_rails', '~> 0.0.3'
gem 'nprogress-rails', '~> 0.1.2.2'
gem 'animate-rails', '~> 1.0.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'uglifier', '~> 2.2.1'
gem 'uglifier', '~> 2.3.1'
gem 'oily_png', '~> 1.1.0'
gem 'therubyracer', '~> 0.12.0'
gem 'jquery-rails', '~> 3.0.4'
gem 'jquery-ui-rails', '~> 4.0.4'
gem 'jquery-ui-rails', '~> 4.1.0'
gem 'dalli', '~> 2.6.2'
gem 'json', '~> 1.8.0'
gem 'active_scaffold', '~> 3.4.0.rc', github: 'activescaffold/active_scaffold'
gem 'active_scaffold', '~> 3.4.0.rc',
github: 'clyfe/active_scaffold',
branch: 'fix-always-use-build_associated'
# path: '/home/clyfe/dev/active_scaffold'
# github: 'activescaffold/active_scaffold'
gem 'turbolinks', '~> 1.3.0'
gem 'faker','~> 1.2.0'
gem 'factory_girl_rails', '~> 4.2.1'
gem 'factory_girl_rails', '~> 4.3.0'
# gem 'rails_admin', '~> 0.5.0'
# gem 'jquery-cookie-rails', '~> 1.3.1'
# gem 'foreigner', '~> 1.4.2
@ -49,7 +53,8 @@ group :development do
gem 'better_errors', '1.0.1'
gem 'binding_of_caller', '0.7.2'
gem 'debase', '~> 0.0.7'
gem 'ruby-debug-ide', '~> 0.4.18'
# gem 'byebug', '~> 2.3.1'
# gem 'ruby-debug-ide', '~> 0.4.18'
# gem 'mongrel', '>= 1.2.0.pre2'
# gem 'capistrano', '~> 2.15.5'
# gem 'capistrano-ext', '~> 1.2.1'

87
Gemfile.lock

@ -5,18 +5,13 @@ GIT
validates_hostname (1.0.0)
GIT
remote: git://github.com/activescaffold/active_scaffold.git
revision: 37429d94300c07d5c2b27a0d41d01572c2313236
remote: git://github.com/clyfe/active_scaffold.git
revision: 5eaedd36fe4ed404049ca02b39a48acb84fbed4f
branch: fix-always-use-build_associated
specs:
active_scaffold (3.4.0.rc)
rails (>= 3.2.6, < 5)
GIT
remote: git://github.com/james2m/seedbank.git
revision: c7a272751336f0d17103028f45b88eac62cbedd7
specs:
seedbank (0.3.0.pre2)
GIT
remote: git://github.com/jejacks0n/navigasmic.git
revision: 1ffe437f279657c6fb87bb4b0215eb723df4ea7a
@ -31,30 +26,6 @@ GIT
specs:
userstamp (2.0.2)
GIT
remote: git://github.com/plataformatec/mail_form.git
revision: 3b15e8c4fb4607556879419db8956965805a0a76
specs:
mail_form (1.5.0)
actionmailer (>= 3.2, < 5)
activemodel (>= 3.2, < 5)
GIT
remote: git://github.com/plataformatec/simple_form.git
revision: 146cff7ec6bdaba00201b73704f3417a7b978e31
specs:
simple_form (3.0.0)
actionpack (>= 4.0.0, < 4.1)
activemodel (>= 4.0.0, < 4.1)
GIT
remote: git://github.com/thomas-mcdonald/bootstrap-sass.git
revision: 9c6c07f74ff515cf38380b014cfede14a4f0eae4
branch: 3
specs:
bootstrap-sass (3.0.0.0)
sass (~> 3.2)
GEM
remote: http://rubygems.org/
specs:
@ -97,6 +68,8 @@ GEM
erubis (>= 2.6.6)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bootstrap-sass (3.0.2.1)
sass (~> 3.2)
builder (3.1.4)
cancan (1.6.7)
capybara (2.1.0)
@ -129,18 +102,18 @@ GEM
debugger-ruby_core_source (1.2.3)
detect_timezone_rails (0.0.5)
railties (>= 3.1)
devise (3.0.3)
devise (3.0.4)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
warden (~> 1.2.3)
diff-lcs (1.2.4)
diff-lcs (1.2.5)
erubis (2.7.0)
execjs (2.0.2)
factory_girl (4.2.0)
factory_girl (4.3.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.2.1)
factory_girl (~> 4.2.0)
factory_girl_rails (4.3.0)
factory_girl (~> 4.3.0)
railties (>= 3.0.0)
faker (1.2.0)
i18n (~> 0.5)
@ -150,7 +123,7 @@ GEM
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (4.0.5)
jquery-ui-rails (4.1.0)
railties (>= 3.1.0)
json (1.8.1)
kgio (2.8.1)
@ -158,11 +131,14 @@ GEM
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mail_form (1.5.0)
actionmailer (>= 3.2, < 5)
activemodel (>= 3.2, < 5)
mime-types (1.25)
mini_portile (0.5.2)
minitest (4.7.5)
multi_json (1.8.2)
mysql2 (0.3.13)
mysql2 (0.3.14)
nilify_blanks (1.0.2)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
@ -171,7 +147,7 @@ GEM
nprogress-rails (0.1.2.3)
oily_png (1.1.0)
chunky_png (~> 1.2.7)
orm_adapter (0.4.0)
orm_adapter (0.5.0)
polyamorous (0.6.4)
activerecord (>= 3.0)
polyglot (0.3.3)
@ -201,7 +177,7 @@ GEM
rake (10.1.0)
ref (1.0.5)
rspec-core (2.14.7)
rspec-expectations (2.14.3)
rspec-expectations (2.14.4)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.4)
rspec-rails (2.14.0)
@ -211,15 +187,17 @@ GEM
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
ruby-debug-ide (0.4.18)
rake (>= 0.8.1)
sass (3.2.12)
sass-rails (4.0.1)
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
seedbank (0.3.0)
sentient_model (1.0.4)
bundler (>= 1.0)
simple_form (3.0.0)
actionpack (>= 4.0.0, < 4.1)
activemodel (>= 4.0.0, < 4.1)
sprockets (2.10.0)
hike (~> 1.2)
multi_json (~> 1.0)
@ -244,19 +222,19 @@ GEM
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
turbolinks (1.3.0)
turbolinks (1.3.1)
coffee-rails
tzinfo (0.3.38)
uglifier (2.2.1)
uglifier (2.3.1)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
json (>= 1.8.0)
unicorn (4.6.3)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
warden (1.2.3)
rack (>= 1.0)
webshims-rails (1.11.2)
webshims-rails (1.11.3)
rails (> 3.1.0)
xpath (2.0.0)
nokogiri (~> 1.3)
@ -271,7 +249,7 @@ DEPENDENCIES
animate-rails (~> 1.0.0)
better_errors (= 1.0.1)
binding_of_caller (= 0.7.2)
bootstrap-sass!
bootstrap-sass (~> 3.0.2.1)
cancan (= 1.6.7)
capybara (~> 2.1.0)
coffee-rails (~> 4.0.0)
@ -282,12 +260,12 @@ DEPENDENCIES
debase (~> 0.0.7)
detect_timezone_rails (~> 0.0.3)
devise (~> 3.0.3)
factory_girl_rails (~> 4.2.1)
factory_girl_rails (~> 4.3.0)
faker (~> 1.2.0)
jquery-rails (~> 3.0.4)
jquery-ui-rails (~> 4.0.4)
jquery-ui-rails (~> 4.1.0)
json (~> 1.8.0)
mail_form (~> 1.5.0.rc)!
mail_form (~> 1.5.0)
mysql2 (~> 0.3.13)
navigasmic (~> 0.5.6)!
nilify_blanks (~> 1.0.2)
@ -298,16 +276,15 @@ DEPENDENCIES
rails-settings-cached (~> 0.3.1)
rails_config (~> 0.3.3)
rspec-rails (~> 2.14.0)
ruby-debug-ide (~> 0.4.18)
sass-rails (~> 4.0.0)
seedbank (~> 0.3.0.pre2)!
seedbank (~> 0.3.0)
sentient_model (~> 1.0.4)
simple_form (~> 3.0.0.rc)!
simple_form (~> 3.0.0)
squeel (~> 1.1.0)
switch_user (~> 0.9.3)
therubyracer (~> 0.12.0)
turbolinks (~> 1.3.0)
uglifier (~> 2.2.1)
uglifier (~> 2.3.1)
unicorn (~> 4.6.3)
userstamp (~> 2.0.2)!
validates_hostname (~> 1.0.0)!

4
app/models/soa.rb

@ -49,7 +49,7 @@ class SOA < Record
# If the serial number is 0, we opt for PowerDNS's automatic serial number
# generation, that gets triggered by updating the change_date
def update_serial
return if self.content_changed?
return if content_changed?
compute_serial
end
@ -61,7 +61,7 @@ class SOA < Record
# Same as #update_serial and saves the record
def update_serial!
update_serial
save
save!
end
# if SOA record's primary NS is among it's domain's NS records

21
app/views/users/domains/_form_association_footer.html.erb

@ -7,13 +7,15 @@ rescue ActiveScaffold::ControllerNotFound
end
@record = parent_record
show_add_existing = column_show_add_existing(column)
show_add_new = column_show_add_new(column, associated, @record)
show_add_existing = column_show_add_existing(column, parent_record)
show_add_new = column_show_add_new(column, associated, parent_record)
return unless show_add_new or show_add_existing
edit_associated_url = params_for(:action => 'edit_associated', :child_association => column.name, :associated_id => '--ID--') if show_add_existing
add_new_url = params_for(:action => 'edit_associated', :child_association => column.name) if show_add_new
temporary_id = generated_id(parent_record) if parent_record.new_record?
controller_path = active_scaffold_controller_for(parent_record.class).controller_path
edit_associated_url = params_for(:controller => controller_path, :action => 'edit_associated', :child_association => column.name, :associated_id => '--ID--', :scope => scope, :id => parent_record.to_param, :generated_id => temporary_id, :parent_controller => controller.controller_path) if show_add_existing
add_new_url = params_for(:controller => controller_path, :action => 'edit_associated', :child_association => column.name, :scope => scope, :id => parent_record.to_param, :generated_id => temporary_id, :parent_controller => controller.controller_path) if show_add_new
-%>
<div class="footer-wrapper">
@ -26,7 +28,7 @@ add_new_url = params_for(:action => 'edit_associated', :child_association => col
add_label = as_(:replace_with_new)
add_class = 'as_replace_with_new'
end
create_another_id = "#{sub_form_id(:association => column.name)}-create-another" %>
create_another_id = "#{sub_form_id(:association => column.name, :id => parent_record.id || temporary_id || 99999999999)}-create-another" %>
<%= link_to add_label, add_new_url, :id => create_another_id, :remote => true, :class => add_class, :style=> "display: none;" %>
<%= javascript_tag("ActiveScaffold.show('#{create_another_id}');") %>
<% end -%>
@ -35,12 +37,13 @@ add_new_url = params_for(:action => 'edit_associated', :child_association => col
<% if show_add_existing -%>
<% if remote_controller and remote_controller.respond_to? :uses_record_select? and remote_controller.uses_record_select? -%>
<%= link_to_record_select as_(:add_existing), remote_controller.controller_path, :onselect => "ActiveScaffold.record_select_onselect(#{edit_associated_url.to_json}, #{active_scaffold_id.to_json}, id);" -%>
<%= link_to_record_select as_(:add_existing), remote_controller.controller_path, :onselect => "ActiveScaffold.record_select_onselect(#{url_for(edit_associated_url).to_json}, #{active_scaffold_id.to_json}, id);" -%>
<% else -%>
<% select_options = options_for_select(options_for_association(column.association))
add_existing_id = "#{sub_form_id(:association => column.name)}-add-existing" %>
<% select_options = options_from_collection_for_select(sorted_association_options_find(column.association, nil, parent_record), :to_param, :to_label)
add_existing_id = "#{sub_form_id(:association => column.name, :id => parent_record.id || temporary_id || 99999999999)}-add-existing"
add_existing_label = column.plural_association? ? :add_existing : :replace_existing %>
<%= select_tag 'associated_id', '<option value="">'.html_safe + as_(:_select_) + '</option>'.html_safe + select_options %>
<%= link_to as_(:add_existing), edit_associated_url, :id => add_existing_id, :remote => true, :class=> column.plural_association? ? 'as_add_existing' : 'as_replace_existing', :style => "display: none;" %>
<%= link_to as_(add_existing_label), edit_associated_url, :id => add_existing_id, :remote => true, :class=> "as_#{add_existing_label}", :style => "display: none;" %>
<%= javascript_tag("ActiveScaffold.show('#{add_existing_id}');") %>
<% end -%>
<% end -%>

64
config/routes.rb

@ -1,6 +1,6 @@
Entrydns::Application.routes.draw do
# mount RailsAdmin::Engine => '/rails_admin', :as => 'rails_admin'
# mount RailsAdmin::Engine => '/rails_admin', as: 'rails_admin'
devise_for :admins
@ -70,67 +70,11 @@ Entrydns::Application.routes.draw do
scope module: 'public' do
resources :pages, only: :show
post 'pages/contact', to: 'pages#contact'
resources :pages, only: :show, path: ''
post 'contact', to: 'pages#contact'
root :to => 'pages#show', id: 'home'
root to: 'pages#show', id: 'home'
end
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Sample resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Sample resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Sample resource route with more complex sub-resources
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# end
# end
# Sample resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => 'welcome#index'
# See how all your routes lay out with "rake routes"
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'
end

25
spec/controllers/users/domains_controller_spec.rb

@ -1,15 +1,32 @@
require 'spec_helper'
describe Users::DomainsController do
include_context "data"
before do
sign_in user
end
context "crud" do
it "creates a new domain" do
params = { "utf8" => "", "commit" => "Create",
"record" => { "name" => "domain.com", "ip" => "",
"soa_record" => { "contact" => "user@entrydns.net", ttl: "3600" },
"ns_records" => { "0" => "",
"1384548529585" => { "content" => "ns1.entrydns.net", "ttl" => "3600" },
"1384548529591" => { "content" => "ns2.entrydns.net", "ttl" => "3600" },
"1384548529660" => { "content" => "ns3.entrydns.net", "ttl" => "3600" }
}}}
->() { post :create, params }.should change(Domain, :count).by(1)
end
end
context "wiring" do
include_context "data"
# a domain who's parent domain is not in our system
context "domain" do
before do
sign_in user
end
it "is wired with the current user by #new_model" do
@controller.send(:new_model).user.should == user

2
spec/models/domain_spec.rb

@ -19,7 +19,7 @@ describe Domain do
end
it "has a soa serial updated" do
(domain.soa_record.serial % 10).should == 1
(domain.soa_record.serial % 100).should_not == 0
end
it "updates name to records when name changed" do

Loading…
Cancel
Save