Skip to content

Commit

Permalink
tests:end_to_end is running correctly in the test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sussman committed Aug 12, 2024
1 parent 2e37eda commit 673c2d4
Show file tree
Hide file tree
Showing 9 changed files with 684 additions and 31 deletions.
4 changes: 3 additions & 1 deletion app/jobs/applier/apply_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class ApplyJob < ApplicationJob
sidekiq_options retry: false

def perform(job_application)
Applier::ApplyToJob.call(job_application) if job_application.status == 'submitted'
# NB: There isn't enough time for job_application.status to update from 'completed' to 'submitted' when running the job inline in test environment
Applier::ApplyToJob.call(job_application)
# Applier::ApplyToJob.call(job_application) if job_application.status == 'submitted'
end
end
end
1 change: 1 addition & 0 deletions app/services/applier/apply_to_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Applier
# TODO: Add routing logic - in future will route to either FormFiller or ApiApply depending on the ATS
class ApplyToJob < ApplicationTask
def initialize(job_application)
p "Initializing job_application: #{job_application}" # for testing
@job_application = job_application
@payload = @job_application.payload
end
Expand Down
7 changes: 7 additions & 0 deletions config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,11 @@

# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true

# Enqueued jobs run immediately in test env
config.active_job.queue_adapter = :inline

# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :cloudinary
config.action_mailer.default_url_options = { host: "http://localhost:3000" }
end
7 changes: 4 additions & 3 deletions lib/tasks/tests.rake
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
require './app/helpers/rake_helpers'

namespace :tests do
# Call this with e.g. rake "tests:end_to_end[https://apply.workable.com/starling-bank/j/60ACE7278C, 15]"
# It takes a required argument, the posting_url of the job to be tested.
# There's an optional argument, which is a number of seconds to pause after completing the Cheddar form to allow for manual review. Default is 0.
# The rake task runs apply_to_job_spec.rb. That file has its own comments to explain what it does.
desc "Conduct end-to-end tests on a given url"
task :end_to_end, %i[url_string sleep_time] => :environment do |_, args|
ENV['URL_FOR_TESTING'] = args[:url_string]
Expand All @@ -11,6 +12,6 @@ namespace :tests do
t.pattern = 'spec/features/apply_to_job_spec.rb'
end

Rake::Task['spec_task'].invoke
Rake::Task[:spec_task].invoke
end
end
Loading

0 comments on commit 673c2d4

Please sign in to comment.