merb-action-args 1.0.8.1 → 1.0.9
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.
@@ -32,9 +32,11 @@ class Merb::AbstractController
|
|
32
32
|
arguments, defaults = self.class.action_argument_list[action]
|
33
33
|
|
34
34
|
args = arguments.map do |arg, default|
|
35
|
-
arg = arg
|
36
35
|
p = params.key?(arg.to_sym)
|
37
|
-
|
36
|
+
unless p || (defaults && defaults.include?(arg))
|
37
|
+
missing = arguments.reject {|arg| params.key?(arg[0].to_sym || arg[1])}
|
38
|
+
raise BadRequest, "Your parameters (#{params.inspect}) were missing #{missing.join(", ")}"
|
39
|
+
end
|
38
40
|
p ? params[arg.to_sym] : default
|
39
41
|
end
|
40
42
|
__send__(action, *args)
|
data/spec/action_args_spec.rb
CHANGED
@@ -54,4 +54,14 @@ describe Merb::AbstractController do
|
|
54
54
|
dispatch_to(ActionArgs, :with_default_array, :foo => "bar").body.should == "bar []"
|
55
55
|
end
|
56
56
|
|
57
|
+
it "should print out the missing parameters if all are required" do
|
58
|
+
lambda { dispatch_to(ActionArgs, :multi) }.should raise_error(
|
59
|
+
Merb::ControllerExceptions::BadRequest, /were missing foo, bar/)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should only print out missing parameters" do
|
63
|
+
lambda { dispatch_to(ActionArgs, :multi, :foo => "Hello") }.should raise_error(
|
64
|
+
Merb::ControllerExceptions::BadRequest, /were missing bar/)
|
65
|
+
end
|
66
|
+
|
57
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-action-args
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Katz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-02-12 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.0.
|
23
|
+
version: 1.0.9
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: ruby2ruby
|