exception2db 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/Rakefile +48 -0
  3. data/app/controllers/exception2db/main_controller.rb +34 -0
  4. data/app/models/e2db.rb +68 -0
  5. data/app/views/exception2db/main/index.html.erb +15 -0
  6. data/app/views/exception2db/main/show.html.erb +77 -0
  7. data/app/views/layouts/exception2db.html.erb +25 -0
  8. data/config/routes.rb +12 -0
  9. data/init.rb +23 -0
  10. data/lib/css/style.css +377 -0
  11. data/lib/exception2db.rb +27 -0
  12. data/lib/exception2db/config.rb +22 -0
  13. data/lib/exception2db/railtie.rb +12 -0
  14. data/lib/exception2db/util.rb +17 -0
  15. data/lib/exception2db/version.rb +3 -0
  16. data/lib/js/app.js +1 -0
  17. data/spec/exception2db_spec.rb +74 -0
  18. data/spec/spec_helper.rb +175 -0
  19. data/test/error_xml.rb +134 -0
  20. data/test/rails_root/Rakefile +10 -0
  21. data/test/rails_root/app/controllers/application_controller.rb +10 -0
  22. data/test/rails_root/app/controllers/articles_controller.rb +7 -0
  23. data/test/rails_root/app/models/article.rb +25 -0
  24. data/test/rails_root/app/models/city.rb +15 -0
  25. data/test/rails_root/app/models/comment.rb +13 -0
  26. data/test/rails_root/app/models/tech_magazine.rb +2 -0
  27. data/test/rails_root/app/models/vehicle/car.rb +4 -0
  28. data/test/rails_root/app/models/vehicle/door.rb +3 -0
  29. data/test/rails_root/app/models/vehicle/engine.rb +3 -0
  30. data/test/rails_root/config/boot.rb +110 -0
  31. data/test/rails_root/config/database.yml +14 -0
  32. data/test/rails_root/config/environment.rb +17 -0
  33. data/test/rails_root/config/environments/cucumber.rb +26 -0
  34. data/test/rails_root/config/environments/development.rb +0 -0
  35. data/test/rails_root/config/environments/test.rb +0 -0
  36. data/test/rails_root/config/initializers/new_rails_defaults.rb +19 -0
  37. data/test/rails_root/config/routes.rb +6 -0
  38. data/test/rails_root/db/migrate/20090809061114_create_tables.rb +15 -0
  39. data/test/rails_root/db/schema.rb +74 -0
  40. data/test/rails_root/db/sqlite3.db +0 -0
  41. data/test/rails_root/log/cucumber.log +3531 -0
  42. data/test/rails_root/log/development.log +445 -0
  43. data/test/rails_root/log/test.log +59223 -0
  44. data/test/rails_root/script/console +3 -0
  45. data/test/rails_root/script/dbconsole +3 -0
  46. data/test/rails_root/script/runner +3 -0
  47. data/test/rails_root/script/server +3 -0
  48. data/test/rspec-rails/Contribute.rdoc +4 -0
  49. data/test/rspec-rails/History.rdoc +283 -0
  50. data/test/rspec-rails/License.txt +33 -0
  51. data/test/rspec-rails/Manifest.txt +165 -0
  52. data/test/rspec-rails/README.rdoc +45 -0
  53. data/test/rspec-rails/Rakefile +72 -0
  54. data/test/rspec-rails/TODO.txt +17 -0
  55. data/test/rspec-rails/Upgrade.rdoc +148 -0
  56. data/test/rspec-rails/generators/integration_spec/integration_spec_generator.rb +10 -0
  57. data/test/rspec-rails/generators/integration_spec/templates/integration_spec.rb +4 -0
  58. data/test/rspec-rails/generators/rspec/CHANGES +1 -0
  59. data/test/rspec-rails/generators/rspec/rspec_generator.rb +53 -0
  60. data/test/rspec-rails/generators/rspec/templates/previous_failures.txt +0 -0
  61. data/test/rspec-rails/generators/rspec/templates/rcov.opts +2 -0
  62. data/test/rspec-rails/generators/rspec/templates/rspec.rake +144 -0
  63. data/test/rspec-rails/generators/rspec/templates/script/autospec +6 -0
  64. data/test/rspec-rails/generators/rspec/templates/script/spec +10 -0
  65. data/test/rspec-rails/generators/rspec/templates/spec.opts +4 -0
  66. data/test/rspec-rails/generators/rspec/templates/spec_helper.rb +54 -0
  67. data/test/rspec-rails/generators/rspec_controller/USAGE +33 -0
  68. data/test/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb +47 -0
  69. data/test/rspec-rails/generators/rspec_controller/templates/controller_spec.rb +25 -0
  70. data/test/rspec-rails/generators/rspec_controller/templates/helper_spec.rb +11 -0
  71. data/test/rspec-rails/generators/rspec_controller/templates/view_spec.rb +12 -0
  72. data/test/rspec-rails/generators/rspec_default_values.rb +28 -0
  73. data/test/rspec-rails/generators/rspec_model/USAGE +18 -0
  74. data/test/rspec-rails/generators/rspec_model/rspec_model_generator.rb +35 -0
  75. data/test/rspec-rails/generators/rspec_model/templates/model_spec.rb +13 -0
  76. data/test/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb +154 -0
  77. data/test/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb +131 -0
  78. data/test/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb +25 -0
  79. data/test/rspec-rails/generators/rspec_scaffold/templates/helper_spec.rb +11 -0
  80. data/test/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb +27 -0
  81. data/test/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb +25 -0
  82. data/test/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb +33 -0
  83. data/test/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb +22 -0
  84. data/test/rspec-rails/init.rb +9 -0
  85. data/test/rspec-rails/lib/autotest/discover.rb +5 -0
  86. data/test/rspec-rails/lib/autotest/rails_rspec.rb +76 -0
  87. data/test/rspec-rails/lib/spec/rails.rb +26 -0
  88. data/test/rspec-rails/lib/spec/rails/example.rb +48 -0
  89. data/test/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb +39 -0
  90. data/test/rspec-rails/lib/spec/rails/example/controller_example_group.rb +278 -0
  91. data/test/rspec-rails/lib/spec/rails/example/cookies_proxy.rb +29 -0
  92. data/test/rspec-rails/lib/spec/rails/example/functional_example_group.rb +106 -0
  93. data/test/rspec-rails/lib/spec/rails/example/helper_example_group.rb +153 -0
  94. data/test/rspec-rails/lib/spec/rails/example/integration_example_group.rb +16 -0
  95. data/test/rspec-rails/lib/spec/rails/example/model_example_group.rb +14 -0
  96. data/test/rspec-rails/lib/spec/rails/example/render_observer.rb +80 -0
  97. data/test/rspec-rails/lib/spec/rails/example/routing_example_group.rb +13 -0
  98. data/test/rspec-rails/lib/spec/rails/example/routing_helpers.rb +66 -0
  99. data/test/rspec-rails/lib/spec/rails/example/view_example_group.rb +199 -0
  100. data/test/rspec-rails/lib/spec/rails/extensions.rb +11 -0
  101. data/test/rspec-rails/lib/spec/rails/extensions/action_controller/rescue.rb +42 -0
  102. data/test/rspec-rails/lib/spec/rails/extensions/action_controller/test_case.rb +16 -0
  103. data/test/rspec-rails/lib/spec/rails/extensions/action_controller/test_response.rb +21 -0
  104. data/test/rspec-rails/lib/spec/rails/extensions/action_view/base.rb +33 -0
  105. data/test/rspec-rails/lib/spec/rails/extensions/active_record/base.rb +45 -0
  106. data/test/rspec-rails/lib/spec/rails/extensions/active_support/test_case.rb +7 -0
  107. data/test/rspec-rails/lib/spec/rails/extensions/spec/matchers/have.rb +23 -0
  108. data/test/rspec-rails/lib/spec/rails/extensions/spec/runner/configuration.rb +44 -0
  109. data/test/rspec-rails/lib/spec/rails/interop/testcase.rb +14 -0
  110. data/test/rspec-rails/lib/spec/rails/matchers.rb +33 -0
  111. data/test/rspec-rails/lib/spec/rails/matchers/ar_be_valid.rb +46 -0
  112. data/test/rspec-rails/lib/spec/rails/matchers/assert_select.rb +180 -0
  113. data/test/rspec-rails/lib/spec/rails/matchers/change.rb +13 -0
  114. data/test/rspec-rails/lib/spec/rails/matchers/have_text.rb +57 -0
  115. data/test/rspec-rails/lib/spec/rails/matchers/include_text.rb +54 -0
  116. data/test/rspec-rails/lib/spec/rails/matchers/redirect_to.rb +126 -0
  117. data/test/rspec-rails/lib/spec/rails/matchers/render_template.rb +129 -0
  118. data/test/rspec-rails/lib/spec/rails/matchers/route_to.rb +149 -0
  119. data/test/rspec-rails/lib/spec/rails/mocks.rb +135 -0
  120. data/test/rspec-rails/lib/spec/rails/version.rb +16 -0
  121. data/test/rspec-rails/spec/autotest/mappings_spec.rb +86 -0
  122. data/test/rspec-rails/spec/rails_suite.rb +7 -0
  123. data/test/rspec-rails/spec/resources/controllers/action_view_base_spec_controller.rb +2 -0
  124. data/test/rspec-rails/spec/resources/controllers/application.rb +9 -0
  125. data/test/rspec-rails/spec/resources/controllers/controller_spec_controller.rb +127 -0
  126. data/test/rspec-rails/spec/resources/controllers/example.txt +1 -0
  127. data/test/rspec-rails/spec/resources/controllers/redirect_spec_controller.rb +70 -0
  128. data/test/rspec-rails/spec/resources/controllers/render_spec_controller.rb +34 -0
  129. data/test/rspec-rails/spec/resources/controllers/rjs_spec_controller.rb +58 -0
  130. data/test/rspec-rails/spec/resources/helpers/addition_helper.rb +5 -0
  131. data/test/rspec-rails/spec/resources/helpers/explicit_helper.rb +46 -0
  132. data/test/rspec-rails/spec/resources/helpers/more_explicit_helper.rb +5 -0
  133. data/test/rspec-rails/spec/resources/helpers/plugin_application_helper.rb +6 -0
  134. data/test/rspec-rails/spec/resources/helpers/view_spec_helper.rb +13 -0
  135. data/test/rspec-rails/spec/resources/models/animal.rb +4 -0
  136. data/test/rspec-rails/spec/resources/models/person.rb +18 -0
  137. data/test/rspec-rails/spec/resources/models/thing.rb +3 -0
  138. data/test/rspec-rails/spec/resources/views/controller_spec/_partial.html.erb +0 -0
  139. data/test/rspec-rails/spec/resources/views/controller_spec/action_setting_flash_after_session_reset.html.erb +1 -0
  140. data/test/rspec-rails/spec/resources/views/controller_spec/action_setting_flash_before_session_reset.html.erb +1 -0
  141. data/test/rspec-rails/spec/resources/views/controller_spec/action_setting_the_assigns_hash.html.erb +0 -0
  142. data/test/rspec-rails/spec/resources/views/controller_spec/action_with_errors_in_template.html.erb +1 -0
  143. data/test/rspec-rails/spec/resources/views/controller_spec/action_with_template.html.erb +1 -0
  144. data/test/rspec-rails/spec/resources/views/controller_spec/non_existent_action_with_existent_template.html.erb +0 -0
  145. data/test/rspec-rails/spec/resources/views/layouts/application.html.erb +0 -0
  146. data/test/rspec-rails/spec/resources/views/layouts/simple.html.erb +0 -0
  147. data/test/rspec-rails/spec/resources/views/objects/_object.html.erb +1 -0
  148. data/test/rspec-rails/spec/resources/views/render_spec/_a_partial.html.erb +0 -0
  149. data/test/rspec-rails/spec/resources/views/render_spec/action_with_alternate_layout.html.erb +0 -0
  150. data/test/rspec-rails/spec/resources/views/render_spec/some_action.html.erb +0 -0
  151. data/test/rspec-rails/spec/resources/views/render_spec/some_action.js.rjs +1 -0
  152. data/test/rspec-rails/spec/resources/views/rjs_spec/_replacement_partial.html.erb +1 -0
  153. data/test/rspec-rails/spec/resources/views/rjs_spec/hide_div.js.rjs +1 -0
  154. data/test/rspec-rails/spec/resources/views/rjs_spec/hide_page_element.js.rjs +1 -0
  155. data/test/rspec-rails/spec/resources/views/rjs_spec/insert_html.js.rjs +1 -0
  156. data/test/rspec-rails/spec/resources/views/rjs_spec/replace.js.rjs +1 -0
  157. data/test/rspec-rails/spec/resources/views/rjs_spec/replace_html.js.rjs +1 -0
  158. data/test/rspec-rails/spec/resources/views/rjs_spec/replace_html_with_partial.js.rjs +1 -0
  159. data/test/rspec-rails/spec/resources/views/rjs_spec/visual_effect.js.rjs +1 -0
  160. data/test/rspec-rails/spec/resources/views/rjs_spec/visual_toggle_effect.js.rjs +1 -0
  161. data/test/rspec-rails/spec/resources/views/tag_spec/no_tags.html.erb +1 -0
  162. data/test/rspec-rails/spec/resources/views/tag_spec/single_div_with_no_attributes.html.erb +1 -0
  163. data/test/rspec-rails/spec/resources/views/tag_spec/single_div_with_one_attribute.html.erb +1 -0
  164. data/test/rspec-rails/spec/resources/views/view_spec/_partial.html.erb +2 -0
  165. data/test/rspec-rails/spec/resources/views/view_spec/_partial_used_twice.html.erb +0 -0
  166. data/test/rspec-rails/spec/resources/views/view_spec/_partial_with_local_variable.html.erb +1 -0
  167. data/test/rspec-rails/spec/resources/views/view_spec/_partial_with_sub_partial.html.erb +1 -0
  168. data/test/rspec-rails/spec/resources/views/view_spec/_spacer.html.erb +1 -0
  169. data/test/rspec-rails/spec/resources/views/view_spec/accessor.html.erb +5 -0
  170. data/test/rspec-rails/spec/resources/views/view_spec/block_helper.html.erb +3 -0
  171. data/test/rspec-rails/spec/resources/views/view_spec/entry_form.html.erb +2 -0
  172. data/test/rspec-rails/spec/resources/views/view_spec/explicit_helper.html.erb +2 -0
  173. data/test/rspec-rails/spec/resources/views/view_spec/foo/show.html.erb +1 -0
  174. data/test/rspec-rails/spec/resources/views/view_spec/implicit_helper.html.erb +2 -0
  175. data/test/rspec-rails/spec/resources/views/view_spec/multiple_helpers.html.erb +3 -0
  176. data/test/rspec-rails/spec/resources/views/view_spec/path_params.html.erb +1 -0
  177. data/test/rspec-rails/spec/resources/views/view_spec/should_not_receive.html.erb +3 -0
  178. data/test/rspec-rails/spec/resources/views/view_spec/template_with_partial.html.erb +5 -0
  179. data/test/rspec-rails/spec/resources/views/view_spec/template_with_partial_using_collection.html.erb +3 -0
  180. data/test/rspec-rails/spec/resources/views/view_spec/template_with_partial_with_array.html.erb +1 -0
  181. data/test/rspec-rails/spec/resources/views/view_spec/view_helpers.html.erb +1 -0
  182. data/test/rspec-rails/spec/spec/rails/example/assigns_hash_proxy_spec.rb +109 -0
  183. data/test/rspec-rails/spec/spec/rails/example/configuration_spec.rb +65 -0
  184. data/test/rspec-rails/spec/spec/rails/example/controller_example_group_spec.rb +307 -0
  185. data/test/rspec-rails/spec/spec/rails/example/controller_isolation_spec.rb +75 -0
  186. data/test/rspec-rails/spec/spec/rails/example/cookies_proxy_spec.rb +87 -0
  187. data/test/rspec-rails/spec/spec/rails/example/error_handling_spec.rb +90 -0
  188. data/test/rspec-rails/spec/spec/rails/example/example_group_factory_spec.rb +112 -0
  189. data/test/rspec-rails/spec/spec/rails/example/helper_example_group_spec.rb +233 -0
  190. data/test/rspec-rails/spec/spec/rails/example/model_example_group_spec.rb +20 -0
  191. data/test/rspec-rails/spec/spec/rails/example/routing_example_group_spec.rb +10 -0
  192. data/test/rspec-rails/spec/spec/rails/example/shared_routing_example_group_examples.rb +237 -0
  193. data/test/rspec-rails/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb +33 -0
  194. data/test/rspec-rails/spec/spec/rails/example/view_example_group_spec.rb +349 -0
  195. data/test/rspec-rails/spec/spec/rails/extensions/action_view_base_spec.rb +74 -0
  196. data/test/rspec-rails/spec/spec/rails/extensions/active_record_spec.rb +14 -0
  197. data/test/rspec-rails/spec/spec/rails/interop/testcase_spec.rb +70 -0
  198. data/test/rspec-rails/spec/spec/rails/matchers/ar_be_valid_spec.rb +19 -0
  199. data/test/rspec-rails/spec/spec/rails/matchers/assert_select_spec.rb +835 -0
  200. data/test/rspec-rails/spec/spec/rails/matchers/errors_on_spec.rb +37 -0
  201. data/test/rspec-rails/spec/spec/rails/matchers/have_text_spec.rb +69 -0
  202. data/test/rspec-rails/spec/spec/rails/matchers/include_text_spec.rb +62 -0
  203. data/test/rspec-rails/spec/spec/rails/matchers/redirect_to_spec.rb +253 -0
  204. data/test/rspec-rails/spec/spec/rails/matchers/render_template_spec.rb +208 -0
  205. data/test/rspec-rails/spec/spec/rails/matchers/should_change_spec.rb +15 -0
  206. data/test/rspec-rails/spec/spec/rails/mocks/ar_classes.rb +10 -0
  207. data/test/rspec-rails/spec/spec/rails/mocks/mock_model_spec.rb +106 -0
  208. data/test/rspec-rails/spec/spec/rails/mocks/stub_model_spec.rb +80 -0
  209. data/test/rspec-rails/spec/spec/rails/sample_modified_fixture.rb +8 -0
  210. data/test/rspec-rails/spec/spec/rails/sample_spec.rb +8 -0
  211. data/test/rspec-rails/spec/spec/rails/spec_spec.rb +11 -0
  212. data/test/rspec-rails/spec/spec_helper.rb +78 -0
  213. metadata +476 -0
