utopia 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c561c449df8eaaff74066cd697d74d59144eed35
4
- data.tar.gz: 31e712f26e682f8f6f002b3f7f425ef8b68199f1
3
+ metadata.gz: 015ec482d8717b045b3d2cc12802afaf93b65560
4
+ data.tar.gz: 4a96d5699bc6bdb5398417dd518232a6b7798214
5
5
  SHA512:
6
- metadata.gz: 021df2ac5a3caddcb2c6a1e3951660670bc8e6244f6457791a15a3b93f377495270604575d4ee75b06850a26ef6f2ee56019bc7af6a5fdc44d8c48e2cc10c911
7
- data.tar.gz: 1f30b81c891cebf3a35a5c9536569b18553f7306d32f119967b385c66dd230ae020ac37c30672c6c2763fd93c452d7984c5ef6baf3c85acf0f2faaab2e5ff1d0
6
+ metadata.gz: 5e7f158a4aa3a175b9fc0c0b5686a1b7bb190e2d66018ca7f6f56523ba9d136ef373bd9089ec9ed0999503ba37815dbe3d6c3967a5f5e1bc5da7cca91ab78090
7
+ data.tar.gz: 4ee41e67fa41687bcd379b534c8c2a04947c9838da952aa3b93d448b674d0d059423f239ee6ce8ace1507ae67947ebab61d21be2c663a8f7c1b87913170759a9
data/.rspec CHANGED
@@ -1,2 +1,4 @@
1
- --color
2
- --format documentation
1
+ --color
2
+ --format documentation
3
+ --backtrace
4
+ --warnings
@@ -1,11 +1,13 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - "2.0"
5
- - "2.1"
6
- - "2.2"
7
- - "rbx-2"
4
+ - 2.0.0
5
+ - 2.1.8
6
+ - 2.2.4
7
+ - 2.3.0
8
+ - ruby-head
9
+ - rbx-2
10
+ env: COVERAGE=true
8
11
  matrix:
9
12
  allow_failures:
10
- - rvm: "rbx-2"
11
- env: COVERAGE=true
13
+ - rvm: "rbx-2"
@@ -38,7 +38,9 @@ module Utopia
38
38
  @root = File.expand_path(options[:root] || Utopia::default_root)
39
39
 
40
40
  if options[:cache_templates]
41
- @templates = Concurrent::Map.new
41
+ @template_cache = Concurrent::Map.new
42
+ else
43
+ @template_cache = nil
42
44
  end
43
45
 
44
46
  @tags = options.fetch(:tags, {})
@@ -56,8 +58,8 @@ module Utopia
56
58
  attr :root
57
59
 
58
60
  def fetch_xml(path)
59
- if @templates
60
- @templates.fetch_or_store(path.to_s) do
61
+ if @template_cache
62
+ @template_cache.fetch_or_store(path.to_s) do
61
63
  Trenni::Template.load(path)
62
64
  end
63
65
  else
@@ -21,7 +21,6 @@
21
21
  require 'yaml'
22
22
  require 'trenni/builder'
23
23
 
24
- require_relative '../content'
25
24
  require_relative '../path'
26
25
  require_relative '../locale'
27
26
 
@@ -53,7 +53,7 @@ module Utopia
53
53
 
54
54
  # Named:
55
55
  if name = options[:name]
56
- ordered.select!{|link| link.name[options[:name]]}
56
+ ordered.select!{|link| link.name[name]}
57
57
  end
58
58
 
59
59
  if locale = options[:locale]
@@ -80,7 +80,7 @@ module Utopia
80
80
  links = Links.index(@controller.root, path, options)
81
81
 
82
82
  if block_given?
83
- links.each &block
83
+ links.each(&block)
84
84
  else
85
85
  links
86
86
  end
@@ -88,7 +88,8 @@ module Utopia
88
88
 
89
89
  def related_links
90
90
  name = @uri_path.last.split('.', 2).first
91
- links = Links.index(@controller.root, uri_path.dirname, :name => name, :indices => true)
91
+
92
+ return Links.index(@controller.root, uri_path.dirname, :name => name, :indices => true)
92
93
  end
93
94
 
