diff --git a/Gemfile b/Gemfile index 5a04a0f5f8..b5c9980374 100644 --- a/Gemfile +++ b/Gemfile @@ -30,7 +30,6 @@ group :development do end group :test do - gem "rspec-sidekiq", "~> 3" gem "simplecov", "~> 0.16" end diff --git a/Gemfile.lock b/Gemfile.lock index 92b1e5f10f..2b31c79206 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -349,9 +349,6 @@ GEM rspec-expectations (~> 3.8.0) rspec-mocks (~> 3.8.0) rspec-support (~> 3.8.0) - rspec-sidekiq (3.0.3) - rspec-core (~> 3.0, >= 3.0.0) - sidekiq (>= 2.4.0) rspec-support (3.8.0) rubocop (0.64.0) jaro_winkler (~> 1.5.1) @@ -477,7 +474,6 @@ DEPENDENCIES rails (~> 5.2) rinku (~> 2) rspec-rails (~> 3) - rspec-sidekiq (~> 3) simplecov (~> 0.16) uglifier (~> 4) webmock (~> 3) diff --git a/spec/features/workflow/schedule_publishing_api_down_spec.rb b/spec/features/workflow/schedule_publishing_api_down_spec.rb index e8d73cae3c..d773f33cf5 100644 --- a/spec/features/workflow/schedule_publishing_api_down_spec.rb +++ b/spec/features/workflow/schedule_publishing_api_down_spec.rb @@ -2,7 +2,7 @@ RSpec.feature "Schedule a document when Publishing API is down" do scenario do - given_there_is_an_edition_with_set_scheduled_publishing_datetime + given_there_is_an_edition_ready_to_schedule and_the_publishing_api_is_down when_i_visit_the_summary_page and_i_try_to_schedule_the_edition @@ -10,7 +10,7 @@ and_the_document_has_not_been_scheduled end - def given_there_is_an_edition_with_set_scheduled_publishing_datetime + def given_there_is_an_edition_ready_to_schedule @datetime = Time.current.tomorrow @edition = create(:edition, scheduled_publishing_datetime: @datetime) end diff --git a/spec/features/workflow/schedule_spec.rb b/spec/features/workflow/schedule_spec.rb index f9535a1a50..c9c8536cc7 100644 --- a/spec/features/workflow/schedule_spec.rb +++ b/spec/features/workflow/schedule_spec.rb @@ -2,20 +2,16 @@ RSpec.feature "Schedule an edition" do scenario do - given_there_is_an_edition_with_set_scheduled_publishing_datetime + given_there_is_an_edition_ready_to_schedule when_i_visit_the_summary_page and_i_click_on_schedule and_i_select_the_content_has_been_reviewed_option and_i_click_on_publish - then_i_see_a_confirmation_that_the_edition_has_been_scheduled - - when_i_visit_the_summary_page then_i_see_the_edition_has_been_scheduled - and_i_can_no_longer_see_a_schedule_action and_i_can_no_longer_edit_the_content end - def given_there_is_an_edition_with_set_scheduled_publishing_datetime + def given_there_is_an_edition_ready_to_schedule @datetime = Time.current.tomorrow @edition = create(:edition, scheduled_publishing_datetime: @datetime) @request = stub_default_publishing_api_put_intent @@ -37,25 +33,20 @@ def and_i_click_on_publish click_on "Publish" end - def then_i_see_a_confirmation_that_the_edition_has_been_scheduled + def then_i_see_the_edition_has_been_scheduled expect(page).to have_content(I18n.t!("schedule.scheduled.title")) + expect(Sidekiq::Worker.jobs.count).to eq 1 - govuk_header_args = an_instance_of(Hash) # args from govuk_sidekiq gem - expect(ScheduledPublishingWorker) - .to have_enqueued_sidekiq_job(@edition.id, govuk_header_args) - .at(@datetime) + job = Sidekiq::Worker.jobs.first + expect(job["args"].first).to eq @edition.id + expect(job["at"].to_i).to eq @datetime.to_i assert_requested @request - end - def then_i_see_the_edition_has_been_scheduled + visit document_path(@edition.document) expect(page).to have_content(I18n.t!("user_facing_states.scheduled.name")) end - def and_i_can_no_longer_see_a_schedule_action - expect(page).not_to have_link("Schedule") - end - def and_i_can_no_longer_edit_the_content expect(page).not_to have_link("Change Content") end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ef55b44bd0..f005753f65 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,6 +13,7 @@ require "gds_api/test_helpers/publishing_api" require "gds_api/test_helpers/publishing_api_v2" require "gds_api/test_helpers/asset_manager" +require "govuk_sidekiq/testing" Dir[Rails.root.join("spec", "support", "**", "*.rb")].each { |f| require f } SimpleCov.start @@ -28,12 +29,6 @@ /the server responded with a status of 422/i, ] -Sidekiq::Logging.logger = nil - -RSpec::Sidekiq.configure do |config| - config.warn_when_jobs_not_processed_by_sidekiq = false -end - RSpec.configure do |config| config.expose_dsl_globally = false config.infer_spec_type_from_file_location! @@ -60,6 +55,10 @@ reset_authentication end + config.before :each do + Sidekiq::Worker.clear_all + end + config.after :each, type: :feature, js: true do Capybara::Chromedriver::Logger::TestHooks.after_example! end