Permalink
Browse files

a few updates, trying to automatically add a few more mime-types

git-svn-id: https://svn.thoughtbot.com/plugins/what@354 7bbfaf0e-4d1d-0410-9690-a8bb5f8ef2aa
  • Loading branch information...
1 parent deef9bb commit a236f07f926424e2124a39d1a7d44f159a8e0048 dcroak committed Feb 19, 2008
Showing with 107 additions and 1 deletion.
  1. +9 −1 README
  2. +6 −0 lib/what.rb
  3. +84 −0 test/rails_root/log/sqlite3.log
  4. +8 −0 test/what_test.rb
View
10 README
@@ -2,7 +2,7 @@ What
====
What provides boolean instance methods on controllers
-for the following mime-types:
+for the native Rails mime-types:
atom?
css?
@@ -18,6 +18,14 @@ url_encoded_form?
xml?
yaml?
+... and soon will support a few other beauts:
+
+gif?
+iphone?
+mobile?
+pdf?
+png?
+
Examples
========
View
@@ -1,6 +1,12 @@
module What
module ActionControllerHook
+ # Mime::Type.register 'image/gif', :gif
+ # Mime::Type.register 'text/iphone', :iphone
+ # Mime::Type.register 'text/x-mobile', :mobile
+ # Mime::Type.register 'application/pdf', :pdf
+ # Mime::Type.register 'image/png', :png
+
Mime::SET.each do |mime_type|
define_method "#{mime_type.to_sym}?" do
request.format == mime_type
@@ -26,3 +26,87 @@ Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:25:40) [GET]
Parameters: {"action"=>"index", "controller"=>"what"}
Rendering what/index
Completed in 0.00089 (1125 reqs/sec) | Rendering: 0.00078 (87%) | DB: 0.00000 (0%) | 200 OK [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:36:57) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Redirected to http://www.example.com/what/new
+Completed in 0.00213 (468 reqs/sec) | DB: 0.00000 (0%) | 302 Found [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:36:57) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Rendering what/index
+Completed in 0.00097 (1027 reqs/sec) | Rendering: 0.00085 (87%) | DB: 0.00000 (0%) | 200 OK [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:37:47) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Redirected to http://www.example.com/what/new
+Completed in 0.00217 (461 reqs/sec) | DB: 0.00000 (0%) | 302 Found [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:37:47) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Rendering what/index
+Completed in 0.00092 (1089 reqs/sec) | Rendering: 0.00081 (88%) | DB: 0.00000 (0%) | 200 OK [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:38:26) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Redirected to http://www.example.com/what/new
+Completed in 0.00216 (463 reqs/sec) | DB: 0.00000 (0%) | 302 Found [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:38:26) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Rendering what/index
+Completed in 0.00094 (1060 reqs/sec) | Rendering: 0.00082 (87%) | DB: 0.00000 (0%) | 200 OK [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:41:02) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Redirected to http://www.example.com/what/new
+Completed in 0.00213 (470 reqs/sec) | DB: 0.00000 (0%) | 302 Found [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:41:02) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Rendering what/index
+Completed in 0.00094 (1062 reqs/sec) | Rendering: 0.00083 (87%) | DB: 0.00000 (0%) | 200 OK [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:41:41) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Redirected to http://www.example.com/what/new
+Completed in 0.00213 (469 reqs/sec) | DB: 0.00000 (0%) | 302 Found [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:41:41) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Rendering what/index
+Completed in 0.00099 (1008 reqs/sec) | Rendering: 0.00087 (87%) | DB: 0.00000 (0%) | 200 OK [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:47:15) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Redirected to http://www.example.com/what/new
+Completed in 0.00208 (481 reqs/sec) | DB: 0.00000 (0%) | 302 Found [http://www.example.com/what]
+
+
+Processing WhatController#index (for 0.0.0.0 at 2008-02-18 23:47:15) [GET]
+ Session ID:
+ Parameters: {"action"=>"index", "controller"=>"what"}
+Rendering what/index
+Completed in 0.00098 (1016 reqs/sec) | Rendering: 0.00087 (88%) | DB: 0.00000 (0%) | 200 OK [http://www.example.com/what]
View
@@ -20,6 +20,7 @@ def redirect_to_new
WhatController.view_paths = [ File.dirname(__FILE__) + "/fixtures/" ]
class WhatControllerTest < Test::Unit::TestCase
+
def setup
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@@ -39,4 +40,11 @@ def test_csv
get :index
assert_redirected_to new_what_url
end
+
+ # def test_new_convenience_methods
+ # types = [:gif, :iphone, :mobile, :pdf, :png]
+ # types.each do |type|
+ # assert @controller.send("#{type}?"), "ActionController::Base does not have a #{type}? instance method"
+ # end
+ # end
end

0 comments on commit a236f07

Please sign in to comment.