logging_worker 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +23 -0
- data/app/models/logging_worker/job_run.rb +19 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20141215211104_create_job_runs.rb +16 -0
- data/lib/logging_worker/engine.rb +4 -0
- data/lib/logging_worker/version.rb +3 -0
- data/lib/logging_worker/worker.rb +37 -0
- data/lib/logging_worker.rb +7 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/job_run.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/workers/blank_worker.rb +7 -0
- data/spec/dummy/app/workers/error_worker.rb +8 -0
- data/spec/dummy/app/workers/log_worker.rb +8 -0
- data/spec/dummy/app/workers/new_job_run_worker.rb +11 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +29 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +20 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/schema.rb +32 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/models/job_run_spec.rb +15 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/worker_spec.rb +71 -0
- metadata +208 -0
| @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            Rails.application.routes.draw do
         | 
| 2 | 
            +
              # The priority is based upon order of creation: first created -> highest priority.
         | 
| 3 | 
            +
              # See how all your routes lay out with "rake routes".
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              # You can have the root of your site routed with "root"
         | 
| 6 | 
            +
              # root 'welcome#index'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              # Example of regular route:
         | 
| 9 | 
            +
              #   get 'products/:id' => 'catalog#view'
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              # Example of named route that can be invoked with purchase_url(id: product.id)
         | 
| 12 | 
            +
              #   get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              # Example resource route (maps HTTP verbs to controller actions automatically):
         | 
| 15 | 
            +
              #   resources :products
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              # Example resource route with options:
         | 
| 18 | 
            +
              #   resources :products do
         | 
| 19 | 
            +
              #     member do
         | 
| 20 | 
            +
              #       get 'short'
         | 
| 21 | 
            +
              #       post 'toggle'
         | 
| 22 | 
            +
              #     end
         | 
| 23 | 
            +
              #
         | 
| 24 | 
            +
              #     collection do
         | 
| 25 | 
            +
              #       get 'sold'
         | 
| 26 | 
            +
              #     end
         | 
| 27 | 
            +
              #   end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              # Example resource route with sub-resources:
         | 
| 30 | 
            +
              #   resources :products do
         | 
| 31 | 
            +
              #     resources :comments, :sales
         | 
| 32 | 
            +
              #     resource :seller
         | 
| 33 | 
            +
              #   end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              # Example resource route with more complex sub-resources:
         | 
| 36 | 
            +
              #   resources :products do
         | 
| 37 | 
            +
              #     resources :comments
         | 
| 38 | 
            +
              #     resources :sales do
         | 
| 39 | 
            +
              #       get 'recent', on: :collection
         | 
| 40 | 
            +
              #     end
         | 
| 41 | 
            +
              #   end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              # Example resource route with concerns:
         | 
| 44 | 
            +
              #   concern :toggleable do
         | 
| 45 | 
            +
              #     post 'toggle'
         | 
| 46 | 
            +
              #   end
         | 
| 47 | 
            +
              #   resources :posts, concerns: :toggleable
         | 
| 48 | 
            +
              #   resources :photos, concerns: :toggleable
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              # Example resource route within a namespace:
         | 
| 51 | 
            +
              #   namespace :admin do
         | 
| 52 | 
            +
              #     # Directs /admin/products/* to Admin::ProductsController
         | 
| 53 | 
            +
              #     # (app/controllers/admin/products_controller.rb)
         | 
| 54 | 
            +
              #     resources :products
         | 
| 55 | 
            +
              #   end
         | 
| 56 | 
            +
            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: fa4fdf10c32f6724f686a3c972096705a4227776fb77527ef989b95fa966511e6412117a78e6f7dcdf262a0d6ecb5fce0a118b3cbf79764684a6882a00be2abc
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            test:
         | 
| 17 | 
            +
              secret_key_base: 3f700e4379019135c844ed834fb9b43323ff9e1fc0b651d68870de662328b91d26645547b1edabf2b5cb6849487fcb0170b79668d9c3afd84679569b6c1f4105
         | 
| 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"] %>
         | 