94
95
  def siblings_path
@@ -79,7 +79,7 @@ module Utopia
79
79
  end
80
80
 
81
81
  def cdata(text)
82
- @delegate.cdata(Trenni::Strings::to_html(text))
82
+ @delegate.cdata("<![CDATA[#{text}]]>")
83
83
  end
84
84
 
85
85
  def comment(text)
@@ -41,9 +41,17 @@ module Utopia
41
41
  @closed = false
42
42
  end
43
43
 
44
- attr :name
45
- attr :attributes
46
- attr :closed, true
44
+ def freeze
45
+ @name.freeze
46
+ @attributes.freeze
47
+ @closed.freeze
48
+
49
+ super
50
+ end
51
+
52
+ attr_accessor :name
53
+ attr_accessor :attributes
54
+ attr_accessor :closed
47
55
 
48
56
  def [](key)
49
57
  @attributes[key]
@@ -51,7 +51,9 @@ module Utopia
51
51
  @root = options[:root] || Utopia::default_root
52
52
 
53
53
  if options[:cache_controllers]
54
- @controllers = Concurrent::Map.new
54
+ @controller_cache = Concurrent::Map.new
55
+ else
56
+ @controller_cache = nil
55
57
  end
56
58
 
57
59
  self.freeze
@@ -66,8 +68,8 @@ module Utopia
66
68
  end
67
69
 
68
70
  def lookup_controller(path)
69
- if @controllers
70
- @controllers.fetch_or_store(path.to_s) do
71
+ if @controller_cache
72
+ @controller_cache.fetch_or_store(path.to_s) do
71
73
  load_controller_file(path)
72
74
  end
73
75
  else
@@ -136,7 +138,7 @@ module Utopia
136
138
  end
137
139
 
138
140
  def call(env)
139
- variables = (env[VARIABLES_KEY] ||= Variables.new)
141
+ env[VARIABLES_KEY] ||= Variables.new
140
142
 
141
143
  request = Rack::Request.new(env)
142
144
 
@@ -21,6 +21,14 @@
21
21
  module Utopia
22
22
  class Controller
23
23
  class Action < Hash
24
+ def initialize
25
+ @path = nil
26
+ @options = options
27
+ @callback = nil
28
+
29
+ super
30
+ end
31
+
24
32
  attr_accessor :path, :callback, :options
25
33
 
26
34
  def callback?
@@ -75,7 +83,7 @@ module Utopia
75
83
  # relative_path = 2014/mr-potato
76
84
  # actions => {:** => A}
77
85
  def select(relative_path)
78
- selection = [].tap do |actions|
86
+ [].tap do |actions|
79
87
  append(relative_path.reverse, 0, actions)
80
88
  end
81
89
  end
@@ -90,7 +90,7 @@ module Utopia
90
90
  code = STATUS_CODES[code]
91
91
  end
92
92
 
93
- unless 100...600
93
+ unless valid_range.include? code
94
94
  raise ArgumentError.new("Status must be in range #{valid_range}, was given #{code}!")
95
95
  end
96
96
 
@@ -91,7 +91,7 @@ module Utopia
91
91
  end
92
92
 
93
93
  def freeze
94
- @all_locale.freeze
94
+ @all_locales.freeze
95
95
  @default_locales.freeze
96
96
  @default_locale.freeze
97
97
  @hosts.freeze
@@ -132,8 +132,6 @@ module Utopia
132
132
  def host_preferred_locales(env)
133
133
  http_host = env[Rack::HTTP_HOST]
134
134
 
135
- locales = []
136
-
137
135
  # Get a list of all hosts which match the incoming htt_host:
138
136
  matching_hosts = @hosts.select{|host_pattern, locale| http_host =~ host_pattern}
139
137
 
@@ -203,10 +201,10 @@ module Utopia
203
201
  response = nil
204
202
 
205
203
  # We have a non-localized request, but there might be a localized resource. We return the best localization possible:
206
- preferred_locales(env) do |env|
204
+ preferred_locales(env) do |localized_env|
207
205
  # puts "Trying locale: #{env[CURRENT_LOCALE_KEY]}: #{env[Rack::PATH_INFO]}..."
