inherited_resources 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +1 -0
- data/README.rdoc +4 -4
- data/Rakefile +1 -1
- data/lib/inherited_resources/actions.rb +3 -3
- data/lib/inherited_resources/base.rb +2 -1
- data/test/base_test.rb +8 -1
- data/test/optional_belongs_to_test.rb +2 -2
- metadata +2 -2
data/CHANGELOG
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Version 0.9
|
2
2
|
|
3
|
+
* Allow dual blocks in destroy;
|
3
4
|
* Added :if and :unless to has_scope (thanks to Jack Danger);
|
4
5
|
* Added create_resource, update_resource and delete_resource hooks (thanks to Carlos Antonio da Silva);
|
5
6
|
* Backported ActionController::Responder from Rails 3;
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Inherited Resources
|
2
2
|
License: MIT
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.2
|
4
4
|
|
5
5
|
== Description
|
6
6
|
|
@@ -23,8 +23,8 @@ keywords: resources, controller, singleton, belongs_to, polymorphic, named_scope
|
|
23
23
|
Install Inherited Resources is very easy. It is stored in GitHub, so just run
|
24
24
|
the following:
|
25
25
|
|
26
|
-
gem sources -a http://
|
27
|
-
sudo gem install
|
26
|
+
gem sources -a http://gemcutter.org
|
27
|
+
sudo gem install inherited_resources
|
28
28
|
|
29
29
|
If you want it as plugin, just do:
|
30
30
|
|
@@ -232,7 +232,7 @@ clean and organized inside the same action.
|
|
232
232
|
|
233
233
|
For those DSL lovers, InheritedResources won't leave you alone. You can overwrite
|
234
234
|
your success/failure blocks straight from your class binding. For it, you just
|
235
|
-
need to add a DSL
|
235
|
+
need to add a DSL module to your application controller:
|
236
236
|
|
237
237
|
class ApplicationController < ActionController::Base
|
238
238
|
include InheritedResources::DSL
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ begin
|
|
8
8
|
require 'jeweler'
|
9
9
|
Jeweler::Tasks.new do |s|
|
10
10
|
s.name = "inherited_resources"
|
11
|
-
s.version = "0.9.
|
11
|
+
s.version = "0.9.3"
|
12
12
|
s.rubyforge_project = "inherited_resources"
|
13
13
|
s.summary = "Inherited Resources speeds up development by making your controllers inherit all restful actions so you just have to focus on what is important."
|
14
14
|
s.email = "jose.valim@gmail.com"
|
@@ -59,15 +59,15 @@ module InheritedResources
|
|
59
59
|
# DELETE /resources/1
|
60
60
|
def destroy(options={}, &block)
|
61
61
|
object = resource
|
62
|
+
options[:location] ||= collection_url rescue nil
|
62
63
|
|
63
64
|
if destroy_resource(object)
|
64
65
|
set_flash_message!(:notice, '{{resource_name}} was successfully destroyed.')
|
66
|
+
respond_with_dual_blocks(object, options, true, block)
|
65
67
|
else
|
66
68
|
set_flash_message!(:error, '{{resource_name}} could not be destroyed.')
|
69
|
+
respond_with_dual_blocks(object, options, false, block)
|
67
70
|
end
|
68
|
-
|
69
|
-
options[:location] ||= collection_url rescue nil
|
70
|
-
respond_with_dual_blocks(object, options, nil, block)
|
71
71
|
end
|
72
72
|
alias :destroy! :destroy
|
73
73
|
|
@@ -25,7 +25,8 @@ module InheritedResources
|
|
25
25
|
|
26
26
|
helper_method :collection_url, :collection_path, :resource_url, :resource_path,
|
27
27
|
:new_resource_url, :new_resource_path, :edit_resource_url, :edit_resource_path,
|
28
|
-
:parent_url, :parent_path, :resource, :collection, :resource_class, :association_chain
|
28
|
+
:parent_url, :parent_path, :resource, :collection, :resource_class, :association_chain,
|
29
|
+
:resource_instance_name, :resource_collection_name
|
29
30
|
|
30
31
|
base.with_options :instance_writer => false do |c|
|
31
32
|
c.class_inheritable_accessor :resource_class
|
data/test/base_test.rb
CHANGED
@@ -198,7 +198,7 @@ class DestroyActionBaseTest < ActionController::TestCase
|
|
198
198
|
|
199
199
|
def test_the_requested_user_is_destroyed
|
200
200
|
User.expects(:find).with('42').returns(mock_user)
|
201
|
-
mock_user.expects(:destroy)
|
201
|
+
mock_user.expects(:destroy).returns(true)
|
202
202
|
delete :destroy, :id => '42'
|
203
203
|
assert_equal mock_user, assigns(:user)
|
204
204
|
end
|
@@ -221,5 +221,12 @@ class DestroyActionBaseTest < ActionController::TestCase
|
|
221
221
|
delete :destroy
|
222
222
|
assert_redirected_to 'http://test.host/'
|
223
223
|
end
|
224
|
+
|
225
|
+
def test_redirects_to_the_resource_if_cannot_be_destroyed
|
226
|
+
User.stubs(:find).returns(mock_user(:destroy => false))
|
227
|
+
@controller.expects(:collection_url).returns('http://test.host/')
|
228
|
+
delete :destroy
|
229
|
+
assert_redirected_to 'http://test.host/'
|
230
|
+
end
|
224
231
|
end
|
225
232
|
|
@@ -123,7 +123,7 @@ class OptionalTest < ActionController::TestCase
|
|
123
123
|
Category.expects(:find).with('37').returns(mock_category)
|
124
124
|
mock_category.expects(:products).returns(Product)
|
125
125
|
Product.expects(:find).with('42').returns(mock_product)
|
126
|
-
mock_product.expects(:destroy)
|
126
|
+
mock_product.expects(:destroy).returns(true)
|
127
127
|
@controller.expects(:collection_url).returns('/')
|
128
128
|
|
129
129
|
delete :destroy, :id => '42', :category_id => '37'
|
@@ -133,7 +133,7 @@ class OptionalTest < ActionController::TestCase
|
|
133
133
|
|
134
134
|
def test_the_resquested_product_is_destroyed_without_category
|
135
135
|
Product.expects(:find).with('42').returns(mock_product)
|
136
|
-
mock_product.expects(:destroy)
|
136
|
+
mock_product.expects(:destroy).returns(true)
|
137
137
|
@controller.expects(:collection_url).returns('/')
|
138
138
|
|
139
139
|
delete :destroy, :id => '42'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inherited_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jos\xC3\xA9 Valim"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-21 00:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|