| @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
            # This file is auto-generated from the current state of the database. Instead
         | 
| 3 | 
            +
            # of editing this file, please use the migrations feature of Active Record to
         | 
| 4 | 
            +
            # incrementally modify your database, and then regenerate this schema definition.
         | 
| 5 | 
            +
            #
         | 
| 6 | 
            +
            # Note that this schema.rb definition is the authoritative source for your
         | 
| 7 | 
            +
            # database schema. If you need to create the application database on another
         | 
| 8 | 
            +
            # system, you should be using db:schema:load, not running all the migrations
         | 
| 9 | 
            +
            # from scratch. The latter is a flawed and unsustainable approach (the more migrations
         | 
| 10 | 
            +
            # you'll amass, the slower it'll run and the greater likelihood for issues).
         | 
| 11 | 
            +
            #
         | 
| 12 | 
            +
            # It's strongly recommended that you check this file into your version control system.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            ActiveRecord::Schema.define(version: 20141215211104) do
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              # These are extensions that must be enabled in order to support this database
         | 
| 17 | 
            +
              enable_extension "plpgsql"
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              create_table "job_runs", force: true do |t|
         | 
| 20 | 
            +
                t.string   "worker_class"
         | 
| 21 | 
            +
                t.string   "arguments",       array: true
         | 
| 22 | 
            +
                t.boolean  "successful"
         | 
| 23 | 
            +
                t.datetime "completed_at"
         | 
| 24 | 
            +
                t.text     "log"
         | 
| 25 | 
            +
                t.text     "error_class"
         | 
| 26 | 
            +
                t.text     "error_message"
         | 
| 27 | 
            +
                t.text     "error_backtrace", array: true
         | 
| 28 | 
            +
                t.datetime "created_at"
         | 
| 29 | 
            +
                t.datetime "updated_at"
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            end
         | 
| @@ -0,0 +1,67 @@ | |
| 1 | 
            +
            <!DOCTYPE html>
         | 
| 2 | 
            +
            <html>
         | 
| 3 | 
            +
            <head>
         | 
| 4 | 
            +
              <title>The page you were looking for doesn't exist (404)</title>
         | 
| 5 | 
            +
              <meta name="viewport" content="width=device-width,initial-scale=1">
         | 
| 6 | 
            +
              <style>
         | 
| 7 | 
            +
              body {
         | 
| 8 | 
            +
                background-color: #EFEFEF;
         | 
| 9 | 
            +
                color: #2E2F30;
         | 
| 10 | 
            +
                text-align: center;
         | 
| 11 | 
            +
                font-family: arial, sans-serif;
         | 
| 12 | 
            +
                margin: 0;
         | 
| 13 | 
            +
              }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              div.dialog {
         | 
| 16 | 
            +
                width: 95%;
         | 
| 17 | 
            +
                max-width: 33em;
         | 
| 18 | 
            +
                margin: 4em auto 0;
         | 
| 19 | 
            +
              }
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              div.dialog > div {
         | 
| 22 | 
            +
                border: 1px solid #CCC;
         | 
| 23 | 
            +
                border-right-color: #999;
         | 
| 24 | 
            +
                border-left-color: #999;
         | 
| 25 | 
            +
                border-bottom-color: #BBB;
         | 
| 26 | 
            +
                border-top: #B00100 solid 4px;
         | 
| 27 | 
            +
                border-top-left-radius: 9px;
         | 
| 28 | 
            +
                border-top-right-radius: 9px;
         | 
| 29 | 
            +
                background-color: white;
         | 
| 30 | 
            +
                padding: 7px 12% 0;
         | 
| 31 | 
            +
                box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
         | 
| 32 | 
            +
              }
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              h1 {
         | 
| 35 | 
            +
                font-size: 100%;
         | 
| 36 | 
            +
                color: #730E15;
         | 
| 37 | 
            +
                line-height: 1.5em;
         | 
| 38 | 
            +
              }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              div.dialog > p {
         | 
| 41 | 
            +
                margin: 0 0 1em;
         | 
| 42 | 
            +
                padding: 1em;
         | 
| 43 | 
            +
                background-color: #F7F7F7;
         | 
| 44 | 
            +
                border: 1px solid #CCC;
         | 
| 45 | 
            +
                border-right-color: #999;
         | 
| 46 | 
            +
                border-left-color: #999;
         | 
| 47 | 
            +
                border-bottom-color: #999;
         | 
| 48 | 
            +
                border-bottom-left-radius: 4px;
         | 
| 49 | 
            +
                border-bottom-right-radius: 4px;
         | 
| 50 | 
            +
                border-top-color: #DADADA;
         | 
| 51 | 
            +
                color: #666;
         | 
| 52 | 
            +
                box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
         | 
| 53 | 
            +
              }
         | 
