-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
97 Added database table and endpoint for average number of days for c…
…ompletion (#16313) * 97 Added database table and endpoint for average number of days for claim completion. * 97 Added SPEC file for unittest coverage and also linted everything. * 97 Updated CODEOWNERS file. * 97 Missed the spec at the end of the spec file in CODEOWNERS. * 97 Updated test name to be reflective of what we are expecting. --------- Co-authored-by: Rebecca Tolmach <[email protected]> Co-authored-by: bmatos312 <[email protected]>
- Loading branch information
1 parent
9fbe39d
commit 0234cb7
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
app/controllers/v0/average_days_for_claim_completion_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module V0 | ||
class AverageDaysForClaimCompletionController < ApplicationController | ||
service_tag 'average-days-to-completion' | ||
skip_before_action :authenticate, only: :index | ||
|
||
def index | ||
rtn = AverageDaysForClaimCompletion.order('created_at DESC').first | ||
render json: { | ||
average_days: rtn.present? ? rtn.average_days : -1.0 | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class AverageDaysForClaimCompletion < ApplicationRecord | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
spec/controllers/v0/average_days_for_claim_completion_controller_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe V0::AverageDaysForClaimCompletionController, type: :controller do | ||
context 'when querying with nothing in db' do | ||
it 'returns -1 for value' do | ||
get :index | ||
expect(response).to have_http_status(:ok) | ||
expect(JSON.parse(response.body)['average_days']).to eq(-1.0) | ||
end | ||
end | ||
|
||
context 'when querying with record in db' do | ||
before do | ||
AverageDaysForClaimCompletion.create(average_days: 100) | ||
end | ||
|
||
it 'returns the value' do | ||
get :index | ||
expect(response).to have_http_status(:ok) | ||
expect(JSON.parse(response.body)['average_days']).to eq(100.0) | ||
end | ||
end | ||
|
||
context 'when querying with multiple records in db' do | ||
before do | ||
AverageDaysForClaimCompletion.create(average_days: 100) | ||
AverageDaysForClaimCompletion.create(average_days: 200) | ||
AverageDaysForClaimCompletion.create(average_days: 300) | ||
end | ||
|
||
it 'returns the most recently inserted value' do | ||
get :index | ||
expect(response).to have_http_status(:ok) | ||
expect(JSON.parse(response.body)['average_days']).to eq(300.0) | ||
end | ||
end | ||
end |