resque-stages 0.0.1
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/.gitignore +15 -0
 - data/.rspec +3 -0
 - data/.rubocop.yml +103 -0
 - data/.rubocop_todo.yml +34 -0
 - data/.ruby-version +1 -0
 - data/.travis.yml +6 -0
 - data/CODE_OF_CONDUCT.md +74 -0
 - data/Gemfile +9 -0
 - data/Gemfile.lock +172 -0
 - data/LICENSE.txt +21 -0
 - data/README.md +250 -0
 - data/Rakefile +8 -0
 - data/bin/console +16 -0
 - data/bin/setup +8 -0
 - data/lib/resque-stages.rb +11 -0
 - data/lib/resque/plugins/stages.rb +110 -0
 - data/lib/resque/plugins/stages/cleaner.rb +36 -0
 - data/lib/resque/plugins/stages/redis_access.rb +16 -0
 - data/lib/resque/plugins/stages/staged_group.rb +181 -0
 - data/lib/resque/plugins/stages/staged_group_list.rb +79 -0
 - data/lib/resque/plugins/stages/staged_group_stage.rb +275 -0
 - data/lib/resque/plugins/stages/staged_job.rb +271 -0
 - data/lib/resque/plugins/stages/version.rb +9 -0
 - data/lib/resque/server/public/stages.css +56 -0
 - data/lib/resque/server/views/_group_stages_list_pagination.erb +67 -0
 - data/lib/resque/server/views/_group_stages_list_table.erb +25 -0
 - data/lib/resque/server/views/_stage_job_list_pagination.erb +72 -0
 - data/lib/resque/server/views/_stage_job_list_table.erb +46 -0
 - data/lib/resque/server/views/_staged_group_list_pagination.erb +67 -0
 - data/lib/resque/server/views/_staged_group_list_table.erb +44 -0
 - data/lib/resque/server/views/group_stages_list.erb +58 -0
 - data/lib/resque/server/views/groups.erb +40 -0
 - data/lib/resque/server/views/job_details.erb +91 -0
 - data/lib/resque/server/views/stage.erb +64 -0
 - data/lib/resque/stages_server.rb +240 -0
 - data/read_me/groups_list.png +0 -0
 - data/read_me/job.png +0 -0
 - data/read_me/stage.png +0 -0
 - data/read_me/stages.png +0 -0
 - data/resque-stages.gemspec +49 -0
 - data/spec/rails_helper.rb +40 -0
 - data/spec/resque/plugins/stages/cleaner_spec.rb +82 -0
 - data/spec/resque/plugins/stages/staged_group_list_spec.rb +96 -0
 - data/spec/resque/plugins/stages/staged_group_spec.rb +226 -0
 - data/spec/resque/plugins/stages/staged_group_stage_spec.rb +293 -0
 - data/spec/resque/plugins/stages/staged_job_spec.rb +324 -0
 - data/spec/resque/plugins/stages_spec.rb +369 -0
 - data/spec/resque/server/public/stages.css_spec.rb +18 -0
 - data/spec/resque/server/views/group_stages_list.erb_spec.rb +67 -0
 - data/spec/resque/server/views/groups.erb_spec.rb +81 -0
 - data/spec/resque/server/views/job_details.erb_spec.rb +100 -0
 - data/spec/resque/server/views/stage.erb_spec.rb +68 -0
 - data/spec/spec_helper.rb +104 -0
 - data/spec/support/01_utils/fake_logger.rb +7 -0
 - data/spec/support/config/redis-auth.yml +12 -0
 - data/spec/support/fake_logger.rb +7 -0
 - data/spec/support/jobs/basic_job.rb +17 -0
 - data/spec/support/jobs/compressed_job.rb +18 -0
 - data/spec/support/jobs/retry_job.rb +21 -0
 - data/spec/support/purge_all.rb +15 -0
 - metadata +297 -0
 