| 54 | 
            +
              </style>
         | 
| 55 | 
            +
            </head>
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            <body>
         | 
| 58 | 
            +
              <!-- This file lives in public/404.html -->
         | 
| 59 | 
            +
              <div class="dialog">
         | 
| 60 | 
            +
                <div>
         | 
| 61 | 
            +
                  <h1>The page you were looking for doesn't exist.</h1>
         | 
| 62 | 
            +
                  <p>You may have mistyped the address or the page may have moved.</p>
         | 
| 63 | 
            +
                </div>
         | 
| 64 | 
            +
                <p>If you are the application owner check the logs for more information.</p>
         | 
| 65 | 
            +
              </div>
         | 
| 66 | 
            +
            </body>
         | 
| 67 | 
            +
            </html>
         | 
| @@ -0,0 +1,67 @@ | |
| 1 | 
            +
            <!DOCTYPE html>
         | 
| 2 | 
            +
            <html>
         | 
| 3 | 
            +
            <head>
         | 
| 4 | 
            +
              <title>The change you wanted was rejected (422)</title>
         | 
| 5 | 
            +
              <meta name="viewport" content="width=device-width,initial-scale=1">
         | 
| 6 | 
            +
              <style>
         | 
| 7 | 
            +
              body {
         | 
| 8 | 
            +
                background-color: #EFEFEF;
         | 
| 9 | 
            +
                color: #2E2F30;
         | 
| 10 | 
            +
                text-align: center;
         | 
| 11 | 
            +
                font-family: arial, sans-serif;
         | 
| 12 | 
            +
                margin: 0;
         | 
| 13 | 
            +
              }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              div.dialog {
         | 
| 16 | 
            +
                width: 95%;
         | 
| 17 | 
            +
                max-width: 33em;
         | 
| 18 | 
            +
                margin: 4em auto 0;
         | 
| 19 | 
            +
              }
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              div.dialog > div {
         | 
| 22 | 
            +
                border: 1px solid #CCC;
         | 
| 23 | 
            +
                border-right-color: #999;
         | 
| 24 | 
            +
                border-left-color: #999;
         | 
| 25 | 
            +
                border-bottom-color: #BBB;
         | 
| 26 | 
            +
                border-top: #B00100 solid 4px;
         | 
| 27 | 
            +
                border-top-left-radius: 9px;
         | 
| 28 | 
            +
                border-top-right-radius: 9px;
         | 
| 29 | 
            +
                background-color: white;
         | 
| 30 | 
            +
                padding: 7px 12% 0;
         | 
| 31 | 
            +
                box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
         | 
| 32 | 
            +
              }
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              h1 {
         | 
| 35 | 
            +
                font-size: 100%;
         | 
| 36 | 
            +
                color: #730E15;
         | 
| 37 | 
            +
                line-height: 1.5em;
         | 
| 38 | 
            +
              }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              div.dialog > p {
         | 
| 41 | 
            +
                margin: 0 0 1em;
         | 
| 42 | 
            +
                padding: 1em;
         | 
| 43 | 
            +
                background-color: #F7F7F7;
         | 
| 44 | 
            +
                border: 1px solid #CCC;
         | 
| 45 | 
            +
                border-right-color: #999;
         | 
| 46 | 
            +
                border-left-color: #999;
         | 
| 47 | 
            +
                border-bottom-color: #999;
         | 
| 48 | 
            +
                border-bottom-left-radius: 4px;
         | 
| 49 | 
            +
                border-bottom-right-radius: 4px;
         | 
| 50 | 
            +
                border-top-color: #DADADA;
         | 
| 51 | 
            +
                color: #666;
         | 
| 52 | 
            +
                box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
         | 
| 53 | 
            +
              }
         | 
