test_server 0.2.4 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +3 -0
  3. data/Gemfile +54 -29
  4. data/README.rdoc +28 -0
  5. data/Rakefile +3 -3
  6. data/app/assets/images/.keep +0 -0
  7. data/app/assets/javascripts/application.js +14 -0
  8. data/app/assets/javascripts/errors.js +2 -0
  9. data/app/assets/stylesheets/application.scss +83 -0
  10. data/app/assets/stylesheets/errors.css +4 -0
  11. data/app/controllers/concerns/.keep +0 -0
  12. data/app/controllers/test_server/application_controller.rb +34 -0
  13. data/app/controllers/test_server/dashboard_controller.rb +9 -0
  14. data/app/controllers/test_server/errors_controller.rb +22 -0
  15. data/app/controllers/test_server/generator_controller.rb +40 -0
  16. data/app/controllers/test_server/static_controller.rb +16 -0
  17. data/app/controllers/test_server/streaming_controller.rb +56 -0
  18. data/app/controllers/test_server/string_controller.rb +39 -0
  19. data/app/helpers/application_helper.rb +2 -0
  20. data/app/helpers/errors_helper.rb +2 -0
  21. data/app/mailers/.keep +0 -0
  22. data/app/models/.keep +0 -0
  23. data/app/models/concerns/.keep +0 -0
  24. data/app/views/layouts/application.html.haml +59 -0
  25. data/app/views/shared/_overview.html.haml +16 -0
  26. data/app/views/test_server/dashboard/show.html.haml +7 -0
  27. data/app/views/test_server/errors/not_found.html.haml +2 -0
  28. data/app/views/test_server/errors/show.html.haml +6 -0
  29. data/app/views/test_server/generator/_overview.html.haml +1 -0
  30. data/app/views/test_server/generator/index.html.haml +1 -0
  31. data/app/views/{xhr/show.haml → test_server/generator/xhr.html.haml} +15 -12
  32. data/app/views/test_server/static/_overview.html.haml +1 -0
  33. data/app/views/test_server/static/index.html.haml +1 -0
  34. data/app/views/test_server/streaming/_overview.html.haml +1 -0
  35. data/app/views/test_server/streaming/index.html.haml +1 -0
  36. data/app/views/test_server/string/_overview.html.haml +1 -0
  37. data/app/views/test_server/string/index.html.haml +1 -0
  38. data/config.ru +3 -50
  39. data/config/application.rb +44 -0
  40. data/config/boot.rb +4 -0
  41. data/config/database.yml +25 -0
  42. data/config/environment.rb +5 -0
  43. data/config/environments/development.rb +37 -0
  44. data/config/environments/production.rb +87 -0
  45. data/config/environments/profile.rb +85 -0
  46. data/config/environments/test.rb +39 -0
  47. data/config/initializers/backtrace_silencers.rb +7 -0
  48. data/config/initializers/breadbrumb_builder.rb +24 -0
  49. data/config/initializers/change_values.rb +5 -0
  50. data/config/initializers/cookies_serializer.rb +3 -0
  51. data/config/initializers/filter_parameter_logging.rb +4 -0
  52. data/config/initializers/inflections.rb +16 -0
  53. data/config/initializers/mime_types.rb +4 -0
  54. data/config/initializers/session_store.rb +3 -0
  55. data/config/initializers/to_bool.rb +23 -0
  56. data/config/initializers/wrap_parameters.rb +14 -0
  57. data/config/locales/en.yml +23 -0
  58. data/config/routes.rb +78 -0
  59. data/config/secrets.yml +22 -0
  60. data/lib/assets/.keep +0 -0
  61. data/lib/tasks/.keep +0 -0
  62. data/lib/test_server.rb +13 -15
  63. data/lib/test_server/error_handler.rb +15 -11
  64. data/lib/test_server/error_messages.rb +16 -6
  65. data/lib/test_server/exceptions.rb +6 -0
  66. data/lib/test_server/locales/en.yml +55 -2
  67. data/lib/test_server/permitted_params.rb +107 -0
  68. data/lib/test_server/version.rb +1 -1
  69. data/lib/test_server/web_helper.rb +7 -31
  70. data/log/.keep +0 -0
  71. data/log/development.log +0 -0
  72. data/log/test.log +1 -0
  73. data/public/404.html +67 -0
  74. data/public/422.html +67 -0
  75. data/public/500.html +66 -0
  76. data/public/favicon.ico +0 -0
  77. data/public/robots.txt +5 -0
  78. data/public/static/plain.html +11 -0
  79. data/script/bundle +3 -0
  80. data/script/rails +8 -0
  81. data/script/rake +8 -0
  82. data/script/spring +18 -0
  83. data/spec/controllers/errors_controller_spec.rb +12 -0
  84. data/spec/error_handler_spec.rb +42 -9
  85. data/spec/features/dashboard_spec.rb +35 -0
  86. data/spec/features/fetch_data_via_javascript_spec.rb +14 -14
  87. data/spec/features/fetch_test_data_plain_spec.rb +11 -29
  88. data/spec/features/fetch_test_data_via_streaming_spec.rb +6 -6
  89. data/spec/features/helper_spec.rb +23 -31
  90. data/spec/helpers/errors_helper_spec.rb +15 -0
  91. data/spec/permitted_params_spec.rb +64 -0
  92. data/spec/spec_helper.rb +44 -3
  93. data/spec/support/capybara.rb +4 -0
  94. data/spec/support/rails.rb +33 -0
  95. data/spec/views/errors/not_found.html.haml_spec.rb +5 -0
  96. data/test_server.gemspec +18 -17
  97. data/vendor/assets/components/open-sans/scss/_base.scss +5 -5
  98. data/vendor/assets/javascripts/.keep +0 -0
  99. data/vendor/assets/stylesheets/.keep +0 -0
  100. metadata +133 -116
  101. data/app/controllers/application_controller.rb +0 -76
  102. data/app/controllers/assets_controller.rb +0 -73
  103. data/app/controllers/javascript_controller.rb +0 -36
  104. data/app/controllers/streaming_controller.rb +0 -52
  105. data/app/controllers/string_controller.rb +0 -51
  106. data/app/views/layouts/application.haml +0 -19
