-
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 SPEC file for unittest coverage and also linted everything.
- Loading branch information
1 parent
6cbd764
commit 823a1e8
Showing
3 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
4 changes: 3 additions & 1 deletion
4
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
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class AverageDaysForClaimCompletion < ApplicationRecord | ||
end | ||
end |
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 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 |