| 54 | 
            +
              </style>
         | 
| 55 | 
            +
            </head>
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            <body>
         | 
| 58 | 
            +
              <!-- This file lives in public/422.html -->
         | 
| 59 | 
            +
              <div class="dialog">
         | 
| 60 | 
            +
                <div>
         | 
| 61 | 
            +
                  <h1>The change you wanted was rejected.</h1>
         | 
| 62 | 
            +
                  <p>Maybe you tried to change something you didn't have access to.</p>
         | 
| 63 | 
            +
                </div>
         | 
| 64 | 
            +
                <p>If you are the application owner check the logs for more information.</p>
         | 
| 65 | 
            +
              </div>
         | 
| 66 | 
            +
            </body>
         | 
| 67 | 
            +
            </html>
         | 
| @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            <!DOCTYPE html>
         | 
| 2 | 
            +
            <html>
         | 
| 3 | 
            +
            <head>
         | 
| 4 | 
            +
              <title>We're sorry, but something went wrong (500)</title>
         | 
| 5 | 
            +
              <meta name="viewport" content="width=device-width,initial-scale=1">
         | 
| 6 | 
            +
              <style>
         | 
| 7 | 
            +
              body {
         | 
| 8 | 
            +
                background-color: #EFEFEF;
         | 
| 9 | 
            +
                color: #2E2F30;
         | 
| 10 | 
            +
                text-align: center;
         | 
| 11 | 
            +
                font-family: arial, sans-serif;
         | 
| 12 | 
            +
                margin: 0;
         | 
| 13 | 
            +
              }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              div.dialog {
         | 
| 16 | 
            +
                width: 95%;
         | 
| 17 | 
            +
                max-width: 33em;
         | 
| 18 | 
            +
                margin: 4em auto 0;
         | 
| 19 | 
            +
              }
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              div.dialog > div {
         | 
| 22 | 
            +
                border: 1px solid #CCC;
         | 
| 23 | 
            +
                border-right-color: #999;
         | 
| 24 | 
            +
                border-left-color: #999;
         | 
| 25 | 
            +
                border-bottom-color: #BBB;
         | 
| 26 | 
            +
                border-top: #B00100 solid 4px;
         | 
| 27 | 
            +
                border-top-left-radius: 9px;
         | 
| 28 | 
            +
                border-top-right-radius: 9px;
         | 
| 29 | 
            +
                background-color: white;
         | 
| 30 | 
            +
                padding: 7px 12% 0;
         | 
| 31 | 
            +
                box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
         | 
| 32 | 
            +
              }
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              h1 {
         | 
| 35 | 
            +
                font-size: 100%;
         | 
| 36 | 
            +
                color: #730E15;
         | 
| 37 | 
            +
                line-height: 1.5em;
         | 
| 38 | 
            +
              }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
              div.dialog > p {
         | 
| 41 | 
            +
                margin: 0 0 1em;
         | 
| 42 | 
            +
                padding: 1em;
         | 
| 43 | 
            +
                background-color: #F7F7F7;
         | 
| 44 | 
            +
                border: 1px solid #CCC;
         | 
| 45 | 
            +
                border-right-color: #999;
         | 
| 46 | 
            +
                border-left-color: #999;
         | 
| 47 | 
            +
                border-bottom-color: #999;
         | 
| 48 | 
            +
                border-bottom-left-radius: 4px;
         | 
| 49 | 
            +
                border-bottom-right-radius: 4px;
         | 
| 50 | 
            +
                border-top-color: #DADADA;
         | 
| 51 | 
            +
                color: #666;
         | 
| 52 | 
            +
                box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
         | 
| 53 | 
            +
              }
         | 
| 54 | 
            +
              </style>
         | 
