inherited_resources 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/README.rdoc +12 -5
- data/Rakefile +2 -1
- data/lib/inherited_resources/actions.rb +6 -6
- data/lib/inherited_resources/base_helpers.rb +28 -5
- data/lib/inherited_resources/class_methods.rb +5 -3
- data/lib/inherited_resources/url_helpers.rb +4 -1
- data/lib/inherited_resources/version.rb +3 -0
- data/test/aliases_test.rb +1 -1
- data/test/base_test.rb +2 -2
- data/test/belongs_to_test.rb +3 -3
- data/test/class_methods_test.rb +17 -5
- data/test/customized_base_test.rb +2 -2
- data/test/customized_belongs_to_test.rb +7 -7
- data/test/defaults_test.rb +3 -3
- data/test/flash_test.rb +7 -7
- data/test/optional_belongs_to_test.rb +6 -6
- data/test/polymorphic_test.rb +6 -6
- data/test/singleton_test.rb +3 -3
- data/test/url_helpers_test.rb +24 -9
- metadata +15 -14
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# Version 0.9.4
|
2
|
+
|
3
|
+
* Since InheritedResouces 0.9.4, :notice and :error in I18n messages are deprecated in
|
4
|
+
favor of :success and :failure. If you try to access them, a deprecation message is shown.
|
5
|
+
If you want to skip the message, because you are sure you *won't* access such keys,
|
6
|
+
just set DO_NOT_SET_NOTICE_MESSAGE to true somewhere in your app.
|
7
|
+
|
1
8
|
# Version 0.9
|
2
9
|
|
3
10
|
* Allow dual blocks in destroy;
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Inherited Resources
|
2
2
|
License: MIT
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.4
|
4
4
|
|
5
5
|
== Description
|
6
6
|
|
@@ -36,6 +36,13 @@ When used with integrate_views equals to false, rspec overwrites default_render,
|
|
36
36
|
render and some other controller methods which makes Inherited Resources not work
|
37
37
|
properly. In such cases, you have to set integrate_views to true.
|
38
38
|
|
39
|
+
== Deprecation
|
40
|
+
|
41
|
+
Since InheritedResouces 0.9.4, :notice and :error in I18n messages are deprecated in
|
42
|
+
favor of :success and :failure. If you try to access them, a deprecation message is shown.
|
43
|
+
If you want to skip the message, because you are sure you *won't* access such keys,
|
44
|
+
just set DO_NOT_SET_NOTICE_MESSAGE to true somewhere in your app.
|
45
|
+
|
39
46
|
== Basic Usage
|
40
47
|
|
41
48
|
To use Inherited Resources you just have to inherit (duh) it:
|
@@ -260,8 +267,8 @@ on projects controller, it will search for:
|
|
260
267
|
flash.projects.create.status
|
261
268
|
flash.actions.create.status
|
262
269
|
|
263
|
-
The status can be :
|
264
|
-
or destroyed with success) or :
|
270
|
+
The status can be :success (when the object can be created, updated
|
271
|
+
or destroyed with success) or :failure (when the objecy cannot be created
|
265
272
|
or updated).
|
266
273
|
|
267
274
|
Those messages are interpolated by using the resource class human name, which
|
@@ -270,7 +277,7 @@ is also localized and it means you can set:
|
|
270
277
|
flash:
|
271
278
|
actions:
|
272
279
|
create:
|
273
|
-
|
280
|
+
success: "Hooray! {{resource_name}} was successfully created!"
|
274
281
|
|
275
282
|
It will replace {{resource_name}} by the human name of the resource class,
|
276
283
|
which is "Project" in this case.
|
@@ -281,7 +288,7 @@ the title of the project while updating a project. Well, that's easy also:
|
|
281
288
|
flash:
|
282
289
|
projects:
|
283
290
|
update:
|
284
|
-
|
291
|
+
success: "Hooray! The project "{{project_title}}" was updated!"
|
285
292
|
|
286
293
|
Since :project_title is not available for interpolation by default, you have
|
287
294
|
to overwrite interpolation_options.
|
data/Rakefile
CHANGED
@@ -3,12 +3,13 @@
|
|
3
3
|
require 'rake'
|
4
4
|
require 'rake/testtask'
|
5
5
|
require 'rake/rdoctask'
|
6
|
+
require File.join(File.dirname(__FILE__), 'lib', 'inherited_resources', 'version')
|
6
7
|
|
7
8
|
begin
|
8
9
|
require 'jeweler'
|
9
10
|
Jeweler::Tasks.new do |s|
|
10
11
|
s.name = "inherited_resources"
|
11
|
-
s.version =
|
12
|
+
s.version = InheritedResources::VERSION
|
12
13
|
s.rubyforge_project = "inherited_resources"
|
13
14
|
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
15
|
s.email = "jose.valim@gmail.com"
|
@@ -31,11 +31,11 @@ module InheritedResources
|
|
31
31
|
object = build_resource
|
32
32
|
|
33
33
|
if create_resource(object)
|
34
|
-
set_flash_message!(:
|
34
|
+
set_flash_message!(:success, '{{resource_name}} was successfully created.')
|
35
35
|
options[:location] ||= resource_url rescue nil
|
36
36
|
respond_with_dual_blocks(object, options, true, block)
|
37
37
|
else
|
38
|
-
set_flash_message!(:
|
38
|
+
set_flash_message!(:failure)
|
39
39
|
respond_with_dual_blocks(object, options, false, block)
|
40
40
|
end
|
41
41
|
end
|
@@ -46,11 +46,11 @@ module InheritedResources
|
|
46
46
|
object = resource
|
47
47
|
|
48
48
|
if update_resource(object, params[resource_instance_name])
|
49
|
-
set_flash_message!(:
|
49
|
+
set_flash_message!(:success, '{{resource_name}} was successfully updated.')
|
50
50
|
options[:location] ||= resource_url rescue nil
|
51
51
|
respond_with_dual_blocks(object, options, true, block)
|
52
52
|
else
|
53
|
-
set_flash_message!(:
|
53
|
+
set_flash_message!(:failure)
|
54
54
|
respond_with_dual_blocks(object, options, false, block)
|
55
55
|
end
|
56
56
|
end
|
@@ -62,10 +62,10 @@ module InheritedResources
|
|
62
62
|
options[:location] ||= collection_url rescue nil
|
63
63
|
|
64
64
|
if destroy_resource(object)
|
65
|
-
set_flash_message!(:
|
65
|
+
set_flash_message!(:success, '{{resource_name}} was successfully destroyed.')
|
66
66
|
respond_with_dual_blocks(object, options, true, block)
|
67
67
|
else
|
68
|
-
set_flash_message!(:
|
68
|
+
set_flash_message!(:failure, '{{resource_name}} could not be destroyed.')
|
69
69
|
respond_with_dual_blocks(object, options, false, block)
|
70
70
|
end
|
71
71
|
end
|
@@ -226,8 +226,8 @@ module InheritedResources
|
|
226
226
|
# flash.cars.create.status
|
227
227
|
# flash.actions.create.status
|
228
228
|
#
|
229
|
-
# The statuses can be :
|
230
|
-
# or destroyed with success) or :
|
229
|
+
# The statuses can be :success (when the object can be created, updated
|
230
|
+
# or destroyed with success) or :failure (when the objecy cannot be created
|
231
231
|
# or updated).
|
232
232
|
#
|
233
233
|
# Those messages are interpolated by using the resource class human name.
|
@@ -236,7 +236,7 @@ module InheritedResources
|
|
236
236
|
# flash:
|
237
237
|
# actions:
|
238
238
|
# create:
|
239
|
-
#
|
239
|
+
# success: "Hooray! {{resource_name}} was successfully created!"
|
240
240
|
#
|
241
241
|
# But sometimes, flash messages are not that simple. Going back
|
242
242
|
# to cars example, you might want to say the brand of the car when it's
|
@@ -245,7 +245,7 @@ module InheritedResources
|
|
245
245
|
# flash:
|
246
246
|
# cars:
|
247
247
|
# update:
|
248
|
-
#
|
248
|
+
# success: "Hooray! You just tuned your {{car_brand}}!"
|
249
249
|
#
|
250
250
|
# Since :car_name is not available for interpolation by default, you have
|
251
251
|
# to overwrite interpolation_options.
|
@@ -266,7 +266,7 @@ module InheritedResources
|
|
266
266
|
# flash.cars.create.status
|
267
267
|
# flash.actions.create.status
|
268
268
|
#
|
269
|
-
def
|
269
|
+
def orig_set_flash_message!(status, default_message=nil)
|
270
270
|
return flash[status] = default_message unless defined?(::I18n)
|
271
271
|
|
272
272
|
resource_name = if resource_class
|
@@ -306,6 +306,29 @@ module InheritedResources
|
|
306
306
|
flash[status] = message unless message.blank?
|
307
307
|
end
|
308
308
|
|
309
|
+
def set_flash_message!(status, default_message=nil)
|
310
|
+
return orig_set_flash_message!(status, default_message) if defined?(DO_NOT_SET_DEPRECATED_FLASH)
|
311
|
+
|
312
|
+
fallback = status == :success ? :notice : :error
|
313
|
+
result = orig_set_flash_message!(status)
|
314
|
+
|
315
|
+
if result.blank?
|
316
|
+
result = orig_set_flash_message!(fallback)
|
317
|
+
|
318
|
+
if result.blank?
|
319
|
+
result = orig_set_flash_message!(status, default_message) if default_message
|
320
|
+
else
|
321
|
+
ActiveSupport::Deprecation.warn "Using :#{fallback} in I18n with InheritedResources is deprecated, please use :#{status} instead"
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
unless result.blank?
|
326
|
+
flash[status] = result
|
327
|
+
flash[fallback] = ActiveSupport::Deprecation::DeprecatedObjectProxy.new result, "Accessing :#{fallback} in flash with InheritedResources is deprecated, please use :#{status} instead"
|
328
|
+
result
|
329
|
+
end
|
330
|
+
end
|
331
|
+
|
309
332
|
# Used to allow to specify success and failure within just one block:
|
310
333
|
#
|
311
334
|
# def create
|
@@ -63,9 +63,11 @@ module InheritedResources
|
|
63
63
|
raise ArgumentError, 'Wrong number of arguments. You have to provide which actions you want to keep.' if actions_to_keep.empty?
|
64
64
|
|
65
65
|
options = actions_to_keep.extract_options!
|
66
|
-
actions_to_remove
|
67
|
-
actions_to_remove += ACTIONS - actions_to_keep.map { |a| a.to_sym } unless actions_to_keep.
|
68
|
-
actions_to_remove.map! { |a| a.to_sym }
|
66
|
+
actions_to_remove = Array(options[:except])
|
67
|
+
actions_to_remove += ACTIONS - actions_to_keep.map { |a| a.to_sym } unless actions_to_keep.include?(:all)
|
68
|
+
actions_to_remove.map! { |a| a.to_sym }
|
69
|
+
actions_to_remove.uniq!
|
70
|
+
|
69
71
|
(instance_methods.map { |m| m.to_sym } & actions_to_remove).each do |action|
|
70
72
|
undef_method action, "#{action}!"
|
71
73
|
end
|
@@ -76,7 +76,10 @@ module InheritedResources
|
|
76
76
|
collection_segments = resource_segments.dup
|
77
77
|
|
78
78
|
# Generate parent url before we add resource instances.
|
79
|
-
|
79
|
+
unless parents_symbols.empty?
|
80
|
+
generate_url_and_path_helpers nil, :parent, resource_segments, resource_ivars
|
81
|
+
generate_url_and_path_helpers :edit, :parent, resource_segments, resource_ivars
|
82
|
+
end
|
80
83
|
|
81
84
|
# This is the default route configuration, later we have to deal with
|
82
85
|
# exception from polymorphic and singleton cases.
|
data/test/aliases_test.rb
CHANGED
@@ -55,7 +55,7 @@ class AliasesTest < ActionController::TestCase
|
|
55
55
|
assert_equal 'New HTML', @response.body.strip
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
58
|
+
def test_expose_the_requested_user_on_edit
|
59
59
|
Student.expects(:find).with('42').returns(mock_student)
|
60
60
|
get :edit, :id => '42'
|
61
61
|
assert_equal mock_student, assigns(:student)
|
data/test/base_test.rb
CHANGED
@@ -53,7 +53,7 @@ end
|
|
53
53
|
class ShowActionBaseTest < ActionController::TestCase
|
54
54
|
include UserTestHelper
|
55
55
|
|
56
|
-
def
|
56
|
+
def test_expose_the_requested_user
|
57
57
|
User.expects(:find).with('42').returns(mock_user)
|
58
58
|
get :show, :id => '42'
|
59
59
|
assert_equal mock_user, assigns(:user)
|
@@ -105,7 +105,7 @@ end
|
|
105
105
|
class EditActionBaseTest < ActionController::TestCase
|
106
106
|
include UserTestHelper
|
107
107
|
|
108
|
-
def
|
108
|
+
def test_expose_the_requested_user
|
109
109
|
User.expects(:find).with('42').returns(mock_user)
|
110
110
|
get :edit, :id => '42'
|
111
111
|
assert_response :success
|
data/test/belongs_to_test.rb
CHANGED
@@ -29,7 +29,7 @@ class BelongsToTest < ActionController::TestCase
|
|
29
29
|
assert_equal [mock_comment], assigns(:comments)
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def test_expose_the_requested_comment_on_show
|
33
33
|
Comment.expects(:find).with('42').returns(mock_comment)
|
34
34
|
get :show, :id => '42', :post_id => '37'
|
35
35
|
assert_equal mock_post, assigns(:post)
|
@@ -43,7 +43,7 @@ class BelongsToTest < ActionController::TestCase
|
|
43
43
|
assert_equal mock_comment, assigns(:comment)
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def test_expose_the_requested_comment_on_edit
|
47
47
|
Comment.expects(:find).with('42').returns(mock_comment)
|
48
48
|
get :edit, :id => '42', :post_id => '37'
|
49
49
|
assert_equal mock_post, assigns(:post)
|
@@ -65,7 +65,7 @@ class BelongsToTest < ActionController::TestCase
|
|
65
65
|
assert_equal mock_comment, assigns(:comment)
|
66
66
|
end
|
67
67
|
|
68
|
-
def
|
68
|
+
def test_the_requested_comment_is_destroyed_on_destroy
|
69
69
|
Comment.expects(:find).with('42').returns(mock_comment)
|
70
70
|
mock_comment.expects(:destroy)
|
71
71
|
delete :destroy, :id => '42', :post_id => '37'
|
data/test/class_methods_test.rb
CHANGED
@@ -27,14 +27,27 @@ class DeansController < InheritedResources::Base
|
|
27
27
|
belongs_to :school
|
28
28
|
end
|
29
29
|
|
30
|
+
class ActionsClassMethodTest < ActionController::TestCase
|
31
|
+
tests BooksController
|
32
|
+
|
33
|
+
def test_cannot_render_actions
|
34
|
+
assert_raise ActionController::UnknownAction do
|
35
|
+
get :new
|
36
|
+
end
|
37
|
+
end
|
30
38
|
|
31
|
-
class ActionsClassMethodTest < ActiveSupport::TestCase
|
32
39
|
def test_actions_are_undefined
|
33
|
-
action_methods = BooksController.send(:action_methods)
|
40
|
+
action_methods = BooksController.send(:action_methods).map(&:to_sym)
|
34
41
|
assert_equal 2, action_methods.size
|
35
42
|
|
36
|
-
[
|
37
|
-
assert action_methods.include?
|
43
|
+
[:index, :show].each do |action|
|
44
|
+
assert action_methods.include?(action)
|
45
|
+
end
|
46
|
+
|
47
|
+
instance_methods = BooksController.send(:instance_methods).map(&:to_sym)
|
48
|
+
|
49
|
+
[:new, :edit, :create, :update, :destroy].each do |action|
|
50
|
+
assert !instance_methods.include?(action)
|
38
51
|
end
|
39
52
|
end
|
40
53
|
|
@@ -48,7 +61,6 @@ class ActionsClassMethodTest < ActiveSupport::TestCase
|
|
48
61
|
end
|
49
62
|
end
|
50
63
|
|
51
|
-
|
52
64
|
class DefaultsClassMethodTest < ActiveSupport::TestCase
|
53
65
|
def test_resource_class_is_set_to_nil_when_resource_model_cannot_be_found
|
54
66
|
assert_nil ReadersController.send(:resource_class)
|
@@ -60,7 +60,7 @@ end
|
|
60
60
|
class ShowActionCustomizedBaseTest < ActionController::TestCase
|
61
61
|
include CarTestHelper
|
62
62
|
|
63
|
-
def
|
63
|
+
def test_expose_the_requested_user
|
64
64
|
Car.expects(:get).with('42').returns(mock_car)
|
65
65
|
get :show, :id => '42'
|
66
66
|
assert_equal mock_car, assigns(:car)
|
@@ -80,7 +80,7 @@ end
|
|
80
80
|
class EditActionCustomizedBaseTest < ActionController::TestCase
|
81
81
|
include CarTestHelper
|
82
82
|
|
83
|
-
def
|
83
|
+
def test_expose_the_requested_user
|
84
84
|
Car.expects(:get).with('42').returns(mock_car)
|
85
85
|
get :edit, :id => '42'
|
86
86
|
assert_response :success
|
@@ -21,43 +21,43 @@ class CustomizedBelongsToTest < ActionController::TestCase
|
|
21
21
|
@controller.stubs(:collection_url).returns('/')
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def test_expose_the_requested_school_with_chosen_instance_variable_on_index
|
25
25
|
Professor.stubs(:find).returns([mock_professor])
|
26
26
|
get :index, :school_title => 'nice'
|
27
27
|
assert_equal mock_school, assigns(:great_school)
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def test_expose_the_requested_school_with_chosen_instance_variable_on_show
|
31
31
|
Professor.stubs(:find).returns(mock_professor)
|
32
32
|
get :show, :school_title => 'nice'
|
33
33
|
assert_equal mock_school, assigns(:great_school)
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def test_expose_the_requested_school_with_chosen_instance_variable_on_new
|
37
37
|
Professor.stubs(:build).returns(mock_professor)
|
38
38
|
get :new, :school_title => 'nice'
|
39
39
|
assert_equal mock_school, assigns(:great_school)
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
42
|
+
def test_expose_the_requested_school_with_chosen_instance_variable_on_edit
|
43
43
|
Professor.stubs(:find).returns(mock_professor)
|
44
44
|
get :edit, :school_title => 'nice'
|
45
45
|
assert_equal mock_school, assigns(:great_school)
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def test_expose_the_requested_school_with_chosen_instance_variable_on_create
|
49
49
|
Professor.stubs(:build).returns(mock_professor(:save => true))
|
50
50
|
post :create, :school_title => 'nice'
|
51
51
|
assert_equal mock_school, assigns(:great_school)
|
52
52
|
end
|
53
53
|
|
54
|
-
def
|
54
|
+
def test_expose_the_requested_school_with_chosen_instance_variable_on_update
|
55
55
|
Professor.stubs(:find).returns(mock_professor(:update_attributes => true))
|
56
56
|
put :update, :school_title => 'nice'
|
57
57
|
assert_equal mock_school, assigns(:great_school)
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
60
|
+
def test_expose_the_requested_school_with_chosen_instance_variable_on_destroy
|
61
61
|
Professor.stubs(:find).returns(mock_professor(:destroy => true))
|
62
62
|
delete :destroy, :school_title => 'nice'
|
63
63
|
assert_equal mock_school, assigns(:great_school)
|
data/test/defaults_test.rb
CHANGED
@@ -23,7 +23,7 @@ class DefaultsTest < ActionController::TestCase
|
|
23
23
|
assert_equal [mock_painter], assigns(:malarze)
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
26
|
+
def test_expose_the_requested_painter_on_show
|
27
27
|
Malarz.expects(:find).with('42').returns(mock_painter)
|
28
28
|
get :show, :id => '42'
|
29
29
|
assert_equal mock_painter, assigns(:malarz)
|
@@ -35,7 +35,7 @@ class DefaultsTest < ActionController::TestCase
|
|
35
35
|
assert_equal mock_painter, assigns(:malarz)
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def test_expose_the_requested_painter_on_edit
|
39
39
|
Malarz.expects(:find).with('42').returns(mock_painter)
|
40
40
|
get :edit, :id => '42'
|
41
41
|
assert_response :success
|
@@ -55,7 +55,7 @@ class DefaultsTest < ActionController::TestCase
|
|
55
55
|
assert_equal mock_painter, assigns(:malarz)
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
58
|
+
def test_the_requested_painter_is_destroyed
|
59
59
|
Malarz.expects(:find).with('42').returns(mock_painter)
|
60
60
|
mock_painter.expects(:destroy)
|
61
61
|
delete :destroy, :id => '42'
|
data/test/flash_test.rb
CHANGED
@@ -34,7 +34,7 @@ class FlashBaseHelpersTest < ActionController::TestCase
|
|
34
34
|
def test_success_flash_message_on_create_with_yml
|
35
35
|
Address.stubs(:new).returns(mock_address(:save => true))
|
36
36
|
post :create
|
37
|
-
assert_equal 'You created a new address close to <b>Ocean Avenue</b>.', flash[:
|
37
|
+
assert_equal 'You created a new address close to <b>Ocean Avenue</b>.', flash[:success]
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_success_flash_message_on_create_with_namespaced_controller
|
@@ -42,7 +42,7 @@ class FlashBaseHelpersTest < ActionController::TestCase
|
|
42
42
|
@controller.stubs(:resource_url).returns("http://test.host/")
|
43
43
|
Address.stubs(:new).returns(mock_address(:save => true))
|
44
44
|
post :create
|
45
|
-
assert_equal 'Admin, you created a new address close to <b>Ocean Avenue</b>.', flash[:
|
45
|
+
assert_equal 'Admin, you created a new address close to <b>Ocean Avenue</b>.', flash[:success]
|
46
46
|
end
|
47
47
|
|
48
48
|
def test_failure_flash_message_on_create_with_namespaced_controller_actions
|
@@ -50,7 +50,7 @@ class FlashBaseHelpersTest < ActionController::TestCase
|
|
50
50
|
@controller.stubs(:resource_url).returns("http://test.host/")
|
51
51
|
Address.stubs(:new).returns(mock_address(:save => false))
|
52
52
|
post :create
|
53
|
-
assert_equal 'Admin error message.', flash[:
|
53
|
+
assert_equal 'Admin error message.', flash[:failure]
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_inherited_success_flash_message_on_update_on_namespaced_controllers
|
@@ -59,26 +59,26 @@ class FlashBaseHelpersTest < ActionController::TestCase
|
|
59
59
|
Address.stubs(:find).returns(mock_address(:update_attributes => true))
|
60
60
|
put :update
|
61
61
|
assert_response :success
|
62
|
-
assert_equal 'Nice! Address was updated with success!', flash[:
|
62
|
+
assert_equal 'Nice! Address was updated with success!', flash[:success]
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_success_flash_message_on_update
|
66
66
|
Address.stubs(:find).returns(mock_address(:update_attributes => true))
|
67
67
|
put :update
|
68
68
|
assert_response :success
|
69
|
-
assert_equal 'Nice! Address was updated with success!', flash[:
|
69
|
+
assert_equal 'Nice! Address was updated with success!', flash[:success]
|
70
70
|
end
|
71
71
|
|
72
72
|
def test_failure_flash_message_on_update
|
73
73
|
Address.stubs(:find).returns(mock_address(:update_attributes => false, :errors => {:some => :error}))
|
74
74
|
put :update
|
75
|
-
assert_equal 'Oh no! We could not update your address!', flash[:
|
75
|
+
assert_equal 'Oh no! We could not update your address!', flash[:failure]
|
76
76
|
end
|
77
77
|
|
78
78
|
def test_success_flash_message_on_destroy
|
79
79
|
Address.stubs(:find).returns(mock_address(:destroy => true))
|
80
80
|
delete :destroy
|
81
|
-
assert_equal 'Address was successfully destroyed.', flash[:
|
81
|
+
assert_equal 'Address was successfully destroyed.', flash[:success]
|
82
82
|
end
|
83
83
|
|
84
84
|
protected
|
@@ -35,7 +35,7 @@ class OptionalTest < ActionController::TestCase
|
|
35
35
|
assert_equal [mock_product], assigns(:products)
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
38
|
+
def test_expose_the_requested_product_with_category
|
39
39
|
Category.expects(:find).with('37').returns(mock_category)
|
40
40
|
mock_category.expects(:products).returns(Product)
|
41
41
|
Product.expects(:find).with('42').returns(mock_product)
|
@@ -44,7 +44,7 @@ class OptionalTest < ActionController::TestCase
|
|
44
44
|
assert_equal mock_product, assigns(:product)
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
47
|
+
def test_expose_the_requested_product_without_category
|
48
48
|
Product.expects(:find).with('42').returns(mock_product)
|
49
49
|
get :show, :id => '42'
|
50
50
|
assert_equal nil, assigns(:category)
|
@@ -67,7 +67,7 @@ class OptionalTest < ActionController::TestCase
|
|
67
67
|
assert_equal mock_product, assigns(:product)
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
70
|
+
def test_expose_the_requested_product_for_edition_with_category
|
71
71
|
Category.expects(:find).with('37').returns(mock_category)
|
72
72
|
mock_category.expects(:products).returns(Product)
|
73
73
|
Product.expects(:find).with('42').returns(mock_product)
|
@@ -76,7 +76,7 @@ class OptionalTest < ActionController::TestCase
|
|
76
76
|
assert_equal mock_product, assigns(:product)
|
77
77
|
end
|
78
78
|
|
79
|
-
def
|
79
|
+
def test_expose_the_requested_product_for_edition_without_category
|
80
80
|
Product.expects(:find).with('42').returns(mock_product)
|
81
81
|
get :edit, :id => '42'
|
82
82
|
assert_equal nil, assigns(:category)
|
@@ -119,7 +119,7 @@ class OptionalTest < ActionController::TestCase
|
|
119
119
|
assert_equal mock_product, assigns(:product)
|
120
120
|
end
|
121
121
|
|
122
|
-
def
|
122
|
+
def test_the_requested_product_is_destroyed_with_category
|
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)
|
@@ -131,7 +131,7 @@ class OptionalTest < ActionController::TestCase
|
|
131
131
|
assert_equal mock_product, assigns(:product)
|
132
132
|
end
|
133
133
|
|
134
|
-
def
|
134
|
+
def test_the_requested_product_is_destroyed_without_category
|
135
135
|
Product.expects(:find).with('42').returns(mock_product)
|
136
136
|
mock_product.expects(:destroy).returns(true)
|
137
137
|
@controller.expects(:collection_url).returns('/')
|
data/test/polymorphic_test.rb
CHANGED
@@ -29,7 +29,7 @@ class PolymorphicFactoriesTest < ActionController::TestCase
|
|
29
29
|
assert_equal [mock_employee], assigns(:employees)
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
32
|
+
def test_expose_the_requested_employee_on_show
|
33
33
|
Employee.expects(:find).with('42').returns(mock_employee)
|
34
34
|
get :show, :id => '42', :factory_id => '37'
|
35
35
|
assert_equal mock_factory, assigns(:factory)
|
@@ -43,7 +43,7 @@ class PolymorphicFactoriesTest < ActionController::TestCase
|
|
43
43
|
assert_equal mock_employee, assigns(:employee)
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def test_expose_the_requested_employee_on_edit
|
47
47
|
Employee.expects(:find).with('42').returns(mock_employee)
|
48
48
|
get :edit, :id => '42', :factory_id => '37'
|
49
49
|
assert_equal mock_factory, assigns(:factory)
|
@@ -66,7 +66,7 @@ class PolymorphicFactoriesTest < ActionController::TestCase
|
|
66
66
|
assert_equal mock_employee, assigns(:employee)
|
67
67
|
end
|
68
68
|
|
69
|
-
def
|
69
|
+
def test_the_requested_employee_is_destroyed_on_destroy
|
70
70
|
Employee.expects(:find).with('42').returns(mock_employee)
|
71
71
|
mock_employee.expects(:destroy)
|
72
72
|
delete :destroy, :id => '42', :factory_id => '37'
|
@@ -116,7 +116,7 @@ class PolymorphicCompanyTest < ActionController::TestCase
|
|
116
116
|
assert_equal [mock_employee], assigns(:employees)
|
117
117
|
end
|
118
118
|
|
119
|
-
def
|
119
|
+
def test_expose_the_requested_employee_on_show
|
120
120
|
Employee.expects(:find).with('42').returns(mock_employee)
|
121
121
|
get :show, :id => '42', :company_id => '37'
|
122
122
|
assert_equal mock_company, assigns(:company)
|
@@ -130,7 +130,7 @@ class PolymorphicCompanyTest < ActionController::TestCase
|
|
130
130
|
assert_equal mock_employee, assigns(:employee)
|
131
131
|
end
|
132
132
|
|
133
|
-
def
|
133
|
+
def test_expose_the_requested_employee_on_edit
|
134
134
|
Employee.expects(:find).with('42').returns(mock_employee)
|
135
135
|
get :edit, :id => '42', :company_id => '37'
|
136
136
|
assert_equal mock_company, assigns(:company)
|
@@ -153,7 +153,7 @@ class PolymorphicCompanyTest < ActionController::TestCase
|
|
153
153
|
assert_equal mock_employee, assigns(:employee)
|
154
154
|
end
|
155
155
|
|
156
|
-
def
|
156
|
+
def test_the_requested_employee_is_destroyed_on_destroy
|
157
157
|
Employee.expects(:find).with('42').returns(mock_employee)
|
158
158
|
mock_employee.expects(:destroy)
|
159
159
|
delete :destroy, :id => '42', :company_id => '37'
|
data/test/singleton_test.rb
CHANGED
@@ -22,7 +22,7 @@ class SingletonTest < ActionController::TestCase
|
|
22
22
|
@controller.stubs(:collection_url).returns('/')
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def test_expose_the_requested_manager_on_show
|
26
26
|
Store.expects(:find).with('37').returns(mock_store)
|
27
27
|
mock_store.expects(:manager).returns(mock_manager)
|
28
28
|
get :show, :store_id => '37'
|
@@ -38,7 +38,7 @@ class SingletonTest < ActionController::TestCase
|
|
38
38
|
assert_equal mock_manager, assigns(:manager)
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def test_expose_the_requested_manager_on_edit
|
42
42
|
Store.expects(:find).with('37').returns(mock_store)
|
43
43
|
mock_store.expects(:manager).returns(mock_manager)
|
44
44
|
get :edit, :store_id => '37'
|
@@ -63,7 +63,7 @@ class SingletonTest < ActionController::TestCase
|
|
63
63
|
assert_equal mock_manager, assigns(:manager)
|
64
64
|
end
|
65
65
|
|
66
|
-
def
|
66
|
+
def test_the_requested_manager_is_destroyed_on_destroy
|
67
67
|
Store.expects(:find).with('37').returns(mock_store)
|
68
68
|
mock_store.expects(:manager).returns(mock_manager)
|
69
69
|
mock_manager.expects(:destroy)
|
data/test/url_helpers_test.rb
CHANGED
@@ -82,9 +82,6 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
82
82
|
controller.expects("edit_house_#{path_or_url}").with(:house, {}).once
|
83
83
|
controller.send("edit_resource_#{path_or_url}")
|
84
84
|
|
85
|
-
controller.expects("root_#{path_or_url}").with({}).once
|
86
|
-
controller.send("parent_#{path_or_url}")
|
87
|
-
|
88
85
|
# With arg
|
89
86
|
controller.expects("house_#{path_or_url}").with(:arg, {}).once
|
90
87
|
controller.send("resource_#{path_or_url}", :arg)
|
@@ -117,9 +114,6 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
117
114
|
controller.expects("edit_admin_backpack_#{path_or_url}").with(:backpack, {}).once
|
118
115
|
controller.send("edit_resource_#{path_or_url}")
|
119
116
|
|
120
|
-
controller.expects("admin_#{path_or_url}").with({}).once
|
121
|
-
controller.send("parent_#{path_or_url}")
|
122
|
-
|
123
117
|
# With arg
|
124
118
|
controller.expects("admin_backpack_#{path_or_url}").with(:arg, {}).once
|
125
119
|
controller.send("resource_#{path_or_url}", :arg)
|
@@ -150,9 +144,6 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
150
144
|
controller.expects("edit_universum_#{path_or_url}").with({}).once
|
151
145
|
controller.send("edit_resource_#{path_or_url}")
|
152
146
|
|
153
|
-
controller.expects("root_#{path_or_url}").with({}).once
|
154
|
-
controller.send("parent_#{path_or_url}")
|
155
|
-
|
156
147
|
# With options
|
157
148
|
# Also tests that argument sent are not used
|
158
149
|
controller.expects("universum_#{path_or_url}").with(:page => 1).once
|
@@ -181,6 +172,9 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
181
172
|
controller.expects("house_#{path_or_url}").with(:house, {}).once
|
182
173
|
controller.send("parent_#{path_or_url}")
|
183
174
|
|
175
|
+
controller.expects("edit_house_#{path_or_url}").with(:house, {}).once
|
176
|
+
controller.send("edit_parent_#{path_or_url}")
|
177
|
+
|
184
178
|
# With arg
|
185
179
|
controller.expects("house_table_#{path_or_url}").with(:house, :arg, {}).once
|
186
180
|
controller.send("resource_#{path_or_url}", :arg)
|
@@ -218,6 +212,9 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
218
212
|
controller.expects("big_house_#{path_or_url}").with(:house, {}).once
|
219
213
|
controller.send("parent_#{path_or_url}")
|
220
214
|
|
215
|
+
controller.expects("edit_big_house_#{path_or_url}").with(:house, {}).once
|
216
|
+
controller.send("edit_parent_#{path_or_url}")
|
217
|
+
|
221
218
|
# With args
|
222
219
|
controller.expects("big_house_room_#{path_or_url}").with(:house, :arg, {}).once
|
223
220
|
controller.send("resource_#{path_or_url}", :arg)
|
@@ -256,6 +253,9 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
256
253
|
controller.expects("house_table_#{path_or_url}").with(:house, :table, {}).once
|
257
254
|
controller.send("parent_#{path_or_url}")
|
258
255
|
|
256
|
+
controller.expects("edit_house_table_#{path_or_url}").with(:house, :table, {}).once
|
257
|
+
controller.send("edit_parent_#{path_or_url}")
|
258
|
+
|
259
259
|
# With args
|
260
260
|
controller.expects("edit_house_table_chair_#{path_or_url}").with(:house, :table, :arg, {}).once
|
261
261
|
controller.send("edit_resource_#{path_or_url}", :arg)
|
@@ -293,6 +293,9 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
293
293
|
controller.expects("house_#{path_or_url}").with(:house, {}).once
|
294
294
|
controller.send("parent_#{path_or_url}")
|
295
295
|
|
296
|
+
controller.expects("edit_house_#{path_or_url}").with(:house, {}).once
|
297
|
+
controller.send("edit_parent_#{path_or_url}")
|
298
|
+
|
296
299
|
# With options
|
297
300
|
# Also tests that argument sent are not used
|
298
301
|
controller.expects("house_owner_#{path_or_url}").with(:house, :page => 1).once
|
@@ -328,6 +331,9 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
328
331
|
|
329
332
|
controller.expects("house_#{path_or_url}").with(house).once
|
330
333
|
controller.send("parent_#{path_or_url}")
|
334
|
+
|
335
|
+
controller.expects("edit_house_#{path_or_url}").with(house).once
|
336
|
+
controller.send("edit_parent_#{path_or_url}")
|
331
337
|
end
|
332
338
|
|
333
339
|
# With options
|
@@ -379,6 +385,9 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
379
385
|
|
380
386
|
controller.expects("admin_house_#{path_or_url}").with(house).once
|
381
387
|
controller.send("parent_#{path_or_url}")
|
388
|
+
|
389
|
+
controller.expects("edit_admin_house_#{path_or_url}").with(house).once
|
390
|
+
controller.send("edit_parent_#{path_or_url}")
|
382
391
|
end
|
383
392
|
|
384
393
|
# With options
|
@@ -432,6 +441,9 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
432
441
|
|
433
442
|
controller.expects("house_table_#{path_or_url}").with(house, table).once
|
434
443
|
controller.send("parent_#{path_or_url}")
|
444
|
+
|
445
|
+
controller.expects("edit_house_table_#{path_or_url}").with(house, table).once
|
446
|
+
controller.send("edit_parent_#{path_or_url}")
|
435
447
|
end
|
436
448
|
|
437
449
|
# With options
|
@@ -481,6 +493,9 @@ class UrlHelpersTest < ActiveSupport::TestCase
|
|
481
493
|
|
482
494
|
controller.expects("house_table_#{path_or_url}").with(house, table).once
|
483
495
|
controller.send("parent_#{path_or_url}")
|
496
|
+
|
497
|
+
controller.expects("edit_house_table_#{path_or_url}").with(house, table).once
|
498
|
+
controller.send("edit_parent_#{path_or_url}")
|
484
499
|
end
|
485
500
|
|
486
501
|
# With options
|
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.4
|
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-12-12 00:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/inherited_resources/polymorphic_helpers.rb
|
41
41
|
- lib/inherited_resources/singleton_helpers.rb
|
42
42
|
- lib/inherited_resources/url_helpers.rb
|
43
|
+
- lib/inherited_resources/version.rb
|
43
44
|
has_rdoc: true
|
44
45
|
homepage: http://github.com/josevalim/inherited_resources
|
45
46
|
licenses: []
|
@@ -69,21 +70,21 @@ signing_key:
|
|
69
70
|
specification_version: 3
|
70
71
|
summary: Inherited Resources speeds up development by making your controllers inherit all restful actions so you just have to focus on what is important.
|
71
72
|
test_files:
|
72
|
-
- test/respond_to_test.rb
|
73
|
-
- test/customized_belongs_to_test.rb
|
74
|
-
- test/nested_belongs_to_test.rb
|
75
|
-
- test/base_test.rb
|
76
|
-
- test/redirect_to_test.rb
|
77
|
-
- test/has_scope_test.rb
|
78
|
-
- test/class_methods_test.rb
|
79
|
-
- test/association_chain_test.rb
|
80
73
|
- test/aliases_test.rb
|
81
|
-
- test/
|
82
|
-
- test/
|
74
|
+
- test/association_chain_test.rb
|
75
|
+
- test/base_test.rb
|
83
76
|
- test/belongs_to_test.rb
|
77
|
+
- test/class_methods_test.rb
|
84
78
|
- test/customized_base_test.rb
|
85
|
-
- test/
|
79
|
+
- test/customized_belongs_to_test.rb
|
86
80
|
- test/defaults_test.rb
|
87
|
-
- test/
|
81
|
+
- test/flash_test.rb
|
82
|
+
- test/has_scope_test.rb
|
83
|
+
- test/nested_belongs_to_test.rb
|
88
84
|
- test/optional_belongs_to_test.rb
|
85
|
+
- test/polymorphic_test.rb
|
86
|
+
- test/redirect_to_test.rb
|
87
|
+
- test/respond_to_test.rb
|
88
|
+
- test/singleton_test.rb
|
89
89
|
- test/test_helper.rb
|
90
|
+
- test/url_helpers_test.rb
|