208
206
 
209
- response = @app.call(env)
207
+ response = @app.call(localized_env)
210
208
 
211
209
  break unless response[0] >= 400
212
210
  end
@@ -74,7 +74,7 @@ module Utopia
74
74
  @components = components
75
75
  end
76
76
 
77
- attr :components, true
77
+ attr_accessor :components
78
78
 
79
79
  def freeze
80
80
  @components.freeze
@@ -134,14 +134,15 @@ module Utopia
134
134
  # TODO: Support multiple byte-ranges, for now just send entire file:
135
135
  response[0] = 200
136
136
  response[1]["Content-Length"] = size.to_s
137
- @range = 0..size-1
137
+ @range = 0...size
138
138
  else
139
139
  # Partial content:
140
140
  @range = ranges[0]
141
+ partial_size = @range.count
142
+
141
143
  response[0] = 206
142
- response[1]["Content-Range"] = "bytes #{@range.begin}-#{@range.end}/#{size}"
143
- response[1]["Content-Length"] = (@range.end - @range.begin+1).to_s
144
- size = @range.end - @range.begin + 1
144
+ response[1]["Content-Length"] = partial_size.to_s
145
+ response[1]["Content-Range"] = "bytes #{@range.min}-#{@range.max}/#{size}"
145
146
  end
146
147
 
147
148
  # LOG.debug {"Serving file #{full_path.inspect}, range #{@range.inspect}"}
@@ -169,12 +170,12 @@ module Utopia
169
170
  when Array
170
171
  result["." + type[0]] = type[1]
171
172
  when String
172
- mt = MIME::Types.of(type).select{|mt| !mt.obsolete?}.each do |mt|
173
- extract_extensions.call(mt)
173
+ MIME::Types.of(type).select{|mime_type| !mime_type.obsolete?}.each do |mime_type|
174
+ extract_extensions.call(mime_type)
174
175
  end
175
176
  when Regexp
176
- MIME::Types[type].select{|mt| !mt.obsolete?}.each do |mt|
177
- extract_extensions.call(mt)
177
+ MIME::Types[type].select{|mime_type| !mime_type.obsolete?}.each do |mime_type|
178
+ extract_extensions.call(mime_type)
178
179
  end
179
180
  when MIME::Type
180
181
  extract_extensions.call(type)
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Utopia
22
- VERSION = "1.2.2"
22
+ VERSION = "1.2.3"
23
23
  end