| 55 | 
            +
            </head>
         | 
| 56 | 
            +
             | 
| 57 | 
            +
            <body>
         | 
| 58 | 
            +
              <!-- This file lives in public/500.html -->
         | 
| 59 | 
            +
              <div class="dialog">
         | 
| 60 | 
            +
                <div>
         | 
| 61 | 
            +
                  <h1>We're sorry, but something went wrong.</h1>
         | 
| 62 | 
            +
                </div>
         | 
| 63 | 
            +
                <p>If you are the application owner check the logs for more information.</p>
         | 
| 64 | 
            +
              </div>
         | 
| 65 | 
            +
            </body>
         | 
| 66 | 
            +
            </html>
         | 
| 
            File without changes
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe JobRun do
         | 
| 4 | 
            +
              specify "array arguments column" do
         | 
| 5 | 
            +
                job_run = JobRun.create(:arguments => ["one", "two"])
         | 
| 6 | 
            +
                job_run = JobRun.find(job_run.id)
         | 
| 7 | 
            +
                expect(job_run.arguments).to be_a(Array)
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              specify "logging during the run" do
         | 
| 11 | 
            +
                job_run = JobRun.new
         | 
| 12 | 
            +
                job_run.logger.info("test")
         | 
| 13 | 
            +
                expect(job_run.log).to include("test")
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            # This file is copied to spec/ when you run 'rails generate rspec:install'
         | 
| 2 | 
            +
            ENV["RAILS_ENV"] ||= 'test'
         | 
| 3 | 
            +
            require File.expand_path("../dummy/config/environment.rb", __FILE__)
         | 
| 4 | 
            +
            require 'rspec/rails'
         | 
| 5 | 
            +
            require 'rspec/autorun'
         | 
| 6 | 
            +
            require 'pry'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            # Checks for pending migrations before tests are run.
         | 
| 9 | 
            +
            # If you are not using ActiveRecord, you can remove this line.
         | 
| 10 | 
            +
            ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            RSpec.configure do |config|
         | 
| 13 | 
            +
              # If you're not using ActiveRecord, or you'd prefer not to run each of your
         | 
| 14 | 
            +
              # examples within a transaction, remove the following line or assign false
         | 
| 15 | 
            +
              # instead of true.
         | 
| 16 | 
            +
              config.use_transactional_fixtures = true
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              # If true, the base class of anonymous controllers will be inferred
         | 
| 19 | 
            +
              # automatically. This will be the default behavior in future versions of
         | 
| 20 | 
            +
              # rspec-rails.
         | 
| 21 | 
            +
              config.infer_base_class_for_anonymous_controllers = false
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              # Run specs in random order to surface order dependencies. If you find an
         | 
| 24 | 
            +
              # order dependency and want to debug it, you can fix the order by providing
         | 
| 25 | 
            +
              # the seed, which is printed after each run.
         | 
| 26 | 
            +
              #     --seed 1234
         | 
| 27 | 
            +
              config.order = "random"
         | 
| 28 | 
            +
            end
         | 
    
        data/spec/worker_spec.rb
    ADDED
    
    | @@ -0,0 +1,71 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe LoggingWorker::Worker do
         | 
| 4 | 
            +
              let(:worker) { BlankWorker.new }
         | 
| 5 | 
            +
              let(:error_worker) { ErrorWorker.new }
         | 
| 6 | 
            +
              let(:logging_worker) { LogWorker.new }
         | 
| 7 | 
            +
              let(:new_job_run_worker) { NewJobRunWorker.new }
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              specify "creating a job run when the worker starts performing" do
         | 
| 10 | 
            +
                expect {
         | 
| 11 | 
            +
                  worker.perform
         | 
| 12 | 
            +
                }.to change {
         | 
| 13 | 
            +
                  LoggingWorker::JobRun.count
         | 
| 14 | 
            +
                }.by(1)
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              specify "setting the completed at time" do
         | 
| 18 | 
            +
                worker.perform
         | 
| 19 | 
            +
                expect(worker.job_run.completed_at).to be > 1.second.ago
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              specify "setting the completed at time even if there was an error" do
         | 
