Nicolae Claudius
13 years ago
14 changed files with 175 additions and 127 deletions
@ -1,21 +1,40 @@ |
|||||||
shared_examples_for "wiring controller" do |
shared_examples_for "wiring controller" do |
||||||
context "wiring" do |
context "wiring" do |
||||||
include_context "data" |
include_context "data" |
||||||
|
|
||||||
let(:record){Record.new} |
let(:record){Record.new} |
||||||
|
|
||||||
|
context "on owned domain" do |
||||||
before do |
before do |
||||||
sign_in user |
sign_in user |
||||||
@controller.stub(:nested_parent_record => domain) |
@controller.stub(:nested_parent_record => domain) |
||||||
end |
end |
||||||
|
|
||||||
it "#new_model is wired" do |
it "#new_model is wired" do |
||||||
@controller.send(:new_model).user.should == user |
@controller.send(:new_model).user.should == domain.user |
||||||
end |
end |
||||||
|
|
||||||
it "#before_create_save wires" do |
it "#before_create_save wires" do |
||||||
@controller.send(:before_create_save, record) |
@controller.send(:before_create_save, record) |
||||||
record.user.should == user |
record.user.should == domain.user |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
context "on permitted domain" do |
||||||
|
before do |
||||||
|
sign_in other_user |
||||||
|
permission # touch to ensure creation |
||||||
|
@controller.stub(:nested_parent_record => domain) |
||||||
end |
end |
||||||
|
|
||||||
|
it "#new_model is wired" do |
||||||
|
@controller.send(:new_model).user.should == domain.user |
||||||
|
end |
||||||
|
|
||||||
|
it "#before_create_save wires" do |
||||||
|
@controller.send(:before_create_save, record) |
||||||
|
record.user.should == domain.user |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
end |
end |
||||||
end |
end |
Loading…
Reference in new issue