josevalim-inherited_resources 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +4 -0
- data/MIT-LICENSE +1 -2
- data/README +2 -2
- data/lib/inherited_resources/base_helpers.rb +11 -7
- data/test/base_helpers_test.rb +8 -0
- metadata +2 -2
data/CHANGELOG
CHANGED
data/MIT-LICENSE
CHANGED
data/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Inherited Resources
|
2
2
|
License: MIT
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.1
|
4
4
|
|
5
5
|
You can also read this README in pretty html at the GitHub project Wiki page:
|
6
6
|
|
@@ -16,7 +16,7 @@ your controllers more powerful and cleaner at the same time.
|
|
16
16
|
Plus, making your controllers follow a pattern, it helps you to write better
|
17
17
|
code by following fat models and skinny controllers convention.
|
18
18
|
|
19
|
-
Inherited Resources is tested and compatible with Rails 2.2.
|
19
|
+
Inherited Resources is tested and compatible with Rails 2.2.x and Rails 2.3.x.
|
20
20
|
|
21
21
|
keywords: resources, controller, singleton, belongs_to, polymorphic and I18n
|
22
22
|
|
@@ -185,22 +185,26 @@ module InheritedResources #:nodoc:
|
|
185
185
|
# flash.actions.create.status
|
186
186
|
#
|
187
187
|
def set_flash_message!(status, default_message = '')
|
188
|
+
return flash[status] = default_message unless defined?(::I18n)
|
189
|
+
|
188
190
|
options = {
|
189
|
-
:default => default_message,
|
191
|
+
:default => default_message || '',
|
190
192
|
:resource_name => resource_class.human_name,
|
191
193
|
}.merge(interpolation_options)
|
192
194
|
|
193
195
|
defaults = []
|
194
|
-
slices =
|
195
|
-
|
196
|
-
|
197
|
-
defaults << :"
|
198
|
-
defaults << :"
|
196
|
+
slices = controller_path.split('/')
|
197
|
+
|
198
|
+
while slices.size > 0
|
199
|
+
defaults << :"flash.#{slices.fill(controller_name, -1).join('.')}.#{action_name}.#{status}"
|
200
|
+
defaults << :"flash.#{slices.fill(:actions, -1).join('.')}.#{action_name}.#{status}"
|
201
|
+
slices.shift
|
199
202
|
end
|
203
|
+
|
200
204
|
options[:default] = defaults.push(options[:default])
|
201
205
|
options[:default].flatten!
|
202
206
|
|
203
|
-
message = I18n.t options[:default].shift, options
|
207
|
+
message = ::I18n.t options[:default].shift, options
|
204
208
|
flash[status] = message unless message.blank?
|
205
209
|
end
|
206
210
|
|
data/test/base_helpers_test.rb
CHANGED
@@ -51,6 +51,14 @@ class FlashBaseHelpersTest < TEST_CLASS
|
|
51
51
|
assert_equal 'Admin error message.', flash[:error]
|
52
52
|
end
|
53
53
|
|
54
|
+
def test_inherited_success_flash_message_on_update_on_namespaced_controllers
|
55
|
+
@controller = Admin::AddressesController.new
|
56
|
+
Address.stubs(:find).returns(mock_address(:update_attributes => true))
|
57
|
+
put :update
|
58
|
+
assert_response :success
|
59
|
+
assert_equal 'Nice! Address was updated with success!', flash[:notice]
|
60
|
+
end
|
61
|
+
|
54
62
|
def test_success_flash_message_on_update
|
55
63
|
Address.stubs(:find).returns(mock_address(:update_attributes => true))
|
56
64
|
put :update
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: josevalim-inherited_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
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-03-
|
12
|
+
date: 2009-03-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|