From cc1db52918cbe6008874ad410df27d9a4ea3189f Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Tue, 7 Feb 2012 17:35:14 -0800 Subject: [PATCH] Update rails app to include smoke testing/demo functionality. --- myapp/app/controllers/work_controller.rb | 9 +++++++++ myapp/app/views/work/index.html.erb | 1 + myapp/app/workers/hard_worker.rb | 6 ++++-- myapp/config/environments/development.rb | 1 + myapp/config/routes.rb | 2 ++ 5 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 myapp/app/controllers/work_controller.rb create mode 100644 myapp/app/views/work/index.html.erb diff --git a/myapp/app/controllers/work_controller.rb b/myapp/app/controllers/work_controller.rb new file mode 100644 index 00000000..a6a8ea08 --- /dev/null +++ b/myapp/app/controllers/work_controller.rb @@ -0,0 +1,9 @@ +class WorkController < ApplicationController + def index + @count = rand(100) + puts "Adding #{@count} jobs" + @count.times do + HardWorker.perform_async('bubba', 123) + end + end +end diff --git a/myapp/app/views/work/index.html.erb b/myapp/app/views/work/index.html.erb new file mode 100644 index 00000000..bcbe068d --- /dev/null +++ b/myapp/app/views/work/index.html.erb @@ -0,0 +1 @@ +Added <%= @count %> jobs! diff --git a/myapp/app/workers/hard_worker.rb b/myapp/app/workers/hard_worker.rb index d408ee7d..322c85a8 100644 --- a/myapp/app/workers/hard_worker.rb +++ b/myapp/app/workers/hard_worker.rb @@ -1,6 +1,8 @@ class HardWorker + include Sidekiq::Worker + def perform(name, count) - sleep 0.01 - puts 'done' + sleep 1 + print "#{Time.now}\n" end end diff --git a/myapp/config/environments/development.rb b/myapp/config/environments/development.rb index a520fad5..5194d1f1 100644 --- a/myapp/config/environments/development.rb +++ b/myapp/config/environments/development.rb @@ -34,4 +34,5 @@ Myapp::Application.configure do # Expands the lines which load the assets config.assets.debug = true + config.assets.logger = nil end diff --git a/myapp/config/routes.rb b/myapp/config/routes.rb index bb0d8971..68fbd7a4 100644 --- a/myapp/config/routes.rb +++ b/myapp/config/routes.rb @@ -1,4 +1,6 @@ Myapp::Application.routes.draw do + get "work" => "work#index" + # The priority is based upon order of creation: # first created -> highest priority.