responders_backport 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ # Version 0.1.2
2
+
3
+ Changes from InheritedResources v1.0 branch:
4
+ * Handle some edge cases in respond_to.
5
+ * Fix mime negotiation if no specific format is requested.
6
+
1
7
  # Version 0.1.1
2
8
 
3
9
  * attr_reader :response added.
@@ -136,17 +136,14 @@ module ActionController #:nodoc:
136
136
  def negotiate_mime
137
137
  @mime_type_priority.each do |priority|
138
138
  if priority == Mime::ALL
139
- return @order.first
139
+ return @order.find { |m| m != Mime::ALL } || Mime::SET.first
140
+ elsif @order.include?(Mime::ALL)
141
+ return @mime_type_priority.find { |m| m != Mime::ALL } || Mime::SET.first
140
142
  elsif @order.include?(priority)
141
143
  return priority
142
144
  end
143
145
  end
144
146
 
145
- if @order.include?(Mime::ALL)
146
- return Mime::SET.first if @mime_type_priority.first == Mime::ALL
147
- return @mime_type_priority.first
148
- end
149
-
150
147
  nil
151
148
  end
152
149
  end
@@ -1,3 +1,3 @@
1
1
  module RespondersBackport
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
@@ -55,6 +55,15 @@ end
55
55
  class SuperProjectsController < ProjectsController
56
56
  end
57
57
 
58
+ class NonInheritedResourcesController < ActionController::Base
59
+ def index
60
+ respond_to do |format|
61
+ format.xml { render :text => 'Render XML' }
62
+ format.any { render :text => 'Render HTML' }
63
+ end
64
+ end
65
+ end
66
+
58
67
  class RespondToFunctionalTest < ActionController::TestCase
59
68
  tests ProjectsController
60
69
 
@@ -153,3 +162,13 @@ class RespondToFunctionalTest < ActionController::TestCase
153
162
  assert_equal 'Render HTML', @response.body.strip
154
163
  end
155
164
  end
165
+
166
+ class RespondToFunctionalStandardControllerTest < ActionController::TestCase
167
+ tests NonInheritedResourcesController
168
+
169
+ def test_respond_with_no_specific_format
170
+ @request.accept = 'application/xml,application/xhtml+xml,text/html'
171
+ get :index
172
+ assert_equal 'Render HTML', @response.body.strip
173
+ end
174
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - "George Guimar\xC3\xA3es"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-03-15 00:00:00 -03:00
18
+ date: 2010-03-16 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies: []
21
21