Binary file
@@ -1,25 +1 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <!-- Generator: Adobe Illustrator 15.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
- <svg version="1.1" id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="420px" height="76.993px" viewBox="0 0 420 76.993" enable-background="new 0 0 420 76.993" xml:space="preserve">
6
- <g>
7
- <rect y="-0.246" fill="#F79433" width="420" height="74.246"/>
8
- <rect y="54" fill="#4E8DD8" width="420" height="23"/>
9
- <g>
10
- <path fill="#FFFFFF" d="M74.365,68.163c2.379-2.981,4.189-6.661,5.131-10.939C80.41,53.068,81,48.311,81,43.083V0H18v43.083
11
- c0,2.53,0.245,5.133,0.409,7.734c0.168,2.678,0.676,5.308,1.35,7.814c0.683,2.545,1.746,4.979,3.079,7.235
12
- c1.368,2.315,3.276,4.356,5.631,6.066c2.328,1.69,5.265,3.045,8.711,4.016C38.803,76.408,40.609,77,42.555,77h13.91
13
- c3.083,0,5.82-1.018,8.163-1.926C68.686,73.504,71.962,71.177,74.365,68.163z"/>
14
- <polygon fill="#FFFFFF" points="151,18 151,0 88,-0.021 88,18 110.334,18 110.354,77 128.354,77 128.334,18 "/>
15
- <path fill="#FFFFFF" d="M229.753,38.499c0-21.224-17.046-38.492-38-38.492s-38,17.269-38,38.492c0,21.227,17.046,38.494,38,38.494
16
- S229.753,59.726,229.753,38.499z"/>
17
- <path fill="#FFFFFF" d="M269.219,49c9.755,0,17.248-1.989,22.27-6.155c5.107-4.234,7.697-10.532,7.697-18.841
18
- c0-3.135-0.394-5.739-1.171-8.158c-0.782-2.434-1.891-4.749-3.294-6.559c-1.407-1.811-3.11-3.328-5.065-4.526
19
- c-1.903-1.165-4.019-2.116-6.289-2.833c-2.247-0.709-4.658-1.216-7.167-1.502C273.727,0.145,271.165,0,268.584,0H239v77h18V49
20
- H269.219z"/>
21
- <rect x="305" fill="#FFFFFF" width="18" height="77"/>
22
- <polygon fill="#FFFFFF" points="362.936,0 333.343,77 409.529,77 378.159,0 "/>
23
- </g>
24
- </g>
25
- </svg>
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 420 80" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><g><rect x="0" y="0" width="420" height="56" style="fill:#f79433;"/><rect x="0" y="56" width="420" height="24" style="fill:#4e8dd8;"/><g><path d="M75.145,70.819c2.37,-3.097 4.173,-6.921 5.111,-11.365c0.91,-4.318 1.498,-9.261 1.498,-14.692l0,-44.762l-62.754,0l0,44.762c0,2.628 0.244,5.333 0.407,8.035c0.168,2.782 0.674,5.515 1.345,8.118c0.68,2.644 1.739,5.173 3.067,7.517c1.363,2.405 3.263,4.526 5.609,6.303c2.319,1.755 5.245,3.163 8.677,4.172c1.617,0.478 3.416,1.093 5.354,1.093l13.856,0c3.071,0 5.797,-1.058 8.131,-2.001c4.042,-1.631 7.305,-4.049 9.699,-7.18Z" style="fill:#fff;fill-rule:nonzero;"/><path d="M151.481,18.701l0,-18.701l-62.754,-0.022l0,18.723l22.246,0l0.02,61.299l17.93,0l-0.02,-61.299l22.578,0Z" style="fill:#fff;fill-rule:nonzero;"/><path d="M229.926,39.999c0,-22.051 -16.979,-39.992 -37.852,-39.992c-20.872,0 -37.851,17.942 -37.851,39.992c0,22.054 16.979,39.994 37.851,39.994c20.873,0 37.852,-17.94 37.852,-39.994Z" style="fill:#fff;fill-rule:nonzero;"/><path d="M269.238,50.909c9.717,0 17.181,-2.066 22.183,-6.395c5.087,-4.399 7.667,-10.942 7.667,-19.575c0,-3.257 -0.393,-5.962 -1.167,-8.476c-0.778,-2.528 -1.883,-4.934 -3.281,-6.814c-1.401,-1.882 -3.098,-3.458 -5.045,-4.703c-1.895,-1.21 -4.003,-2.198 -6.264,-2.943c-2.239,-0.737 -4.64,-1.263 -7.139,-1.56c-2.464,-0.292 -5.016,-0.443 -7.587,-0.443l-29.468,0l0,80l17.93,0l0,-29.091l12.171,0Z" style="fill:#fff;fill-rule:nonzero;"/><rect x="304.879" y="0" width="17.93" height="80" style="fill:#fff;"/><path d="M362.589,0l-29.477,80l75.888,0l-31.247,-80l-15.164,0Z" style="fill:#fff;fill-rule:nonzero;"/></g></g></svg>
@@ -16,6 +16,7 @@
16
16
 
17
17
  <body class="#{attributes['class']}">
18
18
  <div id="header">
19
+ <img src="/_static/utopia.svg" />
19
20
  </div>
20
21
 
21
22
  <div id="page">
@@ -1,23 +1,53 @@
1
1
 
2
+ html {
3
+ font-family: "PT Sans", Verdana, Helvetica, Arial, sans-serif;
4
+ }
5
+ @media (min-width: 48em) {
6
+ html {
7
+ font-size: 16px;
8
+ }
9
+ }
10
+ @media (min-width: 58em) {
11
+ html {
12
+ font-size: 20px;
13
+ }
14
+ }
15
+
2
16
  body {
3
- font-family: Verdana, Helvetica, Arial;
4
- background-color: #ccc;
5
- padding: 50px;
17
+ padding: 0;
18
+ margin: 0;
19
+
20
+ background-color: #fafafa;
21
+ }
22
+
23
+ #header {
24
+ margin: 1em 0 1em 0;
25
+
26
+ background-color: white;
27
+
28
+ background-image: url(/_static/utopia-background.svg);
29
+
30
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
31
+ }
32
+
33
+ #header img {
34
+ display: block;
35
+ margin: auto;
36
+ height: 4em;
6
37
  }