| 
         @@ -0,0 +1,81 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "rails_helper"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            RSpec.describe "groups.erb" do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:group_list) { Resque::Plugins::Stages::StagedGroupList.new }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:descriptions) { Array.new(5) { Faker::Lorem.sentence } }
         
     | 
| 
      
 8 
     | 
    
         
            +
              let!(:groups) do
         
     | 
| 
      
 9 
     | 
    
         
            +
                descriptions.map do |description|
         
     | 
| 
      
 10 
     | 
    
         
            +
                  Resque::Plugins::Stages::StagedGroup.new(SecureRandom.uuid, description: description)
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              include Rack::Test::Methods
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def app
         
     | 
| 
      
 17 
     | 
    
         
            +
                @app ||= Resque::Server.new
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              context "actions" do
         
     | 
| 
      
 21 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
      
 22 
     | 
    
         
            +
                  allow(Resque::Plugins::Stages::StagedGroupList).to receive(:new).and_return group_list
         
     | 
| 
      
 23 
     | 
    
         
            +
                  allow(group_list).to receive(:delete_all)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  allow(Resque::Plugins::Stages::Cleaner).to receive(:purge_all)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  allow(Resque::Plugins::Stages::Cleaner).to receive(:cleanup_jobs)
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                it "should respond to /stages/delete_all_groups" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  post "/stages/delete_all_groups"
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  expect(last_response).to be_redirect
         
     | 
| 
      
 32 
     | 
    
         
            +
                  expect(last_response.header["Location"]).to match(/stages$/)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  expect(group_list).to have_received(:delete_all)
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                it "should respond to /stages/purge_all" do
         
     | 
| 
      
 37 
     | 
    
         
            +
                  post "/stages/purge_all"
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  expect(last_response).to be_redirect
         
     | 
| 
      
 40 
     | 
    
         
            +
                  expect(last_response.header["Location"]).to match(/stages$/)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  expect(Resque::Plugins::Stages::Cleaner).to have_received(:purge_all)
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                it "should respond to /stages/cleanup_jobs" do
         
     | 
| 
      
 45 
     | 
    
         
            +
                  post "/stages/cleanup_jobs"
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                  expect(last_response).to be_redirect
         
     | 
| 
      
 48 
     | 
    
         
            +
                  expect(last_response.header["Location"]).to match(/stages$/)
         
     | 
| 
      
 49 
     | 
    
         
            +
                  expect(Resque::Plugins::Stages::Cleaner).to have_received(:cleanup_jobs)
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
              it "should respond to /stages" do
         
     | 
| 
      
 54 
     | 
    
         
            +
                get "/stages"
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                expect(last_response).to be_ok
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                expect(last_response.body).to match %r{action="/stages/delete_all_groups"}
         
     | 
| 
      
 59 
     | 
    
         
            +
                expect(last_response.body).to match %r{action="/stages/purge_all"}
         
     | 
