Permalink
Browse files

Merge branch 'master' into rails3

  • Loading branch information...
2 parents a414776 + 5476f01 commit 44a5a65043d6c3c0143c89286c0337bc97e9b7cd @hcatlin committed Jan 24, 2011
@@ -2,7 +2,7 @@
= error_messages_for :<%= singular_name %>
-- form_for(:<%= singular_name %>, :url => object_url, :html => { :method => :put }) do |f|
+= form_for(:<%= singular_name %>, :url => object_url, :html => { :method => :put }) do |f|
= render :partial => "form", :locals => {:f => f}
%p= submit_tag "Update"
@@ -2,7 +2,7 @@
= error_messages_for :<%= singular_name %>
-- form_for(:<%= singular_name %>, :url => objects_url) do |f|
+= form_for(:<%= singular_name %>, :url => objects_url) do |f|
= render :partial => "form", :locals => {:f => f}
%p= submit_tag "Create"
@@ -17,7 +17,7 @@ module Default
# and are called by the default make_resourceful actions[link:classes/Resourceful/Default/Actions.html].
# This means that overriding one method
# can affect everything else.
- #
+ #
# This can be dangerous, but it can also be very powerful.
# make_resourceful is designed to take advantage of overriding,
# so as long as the new methods accomplish the same purpose as the old ones,
@@ -60,7 +60,7 @@ def current_objects
#
# This is called automatically by the default make_resourceful actions.
# You shouldn't need to use it directly unless you're creating a new action.
- #
+ #
# For example, in UsersController,
# calling +load_objects+ sets <tt>@users = current_objects</tt>.
def load_objects
@@ -99,7 +99,7 @@ def current_object
#
# This is called automatically by the default make_resourceful actions.
# You shouldn't need to use it directly unless you're creating a new action.
- #
+ #
# For example, in UsersController,
# calling +load_object+ sets <tt>@user = current_object</tt>.
def load_object
@@ -120,12 +120,12 @@ def load_object
#
# build_object
# current_object.person.id #=> 4
- #
+ #
def build_object
@current_object = if current_model.respond_to? :build
current_model.build(object_parameters)
else
- returning(current_model.new(object_parameters)) do |obj|
+ current_model.new(object_parameters).tap do |obj|
if singular? && parent?
obj.send("#{parent_name}_id=", parent_object.id)
obj.send("#{parent_name}_type=", parent_object.class.to_s) if polymorphic_parent?
@@ -144,7 +144,7 @@ def current_model_name
# For example, in Admin::Content::PagesController:
#
# namespaces #=> [:admin, :content]
- #
+ #
def namespaces
@namespaces ||= self.class.name.split('::').slice(0...-1).map(&:underscore).map(&:to_sym)
end
@@ -241,7 +241,7 @@ def polymorphic_parent?
# _or_ that the method hasn't been run yet,
# it uses <tt>defined?(@parent_name)</tt> to do the caching
# rather than <tt>@parent_name ||=</tt>. See the source code.
- #
+ #
# Finally, note that parents must be declared via Builder#belongs_to.
#
# FIXME - Perhaps this logic should be moved to parent?() or another init method
@@ -272,7 +272,7 @@ def parent_name
end
@parent_name
end
-
+
def polymorphic_parent_name
@polymorphic_parent_name
end
@@ -330,7 +330,7 @@ def load_parent_object
# For example:
#
# before_filter :ensure_parent_exists, :only => [:create, :update]
- #
+ #
def ensure_parent_exists
return true if parent?
render :text => 'No parent id given', :status => 422
@@ -345,7 +345,7 @@ def save_succeeded?
# Declares that the current databse update was completed successfully.
# Causes subsequent calls to <tt>save_succeeded?</tt> to return +true+.
- #
+ #
# This is mostly meant to be used by the default actions,
# but it can be used by user-defined actions as well.
def save_succeeded!
@@ -354,7 +354,7 @@ def save_succeeded!
# Declares that the current databse update was not completed successfully.
# Causes subsequent calls to <tt>save_succeeded?</tt> to return +false+.
- #
+ #
# This is mostly meant to be used by the default actions,
# but it can be used by user-defined actions as well.
def save_failed!
@@ -378,8 +378,8 @@ def singular_action?
#
# Note that the way this is determined is based on the singularity of the controller name,
# so it may yield false positives for oddly-named controllers and need to be overridden.
- #
- # TODO: maybe we can define plural? and singular? as class_methods,
+ #
+ # TODO: maybe we can define plural? and singular? as class_methods,
# so they are not visible to the world
def singular?
instance_variable_name.singularize == instance_variable_name
@@ -391,8 +391,8 @@ def singular?
# Note that the way this is determined is based on the singularity of the controller name,
# so it may yield false negatives for oddly-named controllers.
# If this is the case, the singular? method should be overridden.
- #
- # TODO: maybe we can define plural? and singular? as class_methods,
+ #
+ # TODO: maybe we can define plural? and singular? as class_methods,
# so they are not visible to the world
def plural?
!singular?
View
@@ -20,8 +20,6 @@
(Resourceful::ACTIONS - Resourceful::MODIFYING_ACTIONS).each(&method(:should_render_html))
Resourceful::ACTIONS.each(&method(:should_render_js))
Resourceful::ACTIONS.each(&method(:shouldnt_render_xml))
-
-
## Specs for #index
@@ -165,7 +163,7 @@
Thing.stubs(:new).returns(@object)
@object.stubs(:save).returns(false)
post :create
- response.should render_template('new')
+ response.body.should include('New object')
end
## Specs for #update
@@ -224,7 +222,7 @@
Thing.stubs(:find).returns(@object)
@object.stubs(:update_attributes).returns(false)
put :update, :id => 12
- response.should render_template('edit')
+ response.body.should include('Editting object')
end
## Specs for #destroy
View
@@ -183,6 +183,7 @@ def init_kontroller(options)
@kontroller.send(:define_method, :inspect) { "#<#{options[:name].camelize}Controller>" }
@kontroller.send(:alias_method, :to_s, :inspect)
@kontroller.send(:include, ControllerMethods)
+ @kontroller.send(:view_paths=, [File.join(File.dirname(__FILE__), 'views')])
@kontroller
end
@@ -270,23 +271,22 @@ module Spec::Example::ExampleGroupMethods
def should_render_html(action)
it "should render HTML by default for #{action_string(action)}" do
action_method(action)[action, action_params(action)]
- response.should_have "Missing template things"
- #response.should be_success
+ response.body.should include("as HTML")
response.content_type.should == 'text/html'
end
end
-
+
def should_render_js(action)
it "should render JS for #{action_string(action)}" do
action_method(action)[action, action_params(action, :format => 'js')]
- #response.contents.should.include? "Missing template things"
- #response.should be_success
+ response.body.should include("insert(\"#{action}")
+ response.should be_success
response.content_type.should == 'text/javascript'
end
end
def shouldnt_render_xml(action)
- it "should render XML for #{action_string(action)}" do
+ it "shouldn't render XML for #{action_string(action)}" do
action_method(action)[action, action_params(action, :format => 'xml')]
response.should_not be_success
response.code.should == '406'
View
@@ -133,7 +133,7 @@
end
it "should get the path of current_object with #object_path" do
- @controller.expects(:send).with('thing_path', @object)
+ @controller.expects(:send).with('person_thing_path', @person, @object)
@controller.object_path
end
@@ -165,7 +165,7 @@
end
it "should get the edit path of the current model with #edit_object_path" do
- @controller.expects(:send).with('edit_thing_path', @object)
+ @controller.expects(:send).with('edit_person_thing_path', @person, @object)
@controller.edit_object_path
end
@@ -175,22 +175,26 @@
end
it "should get the path of the parent_object with #parent_path" do
+ pending
@controller.expects(:send).with('person_path', @person)
@controller.parent_path
end
it "should get the url of the parent_object with #parent_url" do
+ pending
@controller.expects(:send).with('person_url', @person)
@controller.parent_url
end
it "should get the path of the passed object with #parent_path" do
+ pending
model = stub_model('Person')
@controller.expects(:send).with('person_path', model)
@controller.parent_path model
end
it "should get the url of the passed object with #parent_url" do
+ pending
model = stub_model('Person')
@controller.expects(:send).with('person_url', model)
@controller.parent_url model
@@ -257,22 +261,22 @@
end
it "should get the namespaced path of current_object with #object_path" do
- @controller.expects(:send).with('admin_main_thing_path', @object)
+ @controller.expects(:send).with('admin_main_person_thing_path', @person, @object)
@controller.object_path
end
it "should get the namespaced plural path of the current model and its parent with #objects_path" do
- @controller.expects(:send).with('admin_main_things_path', @person)
+ @controller.expects(:send).with('admin_main_person_things_path', @person)
@controller.objects_path
end
it "should get the edit path of the current model with #edit_object_path" do
- @controller.expects(:send).with('edit_admin_main_thing_path', @object)
+ @controller.expects(:send).with('edit_admin_main_person_thing_path', @person, @object)
@controller.edit_object_path
end
it "should get the new path of the current model and its parent with #new_object_path" do
- @controller.expects(:send).with('new_admin_main_thing_path', @person)
+ @controller.expects(:send).with('new_admin_main_person_thing_path', @person)
@controller.new_object_path
end
end
@@ -0,0 +1 @@
+page.insert_html 'test', 'create'
@@ -0,0 +1 @@
+page.insert_html 'test', 'destroy'
@@ -0,0 +1,4 @@
+Notice: <%= flash[:notice]%>
+Error: <%= flash[:error]%>
+
+Editting object as HTML
@@ -0,0 +1 @@
+page.insert_html 'test', 'edit'
@@ -0,0 +1,4 @@
+Notice: <%= flash[:notice]%>
+Error: <%= flash[:error]%>
+
+Objects as HTML
@@ -0,0 +1 @@
+page.insert_html 'test', 'index'
@@ -0,0 +1,4 @@
+Notice: <%= flash[:notice]%>
+Error: <%= flash[:error]%>
+
+New object as HTML
@@ -0,0 +1 @@
+page.insert_html 'test', 'new'
@@ -0,0 +1,4 @@
+Notice: <%= flash[:notice]%>
+Error: <%= flash[:error]%>
+
+Showing object as HTML
@@ -0,0 +1 @@
+page.insert_html 'test', 'show'
@@ -0,0 +1 @@
+page.insert_html 'test', 'update'

0 comments on commit 44a5a65

Please sign in to comment.