@@ -0,0 +1,27 @@
1
+ begin
2
+ require 'will_paginate'
3
+ rescue LoadError => e
4
+ $stderr.puts %(
5
+ *************************************************************************************************
6
+ * gem will_paginate is missing *
7
+ *************************************************************************************************
8
+ )
9
+ end
10
+
11
+ module Exception2db
12
+ class E2db < ActiveRecord::Base
13
+ #
14
+ end
15
+ end
16
+
17
+ if Rails.version >= '3.0'
18
+ require 'exception2db/railtie'
19
+ else
20
+ raise "Please see documentation at http://github.com/neerajdotname/exception2db to find out how to use this gem with rails 2.3.x"
21
+ end
22
+
23
+ require 'exception2db/config.rb'
24
+ require 'exception2db/util.rb'
25
+ require 'rexml/document'
26
+
27
+ Exception2dbConfig.initialize_defaults
@@ -0,0 +1,22 @@
1
+ class Exception2dbConfig
2
+
3
+ cattr_accessor :setting
4
+
5
+ def self.set=(input = {})
6
+ valid_keys = %w(is_allowed_to_view).collect(&:intern)
7
+ extra_keys = input.keys - valid_keys
8
+ raise "Following options are not supported. #{extra_keys.inspect}" unless extra_keys.blank?
9
+ self.setting ||= {}
10
+ self.setting.merge!(input)
11
+ end
12
+
13
+ def self.initialize_defaults
14
+ self.setting = {
15
+ :plugin_dir => File.expand_path(File.join(File.dirname(__FILE__), '..', '..')),
16
+ :will_paginate_per_page => 50,
17
+ # cucumber test was failing with Rails.env.development? . Need to investigate further TODO
18
+ :is_allowed_to_view => lambda { |controller| return true if RAILS_ENV == 'development' }
19
+ }
20
+ end
21
+
22
+ end
@@ -0,0 +1,12 @@
1
+ module Exception2db
2
+ class Engine < Rails::Engine
3
+
4
+ initializer "exception2db.setup" do
5
+ end
6
+
7
+ rake_tasks do
8
+ #
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,17 @@
1
+ class Exception2db::Util
2
+
3
+ def self.stylesheet_link_tag(*args)
4
+ data = args.inject('') do |sum, arg|
5
+ sum << File.new(File.join(::Exception2dbConfig.setting[:plugin_dir], 'lib', 'css', "#{arg}.css")).read
6
+ end
7
+ ["<style type='text/css'>", data, '</style>'].join.html_safe
8
+ end
9
+
10
+ def self.javascript_include_tag(*args)
11
+ data = args.inject('') do |sum, arg|
12
+ sum << File.new(File.join(Exception2dbConfig.setting[:plugin_dir], 'lib', 'js', "#{arg}.js")).read
13
+ end
14
+ ['<script type="text/javascript">', data, '</script>'].join.html_safe
15
+ end
16
+
17
+ end
@@ -0,0 +1,3 @@
1
+ module Exception2db
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1 @@
1
+ // currently empty
@@ -0,0 +1,74 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe Exception2db do
4
+
5
+ it { should validate_presence_of(:exception) }
6
+
7
+ describe "when exception is blank and record is saved with false option" do
8
+ subject { Exception2db.new(:exception => nil) }
9
+ # Pass 'false' to 'save' in order to skip the validations.
10
+ it "should raise an exception" do
11
+ lambda { subject.save(false) }.should raise_exception(ActiveRecord::StatementInvalid)
12
+ end
13
+ end
14
+
15
+ describe "should be able to create a new record" do
16
+ subject { Exception2db.create(:exception => 'hello world') }
17
+ it "should be false for new_record?" do
18
+ subject.new_record?.should be_false
19
+ end
20
+ end
21
+
22
+ context "attributes" do
23
+ subject { Exception2db.create(:exception => $exception_data_xml) }
24
+
25
+ it "#cgi_data should have HTTP_HOST" do
26
+ subject.cgi_data.fetch('HTTP_HOST').should == 'localhost:3000'
27
+ end
28
+
29
+ it "#cgi_data should have HTTP_ACCEPT_ENCODING" do
30
+ subject.cgi_data.fetch('HTTP_ACCEPT_ENCODING').should == 'gzip,deflate'
31
+ end
32
+
33
+ it "#parameters" do
34
+ subject.parameters.should == '{ :action => index , :controller => exception2db/main }'
35
+ end
36
+
37
+ it "#formatted_backtrace" do
38
+ subject.formatted_backtrace.should ==
39
+ "<p>[PROJECT_ROOT]/vendor/plugins/exception2db/app/controllers/exception2db/main_controller.rb:10:in index</p>" <<
40
+ "<p>[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/base.rb:1331:in send</p>"
41
+ end
42
+
43
+ it "#top_file_and_line_number" do
44
+ subject.top_file_and_line_number.should == '[PROJECT_ROOT]/vendor/plugins/exception2db/app/controllers/exception2db/main_controller.rb:10'
45
+ end
46
+
47
+ it "#environment" do
48
+ subject.environment.should == 'production'
49
+ end
50
+
51
+ it "#url" do
52
+ subject.url.should == 'http://localhost:3000/exception2db'
53
+ end
54
+
55
+ it "#controller" do
56
+ subject.controller.should == 'exception2db/main'
57
+ end
58
+
59
+ it "#action" do
60
+ subject.action.should == 'index'
61
+ end
62
+
63
+ it "#error_message" do
64
+ subject.error_message.should == 'RuntimeError: 46'
65
+ end
66
+
67
+ it "#user_agent" do
68
+ subject.user_agent.should == "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US)" <<
69
+ " AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4"
70
+ end
71
+
72
+ end
73
+
74
+ end
@@ -0,0 +1,175 @@
1
+ ENV["RAILS_ENV"] ||= 'test'
2
+
3
+ require 'rubygems'
4
+ require 'rexml/document'
5
+
6
+ gem 'rspec', '= 1.3.0'
7
+ require 'spec'
8
+
9
+ pwd = File.dirname(__FILE__)
10
+ $: << pwd + '/../lib' << pwd
11
+
12
+ ENV['RAILS_ENV'] = 'test'
13
+
14
+ rails_root = File.join(pwd, '..', 'test', 'rails_root')
15
+
16
+
17
+ # start rails
18
+ require "#{rails_root}/config/environment"
19
+
20
+ # spec/rails must be loaded after rails is loaded
21
+ require 'spec/rails'
22
+
23
+ Dir[File.join(pwd, '..', 'app', 'models', '*.rb')].each {|f| require f}
24
+
25
+ # require all the lib files plugin needs
26
+ Dir[File.join(pwd, '..', 'lib', '**', '*.rb')].each {|f| require f}
27
+
28
+ # initialize defaults
29
+ # TODO Change the name to Exception2db::Config
30
+ Exception2dbConfig.initialize_defaults
31
+
32
+ # require all the controllers plugin needs
33
+ Dir[File.join(pwd, '..', 'app', 'controllers', 'exception2db', '*.rb')].each {|f| require f}
34
+
35
+ # require plugin routes
36
+ require "#{rails_root}/../../config/routes.rb"
37
+
38
+ require 'test/unit'
39
+ require 'test_help'
40
+ silence_warnings { RAILS_ENV = ENV['RAILS_ENV'] }
41
+
42
+ # Run migrations
43
+ ActiveRecord::Migration.verbose = true
44
+ ActiveRecord::Migrator.migrate("#{rails_root}/db/migrate")
45
+
46
+ gem 'shoulda', '= 2.10.2'
47
+ require 'shoulda'
48
+
49
+ gem 'will_paginate', '= 2.3.12'
50
+ require 'will_paginate'
51
+
52
+ gem 'factory_girl', '= 1.2.4'
53
+ require 'factory_girl'
54
+
55
+ gem 'flexmock', '= 0.8.6'
56
+ require 'flexmock'
57
+
58
+ gem 'redgreen', '= 1.2.2'
59
+ require 'RedGreen'
60
+
61
+ gem 'cucumber', '= 0.8.5'
62
+ require 'cucumber'
63
+
64
+ # for helper tests
65
+ require 'action_view/test_case'
66
+
67
+ Dir[File.join(pwd, 'factories', '*.rb')].each { |f| require File.expand_path(f) }
68
+
69
+
70
+ class ActiveSupport::TestCase
71
+
72
+ def revoke_read_only_access
73
+ AdminDataConfig.set = ({:is_allowed_to_view => Proc.new { |controller| false } })
74
+ end
75
+
76
+ def grant_read_only_access
77
+ AdminDataConfig.set = ({:is_allowed_to_view => Proc.new { |controller| true } })
78
+ end
79
+
80
+ def grant_update_access
81
+ AdminDataConfig.set = ({:is_allowed_to_update => Proc.new { |controller| true } })
82
+ end
83
+
84
+ def revoke_update_access
85
+ AdminDataConfig.set = ({:is_allowed_to_update => Proc.new { |controller| false } })
86
+ end
87
+
88
+ def show_response
89
+ Dir.mkdir(File.join(RAILS_ROOT, 'tmp')) unless File.directory?(File.join(RAILS_ROOT,'tmp'))
90
+ response_html = File.join(RAILS_ROOT, 'tmp', 'response.html')
91
+ File.open(response_html, 'w') { |f| f.write(@response.body) }
92
+ system 'open ' + File.expand_path(response_html) rescue nil
93
+ end
94
+
95
+ end
96
+
97
+
98
+
99
+ $exception_data_xml = %Q{
100
+ <?xml version="1.0" encoding="UTF-8"?>
101
+ <notice version="2.0">
102
+ <api-key></api-key>
103
+ <notifier>
104
+ <name>Hoptoad Notifier</name>
105
+ <version>2.2.2</version>
106
+ <url>http://hoptoadapp.com</url>
107
+ </notifier>
108
+ <error>
109
+ <class>RuntimeError</class>
110
+ <message>RuntimeError: 46</message>
111
+ <backtrace>
112
+ <line number="10" file="[PROJECT_ROOT]/vendor/plugins/exception2db/app/controllers/exception2db/main_controller.rb" method="index"/>
113
+ <line number="1331" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/base.rb" method="send"/>
114
+ </backtrace>
115
+ </error>
116
+ <request>
117
+ <url>http://localhost:3000/exception2db</url>
118
+ <component>exception2db/main</component>
119
+ <action>index</action>
120
+ <params>
121
+ <var key="action">index</var>
122
+ <var key="controller">exception2db/main</var>
123
+ </params>
124
+ <cgi-data>
125
+ <var key="HTTP_ACCEPT">application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</var>
126
+ <var key="rack.session"></var>
127
+ <var key="SERVER_NAME">localhost</var>
128
+ <var key="HTTP_HOST">localhost:3000</var>
129
+ <var key="rack.url_scheme">http</var>
130
+ <var key="HTTP_USER_AGENT">Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4</var>
131
+ <var key="REQUEST_PATH">/exception2db</var>
132
+ <var key="rack.errors">#&lt;IO:0x1001acb78&gt;</var>
133
+ <var key="SERVER_PROTOCOL">HTTP/1.1</var>
134
+ <var key="action_controller.request.request_parameters"></var>
135
+ <var key="HTTP_ACCEPT_LANGUAGE">en-US,en;q=0.8</var>
136
+ <var key="rack.run_once">false</var>
137
+ <var key="PATH_INFO">/exception2db</var>
138
+ <var key="REMOTE_ADDR">127.0.0.1</var>
139
+ <var key="SERVER_SOFTWARE">Mongrel 1.1.5</var>
140
+ <var key="rack.version">10</var>
141
+ <var key="SCRIPT_NAME"></var>
142
+ <var key="HTTP_VERSION">HTTP/1.1</var>
143
+ <var key="HTTP_COOKIE">_app_demo_session=BAh7BzoQX2NzcmZfdG9rZW4iMVVaUWdTdGhjWVg5MEVxSlJlaUFZNUhsRHlJaU11RjlSRWVrQ1VjbDdVV3M9Og9zZXNzaW9uX2lkIiVmY2M4Nzk2YWM2MzMwMGE2Zjc5YzgwNGJlNjVmNThiMQ%3D%3D--c3e438e8b20cbc2c650cc40d92101f30e23070b8; _exception2db_demo_session=BAh7BjoPc2Vzc2lvbl9pZCIlODc1NDJmZTNlMTg4YTc4NzMwNTY2YTU5Mjc3NjE3Nzg%3D--ad4cf6bade36ccd02b6c07f2e20839e211b81f5a</var>
144
+ <var key="rack.multithread">false</var>
145
+ <var key="rack.multiprocess">false</var>
146
+ <var key="action_controller.request.path_parameters">
147
+ <var key="action">index</var>
148
+ <var key="controller">exception2db/main</var>
149
+ </var>
150
+ <var key="REQUEST_URI">/exception2db</var>
151
+ <var key="SERVER_PORT">3000</var>
152
+ <var key="rack.request.query_hash"></var>
153
+ <var key="HTTP_ACCEPT_CHARSET">ISO-8859-1,utf-8;q=0.7,*;q=0.3</var><var key="rack.session.options"><var key="path">/</var>
154
+ <var key="domain"></var><var key="expire_after"></var>
155
+ <var key="httponly">true</var>
156
+ <var key="key">_session_id</var></var>
157
+ <var key="REQUEST_METHOD">GET</var>
158
+ <var key="action_controller.request.query_parameters"></var>
159
+ <var key="action_controller.rescue.request">#&lt;ActionController::Request:0x103192518&gt;</var>
160
+ <var key="QUERY_STRING"></var>
161
+ <var key="HTTP_CONNECTION">keep-alive</var>
162
+ <var key="GATEWAY_INTERFACE">CGI/1.2</var>
163
+ <var key="rack.request.query_string"></var>
164
+ <var key="action_controller.rescue.response">#&lt;ActionController::Response:0x1031924c8&gt;</var>
165
+ <var key="HTTP_ACCEPT_ENCODING">gzip,deflate</var>
166
+ <var key="rack.input">#&lt;StringIO:0x1031a6270&gt;</var>
167
+ </cgi-data>
168
+ </request>
169
+ <server-environment>
170
+ <project-root>/Users/neerajdotname/dev/working/exception2db_demo</project-root>
171
+ <environment-name>production</environment-name>
172
+ </server-environment>
173
+ </notice>
174
+ }
175
+
@@ -0,0 +1,134 @@
1
+ $exception_data_xml = %Q{
2
+ <?xml version="1.0" encoding="UTF-8"?>
3
+ <notice version="2.0">
4
+ <api-key></api-key>
5
+ <notifier>
6
+ <name>Hoptoad Notifier</name>
7
+ <version>2.2.2</version>
8
+ <url>http://hoptoadapp.com</url>
9
+ </notifier>
10
+ <error>
11
+ <class>RuntimeError</class>
12
+ <message>RuntimeError: 46</message>
13
+ <backtrace>
14
+ <line number="10" file="[PROJECT_ROOT]/vendor/plugins/exception2db/app/controllers/exception2db/main_controller.rb" method="index"/>
15
+ <line number="1331" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/base.rb" method="send"/>
16
+ <line number="1331" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/base.rb" method="perform_action_without_filters"/>
17
+ <line number="617" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/filters.rb" method="call_filters"/>
18
+ <line number="610" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/filters.rb" method="perform_action_without_benchmark"/>
19
+ <line number="68" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb" method="perform_action_without_rescue"/>
20
+ <line number="17" file="[GEM_ROOT]/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb" method="ms"/>
21
+ <line number="308" file="/usr/local/lib/ruby/1.8/benchmark.rb" method="realtime"/>
22
+ <line number="17" file="[GEM_ROOT]/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb" method="ms"/>
23
+ <line number="68" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb" method="perform_action_without_rescue"/>
24
+ <line number="160" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/rescue.rb" method="perform_action_without_flash"/>
25
+ <line number="146" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/flash.rb" method="perform_action"/>
26
+ <line number="532" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/base.rb" method="send"/>
27
+ <line number="532" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/base.rb" method="process_without_filters"/>
28
+ <line number="606" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/filters.rb" method="process"/>
29
+ <line number="391" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/base.rb" method="process"/>
30
+ <line number="386" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/base.rb" method="call"/>
31
+ <line number="437" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb" method="call"/>
32
+ <line number="87" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb" method="dispatch"/>
33
+ <line number="121" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb" method="_call"/>
34
+ <line number="130" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb" method="build_middleware_stack"/>
35
+ <line number="29" file="[GEM_ROOT]/gems/activerecord-2.3.5/lib/active_record/query_cache.rb" method="call"/>
36
+ <line number="29" file="[GEM_ROOT]/gems/activerecord-2.3.5/lib/active_record/query_cache.rb" method="call"/>
37
+ <line number="34" file="[GEM_ROOT]/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb" method="cache"/>
38
+ <line number="9" file="[GEM_ROOT]/gems/activerecord-2.3.5/lib/active_record/query_cache.rb" method="cache"/>
39
+ <line number="28" file="[GEM_ROOT]/gems/activerecord-2.3.5/lib/active_record/query_cache.rb" method="call"/>
40
+ <line number="361" file="[GEM_ROOT]/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/connection_pool.rb" method="call"/>
41
+ <line number="25" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/string_coercion.rb" method="call"/>
42
+ <line number="9" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/head.rb" method="call"/>
43
+ <line number="24" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/methodoverride.rb" method="call"/>
44
+ <line number="15" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/params_parser.rb" method="call"/>
45
+ <line number="93" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/session/cookie_store.rb" method="call"/>
46
+ <line number="26" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/failsafe.rb" method="call"/>
47
+ <line number="11" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/lock.rb" method="call"/>
48
+ <line number="11" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/lock.rb" method="synchronize"/>
49
+ <line number="11" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/lock.rb" method="call"/>
50
+ <line number="106" file="[GEM_ROOT]/gems/actionpack-2.3.5/lib/action_controller/dispatcher.rb" method="call"/>
51
+ <line number="31" file="[GEM_ROOT]/gems/rails-2.3.5/lib/rails/rack/static.rb" method="call"/>
52
+ <line number="46" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/urlmap.rb" method="call"/>
53
+ <line number="40" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/urlmap.rb" method="each"/>
54
+ <line number="40" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/urlmap.rb" method="call"/>
55
+ <line number="17" file="[GEM_ROOT]/gems/rails-2.3.5/lib/rails/rack/log_tailer.rb" method="call"/>
56
+ <line number="13" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/content_length.rb" method="call"/>
57
+ <line number="15" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/chunked.rb" method="call"/>
58
+ <line number="64" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/handler/mongrel.rb" method="process"/>
59
+ <line number="159" file="[GEM_ROOT]/gems/mongrel-1.1.5/lib/mongrel.rb" method="process_client"/>
60
+ <line number="158" file="[GEM_ROOT]/gems/mongrel-1.1.5/lib/mongrel.rb" method="each"/>
61
+ <line number="158" file="[GEM_ROOT]/gems/mongrel-1.1.5/lib/mongrel.rb" method="process_client"/>
62
+ <line number="285" file="[GEM_ROOT]/gems/mongrel-1.1.5/lib/mongrel.rb" method="run"/>
63
+ <line number="285" file="[GEM_ROOT]/gems/mongrel-1.1.5/lib/mongrel.rb" method="initialize"/>
64
+ <line number="285" file="[GEM_ROOT]/gems/mongrel-1.1.5/lib/mongrel.rb" method="new"/>
65
+ <line number="285" file="[GEM_ROOT]/gems/mongrel-1.1.5/lib/mongrel.rb" method="run"/>
66
+ <line number="268" file="[GEM_ROOT]/gems/mongrel-1.1.5/lib/mongrel.rb" method="initialize"/>
67
+ <line number="268" file="[GEM_ROOT]/gems/mongrel-1.1.5/lib/mongrel.rb" method="new"/>
68
+ <line number="268" file="[GEM_ROOT]/gems/mongrel-1.1.5/lib/mongrel.rb" method="run"/>
69
+ <line number="34" file="[GEM_ROOT]/gems/rack-1.0.1/lib/rack/handler/mongrel.rb" method="run"/>
70
+ <line number="111" file="[GEM_ROOT]/gems/rails-2.3.5/lib/commands/server.rb" method=""/>
71
+ <line number="31" file="/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb" method="gem_original_require"/>
72
+ <line number="31" file="/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb" method="require"/>
73
+ <line number="3" file="script/server" method=""/>
74
+ </backtrace>
75
+ </error>
76
+ <request>
77
+ <url>http://localhost:3000/exception2db</url>
78
+ <component>exception2db/main</component>
79
+ <action>index</action>
80
+ <params>
81
+ <var key="action">index</var>
82
+ <var key="controller">exception2db/main</var>
83
+ </params>
84
+ <cgi-data>
85
+ <var key="HTTP_ACCEPT">application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</var>
86
+ <var key="rack.session"></var>
87
+ <var key="SERVER_NAME">localhost</var>
88
+ <var key="HTTP_HOST">localhost:3000</var>
89
+ <var key="rack.url_scheme">http</var>
90
+ <var key="HTTP_USER_AGENT">Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.38 Safari/533.4</var>
91
+ <var key="REQUEST_PATH">/exception2db</var>
92
+ <var key="rack.errors">#&lt;IO:0x1001acb78&gt;</var>
93
+ <var key="SERVER_PROTOCOL">HTTP/1.1</var>
94
+ <var key="action_controller.request.request_parameters"></var>
95
+ <var key="HTTP_ACCEPT_LANGUAGE">en-US,en;q=0.8</var>
96
+ <var key="rack.run_once">false</var>
97
+ <var key="PATH_INFO">/exception2db</var>
98
+ <var key="REMOTE_ADDR">127.0.0.1</var>
99
+ <var key="SERVER_SOFTWARE">Mongrel 1.1.5</var>
100
+ <var key="rack.version">10</var>
101
+ <var key="SCRIPT_NAME"></var>
102
+ <var key="HTTP_VERSION">HTTP/1.1</var>
103
+ <var key="HTTP_COOKIE">_app_demo_session=BAh7BzoQX2NzcmZfdG9rZW4iMVVaUWdTdGhjWVg5MEVxSlJlaUFZNUhsRHlJaU11RjlSRWVrQ1VjbDdVV3M9Og9zZXNzaW9uX2lkIiVmY2M4Nzk2YWM2MzMwMGE2Zjc5YzgwNGJlNjVmNThiMQ%3D%3D--c3e438e8b20cbc2c650cc40d92101f30e23070b8; _exception2db_demo_session=BAh7BjoPc2Vzc2lvbl9pZCIlODc1NDJmZTNlMTg4YTc4NzMwNTY2YTU5Mjc3NjE3Nzg%3D--ad4cf6bade36ccd02b6c07f2e20839e211b81f5a</var>
104
+ <var key="rack.multithread">false</var>
105
+ <var key="rack.multiprocess">false</var>
106
+ <var key="action_controller.request.path_parameters">
107
+ <var key="action">index</var>
108
+ <var key="controller">exception2db/main</var>
109
+ </var>
110
+ <var key="REQUEST_URI">/exception2db</var>
111
+ <var key="SERVER_PORT">3000</var>
112
+ <var key="rack.request.query_hash"></var>
113
+ <var key="HTTP_ACCEPT_CHARSET">ISO-8859-1,utf-8;q=0.7,*;q=0.3</var><var key="rack.session.options"><var key="path">/</var>
114
+ <var key="domain"></var><var key="expire_after"></var>
115
+ <var key="httponly">true</var>
116
+ <var key="key">_session_id</var></var>
117
+ <var key="REQUEST_METHOD">GET</var>
118
+ <var key="action_controller.request.query_parameters"></var>
119
+ <var key="action_controller.rescue.request">#&lt;ActionController::Request:0x103192518&gt;</var>
120
+ <var key="QUERY_STRING"></var>
121
+ <var key="HTTP_CONNECTION">keep-alive</var>
122
+ <var key="GATEWAY_INTERFACE">CGI/1.2</var>
123
+ <var key="rack.request.query_string"></var>
124
+ <var key="action_controller.rescue.response">#&lt;ActionController::Response:0x1031924c8&gt;</var>
125
+ <var key="HTTP_ACCEPT_ENCODING">gzip,deflate</var>
126
+ <var key="rack.input">#&lt;StringIO:0x1031a6270&gt;</var>
127
+ </cgi-data>
128
+ </request>
129
+ <server-environment>
130
+ <project-root>/Users/neerajdotname/dev/working/exception2db_demo</project-root>
131
+ <environment-name>production</environment-name>
132
+ </server-environment>
133
+ </notice>
134
+ }