|
|
|
@ -1,51 +1,85 @@
|
|
|
|
|
require 'spec_helper' |
|
|
|
|
|
|
|
|
|
describe DomainsController do |
|
|
|
|
it_should_behave_like "wiring controller" |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "is wired with the current user by #before_create_save" do |
|
|
|
|
domain = build(:domain) |
|
|
|
|
@controller.send(:before_create_save, domain) |
|
|
|
|
domain.user.should == user |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# a domain who's parent domain is in our system |
|
|
|
|
context "subdomain" do |
|
|
|
|
before do |
|
|
|
|
sign_in other_user |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it "is wired with the user of the parent domain by #before_create_save" do |
|
|
|
|
subdomain = build(:domain, :user => other_user, :name => "x.#{domain.name}") |
|
|
|
|
@controller.send(:before_create_save, subdomain) |
|
|
|
|
subdomain.user.should == user |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# TODO implement me |
|
|
|
|
__END__ |
|
|
|
|
|
|
|
|
|
# This should return the minimal set of attributes required to create a valid |
|
|
|
|
# Domain. As you add validations to Domain, be sure to |
|
|
|
|
# update the return value of this method accordingly. |
|
|
|
|
def valid_attributes |
|
|
|
|
# This should return the minimal set of attributes required to create a valid |
|
|
|
|
# Domain. As you add validations to Domain, be sure to |
|
|
|
|
# update the return value of this method accordingly. |
|
|
|
|
def valid_attributes |
|
|
|
|
{} |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "GET index" do |
|
|
|
|
describe "GET index" do |
|
|
|
|
it "assigns all domains as @domains" do |
|
|
|
|
domain = Domain.create! valid_attributes |
|
|
|
|
get :index |
|
|
|
|
assigns(:domains).should eq([domain]) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "GET show" do |
|
|
|
|
describe "GET show" do |
|
|
|
|
it "assigns the requested domain as @domain" do |
|
|
|
|
domain = Domain.create! valid_attributes |
|
|
|
|
get :show, :id => domain.id.to_s |
|
|
|
|
assigns(:domain).should eq(domain) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "GET new" do |
|
|
|
|
describe "GET new" do |
|
|
|
|
it "assigns a new domain as @domain" do |
|
|
|
|
get :new |
|
|
|
|
assigns(:domain).should be_a_new(Domain) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "GET edit" do |
|
|
|
|
describe "GET edit" do |
|
|
|
|
it "assigns the requested domain as @domain" do |
|
|
|
|
domain = Domain.create! valid_attributes |
|
|
|
|
get :edit, :id => domain.id.to_s |
|
|
|
|
assigns(:domain).should eq(domain) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "POST create" do |
|
|
|
|
describe "POST create" do |
|
|
|
|
describe "with valid params" do |
|
|
|
|
it "creates a new Domain" do |
|
|
|
|
expect { |
|
|
|
@ -80,9 +114,9 @@ __END__
|
|
|
|
|
response.should render_template("new") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "PUT update" do |
|
|
|
|
describe "PUT update" do |
|
|
|
|
describe "with valid params" do |
|
|
|
|
it "updates the requested domain" do |
|
|
|
|
domain = Domain.create! valid_attributes |
|
|
|
@ -124,9 +158,9 @@ __END__
|
|
|
|
|
response.should render_template("edit") |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "DELETE destroy" do |
|
|
|
|
describe "DELETE destroy" do |
|
|
|
|
it "destroys the requested domain" do |
|
|
|
|
domain = Domain.create! valid_attributes |
|
|
|
|
expect { |
|
|
|
@ -139,6 +173,6 @@ __END__
|
|
|
|
|
delete :destroy, :id => domain.id.to_s |
|
|
|
|
response.should redirect_to(domains_url) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
end |