5
5
# COVERAGE=true bundle exec rake test
6
6
7
7
# To test on a specific rails version use this:
8
- # export RAILS_VERSION=4.2.6; bundle update rails; bundle exec rake test
9
- # export RAILS_VERSION=5.0.0; bundle update rails; bundle exec rake test
10
- # export RAILS_VERSION=5.1.0; bundle update rails; bundle exec rake test
11
- # export RAILS_VERSION=6.0.0.beta1; bundle update rails; bundle exec rake test
8
+ # export RAILS_VERSION=5.2.4.4; bundle update; bundle exec rake test
9
+ # export RAILS_VERSION=6.0.3.4; bundle update; bundle exec rake test
10
+ # export RAILS_VERSION=6.1.1; bundle update; bundle exec rake test
12
11
13
- # We are no longer having Travis test Rails 4.1.x ., but you can try it with:
14
- # export RAILS_VERSION=4.1.0 ; bundle update rails; bundle exec rake test
12
+ # We are no longer having Travis test Rails 4.2.11 ., but you can try it with:
13
+ # export RAILS_VERSION=4.2.11 ; bundle update rails; bundle exec rake test
15
14
16
15
# To Switch rails versions and run a particular test order:
17
- # export RAILS_VERSION=4.2.6 ; bundle update rails ; bundle exec rake TESTOPTS="--seed=39333" test
16
+ # export RAILS_VERSION=6.1.1 ; bundle update; bundle exec rake TESTOPTS="--seed=39333" test
18
17
19
18
if ENV [ 'COVERAGE' ]
20
19
SimpleCov . start do
@@ -60,13 +59,11 @@ class TestApp < Rails::Application
60
59
config . active_record . schema_format = :none
61
60
config . active_support . test_order = :random
62
61
63
- if Rails ::VERSION ::MAJOR >= 5
64
- config . active_support . halt_callback_chains_on_return_false = false
65
- config . active_record . time_zone_aware_types = [ :time , :datetime ]
66
- config . active_record . belongs_to_required_by_default = false
67
- if Rails ::VERSION ::MINOR >= 2
68
- config . active_record . sqlite3 . represent_boolean_as_integer = true
69
- end
62
+ config . active_support . halt_callback_chains_on_return_false = false
63
+ config . active_record . time_zone_aware_types = [ :time , :datetime ]
64
+ config . active_record . belongs_to_required_by_default = false
65
+ unless Rails ::VERSION ::MAJOR == 5 && Rails ::VERSION ::MINOR < 2
66
+ config . active_record . sqlite3 . represent_boolean_as_integer = true
70
67
end
71
68
end
72
69
@@ -86,116 +83,80 @@ class Engine < ::Rails::Engine
86
83
end
87
84
88
85
# Monkeypatch ActionController::TestCase to delete the RAW_POST_DATA on subsequent calls in the same test.
89
- if Rails ::VERSION ::MAJOR >= 5
90
- module ClearRawPostHeader
91
- def process ( action , **args )
92
- @request . delete_header 'RAW_POST_DATA'
93
- super action , **args
94
- end
95
- end
96
-
97
- class ActionController ::TestCase
98
- prepend ClearRawPostHeader
86
+ module ClearRawPostHeader
87
+ def process ( action , **args )
88
+ @request . delete_header 'RAW_POST_DATA'
89
+ super action , **args
99
90
end
100
91
end
101
92
102
- # Tests are now using the rails 5 format for the http methods. So for rails 4 we will simply convert them back
103
- # in a standard way.
104
- if Rails ::VERSION ::MAJOR < 5
105
- module Rails4ActionControllerProcess
106
- def process ( *args )
107
- if args [ 2 ] && args [ 2 ] [ :params ]
108
- args [ 2 ] = args [ 2 ] [ :params ]
109
- end
110
- super
111
- end
112
- end
113
- class ActionController ::TestCase
114
- prepend Rails4ActionControllerProcess
115
- end
116
-
117
- module ActionDispatch
118
- module Integration #:nodoc:
119
- module Rails4IntegrationProcess
120
- def process ( method , path , parameters = nil , headers_or_env = nil )
121
- params = parameters . nil? ? nil : parameters [ :params ]
122
- headers = parameters . nil? ? nil : parameters [ :headers ]
123
- super method , path , params , headers
124
- end
125
- end
126
-
127
- class Session
128
- prepend Rails4IntegrationProcess
129
- end
130
- end
131
- end
93
+ class ActionController ::TestCase
94
+ prepend ClearRawPostHeader
132
95
end
133
96
134
97
# Patch to allow :api_json mime type to be treated as JSON
135
98
# Otherwise it is run through `to_query` and empty arrays are dropped.
136
- if Rails ::VERSION ::MAJOR >= 5
137
- module ActionController
138
- class TestRequest < ActionDispatch ::TestRequest
139
- def assign_parameters ( routes , controller_path , action , parameters , generated_path , query_string_keys )
140
- non_path_parameters = { }
141
- path_parameters = { }
142
-
143
- parameters . each do |key , value |
144
- if query_string_keys . include? ( key )
145
- non_path_parameters [ key ] = value
99
+ module ActionController
100
+ class TestRequest < ActionDispatch ::TestRequest
101
+ def assign_parameters ( routes , controller_path , action , parameters , generated_path , query_string_keys )
102
+ non_path_parameters = { }
103
+ path_parameters = { }
104
+
105
+ parameters . each do |key , value |
106
+ if query_string_keys . include? ( key )
107
+ non_path_parameters [ key ] = value
108
+ else
109
+ if value . is_a? ( Array )
110
+ value = value . map ( &:to_param )
146
111
else
147
- if value . is_a? ( Array )
148
- value = value . map ( &:to_param )
149
- else
150
- value = value . to_param
151
- end
152
-
153
- path_parameters [ key ] = value
112
+ value = value . to_param
154
113
end
114
+
115
+ path_parameters [ key ] = value
155
116
end
117
+ end
156
118
157
- if get?
158
- if self . query_string . blank?
159
- self . query_string = non_path_parameters . to_query
160
- end
119
+ if get?
120
+ if self . query_string . blank?
121
+ self . query_string = non_path_parameters . to_query
122
+ end
123
+ else
124
+ if ENCODER . should_multipart? ( non_path_parameters )
125
+ self . content_type = ENCODER . content_type
126
+ data = ENCODER . build_multipart non_path_parameters
161
127
else
162
- if ENCODER . should_multipart? ( non_path_parameters )
163
- self . content_type = ENCODER . content_type
164
- data = ENCODER . build_multipart non_path_parameters
165
- else
166
- fetch_header ( 'CONTENT_TYPE' ) do |k |
167
- set_header k , 'application/x-www-form-urlencoded'
168
- end
169
-
170
- # parser = ActionDispatch::Http::Parameters::DEFAULT_PARSERS[Mime::Type.lookup(fetch_header('CONTENT_TYPE'))]
171
-
172
- case content_mime_type . to_sym
173
- when nil
174
- raise "Unknown Content-Type: #{ content_type } "
175
- when :json , :api_json
176
- data = ActiveSupport ::JSON . encode ( non_path_parameters )
177
- when :xml
178
- data = non_path_parameters . to_xml
179
- when :url_encoded_form
180
- data = non_path_parameters . to_query
181
- else
182
- @custom_param_parsers [ content_mime_type ] = -> ( _ ) { non_path_parameters }
183
- data = non_path_parameters . to_query
184
- end
128
+ fetch_header ( 'CONTENT_TYPE' ) do |k |
129
+ set_header k , 'application/x-www-form-urlencoded'
185
130
end
186
131
187
- set_header 'CONTENT_LENGTH' , data . length . to_s
188
- set_header 'rack.input' , StringIO . new ( data )
132
+ # parser = ActionDispatch::Http::Parameters::DEFAULT_PARSERS[Mime::Type.lookup(fetch_header('CONTENT_TYPE'))]
133
+
134
+ case content_mime_type . to_sym
135
+ when nil
136
+ raise "Unknown Content-Type: #{ content_type } "
137
+ when :json , :api_json
138
+ data = ActiveSupport ::JSON . encode ( non_path_parameters )
139
+ when :xml
140
+ data = non_path_parameters . to_xml
141
+ when :url_encoded_form
142
+ data = non_path_parameters . to_query
143
+ else
144
+ @custom_param_parsers [ content_mime_type ] = -> ( _ ) { non_path_parameters }
145
+ data = non_path_parameters . to_query
146
+ end
189
147
end
190
148
191
- fetch_header ( "PATH_INFO" ) do |k |
192
- set_header k , generated_path
193
- end
194
- path_parameters [ :controller ] = controller_path
195
- path_parameters [ :action ] = action
149
+ set_header 'CONTENT_LENGTH' , data . length . to_s
150
+ set_header 'rack.input' , StringIO . new ( data )
151
+ end
196
152
197
- self . path_parameters = path_parameters
153
+ fetch_header ( "PATH_INFO" ) do |k |
154
+ set_header k , generated_path
198
155
end
156
+ path_parameters [ :controller ] = controller_path
157
+ path_parameters [ :action ] = action
158
+
159
+ self . path_parameters = path_parameters
199
160
end
200
161
end
201
162
end
0 commit comments