bot-away 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/.travis.yml +14 -0
  2. data/History.txt +20 -0
  3. data/README.md +198 -0
  4. data/Rakefile +14 -94
  5. data/bot-away.gemspec +20 -87
  6. data/gemfiles/Gemfile.rails-3.0.x +8 -0
  7. data/gemfiles/Gemfile.rails-3.0.x.lock +121 -0
  8. data/gemfiles/Gemfile.rails-3.1.x +8 -0
  9. data/gemfiles/Gemfile.rails-3.1.x.lock +133 -0
  10. data/lib/bot-away.rb +15 -13
  11. data/lib/bot-away/action_dispatch/params_parser.rb +22 -0
  12. data/lib/bot-away/action_view/helpers/instance_tag.rb +36 -12
  13. data/lib/bot-away/param_parser.rb +2 -2
  14. data/lib/bot-away/railtie.rb +10 -0
  15. data/lib/bot-away/test_case.rb +58 -0
  16. data/lib/bot-away/test_case/controller_test_case.rb +11 -0
  17. data/lib/bot-away/test_case/instance_tag_test_case.rb +15 -0
  18. data/lib/bot-away/test_case/matchers.rb +20 -0
  19. data/lib/bot-away/test_case/matchers/honeypot_matcher.rb +30 -0
  20. data/lib/bot-away/test_case/matchers/obfuscation_matcher.rb +30 -0
  21. data/lib/bot-away/test_case/mock_object.rb +16 -0
  22. data/lib/bot-away/version.rb +12 -0
  23. data/lib/locale/honeypots.yml +6 -0
  24. data/spec/controllers/basic_form_view_spec.rb +112 -0
  25. data/spec/controllers/{test_controller_spec.rb → tests_controller_spec.rb} +29 -80
  26. data/spec/integration/params_post_spec.rb +42 -0
  27. data/spec/lib/action_view/helpers/instance_tag_spec.rb +94 -0
  28. data/spec/{views/lib → lib/action_view}/param_parser_spec.rb +10 -10
  29. data/spec/spec_helper.rb +37 -105
  30. data/spec/test_rails_app/app/controllers/tests_controller.rb +11 -0
  31. data/spec/test_rails_app/app/models/post.rb +13 -0
  32. data/spec/test_rails_app/app/views/tests/basic_form.html.erb +5 -0
  33. data/spec/test_rails_app/app/views/tests/model_form.html.erb +12 -0
  34. data/spec/test_rails_app/config/locales/bot-away-overrides.yml +6 -0
  35. data/spec/views/form_builder_spec.rb +118 -0
  36. metadata +94 -137
  37. data/Manifest.txt +0 -23
  38. data/README.rdoc +0 -179
  39. data/VERSION +0 -1
  40. data/lib/bot-away/action_dispatch/request.rb +0 -20
  41. data/spec/rspec_version.rb +0 -19
  42. data/spec/support/honeypot_matcher.rb +0 -30
  43. data/spec/support/obfuscation_helper.rb +0 -123
  44. data/spec/support/obfuscation_matcher.rb +0 -28
  45. data/spec/support/rails/mock_logger.rb +0 -21
  46. data/spec/support/test_controller.rb +0 -28
  47. data/spec/support/views/test/index.html.erb +0 -4
  48. data/spec/support/views/test/model_form.html.erb +0 -6
  49. data/spec/views/lib/action_view/helpers/instance_tag_spec.rb +0 -75
  50. data/spec/views/lib/disabled_for_spec.rb +0 -101
  51. data/spec/views/lib/form_builder_spec.rb +0 -56
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActionView::Helpers::FormBuilder do
4
- subject { builder }
5
-
6
- it "should not create honeypots with default values" do
7
- builder.text_field(:method_name).should match(/name="object_name\[method_name\]"[^>]*?value=""/)
8
- end
9
-
10
- context "with BotAway.show_honeypots == true" do
11
- before(:each) { BotAway.show_honeypots = true }
12
- after(:each) { BotAway.show_honeypots = false }
13
-
14
- it "should not disguise honeypots" do
15
- builder.text_area(method_name).should_not match(/<\/div>/)
16
- end
17
- end
18
-
19
- it "should not obfuscate names that have been explicitly ignored" do
20
- BotAway.accepts_unfiltered_params 'method_name'
21
- builder.text_field('method_name').should_not match(/name="#{obfuscated_name}/)
22
- BotAway.unfiltered_params.delete 'method_name'
23
- end
24
-
25
- # select(method, choices, options = {}, html_options = {})
26
- obfuscates(:select) { builder.select(:method_name, {1 => :a, 2 => :b }) }
27
-
28
- #collection_select(method, collection, value_method, text_method, options = {}, html_options = {})
29
- obfuscates(:collection_select) { builder.collection_select method_name, [MockObject.new], :method_name, :method_name }
30
-
31
- #grouped_collection_select(method, collection, group_method, group_label_method, option_key_method,
32
- # option_value_method, options = {}, html_options = {})
33
- obfuscates(:grouped_collection_select) do
34
- builder.grouped_collection_select method_name, [MockObject.new], object_name, method_name, method_name, :to_s
35
- end
36
-
37
- #time_zone_select(method, priority_zones = nil, options = {}, html_options = {})
38
- obfuscates(:time_zone_select) do
39
- builder.time_zone_select method_name
40
- end
41
-
42
- %w(hidden_field text_field text_area file_field password_field check_box).each do |field|
43
- obfuscates(field) { builder.send(field, method_name) }
44
- end
45
-
46
- obfuscates(:radio_button, RAILS_VERSION >= "3.0" ? "767c870add970ab6d64803043c4ccfbb" :
47
- "53640013be550817d040597218884288") { builder.radio_button method_name, :value }
48
-
49
- context "#label" do
50
- subject { dump { builder.label(method_name) } }
51
-
52
- it "links labels to their obfuscated elements" do
53
- subject.should match(/for=\"#{obfuscated_id}\"/)
54
- end
55
- end
56
- end