pboling-subdomain-fu 0.2.1 → 0.3.0

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.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == 2009-08-26
2
+
3
+ * Fixed needs_rewrite? method
4
+ * Added is_mirror? method
5
+ * Added tests, and fixed failing tests
6
+
1
7
  == 2009-08-24
2
8
 
3
9
  * Merged forks that added lots of features, tests, and fixes
data/README.rdoc CHANGED
@@ -78,7 +78,8 @@ you can set the preferred mirror like so:
78
78
 
79
79
  SubdomainFu.preferred_mirror = "www"
80
80
 
81
- Now when you create a link to a false subdomain
81
+ Now when you create a link with subdomain => false in the options the subdomain
82
+ will default to the preferred mirror.
82
83
 
83
84
  == Known Issues / Future Work
84
85
 
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 2
4
- :patch: 1
3
+ :minor: 3
4
+ :patch: 0
data/lib/subdomain-fu.rb CHANGED
@@ -10,39 +10,43 @@ module SubdomainFu
10
10
  DEFAULT_TLD_SIZES = {:development => 0, :test => 0, :production => 1}
11
11
  mattr_accessor :tld_sizes
12
12
  @@tld_sizes = DEFAULT_TLD_SIZES.dup
13
-
13
+
14
14
  # Subdomains that are equivalent to going to the website with no subdomain at all.
15
15
  # Defaults to "www" as the only member.
16
16
  DEFAULT_MIRRORS = %w(www)
17
17
  mattr_accessor :mirrors
18
18
  @@mirrors = DEFAULT_MIRRORS.dup
19
-
19
+
20
20
  mattr_accessor :preferred_mirror
21
21
  @@preferred_mirror = nil
22
22
 
23
23
  mattr_accessor :override_only_path
24
24
  @@override_only_path = false
25
-
25
+
26
26
  # Returns the TLD Size of the current environment.
27
27
  def self.tld_size
28
28
  tld_sizes[RAILS_ENV.to_sym]
29
29
  end
30
-
30
+
31
31
  # Sets the TLD Size of the current environment
32
32
  def self.tld_size=(value)
33
33
  tld_sizes[RAILS_ENV.to_sym] = value
34
34
  end
35
-
36
- # Is the current subdomain either nil or a mirror?
35
+
36
+ # Is the current subdomain either nil or not a mirror?
37
37
  def self.has_subdomain?(subdomain)
38
38
  subdomain != false && !subdomain.blank? && !SubdomainFu.mirrors.include?(subdomain)
39
39
  end
40
40
 
41
+ def self.is_mirror?(subdomain)
42
+ subdomain != false && !subdomain.blank? && SubdomainFu.mirrors.include?(subdomain)
43
+ end
44
+
41
45
  # Is the subdomain a preferred mirror
42
46
  def self.preferred_mirror?(subdomain)
43
47
  subdomain == SubdomainFu.preferred_mirror || SubdomainFu.preferred_mirror.nil?
44
48
  end
45
-
49
+
46
50
  # Gets the subdomain from the host based on the TLD size
47
51
  def self.subdomain_from(host)
48
52
  return nil if host.nil? || /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.match(host)
@@ -50,18 +54,18 @@ module SubdomainFu
50
54
  sub = parts[0..-(SubdomainFu.tld_size+2)].join(".")
51
55
  sub.blank? ? nil : sub
52
56
  end
53
-
57
+
54
58
  # Gets only non-mirror subdomains from the host based on the TLD size
55
59
  def self.non_mirror_subdomain_from(host)
56
- sub = subdomain_from(host)
57
- has_subdomain?(sub) ? sub : nil
60
+ sub = subdomain_from(host)
61
+ has_subdomain?(sub) ? sub : nil
58
62
  end
59
63
 
60
64
  def self.host_without_subdomain(host)
61
65
  parts = host.split('.')
62
66
  parts[-(SubdomainFu.tld_size+1)..-1].join(".")
63
67
  end
64
-
68
+
65
69
  # Rewrites the subdomain of the host unless they are equivalent (i.e. mirrors of each other)
66
70
  def self.rewrite_host_for_subdomains(subdomain, host)
67
71
  if needs_rewrite?(subdomain, host)
@@ -75,28 +79,55 @@ module SubdomainFu
75
79
  end
76
80
  end
77
81
  end
78
-
82
+
79
83
  # Changes the subdomain of the host to whatever is passed in.
80
84
  def self.change_subdomain_of_host(subdomain, host)
