diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index cf1fa6ff8a1..dc7b5eb6f2f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -208,7 +208,6 @@ app/models/async_transaction/va_profile @department-of-veterans-affairs/vfs-auth app/models/async_transaction/vet360 @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/backend-review-group app/models/attachment.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/models/average_days_for_claim_completion.rb @department-of-veterans-affairs/benefits-microservices @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group -app/models/backend_status.rb @department-of-veterans-affairs/backend-review-group app/models/bgs_dependents @department-of-veterans-affairs/benefits-dependents-management @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers app/models/central_mail_claim.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/models/central_mail_submission.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group @@ -358,7 +357,6 @@ app/serializers/async_transaction @department-of-veterans-affairs/vfs-authentica app/serializers/async_transaction/base_serializer.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/serializers/attachment_serializer.rb @department-of-veterans-affairs/vfs-10-10 @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers app/serializers/backend_statuses_serializer.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group -app/serializers/backend_status_serializer.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/serializers/category_serializer.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/serializers/cemetery_serializer.rb @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/serializers/central_mail_submission_serializer.rb @department-of-veterans-affairs/backend-review-group @@ -1151,7 +1149,6 @@ spec/factories/appeal_submission_uploads.rb @department-of-veterans-affairs/vfs- spec/factories/ask.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/factories/async_transactions.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/factories/attachments.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group -spec/factories/backend_statuses.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/factories/burial_claim.rb @department-of-veterans-affairs/mbs-core-team @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/factories/caregivers_assistance_claim.rb @department-of-veterans-affairs/vfs-10-10 @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/factories/central_mail_submissions.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group @@ -1714,7 +1711,6 @@ spec/rswag_override.rb @department-of-veterans-affairs/va-api-engineers @departm spec/serializers/appointment_serializer_spec.rb @department-of-veterans-affairs/vfs-vaos @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/serializers/async_transaction/base_serializer_spec.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/serializers/attachment_serializer_spec.rb @department-of-veterans-affairs/vfs-10-10 @department-of-veterans-affairs/backend-review-group @department-of-veterans-affairs/va-api-engineers -spec/serializers/backend_status_serializer_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/serializers/backend_statuses_serializer_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/serializers/category_serializer_spec.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/serializers/central_mail_submission_serializer_spec.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group diff --git a/app/controllers/v0/backend_statuses_controller.rb b/app/controllers/v0/backend_statuses_controller.rb index cd2fc52ab07..e0c6e779270 100644 --- a/app/controllers/v0/backend_statuses_controller.rb +++ b/app/controllers/v0/backend_statuses_controller.rb @@ -7,21 +7,12 @@ module V0 class BackendStatusesController < ApplicationController service_tag 'maintenance-windows' skip_before_action :authenticate - before_action :validate_service, only: [:show] def index options = { params: { maintenance_windows: } } render json: BackendStatusesSerializer.new(backend_statuses, options) end - # TO-DO: After transition of Post-911 GI Bill to 24/7 availability, confirm show action - # and related logic can be completely removed - # - # GET /v0/backend_statuses/:service - def show - render json: BackendStatusSerializer.new(backend_status) - end - private # NOTE: Data is from PagerDuty @@ -32,22 +23,5 @@ def backend_statuses def maintenance_windows @maintenance_windows ||= MaintenanceWindow.end_after(Time.zone.now) end - - # NOTE: Data is GI bill scheduled downtime - def backend_status - @backend_status ||= BackendStatus.new(name: backend_service) - end - - def backend_service - params[:service] - end - - def validate_service - raise Common::Exceptions::RecordNotFound, backend_service unless recognized_service? - end - - def recognized_service? - BackendServices.all.include?(backend_service) - end end end diff --git a/app/controllers/v1/post911_gi_bill_statuses_controller.rb b/app/controllers/v1/post911_gi_bill_statuses_controller.rb index 4836234f414..2e620542d41 100644 --- a/app/controllers/v1/post911_gi_bill_statuses_controller.rb +++ b/app/controllers/v1/post911_gi_bill_statuses_controller.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'formatters/date_formatter' -require 'lighthouse/benefits_education/outside_working_hours' require 'lighthouse/benefits_education/service' module V1 @@ -10,9 +9,6 @@ class Post911GIBillStatusesController < ApplicationController include SentryLogging service_tag 'gibill-statement' - # TO-DO: Remove this action after transition of LTS to 24/7 availability - before_action :service_available?, only: :show - STATSD_GI_BILL_TOTAL_KEY = 'api.lighthouse.gi_bill_status.total' STATSD_GI_BILL_FAIL_KEY = 'api.lighthouse.gi_bill_status.fail' @@ -36,16 +32,6 @@ def handle_error(e) render json: { errors: e.errors }, status: status || :internal_server_error end - # TO-DO: Remove this method after transition of LTS to 24/7 availability - def service_available? - unless Flipper.enabled?(:sob_updated_design) || BenefitsEducation::Service.within_scheduled_uptime? - StatsD.increment(STATSD_GI_BILL_FAIL_KEY, tags: ['error:scheduled_downtime']) - headers['Retry-After'] = BenefitsEducation::Service.retry_after_time - # 503 response - raise BenefitsEducation::OutsideWorkingHours - end - end - def log_vet_not_found(user, timestamp) PersonalInformationLog.create( data: { timestamp:, user: user_json(user) }, @@ -69,11 +55,6 @@ def user_json(user) }.to_json end - # TO-DO: Remove this method after transition of LTS to 24/7 availability - def skip_sentry_exception_types - super + [BenefitsEducation::OutsideWorkingHours] - end - def service BenefitsEducation::Service.new(@current_user&.icn) end diff --git a/app/models/backend_status.rb b/app/models/backend_status.rb deleted file mode 100644 index 8f1bc39999b..00000000000 --- a/app/models/backend_status.rb +++ /dev/null @@ -1,37 +0,0 @@ -# frozen_string_literal: true - -require 'backend_services' - -# TO-DO: After transition of Post-911 GI Bill to 24/7 availability, confirm -# BackendStatus (singular) model and related logic can be removed -class BackendStatus - include ActiveModel::Serialization - include ActiveModel::Validations - - attr_reader :name, :service_id - - validates :name, presence: true - validates :is_available, presence: true - validates :uptime_remaining, presence: true - - def initialize(name:, service_id: nil) - @name = name - @service_id = service_id - end - - def available? - service_subject_to_downtime? ? BenefitsEducation::Service.within_scheduled_uptime? : true - end - - def uptime_remaining - service_subject_to_downtime? ? BenefitsEducation::Service.seconds_until_downtime.to_i : 0 - end - - private - - def service_subject_to_downtime? - return false if Flipper.enabled?(:sob_updated_design) - - @name == BackendServices::GI_BILL_STATUS - end -end diff --git a/app/serializers/backend_status_serializer.rb b/app/serializers/backend_status_serializer.rb deleted file mode 100644 index 83bc9c1c197..00000000000 --- a/app/serializers/backend_status_serializer.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -# TO-DO: After transition of Post-911 GI Bill to 24/7 availability, confirm -# serializer and related logic can be completely removed -class BackendStatusSerializer - include JSONAPI::Serializer - - set_id { '' } - - attribute :name - attribute :service_id - attribute :is_available, &:available? - attribute :uptime_remaining -end diff --git a/app/swagger/swagger/requests/backend_statuses.rb b/app/swagger/swagger/requests/backend_statuses.rb index c67faedb5a7..af972fa9fb3 100644 --- a/app/swagger/swagger/requests/backend_statuses.rb +++ b/app/swagger/swagger/requests/backend_statuses.rb @@ -87,44 +87,6 @@ class BackendStatuses end end end - - swagger_path '/v0/backend_statuses/{service}' do - operation :get do - key :description, 'Gets the status of backend service' - key :operationId, 'getBackendStatus' - key :tags, %w[backend_statuses] - - parameter do - key :name, 'service' - key :in, :path - key :description, 'The name of the backend service' - key :required, true - key :type, :string - key :enum, BackendServices.all - end - - response 200 do - key :description, 'Response is OK' - schema do - key :$ref, :Availability - end - end - end - end - - swagger_schema :Availability do - key :required, %i[data] - property :data, type: :object do - key :required, %i[attributes] - property :id, type: :string - property :type, type: :string - property :attributes, type: :object do - key :required, %i[name is_available] - property :is_available, type: :boolean, example: true - property :name, type: :string, example: 'gibs' - end - end - end end end end diff --git a/config/locales/exceptions.en.yml b/config/locales/exceptions.en.yml index e43252ad1a2..ec92afe33ba 100644 --- a/config/locales/exceptions.en.yml +++ b/config/locales/exceptions.en.yml @@ -2247,13 +2247,6 @@ en: <<: *defaults code: LH_gateway_timeout status: 504 - benefits_education: - outside_working_hours: - <<: *defaults - title: External service unavailable - detail: 'Lighthouse GI Bill Status is not available outside of working hours' - code: 114 - status: 503 evss: external_service_unavailable: <<: *defaults diff --git a/config/routes.rb b/config/routes.rb index 39d972369ae..b7131dddba1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -337,7 +337,7 @@ get 'profile/mailing_address', to: 'addresses#show' put 'profile/mailing_address', to: 'addresses#update' - resources :backend_statuses, param: :service, only: %i[index show] + resources :backend_statuses, only: %i[index] resources :apidocs, only: [:index] diff --git a/lib/lighthouse/benefits_education/outside_working_hours.rb b/lib/lighthouse/benefits_education/outside_working_hours.rb deleted file mode 100644 index 104f77c9a12..00000000000 --- a/lib/lighthouse/benefits_education/outside_working_hours.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -require 'common/exceptions/base_error' - -# TO-DO: Remove this error after transition of LTS to 24/7 availability and associated lines -# in exceptions.en.yml -module BenefitsEducation - ## - # Custom error for when the user is attempting to access the service - # outside of working hours. The service proxies to a service which - # has nightly downtime - class OutsideWorkingHours < Common::Exceptions::BaseError - ## - # @return [Array[Common::Exceptions::SerializableError]] An array containing the error - # - def errors - [Common::Exceptions::SerializableError.new(i18n_data)] - end - - ## - # @return [String] The i18n key - # - def i18n_key - 'lighthouse.benefits_education.outside_working_hours' - end - end -end diff --git a/lib/lighthouse/benefits_education/service.rb b/lib/lighthouse/benefits_education/service.rb index b1c8418dc63..9d60de436a2 100644 --- a/lib/lighthouse/benefits_education/service.rb +++ b/lib/lighthouse/benefits_education/service.rb @@ -15,14 +15,6 @@ class Service < Common::Client::Base STATSD_KEY_PREFIX = 'api.benefits_education' - # TO-DO: Remove these constants after transition of LTS to 24/7 availability - OPERATING_ZONE = 'Eastern Time (US & Canada)' - OPERATING_HOURS = { - start: 6, - end: 22, - saturday_end: 19 - }.freeze - ## # @parameter [String] icn: icn of the Veteran requesting education benefits information # @return [BenefitsEducation::Service] a new instance of the service @@ -66,57 +58,5 @@ def handle_error(error, lighthouse_client_id, endpoint) endpoint ) end - - ## - # TO-DO: Remove this method after transition of LTS to 24/7 availability - # - # @return [Boolean] Is the current time within the system's scheduled uptime - # - def self.within_scheduled_uptime? - current_time = get_current_time - if current_time.saturday? - (OPERATING_HOURS[:start]...OPERATING_HOURS[:saturday_end]).cover?(current_time.hour) - else - (OPERATING_HOURS[:start]...OPERATING_HOURS[:end]).cover?(current_time.hour) - end - end - - ## - # TO-DO: Remove this method after transition of LTS to 24/7 availability - # - # @return [Integer] The number of seconds until scheduled system downtime begins - # - def self.seconds_until_downtime - if within_scheduled_uptime? - current_time = get_current_time - end_hour = current_time.saturday? ? OPERATING_HOURS[:saturday_end] : OPERATING_HOURS[:end] - tz = ActiveSupport::TimeZone.new(OPERATING_ZONE) - service_end_time = tz.parse("#{tz.today} #{end_hour}:00:00") - service_end_time - current_time - else - 0 - end - end - - ## - # TO-DO: Remove this method after transition of LTS to 24/7 availability - # - # @return [String] Next earliest date and time that the service will be available - # - def self.retry_after_time - current_time = get_current_time - tz = ActiveSupport::TimeZone.new(OPERATING_ZONE) - service_start_time = tz.parse("#{tz.today} 0#{OPERATING_HOURS[:start]}:00:00") - - return service_start_time.httpdate if current_time.hour < OPERATING_HOURS[:start] - - service_start_time.tomorrow.httpdate - end - - def self.get_current_time - Time.now.in_time_zone(OPERATING_ZONE) - end - - private_class_method :get_current_time end end diff --git a/postman/vets-api.pm-collection.json b/postman/vets-api.pm-collection.json index 036eba50d0e..d50b14e5d58 100644 --- a/postman/vets-api.pm-collection.json +++ b/postman/vets-api.pm-collection.json @@ -145,43 +145,6 @@ }, "response": [] }, - { - "name": "/v0/backend_statuses/{service}", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Endpoint returns valid backend status object\", function () {", - " if (pm.response.code != 200) { return };", - " var responseBody = pm.response.json();", - " pm.expect(responseBody).to.have.property('data');", - "});", - "" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{vets_api_env}}//v0/backend_statuses/gibs", - "host": [ - "{{vets_api_env}}" - ], - "path": [ - "", - "v0", - "backend_statuses", - "gibs" - ] - } - }, - "response": [] - }, { "name": "/v0/forms", "event": [ @@ -1175,4 +1138,4 @@ "type": "string" } ] -} \ No newline at end of file +} diff --git a/spec/controllers/v1/post911_gi_bill_statuses_controller_spec.rb b/spec/controllers/v1/post911_gi_bill_statuses_controller_spec.rb index 301939a0a7b..177ff442d51 100644 --- a/spec/controllers/v1/post911_gi_bill_statuses_controller_spec.rb +++ b/spec/controllers/v1/post911_gi_bill_statuses_controller_spec.rb @@ -2,7 +2,6 @@ require 'rails_helper' require 'lighthouse/benefits_education/service' -require 'lighthouse/benefits_education/outside_working_hours' RSpec.describe V1::Post911GIBillStatusesController, type: :controller do let(:user) { FactoryBot.create(:user, :loa3, icn: '1000000000V100000') } @@ -12,13 +11,7 @@ before { sign_in_as(user) } - context 'inside working hours' do - before do - # TO-DO: Remove this flipper toggle after transition of LTS to 24/7 availability - Flipper.enable(:sob_updated_design) - allow(BenefitsEducation::Service).to receive(:within_scheduled_uptime?).and_return(true) - end - + context 'service is available' do it 'returns a 200 success' do # valid icn retrieved from # https://github.com/department-of-veterans-affairs/vets-api-clients/blob/master/test_accounts/benefits_test_accounts.md @@ -65,32 +58,6 @@ end end - # TO-DO: Remove this suite of tests after transition of LTS to 24/7 availability - context 'outside working hours' do - # midnight - before do - Flipper.disable(:sob_updated_design) - Timecop.freeze(tz.parse('2nd Feb 1993 00:00:00')) - end - - after { Timecop.return } - - it 'returns 503' do - get :show - expect(response).to have_http_status(:service_unavailable) - end - - it 'includes a Retry-After header' do - get :show - expect(response.headers).to include('Retry-After') - end - - it 'ignores OutsideWorkingHours exception' do - expect(Sentry).not_to receive(:capture_message) - get :show - end - end - context 'when Breakers::OutageException is raised' do let(:mock_service) do instance_double( diff --git a/spec/factories/backend_statuses.rb b/spec/factories/backend_statuses.rb deleted file mode 100644 index 086c6e224ab..00000000000 --- a/spec/factories/backend_statuses.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -FactoryBot.define do - factory :backend_status do - name { 'gibs' } - service_id { 'appeals' } - - initialize_with { new(name:, service_id:) } - end -end diff --git a/spec/lib/lighthouse/benefits_education/service_spec.rb b/spec/lib/lighthouse/benefits_education/service_spec.rb index 842d3010622..caeffa67946 100644 --- a/spec/lib/lighthouse/benefits_education/service_spec.rb +++ b/spec/lib/lighthouse/benefits_education/service_spec.rb @@ -43,87 +43,4 @@ end end end - - # TO-DO: Remove this context after transition of LTS to 24/7 availability - describe 'uptime/downtime tests' do - let(:tz) { ActiveSupport::TimeZone.new(described_class::OPERATING_ZONE) } - let(:late_time) { tz.parse('1st Feb 2018 23:00:00') } - let(:early_time) { tz.parse('1st Feb 2018 1:00:00') } - let(:saturday_time) { tz.parse('3rd Feb 2018 20:00:00') } - let(:non_dst) { tz.parse('18th Mar 2018 18:00:00') } - - context 'not during daylight savings' do - before { Timecop.freeze(non_dst) } - - after { Timecop.return } - - it 'calculates at 6am tomorrow' do - calculated_time = tz.parse(described_class.retry_after_time) - expect(calculated_time.day).to eq(19) - expect(calculated_time.hour).to eq(6) - end - end - - context 'before operating hours' do - before { Timecop.freeze(early_time) } - - after { Timecop.return } - - describe '#retry_after_time' do - it 'calculates at 6am today' do - calculated_time = tz.parse(described_class.retry_after_time) - expect(calculated_time.day).to eq(1) - expect(calculated_time.hour).to eq(6) - end - end - end - - context 'after operating hours' do - before { Timecop.freeze(late_time) } - - after { Timecop.return } - - describe '#retry_after_time' do - it 'calculates tomorrow at 6am' do - calculated_time = tz.parse(described_class.retry_after_time) - expect(calculated_time.day).to eq(2) - expect(calculated_time.hour).to eq(6) - end - end - end - - context 'on saturday' do - before { Timecop.freeze(saturday_time) } - - after { Timecop.return } - - describe '#within_scheduled_uptime?' do - it 'properly indicates availability' do - expect(described_class.within_scheduled_uptime?).to eq(false) - end - end - end - - describe '.seconds_until_downtime' do - context 'during downtime' do - before { Timecop.freeze(late_time) } - - after { Timecop.return } - - it 'returns 0' do - expect(described_class.seconds_until_downtime).to eq(0) - end - end - - context 'during uptime' do - before { Timecop.freeze(non_dst) } - - after { Timecop.return } - - it 'returns number of seconds until uptime ends/downtime starts' do - expect(described_class.seconds_until_downtime).to eq(14_400) - end - end - end - end end diff --git a/spec/requests/swagger_spec.rb b/spec/requests/swagger_spec.rb index bc2b7e3c700..85878860df9 100644 --- a/spec/requests/swagger_spec.rb +++ b/spec/requests/swagger_spec.rb @@ -51,12 +51,6 @@ end describe 'backend statuses' do - describe '/v0/backend_statuses/{service}' do - it 'supports getting backend service status' do - expect(subject).to validate(:get, '/v0/backend_statuses/{service}', 200, headers.merge('service' => 'gibs')) - end - end - describe '/v0/backend_statuses' do context 'when successful' do include_context 'simulating Redis caching of PagerDuty#get_services' @@ -3803,21 +3797,12 @@ context 'GI Bill Status' do it 'supports getting Gi Bill Status' do - Flipper.enable(:sob_updated_design) - Timecop.freeze(ActiveSupport::TimeZone.new('Eastern Time (US & Canada)').parse('1st Feb 2018 12:15:06')) expect(subject).to validate(:get, '/v1/post911_gi_bill_status', 401) VCR.use_cassette('lighthouse/benefits_education/200_response') do expect(subject).to validate(:get, '/v1/post911_gi_bill_status', 200, headers) end Timecop.return end - - it 'supports Gi Bill Status 503 condition' do - Flipper.disable(:sob_updated_design) - Timecop.freeze(ActiveSupport::TimeZone.new('Eastern Time (US & Canada)').parse('1st Feb 2018 00:15:06')) - expect(subject).to validate(:get, '/v1/post911_gi_bill_status', 503, headers) - Timecop.return - end end describe 'decision review evidence upload' do diff --git a/spec/requests/v0/backend_status_spec.rb b/spec/requests/v0/backend_status_spec.rb index 9d44b7f5663..d97599e8372 100644 --- a/spec/requests/v0/backend_status_spec.rb +++ b/spec/requests/v0/backend_status_spec.rb @@ -8,84 +8,6 @@ let(:user) { build(:user, :loa3) } - # TO-DO: After transition of Post-911 GI Bill to 24/7 availability, confirm show action - # and related logic can be completely removed - describe '#show' do - let(:token) { 'fa0f28d6-224a-4015-a3b0-81e77de269f2' } - let(:auth_header) { { 'Authorization' => "Token token=#{token}" } } - let(:tz) { ActiveSupport::TimeZone.new(BenefitsEducation::Service::OPERATING_ZONE) } - let(:offline_saturday) { tz.parse('17th Mar 2018 19:00:01') } - let(:online_weekday) { tz.parse('24th Jan 2018 06:00:00') } - - before do - Session.create(uuid: user.uuid, token:) - User.create(user) - end - - it 'responds 200' do - get v0_backend_status_url('gibs'), params: nil, headers: auth_header - expect(response).to have_http_status(:ok) - end - - context 'for the gibs service' do - before { Flipper.disable(:sob_updated_design) } - - context 'during offline hours on saturday' do - before { Timecop.freeze(offline_saturday) } - - after { Timecop.return } - - it 'indicates the service is unavailable' do - get v0_backend_status_url('gibs'), params: nil, headers: auth_header - json = JSON.parse(response.body) - - expect(json['data']['attributes']['is_available']).to eq(false) - expect(json['data']['attributes']['name']).to be_a(String).and eq('gibs') - end - - it 'returns 0 as number of seconds until next downtime' do - get v0_backend_status_url('gibs'), params: nil, headers: auth_header - json = JSON.parse(response.body) - expect(json['data']['attributes']['uptime_remaining']).to be_a(Integer).and eq(0) - end - end - - context 'during online hours on weekday' do - before { Timecop.freeze(online_weekday) } - - after { Timecop.return } - - it 'indicates the service is available' do - get v0_backend_status_url('gibs'), params: nil, headers: auth_header - json = JSON.parse(response.body) - expect(json['data']['attributes']['is_available']).to eq(true) - expect(json['data']['attributes']['name']).to be_a(String).and eq('gibs') - end - - it 'returns number of seconds until next downtime' do - get v0_backend_status_url('gibs'), params: nil, headers: auth_header - json = JSON.parse(response.body) - expect(json['data']['attributes']['uptime_remaining']).to be_a(Integer).and eq(57_600) - end - end - end - - context 'for non-gibs service' do - it 'always indicates the service is available' do - get v0_backend_status_url('hca'), params: nil, headers: auth_header - json = JSON.parse(response.body) - expect(json['data']['attributes']['is_available']).to eq(true) - expect(json['data']['attributes']['name']).to be_a(String).and eq('hca') - end - - it 'always returns 0 as number of seconds until next downtime' do - get v0_backend_status_url('hca'), params: nil, headers: auth_header - json = JSON.parse(response.body) - expect(json['data']['attributes']['uptime_remaining']).to be_a(Integer).and eq(0) - end - end - end - describe 'GET /v0/backend_statuses' do before { sign_in_as(user) } diff --git a/spec/requests/v1/post911_gi_bill_status_spec.rb b/spec/requests/v1/post911_gi_bill_status_spec.rb index 0bacd87bf1b..9ede14d2a48 100644 --- a/spec/requests/v1/post911_gi_bill_status_spec.rb +++ b/spec/requests/v1/post911_gi_bill_status_spec.rb @@ -5,9 +5,6 @@ RSpec.describe 'V1::Post911GIBillStatus', type: :request do include SchemaMatchers - let(:tz) { ActiveSupport::TimeZone.new(BenefitsEducation::Service::OPERATING_ZONE) } - let(:noon) { tz.parse('1st Feb 2018 12:00:00') } - let(:midnight) { tz.parse('15th Mar 2018 00:00:00') } let(:user) { create(:user, icn: '1012667145V762142') } before do @@ -15,48 +12,16 @@ allow(Settings.evss).to receive(:mock_gi_bill_status).and_return(false) end - # TO-DO: Rename context after transition of LTS to 24/7 availability - context 'inside working hours' do - before { Timecop.freeze(noon) } - - after { Timecop.return } - - context 'with a 200 response' do - it 'GET /v1/post911_gi_bill_status returns proper json' do - VCR.use_cassette('lighthouse/benefits_education/gi_bill_status/200_response') do - get v1_post911_gi_bill_status_url, params: nil - expect(response).to match_response_schema('post911_gi_bill_status') - assert_response :success - end + context 'with a 200 response' do + it 'GET /v1/post911_gi_bill_status returns proper json' do + VCR.use_cassette('lighthouse/benefits_education/gi_bill_status/200_response') do + get v1_post911_gi_bill_status_url, params: nil + expect(response).to match_response_schema('post911_gi_bill_status') + assert_response :success end end end - # TO-DO: Remove context after transition of LTS to 24/7 availability - context 'outside working hours' do - before do - Flipper.disable(:sob_updated_design) - Timecop.freeze(midnight) - end - - after { Timecop.return } - - it 'returns 503' do - get v1_post911_gi_bill_status_url, params: nil - expect(response).to have_http_status(:service_unavailable) - end - - it 'includes a Retry-After header' do - get v1_post911_gi_bill_status_url, params: nil - expect(response.headers).to include('Retry-After') - end - - it 'ignores OutsideWorkingHours exception' do - expect(Sentry).not_to receive(:capture_message) - get v1_post911_gi_bill_status_url, params: nil - end - end - context 'with deprecated GibsNotFoundUser class' do it 'loads the class for coverage', skip: 'No expectation in this example' do GibsNotFoundUser diff --git a/spec/serializers/backend_status_serializer_spec.rb b/spec/serializers/backend_status_serializer_spec.rb deleted file mode 100644 index 412f07f66b9..00000000000 --- a/spec/serializers/backend_status_serializer_spec.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -describe BackendStatusSerializer do - subject { serialize(backend_status, serializer_class: described_class) } - - let(:backend_status) { build_stubbed(:backend_status) } - let(:data) { JSON.parse(subject)['data'] } - let(:attributes) { data['attributes'] } - - it 'includes :id' do - expect(data['id']).to be_blank - end - - it 'includes :name' do - expect(attributes['name']).to eq backend_status.name - end - - it 'includes :service_id' do - expect(attributes['service_id']).to eq backend_status.service_id - end - - it 'includes :is_available' do - expect(attributes['is_available']).to eq backend_status.available? - end - - it 'includes :uptime_remaining' do - expect(attributes['uptime_remaining']).to eq backend_status.uptime_remaining - end -end