You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
40 lines
1.0 KiB
shared_examples_for "wiring controller" do |
|
context "wiring" do |
|
include_context "data" |
|
let(:record){Record.new} |
|
|
|
context "on owned domain" do |
|
before do |
|
sign_in user |
|
@controller.stub(:nested_parent_record => domain) |
|
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 |
|
|
|
context "on permitted domain" do |
|
before do |
|
sign_in user2 |
|
permission # touch to ensure creation |
|
@controller.stub(:nested_parent_record => domain) |
|
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 |