81
85
  host = SubdomainFu.host_without_subdomain(host)
82
86
  host = "#{subdomain}.#{host}" if subdomain
83
87
  host
84
88
  end
85
-
89
+
86
90
  # Is this subdomain equivalent to the subdomain found in this host string?
87
91
  def self.same_subdomain?(subdomain, host)
88
92
  subdomain = nil unless subdomain
89
93
  (subdomain == subdomain_from(host)) ||
90
94
  (!has_subdomain?(subdomain) && !has_subdomain?(subdomain_from(host)))
91
95
  end
92
-
96
+
97
+ def self.override_only_path?
98
+ self.override_only_path
99
+ end
100
+
93
101
  def self.needs_rewrite?(subdomain, host)
94
- return false if subdomain.nil?
102
+ case subdomain
103
+ when nil
104
+ #rewrite when there is a preferred mirror set and there is no subdomain on the host
105
+ return true if self.preferred_mirror && subdomain_from(host).nil?
106
+ return false
107
+ when false
108
+ h = subdomain_from(host)
109
+ #if the host has a subdomain
110
+ if !h.nil?
111
+ #rewrite when there is a subdomain in the host, and it is not a preferred mirror
112
+ return true if !preferred_mirror?(h)
113
+ #rewrite when there is a preferred mirror set and the subdomain of the host is not a mirror
114
+ return true if self.preferred_mirror && !is_mirror?(h)
115
+ #no rewrite if host already has mirror subdomain
116
+ #it { SubdomainFu.needs_rewrite?(false,"www.localhost").should be_false }
117
+ return false if is_mirror?(h)
118
+ end
119
+ return self.crazy_rewrite_rule(subdomain, host)
120
+ else
121
+ return self.crazy_rewrite_rule(subdomain, host)
122
+ end
123
+ end
95
124
 
96
- (!has_subdomain?(subdomain) && preferred_mirror?(subdomain) && !preferred_mirror?(subdomain_from(host))) ||
125
+ #This is a black box of crazy! So I split some of the simpler logic out into the case statement above to make my brain happy!
126
+ def self.crazy_rewrite_rule(subdomain, host)
127
+ (!has_subdomain?(subdomain) && preferred_mirror?(subdomain) && !preferred_mirror?(subdomain_from(host))) ||
97
128
  !same_subdomain?(subdomain, host)
98
129
  end
99
-
130
+
100
131
  def self.current_subdomain(request)
101
132
  subdomain = request.subdomains(SubdomainFu.tld_size).join(".")
102
133
  if has_subdomain?(subdomain)
@@ -105,12 +136,12 @@ module SubdomainFu
105
136
  nil
106
137
  end
107
138
  end
108
-
139
+
109
140
  module Controller
110
141
  def self.included(controller)
111
142
  controller.helper_method(:current_subdomain)
112
143
  end
113
-
144
+
114
145
  protected
115
146
  def current_subdomain
116
147
  SubdomainFu.current_subdomain(request)
@@ -16,10 +16,10 @@ module SubdomainFu
16
16
  result
17
17
  end
18
18
  end
19
-
19
+
20
20
  module RouteSetExtensions
21
21
  def self.included(base)
22
- base.alias_method_chain :extract_request_environment, :subdomain
22
+ base.alias_method_chain :extract_request_environment, :subdomain
23
23
  end
24
24
 
25
25
  def extract_request_environment_with_subdomain(request)
@@ -27,7 +27,7 @@ module SubdomainFu
27
27
  env.merge(:host => request.host, :domain => request.domain, :subdomain => SubdomainFu.subdomain_from(request.host))
28
28
  end
29
29
  end
30
-
30
+
31
31
  module MapperExtensions
32
32
  def quick_map(has_unless, *args, &block)
33
33
  options = args.find{|a| a.is_a?(Hash)}
@@ -1,8 +1,8 @@
1
1
  module ActionController
2
2
  module UrlWriter
3
3
  def url_for_with_subdomains(options)
4
- if SubdomainFu.needs_rewrite?(options[:subdomain], options[:host] || default_url_options[:host])
5
- options[:only_path] = false if SubdomainFu.override_only_path
4
+ if SubdomainFu.needs_rewrite?(options[:subdomain], options[:host] || default_url_options[:host]) || options[:only_path] == false
5
+ options[:only_path] = false if SubdomainFu.override_only_path?
6
6
  options[:host] = SubdomainFu.rewrite_host_for_subdomains(options.delete(:subdomain), options[:host] || default_url_options[:host])
