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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e85034c2269a1d8427dedad5de680834830606d5
4
- data.tar.gz: 6733a2d52caee86fcbbf91f1be323540878d7f03
3
+ metadata.gz: 67519694e42e40bb318a582f636068d78db28f8b
4
+ data.tar.gz: cc6f2d10a2e614c6f9608166b9f366e0edaf266c
5
5
  SHA512:
6
- metadata.gz: 1f7b906a453c63d6b94b6b92c5a8727d03188979b2778c26b3f40544ef4cae4464cc67252984a7b681587f76bcf2a5c3072d41a51c93371778b68d9e034bec71
7
- data.tar.gz: 5cfea1660f505122b2ffa47e39f3d850e2370630ae9ef015ebc98d4d99770db09a764bc2121bd9a3668df0ece67b329d19d97936e4ef33b62a43b96cc34b0bfa
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:
@@ -1,3 +1,3 @@
1
1
  module GoToParam
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/go_to_param.rb CHANGED
@@ -30,6 +30,10 @@ module GoToParam
30
30
  end
31
31
  end
32
32
 
33
+ def go_to_path_or(default)
34
+ go_to_path || default
35
+ end
36
+
33
37
  private
34
38
 
35
39
  def go_to_param_value
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_to_param
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik N