Skip to content

Commit

Permalink
allow model to be pre-assigned in pages#new
Browse files Browse the repository at this point in the history
  • Loading branch information
saturnflyer committed Sep 25, 2010
1 parent f1d9824 commit 9275938
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/admin/pages_controller.rb
Expand Up @@ -17,7 +17,7 @@ def index
end

def new
self.model = model_class.new_with_defaults(config)
self.model ||= model_class.new_with_defaults(config)
assign_page_attributes
response_for :new
end
Expand Down
10 changes: 10 additions & 0 deletions spec/controllers/admin/pages_controller_spec.rb
Expand Up @@ -210,6 +210,16 @@
assigns(:meta).should be_kind_of(Array)
assigns(:buttons_partials).should be_kind_of(Array)
end

describe '#new' do
it "should not override a pre-assigned model" do
pending "Need to test ||= operator for pre-assigning the model"
@new_page = Page.new(:title => 'Pre-Assigned!')
controller.stub(:model).and_return(@new_page)
get :new, :page_id => page_id(:home)
assigns(:page).title.should == 'Pre-Assigned!'
end
end

it "should initialize meta and buttons_partials in edit action" do
get :edit, :id => page_id(:home)
Expand Down

0 comments on commit 9275938

Please sign in to comment.