7
7
  else
8
8
  options.delete(:subdomain)
@@ -11,14 +11,15 @@ module ActionController
11
11
  end
12
12
  alias_method_chain :url_for, :subdomains
13
13
  end
14
-
14
+
15
15
  class UrlRewriter #:nodoc:
16
16
  private
17
-
17
+
18
18
  def rewrite_url_with_subdomains(options)
19
- if SubdomainFu.needs_rewrite?(options[:subdomain], (options[:host] || @request.host_with_port))
20
- options[:only_path] = false if SubdomainFu.override_only_path
19
+ if SubdomainFu.needs_rewrite?(options[:subdomain], (options[:host] || @request.host_with_port)) || options[:only_path] == false
20
+ options[:only_path] = false if SubdomainFu.override_only_path?
21
21
  options[:host] = SubdomainFu.rewrite_host_for_subdomains(options.delete(:subdomain), options[:host] || @request.host_with_port)
22
+ puts "options[:host]: #{options[:host].inspect}"
22
23
  else
23
24
  options.delete(:subdomain)
24
25
  end
@@ -26,7 +27,7 @@ module ActionController
26
27
  end
27
28
  alias_method_chain :rewrite_url, :subdomains
28
29
  end
29
-
30
+
30
31
  if Rails::VERSION::MAJOR >= 2 and Rails::VERSION::MINOR <= 1
31
32
  # hack for http://www.portallabs.com/blog/2008/10/22/fixing-subdomain_fu-with-named-routes/
32
33
  module Routing
data/rails/init.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'action_controller'
2
-
3
1
  # Add this path to ruby load path
4
2
  $:.unshift "#{File.dirname(__FILE__)}/../lib"
5
3
 
data/spec/spec_helper.rb CHANGED
@@ -12,20 +12,20 @@ ActionController::Routing::Routes.draw do |map|
12
12
  map.needs_subdomain '/needs_subdomain', :controller => "fu", :action => "awesome"
13
13
  map.no_subdomain '/no_subdomain', :controller => "fu", :action => "lame"
14
14
  map.needs_awesome '/needs_awesome', :controller => "fu", :action => "lame"
15
-
15
+
16
16
  map.resources :foos do |fu|
17
17
  fu.resources :bars
18
18
  end
19
-
19
+
20
20
  map.connect '/', :controller => "site", :action => "home", :conditions => {:subdomain => false}
21
21
  map.connect '/', :controller => "app", :action => "home", :conditions => {:subdomain => true}
22
22
  map.connect '/', :controller => "mobile", :action => "home", :conditions => {:subdomain => "m"}
23
-
23
+
24
24
  map.connect '/subdomain_here', :controller => "app", :action => "success", :conditions => {:subdomain => true}
25
25
  map.connect '/no_subdomain_here', :controller => "site", :action => "success", :conditions => {:subdomain => false}
26
26
  map.connect '/m_subdomain_here', :controller => "mobile", :action => "success", :conditions => {:subdomain => "m"}
27
27
  map.connect '/numbers_only_here', :controller => "numbers", :action => "success", :conditions => {:subdomain => /[0-9]+/}
28
-
28
+
29
29
  map.connect '/:controller/:action/:id'
30
30
  end
31
31
 
@@ -33,10 +33,10 @@ class Paramed
33
33
  def initialize(param)
34
34
  @param = param
35
35
  end
36
-
36
+
37
37
  def to_param
38
38
  @param || "param"
39
39
  end
40
40
  end
41
41
 
42
- include ActionController::UrlWriter
42
+ include ActionController::UrlWriter
@@ -11,42 +11,42 @@ describe "SubdomainFu" do
11
11
  before do
12
12
  SubdomainFu.tld_sizes = SubdomainFu::DEFAULT_TLD_SIZES.dup
13
13
  end
14
-
14
+
15
15
  it { SubdomainFu.tld_sizes.should be_kind_of(Hash) }
16
-
16
+
17
17
  it "should have default values for development, test, and production" do
18
18
  SubdomainFu.tld_sizes[:development].should == 0
19
19
  SubdomainFu.tld_sizes[:test].should == 0
20
20
  SubdomainFu.tld_sizes[:production].should == 1
21
21
  end
22
-
22
+
23
23
  it "#tld_size should be for the current environment" do
24
24
  SubdomainFu.tld_size.should == SubdomainFu.tld_sizes[RAILS_ENV.to_sym]