7
38
 
8
39
  p {
9
- color: #333;
40
+ color: #555;
10
41
  }
11
42
 
12
43
  p strong {
13
- color: black;
44
+ color: #222;
14
45
  }
15
46
 
16
47
  h1, h2, h3, h4, h5, h6 {
17
- color: #eee;
18
- margin-top: 2em;
19
- margin-bottom: 1em;
20
- text-shadow: 0px 1px 4px rgba(0, 0, 0, 0.7);
48
+ color: #333;
49
+ margin: 2em 1em 1em 1em;
50
+ color: #4E8DD9;
21
51
  }
22
52
 
23
53
  img {
@@ -33,7 +63,7 @@ a:hover {
33
63
  }
34
64
 
35
65
  p, dl, h3 {
36
- margin: 1em;
66
+ margin: 2em;
37
67
  }
38
68
 
39
69
  h3 {
@@ -44,27 +74,14 @@ ul {
44
74
  margin-bottom: 1em;
45
75
  }
46
76
 
47
- h3, h4, h5, h6 {
77
+ h2, h3, h4, h5, h6 {
48
78
  font-weight: normal;
49
79
  }
50
80
 
51
81
  body.front h1 {
52
82
  font-weight: normal;
53
- font-size: 60pt;
54
- color: white;
55
- text-shadow:
56
- 0 1px 0 #ccc,
57
- 0 2px 0 #c9c9c9,
58
- 0 3px 0 #bbb,
59
- 0 4px 0 #b9b9b9,
60
- 0 5px 0 #aaa,
61
- 0 6px 1px rgba(0,0,0,.1),
62
- 0 0 5px rgba(0,0,0,.1),
63
- 0 1px 3px rgba(0,0,0,.3),
64
- 0 3px 5px rgba(0,0,0,.2),
65
- 0 5px 10px rgba(0,0,0,.25),
66
- 0 10px 10px rgba(0,0,0,.2),
67
- 0 20px 20px rgba(0,0,0,.15);
68
-
83
+ font-size: 300%;
84
+ color: #F89432;
85
+
69
86
  text-align: center;
70
87
  }
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 10 80" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><rect x="0" y="0" width="10" height="56" style="fill:#f79433;"/><rect x="0" y="56" width="10" height="24" style="fill:#4e8dd8;"/></svg>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg width="100%" height="100%" viewBox="0 0 420 80" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><g><rect x="0" y="0" width="420" height="56" style="fill:#f79433;"/><rect x="0" y="56" width="420" height="24" style="fill:#4e8dd8;"/><g><path d="M75.145,70.819c2.37,-3.097 4.173,-6.921 5.111,-11.365c0.91,-4.318 1.498,-9.261 1.498,-14.692l0,-44.762l-62.754,0l0,44.762c0,2.628 0.244,5.333 0.407,8.035c0.168,2.782 0.674,5.515 1.345,8.118c0.68,2.644 1.739,5.173 3.067,7.517c1.363,2.405 3.263,4.526 5.609,6.303c2.319,1.755 5.245,3.163 8.677,4.172c1.617,0.478 3.416,1.093 5.354,1.093l13.856,0c3.071,0 5.797,-1.058 8.131,-2.001c4.042,-1.631 7.305,-4.049 9.699,-7.18Z" style="fill:#fff;fill-rule:nonzero;"/><path d="M151.481,18.701l0,-18.701l-62.754,-0.022l0,18.723l22.246,0l0.02,61.299l17.93,0l-0.02,-61.299l22.578,0Z" style="fill:#fff;fill-rule:nonzero;"/><path d="M229.926,39.999c0,-22.051 -16.979,-39.992 -37.852,-39.992c-20.872,0 -37.851,17.942 -37.851,39.992c0,22.054 16.979,39.994 37.851,39.994c20.873,0 37.852,-17.94 37.852,-39.994Z" style="fill:#fff;fill-rule:nonzero;"/><path d="M269.238,50.909c9.717,0 17.181,-2.066 22.183,-6.395c5.087,-4.399 7.667,-10.942 7.667,-19.575c0,-3.257 -0.393,-5.962 -1.167,-8.476c-0.778,-2.528 -1.883,-4.934 -3.281,-6.814c-1.401,-1.882 -3.098,-3.458 -5.045,-4.703c-1.895,-1.21 -4.003,-2.198 -6.264,-2.943c-2.239,-0.737 -4.64,-1.263 -7.139,-1.56c-2.464,-0.292 -5.016,-0.443 -7.587,-0.443l-29.468,0l0,80l17.93,0l0,-29.091l12.171,0Z" style="fill:#fff;fill-rule:nonzero;"/><rect x="304.879" y="0" width="17.93" height="80" style="fill:#fff;"/><path d="M362.589,0l-29.477,80l75.888,0l-31.247,-80l-15.164,0Z" style="fill:#fff;fill-rule:nonzero;"/></g></g></svg>
@@ -73,7 +73,7 @@ module Utopia::Content::ProcessorSpec
73
73
  [:tag_begin, foo_tag],
74
74
  [:cdata, "Bob &amp; Barley"],
75
75
  [:cdata, "<!-- Comment -->"],
76
- [:cdata, "Hello &amp; World"],
76
+ [:cdata, "<![CDATA[Hello & World]]>"],
77
77
  [:tag_end, foo_tag],
78
78
  ]
79
79
 
@@ -73,5 +73,15 @@ module Utopia::Controller::MiddlewareSpec
73
73
  expect(last_response.status).to be == 302
74
74
  expect(last_response.headers['Location']).to be == 'bar'
75
75
  end
76
+
77
+ # This was a bug, where by the controller URI_PATH was being mutated by Controller#invoke_controllers.
78
+ it "should give the correct URI_PATH" do
79
+ get '/redirect/test/bar'
80
+ expect(last_response.status).to be == 200
81
+
82
+ get '/redirect/test/foo'
83
+ expect(last_response.status).to be == 200
84
+ expect(last_response.body).to be == '/redirect'
85
+ end
76
86
  end
77
87
  end
@@ -1,4 +1,4 @@
1
1
 
2
- use Utopia::Controller, root: File.expand_path('middleware_spec', __dir__)
2
+ use Utopia::Controller, root: File.expand_path('middleware_spec', __dir__), cache_controllers: true
3
3
 
4
4
  run lambda {|env| [404, {}, []]}
@@ -0,0 +1,9 @@
1
+
2
+ on '**' do |request, path|
3
+ #puts "**: #{URI_PATH.inspect}"
4
+
5
+ if path.include? 'foo'
6
+ # This should ALWAYS give /redirect
7
+ succeed! content: URI_PATH.to_s
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+
2
+ on 'bar' do |request, path|
3
+ # puts "bar: #{URI_PATH.inspect}"
4
+
5
+ succeed!
6
+ end
@@ -57,7 +57,7 @@ module Utopia::Controller::RewriteSpec
57
57
  end
58
58
 
59
59
  it "should match path prefix and extract parameters" do
60
- request, path, variables = mock_request("/10/summary/20/edit")
60
+ request, path = mock_request("/10/summary/20/edit")
61
61
  relative_path = path - controller.class.uri_path
62
62
 
63
63
  controller.process!(request, relative_path)
@@ -68,7 +68,7 @@ module Utopia::Controller::RewriteSpec
68
68
  end
69
69
 
70
70
  it "should allow rewrite to fail request" do
71
- request, path, variables = mock_request("/fail")
71
+ request, path = mock_request("/fail")
72
72
  relative_path = path - controller.class.uri_path
73
73
 
74
74
  response = controller.process!(request, relative_path)
@@ -92,6 +92,7 @@ module Utopia::Controller::SequenceSpec
92
92
  expect(result).to be == [400, {}, ["Bad Request"]]
93
93
 
94
94
  result = controller.process!(request, Utopia::Path["/variable"])
95
+ expect(result).to be == nil
95
96
  expect(variables.to_hash).to be == {"variable"=>:value}
96
97
  end
97
98
 
@@ -110,6 +111,7 @@ module Utopia::Controller::SequenceSpec
110
111
  variables << controller
111
112
 
112
113
  result = controller.process!(request, Utopia::Path["/foo/comment/post"])
114
+ expect(result).to be nil
113
115
  expect(variables['sequence']).to be == 'EB'
114
116
  end
115
117
 
@@ -119,6 +121,7 @@ module Utopia::Controller::SequenceSpec
119
121
  variables << controller
120
122
 
121
123
  result = controller.process!(request, Utopia::Path["/comment/delete"])
124
+ expect(result).to be nil
122
125
  expect(variables['sequence']).to be == 'EDC'
123
126
  end
124
127
 
@@ -128,6 +131,7 @@ module Utopia::Controller::SequenceSpec
128
131
  variables << controller
129
132
 
130
133
  result = controller.process!(request, Utopia::Path["/foo"])
134
+ expect(result).to be nil
131
135
  expect(variables['sequence']).to be == 'EF'
132
136
  end
133
137
  end
@@ -123,7 +123,6 @@ module Utopia::PathSpec
123
123
 
124
124
  it "shouldn't expand absolute paths" do
125
125
  root = Utopia::Path['/root']
126
- path = Utopia::Path["dir/foo.html"]
127
126
 
128
127
  expect(root.expand(root)).to be == root
129
128
  end
@@ -37,10 +37,11 @@ module Utopia::StaticSpec
37
37
  end
38
38
 
39
39
  it "should return partial content" do
40
- get "/test.txt", {}, 'HTTP_RANGE' => 'bytes=0-4'
40
+ get "/test.txt", {}, 'HTTP_RANGE' => 'bytes=1-4'
41
41
 
42
42
  expect(last_response.status).to be == 206
43
- expect(last_response.body).to be == "Hello"
43
+ expect(last_response.content_length).to be == 4
44
+ expect(last_response.body).to be == "ello"
44
45
  end
45
46
  end
46
47
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utopia
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-10 00:00:00.000000000 Z
11
+ date: 2016-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: trenni
@@ -220,6 +220,8 @@ files:
220
220
  - setup/site/pages/_page.xnode
221
221
  - setup/site/pages/_static/icon.png
222
222
  - setup/site/pages/_static/site.css
223
+ - setup/site/pages/_static/utopia-background.svg
224
+ - setup/site/pages/_static/utopia.svg
223
225
  - setup/site/pages/errors/exception.xnode
224
226
  - setup/site/pages/errors/file-not-found.xnode
225
227
  - setup/site/pages/links.yaml
@@ -261,6 +263,8 @@ files:
261
263
  - spec/utopia/controller/middleware_spec/controller/index.xnode
262
264
  - spec/utopia/controller/middleware_spec/controller/nested/controller.rb
263
265
  - spec/utopia/controller/middleware_spec/empty/controller.rb
266
+ - spec/utopia/controller/middleware_spec/redirect/controller.rb
267
+ - spec/utopia/controller/middleware_spec/redirect/test/controller.rb
264
268
  - spec/utopia/controller/rewrite_spec.rb
265
269
  - spec/utopia/controller/sequence_spec.rb
266
270
  - spec/utopia/exception_handler_spec.rb
@@ -350,6 +354,8 @@ test_files:
350
354
  - spec/utopia/controller/middleware_spec/controller/index.xnode
351
355
  - spec/utopia/controller/middleware_spec/controller/nested/controller.rb
352
356
  - spec/utopia/controller/middleware_spec/empty/controller.rb
357
+ - spec/utopia/controller/middleware_spec/redirect/controller.rb
358
+ - spec/utopia/controller/middleware_spec/redirect/test/controller.rb
353
359
  - spec/utopia/controller/rewrite_spec.rb
354
360
  - spec/utopia/controller/sequence_spec.rb
355
361
  - spec/utopia/exception_handler_spec.rb