@@ -0,0 +1,87 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = true
24
+
25
+ # Compress JavaScripts and CSS.
26
+ config.assets.js_compressor = :uglifier
27
+ config.assets.css_compressor = :sass
28
+
29
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
30
+ config.assets.compile = false
31
+
32
+ # Generate digests for assets URLs.
33
+ config.assets.digest = true
34
+
35
+ # Version of your assets, change this if you want to expire all your assets.
36
+ config.assets.version = '1.0'
37
+
38
+ # Specifies the header that your server uses for sending files.
39
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
40
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
41
+
42
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
+ # config.force_ssl = true
44
+
45
+ # Set to :debug to see everything in the log.
46
+ config.log_level = :info
47
+
48
+ # Prepend all log lines with the following tags.
49
+ # config.log_tags = [ :subdomain, :uuid ]
50
+
51
+ # Use a different logger for distributed setups.
52
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
53
+
54
+ # Use a different cache store in production.
55
+ # config.cache_store = :mem_cache_store
56
+
57
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
58
+ # config.action_controller.asset_host = "http://assets.example.com"
59
+
60
+ # Precompile additional assets.
61
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
62
+ # config.assets.precompile += %w( search.js )
63
+ #config.assets.precompile += %w( .png .gif .jpg .jpeg .svg .eot .otf .svc .woff .ttf )
64
+ config.assets.precompile << Proc.new { |path|
65
+ true if %w( .png .gif .jpg .jpeg .svg .eot .otf .svc .woff .ttf ).include? Pathname.new(path).extname
66
+ }
67
+
68
+ # Ignore bad email addresses and do not raise email delivery errors.
69
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
70
+ # config.action_mailer.raise_delivery_errors = false
71
+
72
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
73
+ # the I18n.default_locale when a translation cannot be found).
74
+ config.i18n.fallbacks = true
75
+
76
+ # Send deprecation notices to registered listeners.
77
+ config.active_support.deprecation = :notify
78
+
79
+ # Disable automatic flushing of the log to improve performance.
80
+ # config.autoflush_log = false
81
+
82
+ # Use default logging formatter so that PID and timestamp are not suppressed.
83
+ config.log_formatter = ::Logger::Formatter.new
84
+
85
+ # Do not dump schema after migrations.
86
+ config.active_record.dump_schema_after_migration = false
87
+ end
@@ -0,0 +1,85 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+ require 'ruby-prof'
4
+ config.middleware.use Rack::RubyProf, files: '/tmp/profiles'
5
+
6
+ # Code is not reloaded between requests.
7
+ config.cache_classes = true
8
+
9
+ # Eager load code on boot. This eager loads most of Rails and
10
+ # your application in memory, allowing both threaded web servers
11
+ # and those relying on copy on write to perform better.
12
+ # Rake tasks automatically ignore this option for performance.
13
+ config.eager_load = true
14
+
15
+ # Full error reports are disabled and caching is turned on.
16
+ config.consider_all_requests_local = false
17
+ config.action_controller.perform_caching = true
18
+
19
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
20
+ # Add `rack-cache` to your Gemfile before enabling this.
21
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
22
+ # config.action_dispatch.rack_cache = true
23
+
24
+ # Disable Rails's static asset server (Apache or nginx will already do this).
25
+ config.serve_static_assets = false
26
+
27
+ # Compress JavaScripts and CSS.
28
+ config.assets.js_compressor = :uglifier
29
+ config.assets.css_compressor = :sass
30
+
31
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
32
+ config.assets.compile = false
33
+
34
+ # Generate digests for assets URLs.
35
+ config.assets.digest = true
36
+
37
+ # Version of your assets, change this if you want to expire all your assets.
38
+ config.assets.version = '1.0'
39
+
40
+ # Specifies the header that your server uses for sending files.
41
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
42
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
43
+
44
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45
+ # config.force_ssl = true
46
+
47
+ # Set to :debug to see everything in the log.
48
+ config.log_level = :info
49
+
50
+ # Prepend all log lines with the following tags.
51
+ # config.log_tags = [ :subdomain, :uuid ]
52
+
53
+ # Use a different logger for distributed setups.
54
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
55
+
56
+ # Use a different cache store in production.
57
+ # config.cache_store = :mem_cache_store
58
+
59
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
60
+ # config.action_controller.asset_host = "http://assets.example.com"
61
+
62
+ # Precompile additional assets.
63
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
64
+ # config.assets.precompile += %w( search.js )
65
+
66
+ # Ignore bad email addresses and do not raise email delivery errors.
67
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
68
+ # config.action_mailer.raise_delivery_errors = false
69
+
70
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
71
+ # the I18n.default_locale when a translation cannot be found).
72
+ config.i18n.fallbacks = true
73
+
74
+ # Send deprecation notices to registered listeners.
75
+ config.active_support.deprecation = :notify
76
+
77
+ # Disable automatic flushing of the log to improve performance.
78
+ # config.autoflush_log = false
79
+
80
+ # Use default logging formatter so that PID and timestamp are not suppressed.
81
+ config.log_formatter = ::Logger::Formatter.new
82
+
83
+ # Do not dump schema after migrations.
84
+ config.active_record.dump_schema_after_migration = false
85
+ end
@@ -0,0 +1,39 @@
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.serve_static_assets = true
17
+ config.static_cache_control = 'public, max-age=3600'
18
+
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
21
+ config.action_controller.perform_caching = false
22
+
23
+ # Raise exceptions instead of rendering exception templates.
24
+ config.action_dispatch.show_exceptions = false
25
+
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Tell Action Mailer not to deliver emails to the real world.
30
+ # The :test delivery method accumulates sent emails in the
31
+ # ActionMailer::Base.deliveries array.
32
+ config.action_mailer.delivery_method = :test
33
+
34
+ # Print deprecation notices to the stderr.
35
+ config.active_support.deprecation = :stderr
36
+
37
+ # Raises error for missing translations
38
+ # config.action_view.raise_on_missing_translations = true
39
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ module TestServer
3
+ class BreadcrumbBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder
4
+ private
5
+
6
+ attr_reader :elements, :options, :context
7
+
8
+ public
9
+
10
+ def render
11
+ elements.collect { |e| render_element(e) }.join
12
+ end
13
+
14
+ def render_element(element)
15
+ if element.path == nil
16
+ content = compute_name(element)
17
+ else
18
+ content = context.link_to_unless_current(compute_name(element), compute_path(element), element.options)
19
+ end
20
+
21
+ context.content_tag('li', content)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,5 @@
1
+ class Hash
2
+ def modify_values(&block)
3
+ self.dup.inject({}) { |h, (k, v)| h[k] = block.call(v); h }
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_test_server_session'
@@ -0,0 +1,23 @@
1
+ class String
2
+ def to_bool
3
+ return true if self == true || self =~ (/(true|t|yes|y|1|on)$/i)
4
+ return false if self == false || self.blank? || self =~ (/(false|f|no|n|0|off)$/i)
5
+
6
+ #raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
7
+ self
8
+ end
9
+ end
10
+
11
+ class Integer
12
+ def to_bool
13
+ return true if self > 0
14
+
15
+ false
16
+ end
17
+ end
18
+
19
+ class Object
20
+ def to_bool
21
+ false
22
+ end
23
+ end
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
data/config/routes.rb ADDED
@@ -0,0 +1,78 @@
1
+ Rails.application.routes.draw do
2
+ scope module: 'test_server' do
3
+ root 'dashboard#show'
4
+ #match '(errors)/:exception', to: 'errors#show', constraints: {exception: /[a-z_]+/}, via: :all
5
+
6
+ get '/dashboard', to: 'dashboard#show'
7
+
8
+ get '/streaming', to: 'streaming#index'
9
+ get '/streaming/plain', to: 'streaming#plain'
10
+ get '/streaming/eicar', to: 'streaming#eicar'
11
+ get '/streaming/random', to: 'streaming#random'
12
+
13
+ get '/string', to: 'string#index'
14
+ get '/string/plain', to: 'string#plain'
15
+ get '/string/eicar', to: 'string#eicar'
16
+ get '/string/sleep', to: 'string#sleep'
17
+ get '/string/random', to: 'string#random'
18
+
19
+ get '/generator', to: 'generator#index'
20
+ get 'generator/xhr', to: 'generator#xhr', format: false
21
+
22
+ get '/static', to: 'static#index'
23
+ end
24
+
25
+ # The priority is based upon order of creation: first created -> highest priority.
26
+ # See how all your routes lay out with "rake routes".
27
+
28
+ # You can have the root of your site routed with "root"
29
+
30
+ # Example of regular route:
31
+ # get 'products/:id' => 'catalog#view'
32
+
33
+ # Example of named route that can be invoked with purchase_url(id: product.id)
34
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
35
+
36
+ # Example resource route (maps HTTP verbs to controller actions automatically):
37
+ # resources :products
38
+
39
+ # Example resource route with options:
40
+ # resources :products do
41
+ # member do
42
+ # get 'short'
43
+ # post 'toggle'
44
+ # end
45
+ #
46
+ # collection do
47
+ # get 'sold'
48
+ # end
49
+ # end
50
+
51
+ # Example resource route with sub-resources:
52
+ # resources :products do
53
+ # resources :comments, :sales
54
+ # resource :seller
55
+ # end
56
+
57
+ # Example resource route with more complex sub-resources:
58
+ # resources :products do
59
+ # resources :comments
60
+ # resources :sales do
61
+ # get 'recent', on: :collection
62
+ # end
63
+ # end
64
+
65
+ # Example resource route with concerns:
66
+ # concern :toggleable do
67
+ # post 'toggle'
68
+ # end
69
+ # resources :posts, concerns: :toggleable
70
+ # resources :photos, concerns: :toggleable
71
+
72
+ # Example resource route within a namespace:
73
+ # namespace :admin do
74
+ # # Directs /admin/products/* to Admin::ProductsController
75
+ # # (app/controllers/admin/products_controller.rb)
76
+ # resources :products
77
+ # end
78
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 27be4b81f95716c117ba6c009f395666572d99a822669e1fc37b60369f523ac4085a40a3a9aea6934c292b70396bad70cce4b3444ed92de4055b087ad3285913
15
+
16
+ test:
17
+ secret_key_base: 9f369bb6f015b57c3a2151cc9d74f0a108a1b729d6d863fac656c31064a23089c2369070258a8fe67048ddc0d9dff59953ca9afab5a61e5b6dda62a65d02d082
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>