| 23 | 
            +
                expect {
         | 
| 24 | 
            +
                  error_worker.perform
         | 
| 25 | 
            +
                }.to raise_error(RuntimeError)
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                expect(error_worker.job_run.completed_at).to be > 1.second.ago
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              specify "marking job as successful if the job finished without an error" do
         | 
| 31 | 
            +
                worker.perform
         | 
| 32 | 
            +
                expect(worker.job_run.successful).to eq(true)
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              specify "marking job as not successful if the job finished with an error" do
         | 
| 36 | 
            +
                expect {
         | 
| 37 | 
            +
                  error_worker.perform
         | 
| 38 | 
            +
                }.to raise_error(RuntimeError)
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                expect(error_worker.job_run.successful).to eq(false)
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              specify "saving the arguments" do
         | 
| 44 | 
            +
                worker.perform(true)
         | 
| 45 | 
            +
                expect(worker.job_run.arguments).to eq([true])
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              specify "saving the worker class" do
         | 
| 49 | 
            +
                worker.perform
         | 
| 50 | 
            +
                expect(worker.job_run.worker_class).to eq("BlankWorker")
         | 
| 51 | 
            +
              end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
              specify "logging inside of the worker" do
         | 
| 54 | 
            +
                logging_worker.perform
         | 
| 55 | 
            +
                expect(logging_worker.job_run.log).to include("DEBUG")
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              specify "logging the error and backtrace" do
         | 
| 59 | 
            +
                expect {
         | 
| 60 | 
            +
                  error_worker.perform
         | 
| 61 | 
            +
                }.to raise_error(RuntimeError)
         | 
| 62 | 
            +
                expect(error_worker.job_run.error_class).to eq("RuntimeError")
         | 
| 63 | 
            +
                expect(error_worker.job_run.error_message).to eq("There was a problem")
         | 
| 64 | 
            +
                expect(error_worker.job_run.error_backtrace.join).to include("error_worker.rb")
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
              specify "override the logging class" do
         | 
| 68 | 
            +
                new_job_run_worker.perform
         | 
| 69 | 
            +
                expect(new_job_run_worker.job_run).to be_a(::JobRun)
         | 
| 70 | 
            +
              end
         | 
| 71 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,208 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: logging_worker
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.1.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Eric Oestrich
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-02-27 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: rails
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '4.1'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '4.1'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: pg
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0.17'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0.17'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rspec-rails
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: '2.14'
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '2.14'
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: sidekiq
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '3.3'
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: '3.3'
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: pry
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - "~>"
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: '0.10'
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - "~>"
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: '0.10'
         | 
| 83 | 
            +
            description: Save background worker runs to the database
         | 
| 84 | 
            +
            email:
         | 
| 85 | 
            +
            - eric@oestrich.org
         | 
| 86 | 
            +
            executables: []
         | 
| 87 | 
            +
            extensions: []
         | 
| 88 | 
            +
            extra_rdoc_files: []
         | 
| 89 | 
            +
            files:
         | 
| 90 | 
            +
            - MIT-LICENSE
         | 
| 91 | 
            +
            - Rakefile
         | 
| 92 | 
            +
            - app/models/logging_worker/job_run.rb
         | 
| 93 | 
            +
            - config/routes.rb
         | 
| 94 | 
            +
            - db/migrate/20141215211104_create_job_runs.rb
         | 
| 95 | 
            +
            - lib/logging_worker.rb
         | 
| 96 | 
            +
            - lib/logging_worker/engine.rb
         | 
| 97 | 
            +
            - lib/logging_worker/version.rb
         | 
| 98 | 
            +
            - lib/logging_worker/worker.rb
         | 
| 99 | 
            +
            - spec/dummy/README.rdoc
         | 
| 100 | 
            +
            - spec/dummy/Rakefile
         | 
| 101 | 
            +
            - spec/dummy/app/assets/javascripts/application.js
         | 
| 102 | 
            +
            - spec/dummy/app/assets/stylesheets/application.css
         | 
