-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As part of the efforts to simplify multi claim handling we want to move away from creating a claim at the start of the journey and instead only create the claim at the final step where the teacher submits their answers. This commit introduces a new model `Journeys::Session` which will be used to store the answers entered by the teacher. The answers will be stored in a json column on the new model, once validated by the form objects. `Journeys::Session` is currently the best name we could come up with but we're all ears for any better suggestions.
- Loading branch information
Showing
8 changed files
with
66 additions
and
1 deletion.
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
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,7 @@ | ||
module Journeys | ||
class Session < ApplicationRecord | ||
validates :journey, | ||
presence: true, | ||
inclusion: {in: Journeys.all_routing_names} | ||
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,10 @@ | ||
class CreateJourneysSessions < ActiveRecord::Migration[7.0] | ||
def change | ||
create_table :journeys_sessions, id: :uuid do |t| | ||
t.jsonb :answers, default: {} | ||
t.string :journey, null: false | ||
|
||
t.timestamps | ||
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
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,5 @@ | ||
FactoryBot.define do | ||
factory :journeys_session, class: "Journeys::Session" do | ||
journey { "additional-payments" } | ||
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 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Journeys::Session, type: :model do | ||
describe "validations" do | ||
describe "journey" do | ||
it { is_expected.to validate_presence_of(:journey) } | ||
|
||
it do | ||
is_expected.to( | ||
validate_inclusion_of(:journey).in_array(Journeys.all_routing_names) | ||
) | ||
end | ||
end | ||
end | ||
end |