| 
      
 60 
     | 
    
         
            +
                expect(last_response.body).to match %r{action="/stages/cleanup_jobs"}
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                expect(last_response.body).to match %r{&sort=description">(\n *)?Description\n +</a>}
         
     | 
| 
      
 63 
     | 
    
         
            +
                expect(last_response.body).to match %r{&sort=num_stages">(\n *)?Num Stages\n +</a>}
         
     | 
| 
      
 64 
     | 
    
         
            +
                expect(last_response.body).to match %r{&sort=created_at">(\n *)?Created\n +</a>}
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                groups.each do |group|
         
     | 
| 
      
 67 
     | 
    
         
            +
                  expect(last_response.body).to match %r{#{group.description}\n +</a>}
         
     | 
| 
      
 68 
     | 
    
         
            +
                  expect(last_response.body).to match %r{/group_stages_list\?#{{ group_id: group.group_id }.to_param.gsub("+", "\\\\+")}}
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
              end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
              it "pages queues" do
         
     | 
| 
      
 73 
     | 
    
         
            +
                get "/stages?page_size=2"
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                expect(last_response).to be_ok
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                expect(last_response.body).to match(%r{href="/stages?.*page_num=2})
         
     | 
| 
      
 78 
     | 
    
         
            +
                expect(last_response.body).to match(%r{href="/stages?.*page_num=3})
         
     | 
| 
      
 79 
     | 
    
         
            +
                expect(last_response.body).not_to match(%r{href="/stages?.*page_num=4})
         
     | 
| 
      
 80 
     | 
    
         
            +
              end
         
     | 
| 
      
 81 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,100 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "rails_helper"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            RSpec.describe "job_details.erb" do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:group) { Resque::Plugins::Stages::StagedGroup.new(SecureRandom.uuid) }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:stage) { group.current_stage }
         
     | 
| 
      
 8 
     | 
    
         
            +
              let(:test_args) do
         
     | 
| 
      
 9 
     | 
    
         
            +
                rand_args = []
         
     | 
| 
      
 10 
     | 
    
         
            +
                rand_args << Faker::Lorem.sentence
         
     | 
| 
      
 11 
     | 
    
         
            +
                rand_args << Faker::Lorem.paragraph
         
     | 
| 
      
 12 
     | 
    
         
            +
                rand_args << SecureRandom.uuid.to_s
         
     | 
| 
      
 13 
     | 
    
         
            +
                rand_args << rand(0..1_000_000_000_000_000_000_000_000).to_s
         
     | 
| 
      
 14 
     | 
    
         
            +
                rand_args << rand(0..1_000_000_000_000).seconds.ago.to_s
         
     | 
| 
      
 15 
     | 
    
         
            +
                rand_args << rand(0..1_000_000_000_000).seconds.from_now.to_s
         
     | 
| 
      
 16 
     | 
    
         
            +
                rand_args << Array.new(rand(1..5)) { Faker::Lorem.word }
         
     | 
| 
      
 17 
     | 
    
         
            +
                rand_args << Array.new(rand(1..5)).each_with_object({}) do |_nil_value, sub_hash|
         
     | 
| 
      
 18 
     | 
    
         
            +
                  sub_hash[Faker::Lorem.word] = Faker::Lorem.word
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                rand_args = rand_args.sample(rand(3..rand_args.length))
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                if [true, false].sample
         
     | 
| 
      
 24 
     | 
    
         
            +
                  options_hash                    = {}
         
     | 
| 
      
 25 
     | 
    
         
            +
                  options_hash[Faker::Lorem.word] = Faker::Lorem.sentence
         
     | 
| 
      
 26 
     | 
    
         
            +
                  options_hash[Faker::Lorem.word] = Faker::Lorem.paragraph
         
     | 
| 
      
 27 
     | 
    
         
            +
                  options_hash[Faker::Lorem.word] = SecureRandom.uuid.to_s
         
     | 
| 
      
 28 
     | 
    
         
            +
                  options_hash[Faker::Lorem.word] = rand(0..1_000_000_000_000_000_000_000_000).to_s
         
     | 
| 
      
 29 
     | 
    
         
            +
                  options_hash[Faker::Lorem.word] = rand(0..1_000_000_000_000).seconds.ago.to_s
         
     | 
| 
      
 30 
     | 
    
         
            +
                  options_hash[Faker::Lorem.word] = rand(0..1_000_000_000_000).seconds.from_now.to_s
         
     | 
| 
      
 31 
     | 
    
         
            +
                  options_hash[Faker::Lorem.word] = Array.new(rand(1..5)) { Faker::Lorem.word }
         
     | 
| 
      
 32 
     | 
    
         
            +
                  options_hash[Faker::Lorem.word] = Array.new(rand(1..5)).
         
     | 
| 
      
 33 
     | 
    
         
            +
                      each_with_object({}) do |_nil_value, sub_hash|
         
     | 
| 
      
 34 
     | 
    
         
            +
                    sub_hash[Faker::Lorem.word] = Faker::Lorem.word
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  rand_args << options_hash.slice(*options_hash.keys.sample(rand(5..options_hash.keys.length)))
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                rand_args
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
              let(:job_id) { job.job_id }
         
     | 
| 
      
 43 
     | 
    
         
            +
              let(:job) do
         
     | 
| 
      
 44 
     | 
    
         
            +
                stage.enqueue BasicJob, *test_args
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              include Rack::Test::Methods
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              def app
         
     | 
| 
      
 50 
     | 
    
         
            +
                @app ||= Resque::Server.new
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
              before(:each) do
         
     | 
| 
      
 54 
     | 
    
         
            +
                allow(Resque).to receive(:enqueue).and_call_original
         
     | 
| 
      
 55 
     | 
    
         
            +
                allow(Resque::Plugins::Stages::StagedJob).to receive(:new).and_return job
         
     | 
| 
      
 56 
     | 
    
         
            +
                allow(job).to receive(:delete)
         
     | 
| 
      
 57 
     | 
    
         
            +
                allow(job).to receive(:enqueue_job)
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              it "should respond to /stages/delete_job" do
         
     | 
| 
      
 61 
     | 
    
         
            +
                post "/stages/delete_job?job_id=#{job.job_id}"
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                expect(last_response).to be_redirect
         
     | 
| 
      
 64 
     | 
    
         
            +
                expect(last_response.header["Location"]).to match(/stages$/)
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                expect(job).to have_received(:delete)
         
     | 
| 
      
 67 
     | 
    
         
            +
              end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
              it "should respond to /stages/queue_job" do
         
     | 
| 
      
 70 
     | 
    
         
            +
                post "/stages/queue_job?job_id=#{job.job_id}"
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                expect(last_response).to be_redirect
         
     | 
| 
      
 73 
     | 
    
         
            +
                expect(last_response.header["Location"]).to match(/stages$/)
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                expect(job).to have_received(:enqueue_job)
         
     | 
| 
      
 76 
     | 
    
         
            +
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              it "should respond to /stages/job_details" do
         
     | 
| 
      
 79 
     | 
    
         
            +
                get "/stages/job_details?job_id=#{job.job_id}"
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                expect(last_response).to be_ok
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                expect(last_response.body).to match %r{action="/stages/delete_job\?#{{ job_id: job.job_id }.to_param}"}
         
     | 
| 
      
 84 
     | 
    
         
            +
                expect(last_response.body).to match %r{action="/stages/queue_job\?#{{ job_id: job.job_id }.to_param}"}
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                expect(last_response.body).to match(%r{Enqueued(\n *)</td>})
         
     | 
| 
      
 87 
     | 
    
         
            +
                expect(last_response.body).to match(%r{Status(\n *)</td>})
         
     | 
| 
      
 88 
     | 
    
         
            +
                expect(last_response.body).to match(%r{Class(\n *)</td>})
         
     | 
| 
      
 89 
     | 
    
         
            +
                expect(last_response.body).to match(%r{Params(\n *)</td>})
         
     | 
| 
      
 90 
     | 
    
         
            +
                expect(last_response.body).to match(%r{Message(\n *)</td>})
         
     | 
| 
      
 91 
     | 
    
         
            +
              end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
              it "shows the parameters for the jobs" do
         
     | 
| 
      
 94 
     | 
    
         
            +
                get "/stages/job_details?job_id=#{job.job_id}"
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                expect(last_response).to be_ok
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                expect(last_response.body).to be_include("".html_safe + job.uncompressed_args.to_yaml)
         
     | 
| 
      
 99 
     | 
    
         
            +
              end
         
     | 
| 
      
 100 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,68 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "rails_helper"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            RSpec.describe "groups.erb" do
         
     | 
| 
      
 6 
     | 
    
         
            +
              let(:group) { Resque::Plugins::Stages::StagedGroup.new(SecureRandom.uuid) }
         
     | 
| 
      
 7 
     | 
    
         
            +
              let(:stage) { group.current_stage }
         
     | 
| 
      
 8 
     | 
    
         
            +
              let(:numbers) { Array.new(5) { |index| index } }
         
     | 
| 
      
 9 
     | 
    
         
            +
              let!(:jobs) do
         
     | 
| 
      
 10 
     | 
    
         
            +
                numbers.map do |number|
         
     | 
| 
      
 11 
     | 
    
         
            +
                  stage.enqueue BasicJob, number
         
     | 
| 
      
 12 
     | 
    
         
            +
                end
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              include Rack::Test::Methods
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              def app
         
     | 
| 
      
 18 
     | 
    
         
            +
                @app ||= Resque::Server.new
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              context "actions" do
         
     | 
| 
      
 22 
     | 
    
         
            +
                before(:each) do
         
     | 
| 
      
 23 
     | 
    
         
            +
                  allow(Resque::Plugins::Stages::StagedGroupStage).to receive(:new).and_return stage
         
     | 
| 
      
 24 
     | 
    
         
            +
                  allow(stage).to receive(:delete)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  allow(stage).to receive(:initiate)
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                it "should respond to /stages/initiate_stage" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  post "/stages/initiate_stage?group_stage_id=#{stage.group_stage_id}"
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  expect(last_response).to be_redirect
         
     | 
| 
      
 32 
     | 
    
         
            +
                  expect(last_response.header["Location"]).to match(/stages$/)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  expect(stage).to have_received(:initiate)
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                it "should respond to /stages/delete_stage" do
         
     | 
| 
      
 37 
     | 
    
         
            +
                  post "/stages/delete_stage?group_stage_id=#{stage.group_stage_id}"
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                  expect(last_response).to be_redirect
         
     | 
| 
      
 40 
     | 
    
         
            +
                  expect(last_response.header["Location"]).to match(/stages$/)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  expect(stage).to have_received(:delete)
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              it "should respond to /stages/stage" do
         
     | 
| 
      
 46 
     | 
    
         
            +
                get "/stages/stage?group_stage_id=#{stage.group_stage_id}"
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                expect(last_response).to be_ok
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                expect(last_response.body).to match %r{action="/stages/delete_stage\?group_stage_id=#{stage.group_stage_id}"}
         
     | 
| 
      
 51 
     | 
    
         
            +
                expect(last_response.body).to match %r{action="/stages/initiate_stage\?group_stage_id=#{stage.group_stage_id}"}
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                jobs.each do |job|
         
     | 
| 
      
 54 
     | 
    
         
            +
                  expect(last_response.body).to match %r{#{job.class_name}\n +</a>}
         
     | 
| 
      
 55 
     | 
    
         
            +
                  expect(last_response.body).to match %r{/stages/job_details\?#{{ job_id: job.job_id }.to_param.gsub("+", "\\\\+")}}
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              it "pages queues" do
         
     | 
| 
      
 60 
     | 
    
         
            +
                get "/stages/stage?group_stage_id=#{stage.group_stage_id}&page_size=2"
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                expect(last_response).to be_ok
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                expect(last_response.body).to match(%r{href="/stages/stage?.*group_stage_id=#{stage.group_stage_id}.*page_num=2})
         
     | 
| 
      
 65 
     | 
    
         
            +
                expect(last_response.body).to match(%r{href="/stages/stage?.*group_stage_id=#{stage.group_stage_id}.*page_num=3})
         
     | 
| 
      
 66 
     | 
    
         
            +
                expect(last_response.body).not_to match(%r{href="/stages/stage?.*group_stage_id=#{stage.group_stage_id}.*page_num=4})
         
     | 
| 
      
 67 
     | 
    
         
            +
              end
         
     | 
| 
      
 68 
     | 
    
         
            +
            end
         
     | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,104 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # This file was generated by the `rspec --init` command. Conventionally, all
         
     | 
| 
      
 4 
     | 
    
         
            +
            # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
         
     | 
| 
      
 5 
     | 
    
         
            +
            # The generated `.rspec` file contains `--require spec_helper` which will cause
         
     | 
| 
      
 6 
     | 
    
         
            +
            # this file to always be loaded, without a need to explicitly require it in any
         
     | 
| 
      
 7 
     | 
    
         
            +
            # files.
         
     | 
| 
      
 8 
     | 
    
         
            +
            #
         
     | 
| 
      
 9 
     | 
    
         
            +
            # Given that it is always loaded, you are encouraged to keep this file as
         
     | 
| 
      
 10 
     | 
    
         
            +
            # light-weight as possible. Requiring heavyweight dependencies from this file
         
     | 
| 
      
 11 
     | 
    
         
            +
            # will add to the boot time of your test suite on EVERY test run, even for an
         
     | 
| 
      
 12 
     | 
    
         
            +
            # individual file that may not need all of that loaded. Instead, consider making
         
     | 
| 
      
 13 
     | 
    
         
            +
            # a separate helper file that requires the additional dependencies and performs
         
     | 
| 
      
 14 
     | 
    
         
            +
            # the additional setup, and require it from the spec files that actually need
         
     | 
| 
      
 15 
     | 
    
         
            +
            # it.
         
     | 
| 
      
 16 
     | 
    
         
            +
            #
         
     | 
| 
      
 17 
     | 
    
         
            +
            # The `.rspec` file also contains a few flags that are not defaults but that
         
     | 
| 
      
 18 
     | 
    
         
            +
            # users commonly want.
         
     | 
| 
      
 19 
     | 
    
         
            +
            #
         
     | 
| 
      
 20 
     | 
    
         
            +
            # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
         
     | 
| 
      
 21 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 22 
     | 
    
         
            +
              # rspec-expectations config goes here. You can use an alternate
         
     | 
| 
      
 23 
     | 
    
         
            +
              # assertion/expectation library such as wrong or the stdlib/minitest
         
     | 
| 
      
 24 
     | 
    
         
            +
              # assertions if you prefer.
         
     | 
| 
      
 25 
     | 
    
         
            +
              config.expect_with :rspec do |expectations|
         
     | 
| 
      
 26 
     | 
    
         
            +
                # This option will default to `true` in RSpec 4. It makes the `description`
         
     | 
| 
      
 27 
     | 
    
         
            +
                # and `failure_message` of custom matchers include text for helper methods
         
     | 
| 
      
 28 
     | 
    
         
            +
                # defined using `chain`, e.g.:
         
     | 
| 
      
 29 
     | 
    
         
            +
                #     be_bigger_than(2).and_smaller_than(4).description
         
     | 
| 
      
 30 
     | 
    
         
            +
                #     # => "be bigger than 2 and smaller than 4"
         
     | 
| 
      
 31 
     | 
    
         
            +
                # ...rather than:
         
     | 
| 
      
 32 
     | 
    
         
            +
                #     # => "be bigger than 2"
         
     | 
| 
      
 33 
     | 
    
         
            +
                expectations.include_chain_clauses_in_custom_matcher_descriptions = true
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                expectations.syntax = :expect
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              # rspec-mocks config goes here. You can use an alternate test double
         
     | 
| 
      
 39 
     | 
    
         
            +
              # library (such as bogus or mocha) by changing the `mock_with` option here.
         
     | 
| 
      
 40 
     | 
    
         
            +
              config.mock_with :rspec do |mocks|
         
     | 
| 
      
 41 
     | 
    
         
            +
                # Prevents you from mocking or stubbing a method that does not exist on
         
     | 
| 
      
 42 
     | 
    
         
            +
                # a real object. This is generally recommended, and will default to
         
     | 
| 
      
 43 
     | 
    
         
            +
                # `true` in RSpec 4.
         
     | 
| 
      
 44 
     | 
    
         
            +
                mocks.verify_partial_doubles = true
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
         
     | 
| 
      
 48 
     | 
    
         
            +
              # have no way to turn it off -- the option exists only for backwards
         
     | 
| 
      
 49 
     | 
    
         
            +
              # compatibility in RSpec 3). It causes shared context metadata to be
         
     | 
| 
      
 50 
     | 
    
         
            +
              # inherited by the metadata hash of host groups and examples, rather than
         
     | 
| 
      
 51 
     | 
    
         
            +
              # triggering implicit auto-inclusion in groups with matching metadata.
         
     | 
| 
      
 52 
     | 
    
         
            +
              config.shared_context_metadata_behavior = :apply_to_host_groups
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              # This allows you to limit a spec run to individual examples or groups
         
     | 
| 
      
 55 
     | 
    
         
            +
              # you care about by tagging them with `:focus` metadata. When nothing
         
     | 
| 
      
 56 
     | 
    
         
            +
              # is tagged with `:focus`, all examples get run. RSpec also provides
         
     | 
| 
      
 57 
     | 
    
         
            +
              # aliases for `it`, `describe`, and `context` that include `:focus`
         
     | 
| 
      
 58 
     | 
    
         
            +
              # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
         
     | 
| 
      
 59 
     | 
    
         
            +
              config.filter_run_when_matching :focus
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
              # Allows RSpec to persist some state between runs in order to support
         
     | 
| 
      
 62 
     | 
    
         
            +
              # the `--only-failures` and `--next-failure` CLI options. We recommend
         
     | 
| 
      
 63 
     | 
    
         
            +
              # you configure your source control system to ignore this file.
         
     | 
| 
      
 64 
     | 
    
         
            +
              # config.example_status_persistence_file_path = "spec/examples.txt"
         
     | 
| 
      
 65 
     | 
    
         
            +
              config.example_status_persistence_file_path = "log/.rspec_status"
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              # Limits the available syntax to the non-monkey patched syntax that is
         
     | 
| 
      
 68 
     | 
    
         
            +
              # recommended. For more details, see:
         
     | 
| 
      
 69 
     | 
    
         
            +
              #   - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
         
     | 
| 
      
 70 
     | 
    
         
            +
              #   - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
         
     | 
| 
      
 71 
     | 
    
         
            +
              #   - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
         
     | 
| 
      
 72 
     | 
    
         
            +
              config.disable_monkey_patching!
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
              # This setting enables warnings. It's recommended, but in some cases may
         
     | 
| 
      
 75 
     | 
    
         
            +
              # be too noisy due to issues in dependencies.
         
     | 
| 
      
 76 
     | 
    
         
            +
              config.warnings = true
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              # Many RSpec users commonly either run the entire suite or an individual
         
     | 
| 
      
 79 
     | 
    
         
            +
              # file, and it's useful to allow more verbose output when running an
         
     | 
| 
      
 80 
     | 
    
         
            +
              # individual spec file.
         
     | 
| 
      
 81 
     | 
    
         
            +
              if config.files_to_run.one?
         
     | 
| 
      
 82 
     | 
    
         
            +
                # Use the documentation formatter for detailed output,
         
     | 
| 
      
 83 
     | 
    
         
            +
                # unless a formatter has already been configured
         
     | 
| 
      
 84 
     | 
    
         
            +
                # (e.g. via a command-line flag).
         
     | 
| 
      
 85 
     | 
    
         
            +
                config.default_formatter = "doc"
         
     | 
| 
      
 86 
     | 
    
         
            +
              end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
              # Print the 10 slowest examples and example groups at the
         
     | 
| 
      
 89 
     | 
    
         
            +
              # end of the spec run, to help surface which specs are running
         
     | 
| 
      
 90 
     | 
    
         
            +
              # particularly slow.
         
     | 
| 
      
 91 
     | 
    
         
            +
              config.profile_examples = 10
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
              # Run specs in random order to surface order dependencies. If you find an
         
     | 
| 
      
 94 
     | 
    
         
            +
              # order dependency and want to debug it, you can fix the order by providing
         
     | 
| 
      
 95 
     | 
    
         
            +
              # the seed, which is printed after each run.
         
     | 
| 
      
 96 
     | 
    
         
            +
              #     --seed 1234
         
     | 
| 
      
 97 
     | 
    
         
            +
              config.order = :random
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              # Seed global randomization in this process using the `--seed` CLI option.
         
     | 
| 
      
 100 
     | 
    
         
            +
              # Setting this allows you to use `--seed` to deterministically reproduce
         
     | 
| 
      
 101 
     | 
    
         
            +
              # test failures related to randomization by passing the same `--seed` value
         
     | 
| 
      
 102 
     | 
    
         
            +
              # as the one that triggered the failure.
         
     | 
| 
      
 103 
     | 
    
         
            +
              Kernel.srand config.seed
         
     | 
| 
      
 104 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ########################################################################################################################
         
     | 
| 
      
 2 
     | 
    
         
            +
            # WARNING - Never check this into the repository (.erb OK).
         
     | 
| 
      
 3 
     | 
    
         
            +
            ########################################################################################################################
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            # Using a local Redis server (install with 'brew install redis')
         
     | 
| 
      
 6 
     | 
    
         
            +
            host: 127.0.0.1
         
     | 
| 
      
 7 
     | 
    
         
            +
            port: 6379
         
     | 
| 
      
 8 
     | 
    
         
            +
            db: 1
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            # Using RedisToGo (don't use it on your dev station, it's only to be used on staging), otherwise we'll
         
     | 
| 
      
 11 
     | 
    
         
            +
            # run out of clients quickly (cap is at 10 currently)
         
     | 
| 
      
 12 
     | 
    
         
            +
            #url: "redis://redistogo:your_id_here@greeneye.redistogo.com:port/"
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class BasicJob
         
     | 
| 
      
 4 
     | 
    
         
            +
              include Resque::Plugins::Stages
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              def self.queue
         
     | 
| 
      
 7 
     | 
    
         
            +
                "BasicJobQueue"
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              def self.perform(*args)
         
     | 
| 
      
 11 
     | 
    
         
            +
                job = perform_job(*args)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                FakeLogger.error("BasicJob.perform job_id", job.job_id)
         
     | 
| 
      
 14 
     | 
    
         
            +
                FakeLogger.error("BasicJob.perform args", *args)
         
     | 
| 
      
 15 
     | 
    
         
            +
                FakeLogger.error("BasicJob.perform job.args", *job.args)
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class CompressedJob
         
     | 
| 
      
 4 
     | 
    
         
            +
              def self.queue
         
     | 
| 
      
 5 
     | 
    
         
            +
                "CompressedJobQueue"
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              def self.perform(*args)
         
     | 
| 
      
 9 
     | 
    
         
            +
                job = perform_job(*args)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                FakeLogger.error("CompressedJob.perform job_id", job.job_id)
         
     | 
| 
      
 12 
     | 
    
         
            +
                FakeLogger.error("CompressedJob.perform args", *args)
         
     | 
| 
      
 13 
     | 
    
         
            +
                FakeLogger.error("CompressedJob.perform job.args", *job.args)
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              extend Resque::Plugins::Compressible
         
     | 
| 
      
 17 
     | 
    
         
            +
              include Resque::Plugins::Stages
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class RetryJob
         
     | 
| 
      
 4 
     | 
    
         
            +
              extend Resque::Plugins::Retry
         
     | 
| 
      
 5 
     | 
    
         
            +
              include Resque::Plugins::Stages
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              @retry_limit = 5
         
     | 
| 
      
 8 
     | 
    
         
            +
              @retry_delay = 1.minute
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              def self.queue
         
     | 
| 
      
 11 
     | 
    
         
            +
                "RetryJobQueue"
         
     | 
| 
      
 12 
     | 
    
         
            +
              end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              def self.perform(*args)
         
     | 
| 
      
 15 
     | 
    
         
            +
                job = perform_job(*args)
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                FakeLogger.error("RetryJob.perform job_id", job.job_id)
         
     | 
| 
      
 18 
     | 
    
         
            +
                FakeLogger.error("RetryJob.perform args", *args)
         
     | 
| 
      
 19 
     | 
    
         
            +
                FakeLogger.error("RetryJob.perform job.args", *job.args)
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     |