| 103 | 
            +
            - spec/dummy/app/controllers/application_controller.rb
         | 
| 104 | 
            +
            - spec/dummy/app/helpers/application_helper.rb
         | 
| 105 | 
            +
            - spec/dummy/app/models/job_run.rb
         | 
| 106 | 
            +
            - spec/dummy/app/views/layouts/application.html.erb
         | 
| 107 | 
            +
            - spec/dummy/app/workers/blank_worker.rb
         | 
| 108 | 
            +
            - spec/dummy/app/workers/error_worker.rb
         | 
| 109 | 
            +
            - spec/dummy/app/workers/log_worker.rb
         | 
| 110 | 
            +
            - spec/dummy/app/workers/new_job_run_worker.rb
         | 
| 111 | 
            +
            - spec/dummy/bin/bundle
         | 
| 112 | 
            +
            - spec/dummy/bin/rails
         | 
| 113 | 
            +
            - spec/dummy/bin/rake
         | 
| 114 | 
            +
            - spec/dummy/config.ru
         | 
| 115 | 
            +
            - spec/dummy/config/application.rb
         | 
| 116 | 
            +
            - spec/dummy/config/boot.rb
         | 
| 117 | 
            +
            - spec/dummy/config/database.yml
         | 
| 118 | 
            +
            - spec/dummy/config/environment.rb
         | 
| 119 | 
            +
            - spec/dummy/config/environments/development.rb
         | 
| 120 | 
            +
            - spec/dummy/config/environments/production.rb
         | 
| 121 | 
            +
            - spec/dummy/config/environments/test.rb
         | 
| 122 | 
            +
            - spec/dummy/config/initializers/assets.rb
         | 
| 123 | 
            +
            - spec/dummy/config/initializers/backtrace_silencers.rb
         | 
| 124 | 
            +
            - spec/dummy/config/initializers/cookies_serializer.rb
         | 
| 125 | 
            +
            - spec/dummy/config/initializers/filter_parameter_logging.rb
         | 
| 126 | 
            +
            - spec/dummy/config/initializers/inflections.rb
         | 
| 127 | 
            +
            - spec/dummy/config/initializers/mime_types.rb
         | 
| 128 | 
            +
            - spec/dummy/config/initializers/session_store.rb
         | 
| 129 | 
            +
            - spec/dummy/config/initializers/wrap_parameters.rb
         | 
| 130 | 
            +
            - spec/dummy/config/locales/en.yml
         | 
| 131 | 
            +
            - spec/dummy/config/routes.rb
         | 
| 132 | 
            +
            - spec/dummy/config/secrets.yml
         | 
| 133 | 
            +
            - spec/dummy/db/schema.rb
         | 
| 134 | 
            +
            - spec/dummy/public/404.html
         | 
| 135 | 
            +
            - spec/dummy/public/422.html
         | 
| 136 | 
            +
            - spec/dummy/public/500.html
         | 
| 137 | 
            +
            - spec/dummy/public/favicon.ico
         | 
| 138 | 
            +
            - spec/models/job_run_spec.rb
         | 
| 139 | 
            +
            - spec/spec_helper.rb
         | 
| 140 | 
            +
            - spec/worker_spec.rb
         | 
| 141 | 
            +
            homepage: http://smartlogic.io
         | 
| 142 | 
            +
            licenses:
         | 
| 143 | 
            +
            - MIT
         | 
| 144 | 
            +
            metadata: {}
         | 
| 145 | 
            +
            post_install_message: 
         | 
| 146 | 
            +
            rdoc_options: []
         | 
| 147 | 
            +
            require_paths:
         | 
| 148 | 
            +
            - lib
         | 
| 149 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 150 | 
            +
              requirements:
         | 
| 151 | 
            +
              - - ">="
         | 
| 152 | 
            +
                - !ruby/object:Gem::Version
         | 
| 153 | 
            +
                  version: '0'
         | 
| 154 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 155 | 
            +
              requirements:
         | 
| 156 | 
            +
              - - ">="
         | 
| 157 | 
            +
                - !ruby/object:Gem::Version
         | 