25
25
  end
26
-
26
+
27
27
  it "should be able to be set for the current environment" do
28
28
  SubdomainFu.tld_size = 5
29
29
  SubdomainFu.tld_size.should == 5
30
30
  SubdomainFu.tld_sizes[:test].should == 5
31
31
  end
32
32
  end
33
-
33
+
34
34
  describe "#has_subdomain?" do
35
35
  it "should be true for non-mirrored subdomains" do
36
36
  SubdomainFu.has_subdomain?("awesome").should be_true
37
37
  end
38
-
38
+
39
39
  it "should be false for mirrored subdomains" do
40
40
  SubdomainFu.has_subdomain?(SubdomainFu.mirrors.first).should be_false
41
41
  end
42
-
42
+
43
43
  it "shoud be false for a nil or blank subdomain" do
44
44
  SubdomainFu.has_subdomain?("").should be_false
45
45
  SubdomainFu.has_subdomain?(nil).should be_false
46
46
  SubdomainFu.has_subdomain?(false).should be_false
47
47
  end
48
48
  end
49
-
49
+
50
50
  describe "#subdomain_from" do
51
51
  it "should return the subdomain based on the TLD of the current environment" do
52
52
  SubdomainFu.subdomain_from("awesome.localhost").should == "awesome"
@@ -56,16 +56,16 @@ describe "SubdomainFu" do
56
56
  SubdomainFu.subdomain_from("awesome.localhost.com").should == "awesome"
57
57
  SubdomainFu.tld_size = 0
58
58
  end
59
-
59
+
60
60
  it "should join deep subdomains with a period" do
61
61
  SubdomainFu.subdomain_from("awesome.coolguy.localhost").should == "awesome.coolguy"
62
62
  end
63
-
63
+
64
64
  it "should return nil for no subdomain" do
65
65
  SubdomainFu.subdomain_from("localhost").should be_nil
66
66
  end
67
67
  end
68
-
68
+
69
69
  it "#host_without_subdomain should chop of the subdomain and return the rest" do
70
70
  SubdomainFu.host_without_subdomain("awesome.localhost:3000").should == "localhost:3000"
71
71
  SubdomainFu.host_without_subdomain("something.awful.localhost:3000").should == "localhost:3000"
@@ -87,15 +87,15 @@ describe "SubdomainFu" do
87
87
  it "should not change the same subdomain" do
88
88
  SubdomainFu.rewrite_host_for_subdomains("awesome","awesome.localhost").should == "awesome.localhost"
89
89
  end
90
-
90
+
91
91
  it "should not change an equivalent (mirrored) subdomain" do
92
92
  SubdomainFu.rewrite_host_for_subdomains("www","localhost").should == "localhost"
93
93
  end
94
-
94
+
95
95
  it "should change the subdomain if it's different" do
96
96
  SubdomainFu.rewrite_host_for_subdomains("cool","www.localhost").should == "cool.localhost"
97
97
  end
98
-
98
+
99
99
  it "should remove the subdomain if passed false when it's not a mirror" do
100
100
  SubdomainFu.rewrite_host_for_subdomains(false,"cool.localhost").should == "localhost"
101
101
  end
@@ -122,43 +122,43 @@ describe "SubdomainFu" do
122
122
  end
123
123
  end
124
124
  end
125
-
125
+
126
126
  describe "#change_subdomain_of_host" do
127
127
  it "should change it if passed a different one" do
128
128
  SubdomainFu.change_subdomain_of_host("awesome","cool.localhost").should == "awesome.localhost"
129
129
  end
130
-
130
+
131
131
  it "should remove it if passed nil" do
132
132
  SubdomainFu.change_subdomain_of_host(nil,"cool.localhost").should == "localhost"
133
133
  end
134
-
134
+
135
135
  it "should add it if there isn't one" do
136
136
  SubdomainFu.change_subdomain_of_host("awesome","localhost").should == "awesome.localhost"
137
137
  end
138
138
  end
139
-
139
+
140
140
  describe "#current_subdomain" do
141
141
  it "should return the current subdomain if there is one" do
142
142
  request = mock("request", :subdomains => ["awesome"])
143
143
  SubdomainFu.current_subdomain(request).should == "awesome"
144
144
  end
145
-
145
+
146
146
  it "should return nil if there's no subdomain" do
147
147
  request = mock("request", :subdomains => [])
148
148
  SubdomainFu.current_subdomain(request).should be_nil
