redirector 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -33,9 +33,9 @@ describe 'Redirector middleware', :type => :feature do
33
33
  it 'should preserve the query string if the Redirector.preserve_query is true' do
34
34
  original_option = Redirector.preserve_query
35
35
  Redirector.preserve_query = true
36
- visit '/my_custom_url/20?categoryID=12345'
36
+ visit '/my_custom_url/20?categoryID=43257'
37
37
  uri = URI.parse(current_url)
38
- uri.query.should == 'categoryID=12345'
38
+ uri.query.should == 'categoryID=43257'
39
39
  current_path.should == '/news/20'
40
40
  Redirector.preserve_query = original_option
41
41
  end
@@ -60,13 +60,25 @@ describe 'Redirector middleware', :type => :feature do
60
60
  current_url.should == 'http://example.com:3000/news/5'
61
61
  end
62
62
 
63
- it 'handles invalid URIs properly' do
64
- bad_rule = create(:redirect_rule_regex, :destination => 'http://www.example.com$1', :source => '^/custom(.*)$')
63
+ it 'foregoes search if ignored path pattern is detected' do
64
+ original_option = Redirector.ignored_patterns
65
+ Redirector.ignored_patterns = [/^\/my_custom_url\/.+/]
65
66
 
66
- begin
67
- visit '/custom)e2'
68
- rescue Redirector::RuleError => e
69
- e.message.should == "RedirectRule #{bad_rule.id} generated the bad destination: http://www.example.com)e2"
67
+ visit '/my_custom_url/20'
68
+ current_path.should == '/my_custom_url/20'
69
+
70
+ Redirector.ignored_patterns = original_option
71
+ end
72
+
73
+ unless Rails.version =~ /\A4\.2\.\d\z/
74
+ it 'handles invalid URIs properly' do
75
+ bad_rule = create(:redirect_rule_regex, :destination => 'http://www.example.com$1', :source => '^/custom(.*)$')
76
+
77
+ begin
78
+ visit '/custom)e2'
79
+ rescue Redirector::RuleError => e
80
+ e.message.should == "RedirectRule #{bad_rule.id} generated the bad destination: http://www.example.com)e2"
81
+ end
70
82
  end
71
83
  end
72
84
  end
@@ -32,6 +32,15 @@ describe RedirectRule do
32
32
  new_rule.errors_on(:source).should == ['is an invalid regular expression']
33
33
  end
34
34
 
35
+ describe 'strip_source_whitespace before_save callback' do
36
+ it 'strips leading and trailing whitespace when saved' do
37
+ subject = FactoryGirl.build(:redirect_rule, :source => ' /needs-stripping ')
38
+
39
+ subject.save
40
+ subject.reload.source.should == '/needs-stripping'
41
+ end
42
+ end
43
+
35
44
  describe '.match_for' do
36
45
  it 'returns nil if there is no matching rule' do
37
46
  RedirectRule.match_for('/someplace', {}).should be_nil
metadata CHANGED
@@ -1,35 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redirector
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Landau
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDOjCCAiKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBDMRUwEwYDVQQDDAxicmlh
14
- bmpsYW5kYXUxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkW
15
- A2NvbTAeFw0wNzEyMDUwMzA5NTBaFw0wODEyMDQwMzA5NTBaMEMxFTATBgNVBAMM
16
- DGJyaWFuamxhbmRhdTEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy
17
- LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvizK5bV4
18
- NQARcbPgZpLkSaashTY2JgLqQbxw9en6F4JFQsAlalWvmPqaC65NUxpV+Yb7mK1e
19
- Rx/6HBln8QeywVMwYTRvqYXXVn1MTLxnYLpLjQQrsM0vZIxwNsmQzrNqvvdGJRok
20
- gSrJx8lnb3LkmO68N6mG1lETaviaPwWhlB8mu3kcDG9dDXLWbPLDO4wHIIMl+0Nb
21
- wpyl7d4vteRAXOHmA+Ir5KkWloEhpPJ/WzUL4kxmvcqVSo04aEGsGecgkgSWfyID
22
- 7Z4KcE1dqjA1RjmeRHwxQilW49GkthB3CQhfhsjYJ3IYvUfiQIzDdrWLbJpxzShk
23
- E1IpSLMiP4svBQIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
24
- HQ4EFgQU00bxUNAS/W5tSWPDvnSlm3Tf9VYwDQYJKoZIhvcNAQEFBQADggEBAKUC
25
- 669HsZByRjaana3sE5Tyo59/Cb8LxphAS0s9rMtiQyh2sPIno02/pAKrC7S2qnwZ
26
- 8W71VKqROGnBhaSjWshwU0BjbcCpNDAE4YPLP3lUlP69FuGXbsqv9sYH1GKjgFHi
27
- OCM/uh9PLtUOQ0gRKixi8/edn11sUxYLMjpThagIU/kzw2J/xQoUpOgzHzrDnN00
28
- 8VWE27Mw4BMckRzTjgyEbGB6+j1NYaaQ76a1q1yFc3XiR9crZhyTmXT887lPCe3B
29
- QHjym4e4y/FmXBJjpO/TtRoYd8a5YTCaOsML7M/nb/XrArvE3l5JaNEXkhH/nGs7
30
- wR9huisTMlESX3ReGKU=
31
- -----END CERTIFICATE-----
32
- date: 2014-09-26 00:00:00.000000000 Z
10
+ cert_chain: []
11
+ date: 2017-10-13 00:00:00.000000000 Z
33
12
  dependencies:
34
13
  - !ruby/object:Gem::Dependency
35
14
  name: rails
@@ -266,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
245
  version: '0'
267
246
  requirements: []
268
247
  rubyforge_project:
269
- rubygems_version: 2.2.2
248
+ rubygems_version: 2.5.1
270
249
  signing_key:
271
250
  specification_version: 4
272
251
  summary: A Rails engine that adds a piece of middleware to the top of your middleware