| 158 | 
            +
                  version: '0'
         | 
| 159 | 
            +
            requirements: []
         | 
| 160 | 
            +
            rubyforge_project: 
         | 
| 161 | 
            +
            rubygems_version: 2.2.2
         | 
| 162 | 
            +
            signing_key: 
         | 
| 163 | 
            +
            specification_version: 4
         | 
| 164 | 
            +
            summary: Save background worker runs
         | 
| 165 | 
            +
            test_files:
         | 
| 166 | 
            +
            - spec/models/job_run_spec.rb
         | 
| 167 | 
            +
            - spec/spec_helper.rb
         | 
| 168 | 
            +
            - spec/dummy/README.rdoc
         | 
| 169 | 
            +
            - spec/dummy/db/schema.rb
         | 
| 170 | 
            +
            - spec/dummy/app/models/job_run.rb
         | 
| 171 | 
            +
            - spec/dummy/app/helpers/application_helper.rb
         | 
| 172 | 
            +
            - spec/dummy/app/views/layouts/application.html.erb
         | 
| 173 | 
            +
            - spec/dummy/app/assets/javascripts/application.js
         | 
| 174 | 
            +
            - spec/dummy/app/assets/stylesheets/application.css
         | 
| 175 | 
            +
            - spec/dummy/app/workers/new_job_run_worker.rb
         | 
| 176 | 
            +
            - spec/dummy/app/workers/error_worker.rb
         | 
| 177 | 
            +
            - spec/dummy/app/workers/blank_worker.rb
         | 
| 178 | 
            +
            - spec/dummy/app/workers/log_worker.rb
         | 
| 179 | 
            +
            - spec/dummy/app/controllers/application_controller.rb
         | 
| 180 | 
            +
            - spec/dummy/config/routes.rb
         | 
| 181 | 
            +
            - spec/dummy/config/environments/test.rb
         | 
| 182 | 
            +
            - spec/dummy/config/environments/production.rb
         | 
| 183 | 
            +
            - spec/dummy/config/environments/development.rb
         | 
| 184 | 
            +
            - spec/dummy/config/boot.rb
         | 
| 185 | 
            +
            - spec/dummy/config/database.yml
         | 
| 186 | 
            +
            - spec/dummy/config/initializers/wrap_parameters.rb
         | 
| 187 | 
            +
            - spec/dummy/config/initializers/cookies_serializer.rb
         | 
| 188 | 
            +
            - spec/dummy/config/initializers/assets.rb
         | 
| 189 | 
            +
            - spec/dummy/config/initializers/filter_parameter_logging.rb
         | 
| 190 | 
            +
            - spec/dummy/config/initializers/inflections.rb
         | 
| 191 | 
            +
            - spec/dummy/config/initializers/mime_types.rb
         | 
| 192 | 
            +
            - spec/dummy/config/initializers/session_store.rb
         | 
| 193 | 
            +
            - spec/dummy/config/initializers/backtrace_silencers.rb
         | 
| 194 | 
            +
            - spec/dummy/config/environment.rb
         | 
| 195 | 
            +
            - spec/dummy/config/locales/en.yml
         | 
| 196 | 
            +
            - spec/dummy/config/application.rb
         | 
| 197 | 
            +
            - spec/dummy/config/secrets.yml
         | 
| 198 | 
            +
            - spec/dummy/config.ru
         | 
| 199 | 
            +
            - spec/dummy/bin/rake
         | 
| 200 | 
            +
            - spec/dummy/bin/bundle
         | 
| 201 | 
            +
            - spec/dummy/bin/rails
         | 
| 202 | 
            +
            - spec/dummy/public/favicon.ico
         | 
| 203 | 
            +
            - spec/dummy/public/500.html
         | 
| 204 | 
            +
            - spec/dummy/public/404.html
         | 
| 205 | 
            +
            - spec/dummy/public/422.html
         | 
| 206 | 
            +
            - spec/dummy/Rakefile
         | 
| 207 | 
            +
            - spec/worker_spec.rb
         | 
| 208 | 
            +
            has_rdoc: 
         |