trusty-layouts-extension 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,344 +0,0 @@
1
- require 'test_helper'
2
- require 'application_checker'
3
- require 'fileutils'
4
-
5
- tmp_dir = File.expand_path("#{File.dirname(__FILE__)}/fixtures/tmp")
6
-
7
- if defined? BASE_ROOT
8
- BASE_ROOT.replace tmp_dir
9
- else
10
- BASE_ROOT = tmp_dir
11
- end
12
- FileUtils.mkdir_p BASE_ROOT
13
-
14
- # Stub out methods on upgrader class
15
- module Rails
16
- module Upgrading
17
- class ApplicationChecker
18
- attr_reader :alerts, :culprits
19
-
20
- def base_path
21
- BASE_ROOT + "/"
22
- end
23
-
24
- def in_rails_app?
25
- true
26
- end
27
-
28
- def initialize
29
- @alerts = {}
30
- @culprits = {}
31
- end
32
-
33
- def alert(title, text, more_info_url, culprits)
34
- @alerts[title] = [text, more_info_url]
35
- @culprits[title] = culprits
36
- end
37
- end
38
- end
39
- end
40
-
41
- class ApplicationCheckerTest < ActiveSupport::TestCase
42
- def setup
43
- @checker = Rails::Upgrading::ApplicationChecker.new
44
- @old_dir = Dir.pwd
45
-
46
- Dir.chdir(BASE_ROOT)
47
- end
48
-
49
- def test_check_ar_methods_in_controller
50
- make_file("app/controllers", "post_controller.rb", "Post.find(:all)")
51
- @checker.check_ar_methods
52
-
53
- assert @checker.alerts.has_key?("Soon-to-be-deprecated ActiveRecord calls")
54
- end
55
-
56
- def test_check_ar_methods_in_models
57
- make_file("app/models", "post.rb", "Post.find(:all)")
58
- @checker.check_ar_methods
59
-
60
- key = "Soon-to-be-deprecated ActiveRecord calls"
61
- assert @checker.alerts.has_key?(key)
62
- assert_equal "app/models/post.rb", @checker.culprits[key].first
63
- end
64
-
65
- def test_check_svn_subdirs_are_not_included
66
- make_file("app/models/.svn/text-base", "foo.rb.tmp", "Post.find(:all)")
67
- @checker.check_ar_methods
68
- assert @checker.alerts.empty?
69
- end
70
-
71
- def test_check_validation_on_methods
72
- make_file("app/models", "post.rb", "validate_on_create :comments_valid?")
73
- @checker.check_validation_on_methods
74
-
75
- assert @checker.alerts.has_key?("Updated syntax for validate_on_* methods")
76
- end
77
-
78
- def test_check_before_validation_on_methods
79
- make_file("app/models", "post.rb", "before_validation_on_create :comments_valid?")
80
- @checker.check_before_validation_on_methods
81
-
82
- assert @checker.alerts.has_key?("Updated syntax for before_validation_on_* methods")
83
- end
84
-
85
- def test_named_scope_left_over
86
- make_file("app/models", "post.rb", "named_scope :failure")
87
- @checker.check_ar_methods
88
-
89
- assert @checker.alerts.has_key?("named_scope is now just scope")
90
- end
91
-
92
- def test_check_routes
93
- make_file("config/", "routes.rb", " map.connect 'fail'")
94
- @checker.check_routes
95
-
96
- assert @checker.alerts.has_key?("Old router API")
97
- end
98
-
99
- def test_check_for_old_test_help
100
- make_file("test/", "test_helper.rb", " require 'test_help'")
101
- @checker.check_test_help
102
-
103
- assert @checker.alerts.has_key?("Deprecated test_help path")
104
- end
105
-
106
- def test_check_for_old_test_help_with_double_quotes
107
- make_file("test/", "test_helper.rb", " require \"test_help\"")
108
- @checker.check_test_help
109
-
110
- assert @checker.alerts.has_key?("Deprecated test_help path")
111
- end
112
-
113
- def test_check_for_old_test_help_doesnt_see_test_helper
114
- make_file("test/", "test_helper.rb", " require 'test_helper'")
115
- @checker.check_test_help
116
-
117
- assert !@checker.alerts.has_key?("Deprecated test_help path")
118
- end
119
-
120
- def test_check_lack_of_app_dot_rb
121
- @checker.check_environment
122
-
123
- assert @checker.alerts.has_key?("New file needed: config/application.rb")
124
- end
125
-
126
- def test_check_environment_syntax
127
- make_file("config/", "environment.rb", "config.frameworks = []")
128
- @checker.check_environment
129
-
130
- assert @checker.alerts.has_key?("Old environment.rb")
131
- end
132
-
133
- def test_check_gems
134
- make_file("config/", "environment.rb", "config.gem 'rails'")
135
- @checker.check_gems
136
-
137
- assert @checker.alerts.has_key?("Old gem bundling (config.gems)")
138
- end
139
-
140
- def test_check_gems_finds_nothing
141
- @checker.check_gems
142
-
143
- assert_equal false, @checker.alerts.has_key?("Old gem bundling (config.gems)")
144
- end
145
-
146
- def test_check_mailer_finds_nothing
147
- @checker.check_mailers
148
-
149
- assert_equal false, @checker.alerts.has_key?("Old ActionMailer class API")
150
- end
151
-
152
- def test_check_mailer_syntax
153
- make_file("app/models/", "notifications.rb", "def signup\nrecipients @users\n end")
154
- @checker.check_mailers
155
-
156
- assert @checker.alerts.has_key?("Old ActionMailer class API")
157
- end
158
-
159
- def test_check_mailer_syntax_from
160
- make_file("app/models/", "notifications.rb", "def signup\nfrom @user\n end")
161
- @checker.check_mailers
162
-
163
- assert @checker.alerts.has_key?("Old ActionMailer class API")
164
- end
165
-
166
- def test_check_mailer_syntax_subject
167
- make_file("app/models/", "notifications.rb", "def signup\nsubject @subject\n end")
168
- @checker.check_mailers
169
-
170
- assert @checker.alerts.has_key?("Old ActionMailer class API")
171
- end
172
-
173
- def test_check_mailer_syntax_attachment
174
- make_file("app/models/", "notifications.rb", "def signup\nattachment 'application/pdf' do |a|\n end")
175
- @checker.check_mailers
176
-
177
- assert @checker.alerts.has_key?("Old ActionMailer class API")
178
- end
179
-
180
- def test_new_check_mailer_syntax_from
181
- make_file("app/models/", "notifications.rb", "def signup\n:from => @users\n end")
182
- @checker.check_mailers
183
-
184
- assert ! @checker.alerts.has_key?("Old ActionMailer class API")
185
- end
186
-
187
- def test_new_check_mailer_syntax_subject
188
- make_file("app/models/", "notifications.rb", "def signup\n:subject => @users\n end")
189
- @checker.check_mailers
190
-
191
- assert ! @checker.alerts.has_key?("Old ActionMailer class API")
192
- end
193
-
194
- def test_new_check_mailer_syntax_attachments
195
- make_file("app/models/", "notifications.rb", "def signup\nattachments['an-image.jp'] = File.read('an-image.jpg')\n end")
196
- @checker.check_mailers
197
-
198
- assert ! @checker.alerts.has_key?("Old ActionMailer class API")
199
- end
200
-
201
- def test_check_mailer_api
202
- make_file("app/controllers/", "thing_controller.rb", "def signup\n Notifications.deliver_signup\n end")
203
- @checker.check_mailers
204
-
205
- assert @checker.alerts.has_key?("Deprecated ActionMailer API")
206
- end
207
-
208
- def test_check_generators
209
- make_file("vendor/plugins/thing/generators/thing/", "thing_generator.rb", "def manifest\n m.whatever\n end")
210
- @checker.check_generators
211
-
212
- assert @checker.alerts.has_key?("Old Rails generator API")
213
- end
214
-
215
- def test_check_plugins
216
- make_file("vendor/plugins/rspec-rails/", "whatever.rb", "def rspec; end")
217
- @checker.check_plugins
218
-
219
- assert @checker.alerts.has_key?("Known broken plugins")
220
- end
221
-
222
- def test_ignoring_comments
223
- make_file("config/", "routes.rb", "# map.connect 'fail'")
224
- @checker.check_routes
225
-
226
- assert !@checker.alerts.has_key?("Old router API")
227
- end
228
-
229
- def test_check_deprecated_constants_in_app_code
230
- make_file("app/controllers/", "thing_controller.rb", "class ThingController; THING = Rails.env; end;")
231
- @checker.check_deprecated_constants
232
-
233
- assert @checker.alerts.has_key?("Deprecated constant(s)")
234
- end
235
-
236
- def test_check_deprecated_constants_in_lib
237
- make_file("lib/", "extra_thing.rb", "class ExtraThing; THING = Rails.env; end;")
238
- @checker.check_deprecated_constants
239
-
240
- assert @checker.alerts.has_key?("Deprecated constant(s)")
241
- end
242
-
243
- def test_check_deprecated_cookie_finds_nothing
244
- @checker.check_old_cookie_secret
245
- assert_equal false, @checker.alerts.has_key?("Deprecated cookie secret setting")
246
- end
247
-
248
- def test_check_deprecated_cookie_settings
249
- make_file("config/initializers/", "more_settings.rb", "ActionController::Base.cookie_verifier_secret = 'OMG'")
250
- @checker.check_old_cookie_secret
251
-
252
- assert @checker.alerts.has_key?("Deprecated cookie secret setting")
253
- end
254
-
255
- def test_check_deprecated_session_finds_nothing
256
- @checker.check_old_session_secret
257
- assert_equal false, @checker.alerts.has_key?("Deprecated session secret setting")
258
- end
259
-
260
- def test_check_deprecated_session_secret
261
- make_file("config/initializers/", "more_settings.rb", "ActionController::Base.session = {\n:whatever => 'woot'\n}")
262
- @checker.check_old_session_secret
263
-
264
- assert @checker.alerts.has_key?("Deprecated session secret setting")
265
- end
266
-
267
- def test_check_old_session_setting_finds_nothing
268
- @checker.check_old_session_setting
269
- assert_equal false, @checker.alerts.has_key?("Old session store setting")
270
- end
271
-
272
- def test_check_deprecated_session_settings
273
- make_file("config/initializers/", "more_settings.rb", "ActionController::Base.session_store = :cookie\nthings.awesome(:whatever)")
274
- @checker.check_old_session_setting
275
-
276
- assert @checker.alerts.has_key?("Old session store setting")
277
- end
278
-
279
- def test_check_helpers
280
- make_file("app/views/users/", "test.html.erb", "<b>blah blah blah</b><% form_for(:thing) do |f| %> <label>doo dah</label> <%= f.whatever %> <% end %>")
281
- @checker.check_old_helpers
282
-
283
- assert @checker.alerts.has_key?("Deprecated ERb helper calls")
284
-
285
- end
286
-
287
- def test_check_old_helpers_lets_regular_blocks_pass
288
- make_file("app/views/users/", "another_test.html.erb", "<b>blah blah blah</b><% @some_items.each do |item| %> <label>doo dah</label> <%= item %> <% end %>")
289
- @checker.check_old_helpers
290
-
291
- assert_equal @checker.alerts.has_key?("Deprecated ERb helper calls"), false
292
- end
293
-
294
- def test_check_old_helpers_lets_regular_blocks_pass
295
- make_file("app/views/users/", "another_test.html.erb", "<b>blah blah blah</b><% @some_items.each do |item| %> <label>doo dah</label> <%= item %> <% end %>")
296
- @checker.check_old_helpers
297
-
298
- assert_equal false, @checker.alerts.has_key?("Deprecated ERb helper calls")
299
- end
300
-
301
- def test_check_old_ajax_helpers
302
- make_file("app/views/sections", "section.js", "<%= link_to_remote 'section-', :update => 'sections', :url => {:action => :destroy, :controller => 'sections', :id => @section.id } %>")
303
- @checker.check_old_ajax_helpers
304
-
305
- assert @checker.alerts.has_key?("Deprecated AJAX helper calls")
306
- end
307
-
308
- def test_check_old_ajax_helpers
309
- make_file("app/controllers", "application_controller.rb", "filter_parameter_logging :password")
310
- @checker.check_old_filter_parameter
311
-
312
- assert @checker.alerts.has_key?("Deprecated filter_parameter_logging calls")
313
- end
314
-
315
- def test_check_old_ajax_helpers_empty
316
- @checker.check_old_ajax_helpers
317
-
318
- assert ! @checker.alerts.has_key?("Deprecated AJAX helper calls")
319
- end
320
-
321
- def test_check_old_action_mailer_sent_on_setting
322
- make_file("app/models", "mailer.rb", "sent_on Time.now")
323
- @checker.check_old_action_mailer_sent_on_setting
324
-
325
- assert @checker.alerts.has_key?("Deprecated ActionMailer attribute :sent_on")
326
- end
327
-
328
- def teardown
329
- clear_files
330
-
331
- Dir.chdir(@old_dir)
332
- end
333
-
334
- def make_file(where, name=nil, contents=nil)
335
- FileUtils.mkdir_p "#{BASE_ROOT}/#{where}"
336
- File.open("#{BASE_ROOT}/#{where}/#{name}", "w+") do |f|
337
- f.write(contents)
338
- end if name
339
- end
340
-
341
- def clear_files
342
- FileUtils.rm_rf(Dir.glob("#{BASE_ROOT}/*"))
343
- end
344
- end
@@ -1,72 +0,0 @@
1
- require 'test_helper'
2
- require 'gemfile_generator'
3
-
4
- # Stub out methods on upgrader class
5
- module Rails
6
- module Upgrading
7
- class GemfileGenerator
8
- attr_writer :environment_code
9
-
10
- def has_environment?
11
- true
12
- end
13
-
14
- def environment_code
15
- @environment_code
16
- end
17
- end
18
- end
19
- end
20
-
21
- class GemfileGeneratorTest < ActiveSupport::TestCase
22
- PREAMBLE = <<STR
23
- # Edit this Gemfile to bundle your application's dependencies.
24
- # This preamble is the current preamble for Rails 3 apps; edit as needed.
25
- source 'http://rubygems.org'
26
-
27
- gem 'rails', '3.0.6'
28
-
29
- STR
30
-
31
- def test_generates_with_no_gems
32
- generator = Rails::Upgrading::GemfileGenerator.new
33
- generator.environment_code = ""
34
-
35
- assert_equal PREAMBLE, generator.generate_gemfile
36
- end
37
-
38
- def test_generates_with_gem
39
- generator = Rails::Upgrading::GemfileGenerator.new
40
- generator.environment_code = "config.gem 'camping'"
41
-
42
- assert_equal PREAMBLE + "gem 'camping'", generator.generate_gemfile
43
- end
44
-
45
- def test_generates_with_version
46
- generator = Rails::Upgrading::GemfileGenerator.new
47
- generator.environment_code = "config.gem 'camping', :version => '2.1.1'"
48
-
49
- assert_equal PREAMBLE + "gem 'camping', '2.1.1'", generator.generate_gemfile
50
- end
51
-
52
- def test_can_add_sources
53
- generator = Rails::Upgrading::GemfileGenerator.new
54
- generator.environment_code = "config.gem 'camping', :source => 'http://code.whytheluckystiff.net'"
55
-
56
- assert_equal PREAMBLE + "source 'http://code.whytheluckystiff.net'\ngem 'camping'", generator.generate_gemfile
57
- end
58
-
59
- def test_changes_lib_to_new_key
60
- generator = Rails::Upgrading::GemfileGenerator.new
61
- generator.environment_code = "config.gem 'camping', :lib => 'kamping'"
62
-
63
- assert_equal PREAMBLE + "gem 'camping', :require => 'kamping'", generator.generate_gemfile
64
- end
65
-
66
- def test_generates_with_all_options
67
- generator = Rails::Upgrading::GemfileGenerator.new
68
- generator.environment_code = "config.gem 'camping', :lib => 'kamping', :source => 'http://code.whytheluckystiff.net', :version => '2.1.1'"
69
-
70
- assert_equal PREAMBLE + "source 'http://code.whytheluckystiff.net'\ngem 'camping', '2.1.1', :require => 'kamping'", generator.generate_gemfile
71
- end
72
- end
@@ -1,63 +0,0 @@
1
- require 'test_helper'
2
- require 'new_configuration_generator'
3
-
4
- # Stub out methods on upgrader class
5
- module Rails
6
- module Upgrading
7
- class NewConfigurationGenerator
8
- attr_writer :environment_code
9
-
10
- def has_environment?
11
- true
12
- end
13
-
14
- def environment_code
15
- @environment_code
16
- end
17
-
18
- def app_name
19
- "my_application"
20
- end
21
- end
22
- end
23
- end
24
-
25
- class NewConfigurationGeneratorTest < ActiveSupport::TestCase
26
- FRAME = "# Put this in config/application.rb
27
- require File.expand_path('../boot', __FILE__)
28
-
29
- module MyApplication
30
- class Application < Rails::Application
31
- %s
32
- end
33
- end"
34
-
35
- CONFIG = " config.what_have_you = 'thing'
36
- config.action_controller = 'what'"
37
-
38
- CODE = "require 'w/e'
39
-
40
- this_happens_before_the(code)
41
- more_before_the_code!
42
-
43
- Rails::Initializer.run do |config|
44
- %s
45
- end
46
-
47
- this_is_after_the_code
48
- "
49
-
50
- def test_raises_error_with_no_code
51
- generator = Rails::Upgrading::NewConfigurationGenerator.new
52
- generator.environment_code = ""
53
-
54
- assert_raises(RuntimeError) { generator.generate_new_application_rb }
55
- end
56
-
57
- def test_generates_with_code
58
- generator = Rails::Upgrading::NewConfigurationGenerator.new
59
- generator.environment_code = CODE % [CONFIG]
60
-
61
- assert_equal FRAME % [generator.indent(CONFIG)], generator.generate_new_application_rb
62
- end
63
- end
@@ -1,218 +0,0 @@
1
- require 'test_helper'
2
- require 'routes_upgrader'
3
-
4
- # Stub out methods on upgrader class
5
- module Rails
6
- module Upgrading
7
- class RoutesUpgrader
8
- attr_writer :routes_code
9
-
10
- def has_routes_file?
11
- true
12
- end
13
-
14
- def routes_code
15
- @routes_code
16
- end
17
- end
18
-
19
- class RouteGenerator
20
- def app_name
21
- "MyApplication"
22
- end
23
- end
24
- end
25
- end
26
-
27
- class RoutesUpgraderTest < ActiveSupport::TestCase
28
- def setup
29
- Rails::Upgrading::RouteRedrawer.stack = []
30
- end
31
-
32
- def test_generates_routes_file
33
- routes_code = "
34
- ActionController::Routing::Routes.draw do |map|
35
- map.connect '/home', :controller => 'home', :action => 'index'
36
- map.login '/login', :controller => 'sessions', :action => 'new'
37
-
38
- map.resources :hats
39
- map.resource :store
40
- end
41
- "
42
-
43
- new_routes_code = "MyApplication::Application.routes.draw do
44
- match '/home' => 'home#index'
45
- match '/login' => 'sessions#new', :as => :login
46
- resources :hats
47
- resource :store
48
- end
49
- "
50
-
51
- upgrader = Rails::Upgrading::RoutesUpgrader.new
52
- upgrader.routes_code = routes_code
53
-
54
- result = upgrader.generate_new_routes
55
-
56
- assert_equal new_routes_code, result
57
- end
58
-
59
- def test_generates_code_for_regular_route
60
- route = Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about'})
61
- assert_equal "match '/about' => 'static#about'", route.to_route_code
62
- end
63
-
64
- def test_generates_code_for_named_route
65
- route = Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about'}, "about")
66
- assert_equal "match '/about' => 'static#about', :as => :about", route.to_route_code
67
- end
68
-
69
- def test_generates_code_for_namespace
70
- ns = Rails::Upgrading::FakeNamespace.new("static")
71
- # Add a route to the namespace
72
- ns << Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about'})
73
-
74
- assert_equal "namespace :static do\nmatch '/about' => 'static#about'\nend\n", ns.to_route_code
75
- end
76
-
77
- def test_generates_code_for_namespace_with_options
78
- ns = Rails::Upgrading::FakeNamespace.new("static", { :path_prefix => 'prefix' })
79
- # Add a route to the namespace
80
- ns << Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about'})
81
-
82
- assert_equal "namespace :static, :path_prefix => 'prefix' do\nmatch '/about' => 'static#about'\nend\n", ns.to_route_code
83
- end
84
-
85
- def test_generates_code_for_resources
86
- route = Rails::Upgrading::FakeResourceRoute.new("hats")
87
- assert_equal "resources :hats", route.to_route_code
88
- end
89
-
90
- def test_generates_code_for_resources
91
- route = Rails::Upgrading::FakeSingletonResourceRoute.new("hat")
92
- assert_equal "resource :hat", route.to_route_code
93
- end
94
-
95
- def test_generates_code_for_resources_with_block_and_options
96
- routes_code = <<-ROUTES
97
- ActionController::Routing::Routes.draw do |map|
98
- map.resources :people, :collection => {:search => :get} do |p|
99
- p.resource :vuvuzela
100
- end
101
- end
102
- ROUTES
103
-
104
- upgrader = Rails::Upgrading::RoutesUpgrader.new
105
- upgrader.routes_code = routes_code
106
- result = upgrader.generate_new_routes
107
-
108
- assert_equal "MyApplication::Application.routes.draw do\n resources :people do\n collection do\n get :search\n end\n \n resource :vuvuzela\n end\n\nend\n", result
109
- end
110
-
111
- def test_generates_code_for_resources_with_special_methods
112
- route = Rails::Upgrading::FakeResourceRoute.new("hats", {:member => {:wear => :get}, :collection => {:toss => :post}})
113
- assert_equal "resources :hats do\ncollection do\npost :toss\nend\nmember do\nget :wear\nend\n\nend\n", route.to_route_code
114
- end
115
-
116
- def test_generates_code_for_resources_with_multiple_special_methods_per_name
117
- route = Rails::Upgrading::FakeResourceRoute.new("hats", {:member => {:wear => [:get, :put]}, :collection => {:toss => [:get, :post]}})
118
- assert_equal "resources :hats do\ncollection do\nget :toss\npost :toss\nend\nmember do\nget :wear\nput :wear\nend\n\nend\n", route.to_route_code
119
- end
120
-
121
- def test_generates_code_for_route_with_extra_params
122
- route = Rails::Upgrading::FakeRoute.new("/about", {:controller => 'static', :action => 'about', :something => 'extra'})
123
- assert_equal "match '/about' => 'static#about', :something => 'extra'", route.to_route_code
124
- end
125
-
126
- def test_generates_code_for_route_with_requirements
127
- route = Rails::Upgrading::FakeRoute.new("/foo", {:controller => 'foo', :action => 'bar', :requirements => {:digit => /%d/}})
128
- assert_equal "match '/foo' => 'foo#bar', :constraints => { :digit => /%d/ }", route.to_route_code
129
- end
130
-
131
- def test_generates_code_for_root
132
- routes_code = "
133
- ActionController::Routing::Routes.draw do |map|
134
- map.root :controller => 'home', :action => 'index'
135
- end
136
- "
137
-
138
- new_routes_code = "MyApplication::Application.routes.draw do
139
- match '/' => 'home#index'
140
- end
141
- "
142
-
143
- upgrader = Rails::Upgrading::RoutesUpgrader.new
144
- upgrader.routes_code = routes_code
145
-
146
- result = upgrader.generate_new_routes
147
-
148
- assert_equal new_routes_code, result
149
- end
150
-
151
- def test_generates_code_for_default_route
152
- routes_code = "
153
- ActionController::Routing::Routes.draw do |map|
154
- map.connect ':controller/:action/:id.:format'
155
- map.connect ':controller/:action/:id'
156
- end
157
- "
158
-
159
- new_routes_code = "MyApplication::Application.routes.draw do
160
- match '/:controller(/:action(/:id))'
161
- end
162
- "
163
-
164
- upgrader = Rails::Upgrading::RoutesUpgrader.new
165
- upgrader.routes_code = routes_code
166
-
167
- result = upgrader.generate_new_routes
168
-
169
- assert_equal new_routes_code, result
170
- end
171
-
172
-
173
- def test_preserves_resources_except_option
174
- route = Rails::Upgrading::FakeResourceRoute.new("hats", :except => [:index])
175
- assert_equal "resources :hats, :except => [:index]", route.to_route_code
176
- end
177
-
178
- def test_preserves_resources_only_option
179
- route = Rails::Upgrading::FakeResourceRoute.new("hats", :only => :show)
180
- assert_equal "resources :hats, :only => :show", route.to_route_code
181
- end
182
-
183
- def test_generates_code_for_delete_route
184
- routes_code = %Q{
185
- ActionController::Routing::Routes.draw do |map|
186
- map.sign_out '/sign_out', :controller => 'sessions', :action => 'destroy', :conditions => {:method => :delete}
187
- end
188
- }
189
-
190
- new_routes_code = %Q{
191
- MyApplication::Application.routes.draw do
192
- match '/sign_out' => 'sessions#destroy', :as => :sign_out, :via => :delete
193
- end
194
- }
195
-
196
- upgrader = Rails::Upgrading::RoutesUpgrader.new
197
- upgrader.routes_code = routes_code
198
- assert_equal new_routes_code.strip, upgrader.generate_new_routes.strip
199
- end
200
-
201
- def test_generates_code_for_delete_route
202
- routes_code = %Q{
203
- ActionController::Routing::Routes.draw do |map|
204
- map.sign_out '/sign_out', :controller => 'sessions', :action => 'destroy', :conditions => {:method => [:delete, :get]}
205
- end
206
- }
207
-
208
- new_routes_code = %Q{
209
- MyApplication::Application.routes.draw do
210
- match '/sign_out' => 'sessions#destroy', :as => :sign_out, :via => [:delete, :get]
211
- end
212
- }
213
-
214
- upgrader = Rails::Upgrading::RoutesUpgrader.new
215
- upgrader.routes_code = routes_code
216
- assert_equal new_routes_code.strip, upgrader.generate_new_routes.strip
217
- end
218
- end
@@ -1,5 +0,0 @@
1
- require 'test/unit'
2
-
3
- require 'rubygems'
4
- require 'active_support'
5
- require 'active_support/test_case'