warden-redirect 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +15 -0
- data/README.md +1 -0
- data/lib/warden/redirect.rb +1 -1
- data/lib/warden/redirect/version.rb +1 -1
- data/spec/warden/redirect_spec.rb +44 -47
- data/warden-redirect.gemspec +4 -0
- metadata +27 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dd819103d3382aa6fbc900bd2f29cb16a84cd760
|
4
|
+
data.tar.gz: aa90094975163487b8ca23e35b612b0667e0f461
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 092e37a52d66b7d7c209d4c7184d52114ac09f6e7a4365e9bc8e609e27bfa4f37cc8d3d68135335a6d3bca3d3065ab724f36d81c950bfc7f6f5d1aacb58723b8
|
7
|
+
data.tar.gz: 830c71ce480db34b5efa6b19e37cec314369105b69c25c173fbd3eb756e5759b83846b1b829fb35d22be6b3d61bae3411242c9f579c6e586af5cab17123cd2e5
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Warden::Redirect
|
2
|
+
[![Build Status](https://secure.travis-ci.org/JonRowe/warden-redirect.png)](http://travis-ci.org/JonRowe/warden-redirect) [![Code Climate](https://codeclimate.com/github/JonRowe/warden-redirect.png)](https://codeclimate.com/github/JonRowe/warden-redirect)
|
2
3
|
|
3
4
|
Simple gem for throwing redirects in warden.
|
4
5
|
|
data/lib/warden/redirect.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Warden
|
2
2
|
class Redirect < Array
|
3
|
-
def initialize(location,status=302,headers={})
|
3
|
+
def initialize(location, status = 302, headers = {})
|
4
4
|
redirect_headers = headers.merge({ "Content-Type" => "text/html", "Location" => location })
|
5
5
|
body = "<html><body>You are being redirected to <a href='#{location}'>#{location}</a></body></html>"
|
6
6
|
super [status,redirect_headers,[body]]
|
@@ -1,64 +1,61 @@
|
|
1
1
|
require 'warden/redirect'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
RSpec.describe 'Warden::Redirect' do
|
4
|
+
shared_examples_for 'redirecting' do |opts|
|
5
|
+
it 'behaves like an array' do
|
6
|
+
status, headers, body = redirect_response
|
7
|
+
|
8
|
+
expect(redirect_response).to be_a Array
|
9
|
+
expect(status).to eq opts[:status]
|
10
|
+
expect(headers).to eq opts[:headers]
|
11
|
+
expect(body).to include a_string_including 'You are being redirected'
|
12
|
+
end
|
9
13
|
|
10
|
-
|
11
|
-
|
12
|
-
|
14
|
+
it 'exposes status' do
|
15
|
+
expect(redirect_response.status).to eq opts[:status]
|
16
|
+
end
|
13
17
|
|
14
|
-
|
15
|
-
|
18
|
+
it 'exposes headers' do
|
19
|
+
expect(redirect_response.headers).to eq opts[:headers]
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
status, headers, body = subject
|
21
|
-
status.should == opts[:status]
|
22
|
-
headers.should == opts[:headers]
|
23
|
-
body.should == subject[2]
|
22
|
+
it 'exposes the body' do
|
23
|
+
expect(redirect_response.body).to include a_string_including 'You are being redirected'
|
24
|
+
end
|
24
25
|
end
|
25
|
-
end
|
26
26
|
|
27
|
-
describe 'redirecting to a specific location' do
|
28
|
-
|
27
|
+
describe 'redirecting to a specific location' do
|
28
|
+
let(:redirect_response) { Warden::Redirect.new '/location' }
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
30
|
+
it_behaves_like 'redirecting',
|
31
|
+
:status => 302,
|
32
|
+
:headers => { "Location" => "/location", "Content-Type" => "text/html" }
|
33
|
+
end
|
34
34
|
|
35
|
-
describe 'redirecting to a specific location with a status' do
|
36
|
-
|
35
|
+
describe 'redirecting to a specific location with a status' do
|
36
|
+
let(:redirect_response) { Warden::Redirect.new '/location', 301 }
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
38
|
+
it_behaves_like 'redirecting',
|
39
|
+
:status => 301,
|
40
|
+
:headers => { "Location" => "/location", "Content-Type" => "text/html" }
|
41
|
+
end
|
42
42
|
|
43
|
-
describe 'redirecting to a specific location with a status and headers' do
|
44
|
-
|
43
|
+
describe 'redirecting to a specific location with a status and headers' do
|
44
|
+
let(:redirect_response) { Warden::Redirect.new '/location', 301, "X-SHALL-NOT-PASS" => true }
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
46
|
+
it_behaves_like 'redirecting',
|
47
|
+
:status => 301,
|
48
|
+
:headers => { "Location" => "/location", "Content-Type" => "text/html", "X-SHALL-NOT-PASS" => true }
|
49
|
+
end
|
50
50
|
|
51
|
-
describe 'warden
|
52
|
-
|
53
|
-
|
51
|
+
describe 'warden compatibility' do
|
52
|
+
let(:redirect_response) { throw :warden, Warden::Redirect.new('/location') }
|
53
|
+
let(:result) { catch(:warden) { redirect } }
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
else
|
60
|
-
fail
|
55
|
+
it 'returns an array for compatibility with warden' do
|
56
|
+
expect(
|
57
|
+
catch(:warden) { throw :warden, Warden::Redirect.new('/location') }
|
58
|
+
).to be_a Array
|
61
59
|
end
|
62
60
|
end
|
63
|
-
|
64
61
|
end
|
data/warden-redirect.gemspec
CHANGED
@@ -18,7 +18,11 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
20
|
gem.add_runtime_dependency 'warden'
|
21
|
+
if RUBY_VERSION <= '2.2.2'
|
22
|
+
gem.add_runtime_dependency 'rack', '< 2.0.0'
|
23
|
+
end
|
21
24
|
|
22
25
|
gem.add_development_dependency 'rspec'
|
26
|
+
gem.add_development_dependency 'rake', '~> 10.0.0'
|
23
27
|
|
24
28
|
end
|
metadata
CHANGED
@@ -1,48 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden-redirect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jon Rowe
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: warden
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 10.0.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 10.0.0
|
46
55
|
description: Simple gem for throwing redirects in warden.
|
47
56
|
email:
|
48
57
|
- hello@jonrowe.co.uk
|
@@ -50,7 +59,8 @@ executables: []
|
|
50
59
|
extensions: []
|
51
60
|
extra_rdoc_files: []
|
52
61
|
files:
|
53
|
-
- .gitignore
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
54
64
|
- Gemfile
|
55
65
|
- LICENSE.txt
|
56
66
|
- README.md
|
@@ -62,27 +72,26 @@ files:
|
|
62
72
|
- warden-redirect.gemspec
|
63
73
|
homepage: https://github.com/JonRowe/warden-redirect.git
|
64
74
|
licenses: []
|
75
|
+
metadata: {}
|
65
76
|
post_install_message:
|
66
77
|
rdoc_options: []
|
67
78
|
require_paths:
|
68
79
|
- lib
|
69
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
81
|
requirements:
|
72
|
-
- -
|
82
|
+
- - ">="
|
73
83
|
- !ruby/object:Gem::Version
|
74
84
|
version: '0'
|
75
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
86
|
requirements:
|
78
|
-
- -
|
87
|
+
- - ">="
|
79
88
|
- !ruby/object:Gem::Version
|
80
89
|
version: '0'
|
81
90
|
requirements: []
|
82
91
|
rubyforge_project:
|
83
|
-
rubygems_version:
|
92
|
+
rubygems_version: 2.5.1
|
84
93
|
signing_key:
|
85
|
-
specification_version:
|
94
|
+
specification_version: 4
|
86
95
|
summary: Simple gem for throwing redirects in warden.
|
87
96
|
test_files:
|
88
97
|
- spec/warden/redirect_spec.rb
|