Skip to content

Commit

Permalink
Merge pull request #2051 from DFE-Digital/review-columns
Browse files Browse the repository at this point in the history
Add review columns to consent requests
  • Loading branch information
thomasleese authored Feb 28, 2024
2 parents dc8863a + 8e60d2f commit 357c035
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 12 deletions.
6 changes: 3 additions & 3 deletions app/models/concerns/requestable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ def received?
end

def reviewed?
try(:review_passed) != nil
review_passed != nil
end

def review_passed?
try(:review_passed) == true
review_passed == true
end

def review_failed?
try(:review_passed) == false
review_passed == false
end

def verified?
Expand Down
3 changes: 3 additions & 0 deletions app/models/consent_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# expired_at :datetime
# received_at :datetime
# requested_at :datetime
# review_note :text default(""), not null
# review_passed :boolean
# reviewed_at :datetime
# unsigned_document_downloaded :boolean default(FALSE), not null
# verified_at :datetime
# verify_note :text default(""), not null
Expand Down
3 changes: 3 additions & 0 deletions config/analytics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
- qualification_id
- received_at
- requested_at
- review_note
- review_passed
- reviewed_at
- unsigned_document_downloaded
- updated_at
- verified_at
Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20240228140334_add_review_to_consent_requests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddReviewToConsentRequests < ActiveRecord::Migration[7.1]
def change
change_table :consent_requests, bulk: true do |t|
t.boolean :review_passed
t.datetime :reviewed_at
t.text :review_note, default: "", null: false
end
end
end
5 changes: 4 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions spec/factories/consent_requests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# expired_at :datetime
# received_at :datetime
# requested_at :datetime
# review_note :text default(""), not null
# review_passed :boolean
# reviewed_at :datetime
# unsigned_document_downloaded :boolean default(FALSE), not null
# verified_at :datetime
# verify_note :text default(""), not null
Expand Down
3 changes: 3 additions & 0 deletions spec/models/consent_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# expired_at :datetime
# received_at :datetime
# requested_at :datetime
# review_note :text default(""), not null
# review_passed :boolean
# reviewed_at :datetime
# unsigned_document_downloaded :boolean default(FALSE), not null
# verified_at :datetime
# verify_note :text default(""), not null
Expand Down
22 changes: 14 additions & 8 deletions spec/support/shared_examples/requestable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
end

describe "#status" do
it "is completed when review passed is true" do
subject.review_passed = true
expect(subject.status).to eq("accepted")
end

it "is rejected when review passed is false" do
subject.review_passed = false
expect(subject.status).to eq("rejected")
end

it "is received when received at is set" do
subject.received_at = Time.zone.now
expect(subject.status).to eq("received")
Expand All @@ -70,17 +80,13 @@

describe "#review_status" do
it "is accepted when passed is true" do
if subject.respond_to?(:review_passed)
subject.review_passed = true
expect(subject.review_status).to eq("accepted")
end
subject.review_passed = true
expect(subject.review_status).to eq("accepted")
end

it "is rejected when passed is false" do
if subject.respond_to?(:review_passed)
subject.review_passed = false
expect(subject.review_status).to eq("rejected")
end
subject.review_passed = false
expect(subject.review_status).to eq("rejected")
end

it "is not started if not reviewed" do
Expand Down

0 comments on commit 357c035

Please sign in to comment.