149
149
  end
150
-
150
+
151
151
  it "should return nil if the current subdomain is a mirror" do
152
152
  request = mock("request", :subdomains => ["www"])
153
153
  SubdomainFu.current_subdomain(request).should be_nil
154
154
  end
155
-
155
+
156
156
  it "should return the whole thing (including a .) if there's multiple subdomains" do
157
157
  request = mock("request", :subdomains => ["awesome","rad"])
158
158
  SubdomainFu.current_subdomain(request).should == "awesome.rad"
159
159
  end
160
160
  end
161
-
161
+
162
162
  describe "#same_subdomain?" do
163
163
  it { SubdomainFu.same_subdomain?("www","www.localhost").should be_true }
164
164
  it { SubdomainFu.same_subdomain?("www","localhost").should be_true }
@@ -184,8 +184,34 @@ describe "SubdomainFu" do
184
184
  SubdomainFu.preferred_mirror = false
185
185
  end
186
186
 
187
+ it { SubdomainFu.needs_rewrite?("www","www.localhost").should be_false }
188
+ it { SubdomainFu.needs_rewrite?("www","localhost").should be_false }
189
+ it { SubdomainFu.needs_rewrite?("awesome","www.localhost").should be_true }
190
+ it { SubdomainFu.needs_rewrite?("cool","awesome.localhost").should be_true }
191
+ it { SubdomainFu.needs_rewrite?(nil,"www.localhost").should be_false }
192
+ it { SubdomainFu.needs_rewrite?(nil,"awesome.localhost").should be_false }
193
+ it { SubdomainFu.needs_rewrite?(false,"awesome.localhost").should be_true }
194
+ #Only one different from default set of tests
187
195
  it { SubdomainFu.needs_rewrite?(false,"www.localhost").should be_true }
196
+ it { SubdomainFu.needs_rewrite?("www","awesome.localhost").should be_true }
197
+ end
198
+
199
+ describe "when preferred_mirror is string" do
200
+ before do
201
+ SubdomainFu.preferred_mirror = "www"
202
+ end
203
+
204
+ it { SubdomainFu.needs_rewrite?("www","www.localhost").should be_false }
205
+ it { SubdomainFu.needs_rewrite?("awesome","www.localhost").should be_true }
206
+ # Following is different from default set of tests
207
+ it { SubdomainFu.needs_rewrite?("www","localhost").should be_true }
208
+ it { SubdomainFu.needs_rewrite?("cool","awesome.localhost").should be_true }
209
+ it { SubdomainFu.needs_rewrite?(nil,"www.localhost").should be_false }
188
210
  it { SubdomainFu.needs_rewrite?(nil,"awesome.localhost").should be_false }
211
+ it { SubdomainFu.needs_rewrite?(false,"awesome.localhost").should be_true }
212
+ it { SubdomainFu.needs_rewrite?(false,"www.localhost").should be_false }
213
+ it { SubdomainFu.needs_rewrite?("www","awesome.localhost").should be_true }
189
214
  end
215
+
190
216
  end
191
- end
217
+ end
@@ -4,25 +4,27 @@ describe "SubdomainFu URL Writing" do
4
4
  before do
5
5
  SubdomainFu.tld_size = 1
6
6
  SubdomainFu.mirrors = SubdomainFu::DEFAULT_MIRRORS.dup
7
+ SubdomainFu.override_only_path = true
7
8
  SubdomainFu.preferred_mirror = nil
8
9
  default_url_options[:host] = "example.com"
9
10
  end
10
-
11
+
11
12
  describe "#url_for" do
12
13
  it "should be able to add a subdomain" do
13
14
  url_for(:controller => "something", :action => "other", :subdomain => "awesome").should == "http://awesome.example.com/something/other"
14
15
  end
15
-
16
+
16
17
  it "should be able to remove a subdomain" do
17
18
  url_for(:controller => "something", :action => "other", :subdomain => false, :host => "awesome.example.com").should == "http://example.com/something/other"
18
19
  end
19
-
20
+
20
21
  it "should not change a mirrored subdomain" do
21
22
  url_for(:controller => "something", :action => "other", :subdomain => false, :host => "www.example.com").should == "http://www.example.com/something/other"
22
23
  end
23
24
 
24
25
  it "should should not force the full url with :only_path if override_only_path is false (default)" do
