diff --git a/app/controllers/aaaas_controller.rb b/app/controllers/aaaas_controller.rb index bfba450..935a385 100644 --- a/app/controllers/aaaas_controller.rb +++ b/app/controllers/aaaas_controller.rb @@ -20,9 +20,14 @@ class AaaasController < ApplicationController # override, we make our own sti logic def new_model - model = beginning_of_chain.new - model.name = nested_parent_record.name - model + record = beginning_of_chain.new + record.name = nested_parent_record.name + before_create_save(record) + record + end + + def before_create_save(record) + record.user = current_user end # override to close create form after success diff --git a/app/controllers/as_controller.rb b/app/controllers/as_controller.rb index f925b45..cb0f628 100644 --- a/app/controllers/as_controller.rb +++ b/app/controllers/as_controller.rb @@ -20,10 +20,15 @@ class AsController < ApplicationController # override, we make our own sti logic def new_model - model = beginning_of_chain.new - model.name = nested_parent_record.name - model.content = client_remote_ip if client_remote_ip.present? - model + record = beginning_of_chain.new + record.name = nested_parent_record.name + record.content = client_remote_ip if client_remote_ip.present? + before_create_save(record) + record + end + + def before_create_save(record) + record.user = current_user end # override to close create form after success diff --git a/app/controllers/cnames_controller.rb b/app/controllers/cnames_controller.rb index b4605b0..e08ae4d 100644 --- a/app/controllers/cnames_controller.rb +++ b/app/controllers/cnames_controller.rb @@ -21,8 +21,13 @@ class CnamesController < ApplicationController # override, we make our own sti logic def new_model - model = beginning_of_chain.new - model + record = beginning_of_chain.new + before_create_save(record) + record + end + + def before_create_save(record) + record.user = current_user end # override to close create form after success diff --git a/app/controllers/domains_controller.rb b/app/controllers/domains_controller.rb index 161b3a8..2ce8b07 100644 --- a/app/controllers/domains_controller.rb +++ b/app/controllers/domains_controller.rb @@ -25,12 +25,13 @@ class DomainsController < ApplicationController def new_model record = super - record.user_id = current_user.id + before_create_save(record) record end def before_create_save(record) record.type = 'NATIVE' + record.user = current_user end def after_create_save(record) diff --git a/app/controllers/mxes_controller.rb b/app/controllers/mxes_controller.rb index b183ffe..ba12865 100644 --- a/app/controllers/mxes_controller.rb +++ b/app/controllers/mxes_controller.rb @@ -28,9 +28,14 @@ class MxesController < ApplicationController # override, we make our own sti logic def new_model - model = beginning_of_chain.new - model.name = nested_parent_record.name - model + record = beginning_of_chain.new + record.name = nested_parent_record.name + before_create_save(record) + record + end + + def before_create_save(record) + record.user = current_user end # override to close create form after success diff --git a/app/controllers/ns_controller.rb b/app/controllers/ns_controller.rb index 2fe58c5..68f70ae 100644 --- a/app/controllers/ns_controller.rb +++ b/app/controllers/ns_controller.rb @@ -20,10 +20,15 @@ class NsController < ApplicationController # override, we make our own sti logic def new_model - model = beginning_of_chain.new - model.name = nested_parent_record.name - model.content = Settings.ns.sample - model + record = beginning_of_chain.new + record.name = nested_parent_record.name + record.content = Settings.ns.sample + before_create_save(record) + record + end + + def before_create_save(record) + record.user = current_user end # override to close create form after success diff --git a/app/controllers/records_controller.rb b/app/controllers/records_controller.rb index 571bc65..481ed32 100644 --- a/app/controllers/records_controller.rb +++ b/app/controllers/records_controller.rb @@ -50,7 +50,12 @@ class RecordsController < ApplicationController def new_model record = super record.user_id = current_user.id + before_create_save(record) record end + def before_create_save(record) + record.user = current_user + end + end \ No newline at end of file diff --git a/app/controllers/soas_controller.rb b/app/controllers/soas_controller.rb index a99ad79..857a811 100644 --- a/app/controllers/soas_controller.rb +++ b/app/controllers/soas_controller.rb @@ -17,8 +17,13 @@ class SoasController < ApplicationController # override, we make our own sti logic def new_model - model = beginning_of_chain - model.new + record = beginning_of_chain.new + before_create_save(record) + record + end + + def before_create_save(record) + record.user = current_user end # override to close create form after success diff --git a/app/controllers/srvs_controller.rb b/app/controllers/srvs_controller.rb index 849ddd9..a13b23a 100644 --- a/app/controllers/srvs_controller.rb +++ b/app/controllers/srvs_controller.rb @@ -20,18 +20,19 @@ class SrvsController < ApplicationController # 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.srv_records - else - super - end + nested_via_records? ? nested.parent_scope.srv_records : super end # override, we make our own sti logic def new_model - model = beginning_of_chain.new - model.name = nested_parent_record.name - model + record = beginning_of_chain.new + record.name = nested_parent_record.name + before_create_save(record) + record + end + + def before_create_save(record) + record.user = current_user end # override to close create form after success diff --git a/app/controllers/txts_controller.rb b/app/controllers/txts_controller.rb index 4a169ba..1c37692 100644 --- a/app/controllers/txts_controller.rb +++ b/app/controllers/txts_controller.rb @@ -15,18 +15,19 @@ class TxtsController < ApplicationController # 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.txt_records - else - super - end + nested_via_records? ? nested.parent_scope.txt_records : super end # override, we make our own sti logic def new_model - model = beginning_of_chain.new - model.name = nested_parent_record.name - model + record = beginning_of_chain.new + record.name = nested_parent_record.name + before_create_save(record) + record + end + + def before_create_save(record) + record.user = current_user end # override to close create form after success diff --git a/db/migrate/20111129180907_create_permissions.rb b/db/migrate/20111129180907_create_permissions.rb index a322c33..737a6f2 100644 --- a/db/migrate/20111129180907_create_permissions.rb +++ b/db/migrate/20111129180907_create_permissions.rb @@ -2,7 +2,7 @@ class CreatePermissions < ActiveRecord::Migration def change create_table :permissions do |t| t.references :domain # the domain to whom permission is being given - t.references :user # the user permitted to manage + t.references :user # the user newly permitted to manage the domain t.timestamps end diff --git a/spec/controllers/aaaas_controller_spec.rb b/spec/controllers/aaaas_controller_spec.rb new file mode 100644 index 0000000..501f407 --- /dev/null +++ b/spec/controllers/aaaas_controller_spec.rb @@ -0,0 +1,144 @@ +require 'spec_helper' + +describe AaaasController do + it_should_behave_like "wiring controller" +end + +# TODO implement me +__END__ + + # This should return the minimal set of attributes required to create a valid + # Aaaa. As you add validations to Aaaa, be sure to + # update the return value of this method accordingly. + def valid_attributes + {} + end + + describe "GET index" do + it "assigns all aaaas as @aaaas" do + aaaa = Aaaa.create! valid_attributes + get :index + assigns(:aaaas).should eq([aaaa]) + end + end + + describe "GET show" do + it "assigns the requested aaaa as @aaaa" do + aaaa = Aaaa.create! valid_attributes + get :show, :id => aaaa.id.to_s + assigns(:aaaa).should eq(aaaa) + end + end + + describe "GET new" do + it "assigns a new aaaa as @aaaa" do + get :new + assigns(:aaaa).should be_a_new(Aaaa) + end + end + + describe "GET edit" do + it "assigns the requested aaaa as @aaaa" do + aaaa = Aaaa.create! valid_attributes + get :edit, :id => aaaa.id.to_s + assigns(:aaaa).should eq(aaaa) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new Aaaa" do + expect { + post :create, :aaaa => valid_attributes + }.to change(Aaaa, :count).by(1) + end + + it "assigns a newly created aaaa as @aaaa" do + post :create, :aaaa => valid_attributes + assigns(:aaaa).should be_a(Aaaa) + assigns(:aaaa).should be_persisted + end + + it "redirects to the created aaaa" do + post :create, :aaaa => valid_attributes + response.should redirect_to(Aaaa.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved aaaa as @aaaa" do + # Trigger the behavior that occurs when invalid params are submitted + Aaaa.any_instance.stub(:save).and_return(false) + post :create, :aaaa => {} + assigns(:aaaa).should be_a_new(Aaaa) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + Aaaa.any_instance.stub(:save).and_return(false) + post :create, :aaaa => {} + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested aaaa" do + aaaa = Aaaa.create! valid_attributes + # Assuming there are no other aaaas in the database, this + # specifies that the Aaaa created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + Aaaa.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, :id => aaaa.id, :aaaa => {'these' => 'params'} + end + + it "assigns the requested aaaa as @aaaa" do + aaaa = Aaaa.create! valid_attributes + put :update, :id => aaaa.id, :aaaa => valid_attributes + assigns(:aaaa).should eq(aaaa) + end + + it "redirects to the aaaa" do + aaaa = Aaaa.create! valid_attributes + put :update, :id => aaaa.id, :aaaa => valid_attributes + response.should redirect_to(aaaa) + end + end + + describe "with invalid params" do + it "assigns the aaaa as @aaaa" do + aaaa = Aaaa.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Aaaa.any_instance.stub(:save).and_return(false) + put :update, :id => aaaa.id.to_s, :aaaa => {} + assigns(:aaaa).should eq(aaaa) + end + + it "re-renders the 'edit' template" do + aaaa = Aaaa.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Aaaa.any_instance.stub(:save).and_return(false) + put :update, :id => aaaa.id.to_s, :aaaa => {} + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested aaaa" do + aaaa = Aaaa.create! valid_attributes + expect { + delete :destroy, :id => aaaa.id.to_s + }.to change(Aaaa, :count).by(-1) + end + + it "redirects to the aaaas list" do + aaaa = Aaaa.create! valid_attributes + delete :destroy, :id => aaaa.id.to_s + response.should redirect_to(aaaas_url) + end + end + +end diff --git a/spec/controllers/as_controller_spec.rb b/spec/controllers/as_controller_spec.rb new file mode 100644 index 0000000..4bfb218 --- /dev/null +++ b/spec/controllers/as_controller_spec.rb @@ -0,0 +1,144 @@ +require 'spec_helper' + +describe AsController do + it_should_behave_like "wiring controller" +end + +# TODO implement me +__END__ + + # This should return the minimal set of attributes required to create a valid + # A. As you add validations to A, be sure to + # update the return value of this method accordingly. + def valid_attributes + {} + end + + describe "GET index" do + it "assigns all as as @as" do + a = A.create! valid_attributes + get :index + assigns(:as).should eq([a]) + end + end + + describe "GET show" do + it "assigns the requested a as @a" do + a = A.create! valid_attributes + get :show, :id => a.id.to_s + assigns(:a).should eq(a) + end + end + + describe "GET new" do + it "assigns a new a as @a" do + get :new + assigns(:a).should be_a_new(A) + end + end + + describe "GET edit" do + it "assigns the requested a as @a" do + a = A.create! valid_attributes + get :edit, :id => a.id.to_s + assigns(:a).should eq(a) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new A" do + expect { + post :create, :a => valid_attributes + }.to change(A, :count).by(1) + end + + it "assigns a newly created a as @a" do + post :create, :a => valid_attributes + assigns(:a).should be_a(A) + assigns(:a).should be_persisted + end + + it "redirects to the created a" do + post :create, :a => valid_attributes + response.should redirect_to(A.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved a as @a" do + # Trigger the behavior that occurs when invalid params are submitted + A.any_instance.stub(:save).and_return(false) + post :create, :a => {} + assigns(:a).should be_a_new(A) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + A.any_instance.stub(:save).and_return(false) + post :create, :a => {} + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested a" do + a = A.create! valid_attributes + # Assuming there are no other as in the database, this + # specifies that the A created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + A.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, :id => a.id, :a => {'these' => 'params'} + end + + it "assigns the requested a as @a" do + a = A.create! valid_attributes + put :update, :id => a.id, :a => valid_attributes + assigns(:a).should eq(a) + end + + it "redirects to the a" do + a = A.create! valid_attributes + put :update, :id => a.id, :a => valid_attributes + response.should redirect_to(a) + end + end + + describe "with invalid params" do + it "assigns the a as @a" do + a = A.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + A.any_instance.stub(:save).and_return(false) + put :update, :id => a.id.to_s, :a => {} + assigns(:a).should eq(a) + end + + it "re-renders the 'edit' template" do + a = A.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + A.any_instance.stub(:save).and_return(false) + put :update, :id => a.id.to_s, :a => {} + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested a" do + a = A.create! valid_attributes + expect { + delete :destroy, :id => a.id.to_s + }.to change(A, :count).by(-1) + end + + it "redirects to the as list" do + a = A.create! valid_attributes + delete :destroy, :id => a.id.to_s + response.should redirect_to(as_url) + end + end + +end diff --git a/spec/controllers/cnames_controller_spec.rb b/spec/controllers/cnames_controller_spec.rb new file mode 100644 index 0000000..b5965d6 --- /dev/null +++ b/spec/controllers/cnames_controller_spec.rb @@ -0,0 +1,144 @@ +require 'spec_helper' + +describe CnamesController do + it_should_behave_like "wiring controller" +end + +# TODO implement me +__END__ + + # This should return the minimal set of attributes required to create a valid + # Cname. As you add validations to Cname, be sure to + # update the return value of this method accordingly. + def valid_attributes + {} + end + + describe "GET index" do + it "assigns all cnames as @cnames" do + cname = Cname.create! valid_attributes + get :index + assigns(:cnames).should eq([cname]) + end + end + + describe "GET show" do + it "assigns the requested cname as @cname" do + cname = Cname.create! valid_attributes + get :show, :id => cname.id.to_s + assigns(:cname).should eq(cname) + end + end + + describe "GET new" do + it "assigns a new cname as @cname" do + get :new + assigns(:cname).should be_a_new(Cname) + end + end + + describe "GET edit" do + it "assigns the requested cname as @cname" do + cname = Cname.create! valid_attributes + get :edit, :id => cname.id.to_s + assigns(:cname).should eq(cname) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new Cname" do + expect { + post :create, :cname => valid_attributes + }.to change(Cname, :count).by(1) + end + + it "assigns a newly created cname as @cname" do + post :create, :cname => valid_attributes + assigns(:cname).should be_a(Cname) + assigns(:cname).should be_persisted + end + + it "redirects to the created cname" do + post :create, :cname => valid_attributes + response.should redirect_to(Cname.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved cname as @cname" do + # Trigger the behavior that occurs when invalid params are submitted + Cname.any_instance.stub(:save).and_return(false) + post :create, :cname => {} + assigns(:cname).should be_a_new(Cname) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + Cname.any_instance.stub(:save).and_return(false) + post :create, :cname => {} + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested cname" do + cname = Cname.create! valid_attributes + # Assuming there are no other cnames in the database, this + # specifies that the Cname created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + Cname.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, :id => cname.id, :cname => {'these' => 'params'} + end + + it "assigns the requested cname as @cname" do + cname = Cname.create! valid_attributes + put :update, :id => cname.id, :cname => valid_attributes + assigns(:cname).should eq(cname) + end + + it "redirects to the cname" do + cname = Cname.create! valid_attributes + put :update, :id => cname.id, :cname => valid_attributes + response.should redirect_to(cname) + end + end + + describe "with invalid params" do + it "assigns the cname as @cname" do + cname = Cname.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Cname.any_instance.stub(:save).and_return(false) + put :update, :id => cname.id.to_s, :cname => {} + assigns(:cname).should eq(cname) + end + + it "re-renders the 'edit' template" do + cname = Cname.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Cname.any_instance.stub(:save).and_return(false) + put :update, :id => cname.id.to_s, :cname => {} + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested cname" do + cname = Cname.create! valid_attributes + expect { + delete :destroy, :id => cname.id.to_s + }.to change(Cname, :count).by(-1) + end + + it "redirects to the cnames list" do + cname = Cname.create! valid_attributes + delete :destroy, :id => cname.id.to_s + response.should redirect_to(cnames_url) + end + end + +end diff --git a/spec/controllers/hosts_controller_spec.rb b/spec/controllers/hosts_controller_spec.rb new file mode 100644 index 0000000..591747e --- /dev/null +++ b/spec/controllers/hosts_controller_spec.rb @@ -0,0 +1,144 @@ +require 'spec_helper' + +describe HostsController do + it_should_behave_like "wiring controller" +end + +# TODO implement me +__END__ + + # This should return the minimal set of attributes required to create a valid + # Host. As you add validations to Host, be sure to + # update the return value of this method accordingly. + def valid_attributes + {} + end + + describe "GET index" do + it "assigns all hosts as @hosts" do + host = Host.create! valid_attributes + get :index + assigns(:hosts).should eq([host]) + end + end + + describe "GET show" do + it "assigns the requested host as @host" do + host = Host.create! valid_attributes + get :show, :id => host.id.to_s + assigns(:host).should eq(host) + end + end + + describe "GET new" do + it "assigns a new host as @host" do + get :new + assigns(:host).should be_a_new(Host) + end + end + + describe "GET edit" do + it "assigns the requested host as @host" do + host = Host.create! valid_attributes + get :edit, :id => host.id.to_s + assigns(:host).should eq(host) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new Host" do + expect { + post :create, :host => valid_attributes + }.to change(Host, :count).by(1) + end + + it "assigns a newly created host as @host" do + post :create, :host => valid_attributes + assigns(:host).should be_a(Host) + assigns(:host).should be_persisted + end + + it "redirects to the created host" do + post :create, :host => valid_attributes + response.should redirect_to(Host.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved host as @host" do + # Trigger the behavior that occurs when invalid params are submitted + Host.any_instance.stub(:save).and_return(false) + post :create, :host => {} + assigns(:host).should be_a_new(Host) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + Host.any_instance.stub(:save).and_return(false) + post :create, :host => {} + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested host" do + host = Host.create! valid_attributes + # Assuming there are no other hosts in the database, this + # specifies that the Host created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + Host.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, :id => host.id, :host => {'these' => 'params'} + end + + it "assigns the requested host as @host" do + host = Host.create! valid_attributes + put :update, :id => host.id, :host => valid_attributes + assigns(:host).should eq(host) + end + + it "redirects to the host" do + host = Host.create! valid_attributes + put :update, :id => host.id, :host => valid_attributes + response.should redirect_to(host) + end + end + + describe "with invalid params" do + it "assigns the host as @host" do + host = Host.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Host.any_instance.stub(:save).and_return(false) + put :update, :id => host.id.to_s, :host => {} + assigns(:host).should eq(host) + end + + it "re-renders the 'edit' template" do + host = Host.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Host.any_instance.stub(:save).and_return(false) + put :update, :id => host.id.to_s, :host => {} + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested host" do + host = Host.create! valid_attributes + expect { + delete :destroy, :id => host.id.to_s + }.to change(Host, :count).by(-1) + end + + it "redirects to the hosts list" do + host = Host.create! valid_attributes + delete :destroy, :id => host.id.to_s + response.should redirect_to(hosts_url) + end + end + +end diff --git a/spec/controllers/mxes_controller_spec.rb b/spec/controllers/mxes_controller_spec.rb new file mode 100644 index 0000000..af792d2 --- /dev/null +++ b/spec/controllers/mxes_controller_spec.rb @@ -0,0 +1,144 @@ +require 'spec_helper' + +describe MxesController do + it_should_behave_like "wiring controller" +end + +# TODO implement me +__END__ + + # 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 diff --git a/spec/controllers/ns_controller_spec.rb b/spec/controllers/ns_controller_spec.rb new file mode 100644 index 0000000..6613f41 --- /dev/null +++ b/spec/controllers/ns_controller_spec.rb @@ -0,0 +1,144 @@ +require 'spec_helper' + +describe NsController do + it_should_behave_like "wiring controller" +end + +# TODO implement me +__END__ + + # This should return the minimal set of attributes required to create a valid + # Ns. As you add validations to Ns, be sure to + # update the return value of this method accordingly. + def valid_attributes + {} + end + + describe "GET index" do + it "assigns all ns as @ns" do + ns = Ns.create! valid_attributes + get :index + assigns(:ns).should eq([ns]) + end + end + + describe "GET show" do + it "assigns the requested ns as @ns" do + ns = Ns.create! valid_attributes + get :show, :id => ns.id.to_s + assigns(:ns).should eq(ns) + end + end + + describe "GET new" do + it "assigns a new ns as @ns" do + get :new + assigns(:ns).should be_a_new(Ns) + end + end + + describe "GET edit" do + it "assigns the requested ns as @ns" do + ns = Ns.create! valid_attributes + get :edit, :id => ns.id.to_s + assigns(:ns).should eq(ns) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new Ns" do + expect { + post :create, :ns => valid_attributes + }.to change(Ns, :count).by(1) + end + + it "assigns a newly created ns as @ns" do + post :create, :ns => valid_attributes + assigns(:ns).should be_a(Ns) + assigns(:ns).should be_persisted + end + + it "redirects to the created ns" do + post :create, :ns => valid_attributes + response.should redirect_to(Ns.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved ns as @ns" do + # Trigger the behavior that occurs when invalid params are submitted + Ns.any_instance.stub(:save).and_return(false) + post :create, :ns => {} + assigns(:ns).should be_a_new(Ns) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + Ns.any_instance.stub(:save).and_return(false) + post :create, :ns => {} + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested ns" do + ns = Ns.create! valid_attributes + # Assuming there are no other ns in the database, this + # specifies that the Ns created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + Ns.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, :id => ns.id, :ns => {'these' => 'params'} + end + + it "assigns the requested ns as @ns" do + ns = Ns.create! valid_attributes + put :update, :id => ns.id, :ns => valid_attributes + assigns(:ns).should eq(ns) + end + + it "redirects to the ns" do + ns = Ns.create! valid_attributes + put :update, :id => ns.id, :ns => valid_attributes + response.should redirect_to(ns) + end + end + + describe "with invalid params" do + it "assigns the ns as @ns" do + ns = Ns.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Ns.any_instance.stub(:save).and_return(false) + put :update, :id => ns.id.to_s, :ns => {} + assigns(:ns).should eq(ns) + end + + it "re-renders the 'edit' template" do + ns = Ns.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Ns.any_instance.stub(:save).and_return(false) + put :update, :id => ns.id.to_s, :ns => {} + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested ns" do + ns = Ns.create! valid_attributes + expect { + delete :destroy, :id => ns.id.to_s + }.to change(Ns, :count).by(-1) + end + + it "redirects to the ns list" do + ns = Ns.create! valid_attributes + delete :destroy, :id => ns.id.to_s + response.should redirect_to(ns_index_url) + end + end + +end diff --git a/spec/controllers/soas_controller_spec.rb b/spec/controllers/soas_controller_spec.rb new file mode 100644 index 0000000..15c4135 --- /dev/null +++ b/spec/controllers/soas_controller_spec.rb @@ -0,0 +1,144 @@ +require 'spec_helper' + +describe SoasController do + it_should_behave_like "wiring controller" +end + +# TODO implement me +__END__ + + # This should return the minimal set of attributes required to create a valid + # Soa. As you add validations to Soa, be sure to + # update the return value of this method accordingly. + def valid_attributes + {} + end + + describe "GET index" do + it "assigns all soas as @soas" do + soa = Soa.create! valid_attributes + get :index + assigns(:soas).should eq([soa]) + end + end + + describe "GET show" do + it "assigns the requested soa as @soa" do + soa = Soa.create! valid_attributes + get :show, :id => soa.id.to_s + assigns(:soa).should eq(soa) + end + end + + describe "GET new" do + it "assigns a new soa as @soa" do + get :new + assigns(:soa).should be_a_new(Soa) + end + end + + describe "GET edit" do + it "assigns the requested soa as @soa" do + soa = Soa.create! valid_attributes + get :edit, :id => soa.id.to_s + assigns(:soa).should eq(soa) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new Soa" do + expect { + post :create, :soa => valid_attributes + }.to change(Soa, :count).by(1) + end + + it "assigns a newly created soa as @soa" do + post :create, :soa => valid_attributes + assigns(:soa).should be_a(Soa) + assigns(:soa).should be_persisted + end + + it "redirects to the created soa" do + post :create, :soa => valid_attributes + response.should redirect_to(Soa.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved soa as @soa" do + # Trigger the behavior that occurs when invalid params are submitted + Soa.any_instance.stub(:save).and_return(false) + post :create, :soa => {} + assigns(:soa).should be_a_new(Soa) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + Soa.any_instance.stub(:save).and_return(false) + post :create, :soa => {} + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested soa" do + soa = Soa.create! valid_attributes + # Assuming there are no other soas in the database, this + # specifies that the Soa created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + Soa.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, :id => soa.id, :soa => {'these' => 'params'} + end + + it "assigns the requested soa as @soa" do + soa = Soa.create! valid_attributes + put :update, :id => soa.id, :soa => valid_attributes + assigns(:soa).should eq(soa) + end + + it "redirects to the soa" do + soa = Soa.create! valid_attributes + put :update, :id => soa.id, :soa => valid_attributes + response.should redirect_to(soa) + end + end + + describe "with invalid params" do + it "assigns the soa as @soa" do + soa = Soa.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Soa.any_instance.stub(:save).and_return(false) + put :update, :id => soa.id.to_s, :soa => {} + assigns(:soa).should eq(soa) + end + + it "re-renders the 'edit' template" do + soa = Soa.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Soa.any_instance.stub(:save).and_return(false) + put :update, :id => soa.id.to_s, :soa => {} + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested soa" do + soa = Soa.create! valid_attributes + expect { + delete :destroy, :id => soa.id.to_s + }.to change(Soa, :count).by(-1) + end + + it "redirects to the soas list" do + soa = Soa.create! valid_attributes + delete :destroy, :id => soa.id.to_s + response.should redirect_to(soas_url) + end + end + +end diff --git a/spec/controllers/srvs_controller_spec.rb b/spec/controllers/srvs_controller_spec.rb new file mode 100644 index 0000000..dbccf04 --- /dev/null +++ b/spec/controllers/srvs_controller_spec.rb @@ -0,0 +1,144 @@ +require 'spec_helper' + +describe SrvsController do + it_should_behave_like "wiring controller" +end + +# TODO implement me +__END__ + + # This should return the minimal set of attributes required to create a valid + # Srv. As you add validations to Srv, be sure to + # update the return value of this method accordingly. + def valid_attributes + {} + end + + describe "GET index" do + it "assigns all srvs as @srvs" do + srv = Srv.create! valid_attributes + get :index + assigns(:srvs).should eq([srv]) + end + end + + describe "GET show" do + it "assigns the requested srv as @srv" do + srv = Srv.create! valid_attributes + get :show, :id => srv.id.to_s + assigns(:srv).should eq(srv) + end + end + + describe "GET new" do + it "assigns a new srv as @srv" do + get :new + assigns(:srv).should be_a_new(Srv) + end + end + + describe "GET edit" do + it "assigns the requested srv as @srv" do + srv = Srv.create! valid_attributes + get :edit, :id => srv.id.to_s + assigns(:srv).should eq(srv) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new Srv" do + expect { + post :create, :srv => valid_attributes + }.to change(Srv, :count).by(1) + end + + it "assigns a newly created srv as @srv" do + post :create, :srv => valid_attributes + assigns(:srv).should be_a(Srv) + assigns(:srv).should be_persisted + end + + it "redirects to the created srv" do + post :create, :srv => valid_attributes + response.should redirect_to(Srv.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved srv as @srv" do + # Trigger the behavior that occurs when invalid params are submitted + Srv.any_instance.stub(:save).and_return(false) + post :create, :srv => {} + assigns(:srv).should be_a_new(Srv) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + Srv.any_instance.stub(:save).and_return(false) + post :create, :srv => {} + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested srv" do + srv = Srv.create! valid_attributes + # Assuming there are no other srvs in the database, this + # specifies that the Srv created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + Srv.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, :id => srv.id, :srv => {'these' => 'params'} + end + + it "assigns the requested srv as @srv" do + srv = Srv.create! valid_attributes + put :update, :id => srv.id, :srv => valid_attributes + assigns(:srv).should eq(srv) + end + + it "redirects to the srv" do + srv = Srv.create! valid_attributes + put :update, :id => srv.id, :srv => valid_attributes + response.should redirect_to(srv) + end + end + + describe "with invalid params" do + it "assigns the srv as @srv" do + srv = Srv.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Srv.any_instance.stub(:save).and_return(false) + put :update, :id => srv.id.to_s, :srv => {} + assigns(:srv).should eq(srv) + end + + it "re-renders the 'edit' template" do + srv = Srv.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Srv.any_instance.stub(:save).and_return(false) + put :update, :id => srv.id.to_s, :srv => {} + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested srv" do + srv = Srv.create! valid_attributes + expect { + delete :destroy, :id => srv.id.to_s + }.to change(Srv, :count).by(-1) + end + + it "redirects to the srvs list" do + srv = Srv.create! valid_attributes + delete :destroy, :id => srv.id.to_s + response.should redirect_to(srvs_url) + end + end + +end diff --git a/spec/controllers/txts_controller_spec.rb b/spec/controllers/txts_controller_spec.rb new file mode 100644 index 0000000..c397034 --- /dev/null +++ b/spec/controllers/txts_controller_spec.rb @@ -0,0 +1,144 @@ +require 'spec_helper' + +describe TxtsController do + it_should_behave_like "wiring controller" +end + +# TODO implement me +__END__ + + # This should return the minimal set of attributes required to create a valid + # Txt. As you add validations to Txt, be sure to + # update the return value of this method accordingly. + def valid_attributes + {} + end + + describe "GET index" do + it "assigns all txts as @txts" do + txt = Txt.create! valid_attributes + get :index + assigns(:txts).should eq([txt]) + end + end + + describe "GET show" do + it "assigns the requested txt as @txt" do + txt = Txt.create! valid_attributes + get :show, :id => txt.id.to_s + assigns(:txt).should eq(txt) + end + end + + describe "GET new" do + it "assigns a new txt as @txt" do + get :new + assigns(:txt).should be_a_new(Txt) + end + end + + describe "GET edit" do + it "assigns the requested txt as @txt" do + txt = Txt.create! valid_attributes + get :edit, :id => txt.id.to_s + assigns(:txt).should eq(txt) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new Txt" do + expect { + post :create, :txt => valid_attributes + }.to change(Txt, :count).by(1) + end + + it "assigns a newly created txt as @txt" do + post :create, :txt => valid_attributes + assigns(:txt).should be_a(Txt) + assigns(:txt).should be_persisted + end + + it "redirects to the created txt" do + post :create, :txt => valid_attributes + response.should redirect_to(Txt.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved txt as @txt" do + # Trigger the behavior that occurs when invalid params are submitted + Txt.any_instance.stub(:save).and_return(false) + post :create, :txt => {} + assigns(:txt).should be_a_new(Txt) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + Txt.any_instance.stub(:save).and_return(false) + post :create, :txt => {} + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested txt" do + txt = Txt.create! valid_attributes + # Assuming there are no other txts in the database, this + # specifies that the Txt created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + Txt.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, :id => txt.id, :txt => {'these' => 'params'} + end + + it "assigns the requested txt as @txt" do + txt = Txt.create! valid_attributes + put :update, :id => txt.id, :txt => valid_attributes + assigns(:txt).should eq(txt) + end + + it "redirects to the txt" do + txt = Txt.create! valid_attributes + put :update, :id => txt.id, :txt => valid_attributes + response.should redirect_to(txt) + end + end + + describe "with invalid params" do + it "assigns the txt as @txt" do + txt = Txt.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Txt.any_instance.stub(:save).and_return(false) + put :update, :id => txt.id.to_s, :txt => {} + assigns(:txt).should eq(txt) + end + + it "re-renders the 'edit' template" do + txt = Txt.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + Txt.any_instance.stub(:save).and_return(false) + put :update, :id => txt.id.to_s, :txt => {} + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested txt" do + txt = Txt.create! valid_attributes + expect { + delete :destroy, :id => txt.id.to_s + }.to change(Txt, :count).by(-1) + end + + it "redirects to the txts list" do + txt = Txt.create! valid_attributes + delete :destroy, :id => txt.id.to_s + response.should redirect_to(txts_url) + end + end + +end diff --git a/spec/support/shared_examples/wiring_controller.rb b/spec/support/shared_examples/wiring_controller.rb index 6daa90f..1b47248 100644 --- a/spec/support/shared_examples/wiring_controller.rb +++ b/spec/support/shared_examples/wiring_controller.rb @@ -2,12 +2,20 @@ shared_examples_for "wiring controller" do context "wiring" do include_context "data" + let(:record){Record.new} + before do sign_in user + @controller.stub(:nested_parent_record => domain) end it "#new_model is wired" do @controller.send(:new_model).user.should == user end + + it "#before_create_save wires" do + @controller.send(:before_create_save, record) + record.user.should == user + end end end \ No newline at end of file