go_to_param 0.0.4 → 0.0.5
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.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/go_to_param/version.rb +1 -1
- data/lib/go_to_param.rb +4 -0
- data/spec/go_to_param_spec.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67519694e42e40bb318a582f636068d78db28f8b
|
4
|
+
data.tar.gz: cc6f2d10a2e614c6f9608166b9f366e0edaf266c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d9044c27b4633755d1a5c079c66f36520fdd49eafcdd005c4100d886005c1c9c38d751e161576eb997cbf682308d2d806ada5a0997d4a10b8517adc2e2d81b9
|
7
|
+
data.tar.gz: 9b53e109c7f0b7ea51e352a3cac41c3af1540c71f824f5f124e97a3ba69c5ec136c27d3387a0646f3b6976400f0fa3e87a15881b5854670dc78a34ac4f255cc7
|
data/README.md
CHANGED
@@ -79,6 +79,15 @@ class SessionsController < ActionController::Base
|
|
79
79
|
end
|
80
80
|
```
|
81
81
|
|
82
|
+
### go_to_path_or
|
83
|
+
|
84
|
+
Syntactic sugar. These are equivalent:
|
85
|
+
|
86
|
+
``` ruby
|
87
|
+
redirect_to(go_to_path || root_path)
|
88
|
+
redirect_to go_to_path_or(root_path)
|
89
|
+
```
|
90
|
+
|
82
91
|
## Installation
|
83
92
|
|
84
93
|
Add this line to your application's Gemfile:
|
data/lib/go_to_param/version.rb
CHANGED
data/lib/go_to_param.rb
CHANGED
data/spec/go_to_param_spec.rb
CHANGED
@@ -74,4 +74,16 @@ describe GoToParam do
|
|
74
74
|
controller.go_to_path.should be_nil
|
75
75
|
end
|
76
76
|
end
|
77
|
+
|
78
|
+
describe "#go_to_path_or" do
|
79
|
+
it "is the go_to parameter value" do
|
80
|
+
controller.params = { go_to: "/example", id: "1" }
|
81
|
+
controller.go_to_path_or("/default").should == "/example"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "is the passed-in value if the parameter value is not a relative path" do
|
85
|
+
controller.params = { go_to: "http://evil.com", id: "1" }
|
86
|
+
controller.go_to_path_or("/default").should == "/default"
|
87
|
+
end
|
88
|
+
end
|
77
89
|
end
|