25
- url_for(:controller => "something", :action => "other", :subdomain => "awesome", :only_path => true).should == "/something/other"
26
+ SubdomainFu.override_only_path = false
27
+ url_for(:controller => "something", :action => "other", :subdomain => "awesome", :only_path => true).should == "/something/other"
26
28
  end
27
29
 
28
30
  it "should should force the full url, even with :only_path if override_only_path is true" do
@@ -30,7 +32,7 @@ describe "SubdomainFu URL Writing" do
30
32
  url_for(:controller => "something", :action => "other", :subdomain => "awesome", :only_path => true).should == "http://awesome.example.com/something/other"
31
33
  end
32
34
  end
33
-
35
+
34
36
  describe "Standard Routes" do
35
37
  it "should be able to add a subdomain" do
36
38
  needs_subdomain_url(:subdomain => "awesome").should == "http://awesome.example.com/needs_subdomain"
@@ -49,7 +51,7 @@ describe "SubdomainFu URL Writing" do
49
51
  it "should should force the full url, even with _path" do
50
52
  needs_subdomain_path(:subdomain => "awesome").should == needs_subdomain_url(:subdomain => "awesome")
51
53
  end
52
-
54
+
53
55
  it "should not force the full url if it's the same as the current subdomain" do
54
56
  default_url_options[:host] = "awesome.example.com"
55
57
  needs_subdomain_path(:subdomain => "awesome").should == "/needs_subdomain"
@@ -63,19 +65,19 @@ describe "SubdomainFu URL Writing" do
63
65
  it "should not force the full url if the current subdomain is nil and so is the target" do
64
66
  needs_subdomain_path(:subdomain => nil).should == "/needs_subdomain"
65
67
  end
66
-
68
+
67
69
  it "should not force the full url if no :subdomain option is given" do
68
70
  needs_subdomain_path.should == "/needs_subdomain"
69
71
  default_url_options[:host] = "awesome.example.com"
70
72
  needs_subdomain_path.should == "/needs_subdomain"
71
73
  end
72
74
  end
73
-
75
+
74
76
  describe "Resourced Routes" do
75
77
  it "should be able to add a subdomain" do
76
78
  foo_path(:id => "something", :subdomain => "awesome").should == "http://awesome.example.com/foos/something"
77
79
  end
78
-
80
+
79
81
  it "should be able to remove a subdomain" do
80
82
  default_url_options[:host] = "awesome.example.com"
81
83
  foo_path(:id => "something", :subdomain => false).should == "http://example.com/foos/something"
@@ -88,7 +90,7 @@ describe "SubdomainFu URL Writing" do
88
90
  it "should work when passed in a paramable object" do
89
91
  foo_path(Paramed.new("something"), :subdomain => "awesome").should == "http://awesome.example.com/foos/something"
90
92
  end
91
-
93
+
92
94
  it "should work when passed in a paramable object and no subdomain to a _path" do
93
95
  default_url_options[:host] = "awesome.example.com"
94
96
  foo_path(Paramed.new("something")).should == "/foos/something"
@@ -107,12 +109,13 @@ describe "SubdomainFu URL Writing" do
107
109
  foo_bar_path(Paramed.new("something"),Paramed.new("else"), :subdomain => "awesome").should == "http://awesome.example.com/foos/something/bars/else"
108
110
  end
109
111
  end
110
-
112
+
111
113
  describe "Preferred Mirror" do
112
114
  before do
113
115
  SubdomainFu.preferred_mirror = "www"
116
+ SubdomainFu.override_only_path = true
114
117
  end
115
-
118
+
116
119
  it "should switch to the preferred mirror instead of no subdomain" do
117
120
  default_url_options[:host] = "awesome.example.com"
118
121
  needs_subdomain_url(:subdomain => false).should == "http://www.example.com/needs_subdomain"
@@ -138,7 +141,7 @@ describe "SubdomainFu URL Writing" do
138
141
  SubdomainFu.preferred_mirror = nil
139
142
  end
140
143
  end
141
-
144
+
142
145
  after do
143
146
  SubdomainFu.tld_size = 0
144
147
  default_url_options[:host] = "localhost"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pboling-subdomain-fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -15,7 +15,7 @@ default_executable:
15
15
  dependencies: []
16
16
 
17
17
  description: SubdomainFu is a Rails plugin to provide all of the basic functionality necessary to handle multiple subdomain applications (such as Basecamp-esque subdomain accounts and more).
18
- email: michael@intridea.com
18
+ email: michael@intridea.com peter.boling@gmail.com
19
19
  executables: []
20
20
 
21
21
  extensions: []