-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a model for representing a consent request to the applicant where we need their signed consent before we can send the documents to Ecctis.
- Loading branch information
1 parent
b6484cd
commit 2d27e42
Showing
8 changed files
with
143 additions
and
19 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class ConsentRequest < ApplicationRecord | ||
ATTACHABLE_DOCUMENT_TYPES = %w[signed_consent unsigned_consent].freeze | ||
|
||
include Documentable | ||
include Requestable | ||
|
||
belongs_to :qualification | ||
|
||
scope :order_by_role, | ||
-> { joins(:qualification).order("qualifications.start_date": :desc) } | ||
scope :order_by_user, | ||
-> { joins(:qualification).order("qualifications.created_at": :asc) } | ||
|
||
def expires_after | ||
6.weeks | ||
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
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,16 @@ | ||
class AddConsentRequests < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :consent_requests do |t| | ||
t.datetime :received_at | ||
t.datetime :requested_at | ||
t.datetime :expired_at | ||
t.boolean :unsigned_document_downloaded, default: false, null: false | ||
t.datetime :verified_at | ||
t.text :verify_note, default: "", null: false | ||
t.boolean :verify_passed | ||
t.references :assessment, null: false, foreign_key: true | ||
t.references :qualification, null: false, foreign_key: true | ||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,36 @@ | ||
# frozen_string_literal: true | ||
|
||
FactoryBot.define do | ||
factory :consent_request do | ||
association :assessment | ||
association :qualification, :completed | ||
|
||
trait :with_unsigned_upload do | ||
after(:create) do |consent_request, _evaluator| | ||
create(:upload, document: consent_request.unsigned_consent_document) | ||
end | ||
end | ||
|
||
trait :with_signed_upload do | ||
after(:create) do |consent_request, _evaluator| | ||
create(:upload, document: consent_request.signed_consent_document) | ||
end | ||
end | ||
|
||
trait :requested do | ||
with_unsigned_upload | ||
requested_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } | ||
end | ||
|
||
trait :received do | ||
requested | ||
with_signed_upload | ||
received_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } | ||
end | ||
|
||
trait :expired do | ||
requested | ||
expired_at { Faker::Time.between(from: 1.month.ago, to: Time.zone.now) } | ||
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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe ConsentRequest, type: :model do | ||
subject(:consent_request) { create(:consent_request) } | ||
|
||
it_behaves_like "a documentable" | ||
it_behaves_like "a requestable" | ||
|
||
describe "#expires_after" do | ||
subject(:expires_after) { consent_request.expires_after } | ||
it { is_expected.to eq(6.weeks) } | ||
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