File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5151 create ( :gias_school , urn : "100000" )
5252 end
5353
54+ around do |example |
55+ appender = SemanticLogger . add_appender ( io : semantic_logger_io , formatter : :json )
56+ example . run
57+ ensure
58+ SemanticLogger . remove_appender ( appender )
59+ end
60+
61+ let ( :semantic_logger_io ) { StringIO . new }
5462 let ( :programmes ) { [ Programme . flu ] }
5563 let ( :team ) do
5664 if type == "national_reporting"
7785
7886 it_behaves_like "a CSVImportable model"
7987
88+ describe ".create" do
89+ it "a tagged message containing the started_at time of the import" do
90+ import = immunisation_import
91+
92+ SemanticLogger . flush
93+ semantic_logger_io . rewind
94+
95+ log_lines = semantic_logger_io . read . split ( "\n " )
96+ tagged_lines = log_lines . map { |l | JSON . parse ( l ) } . select do |j |
97+ j [ 'named_tags' ] == { 'import_class' => 'ImmunisationImport' , 'import_id' => import . id }
98+ end
99+
100+ expect ( tagged_lines . size ) . to eq ( 1 )
101+ expect ( tagged_lines . first ) . to include ( 'message' => 'started' )
102+
103+ payload = tagged_lines . first [ 'payload' ]
104+ started_at = Time . zone . parse ( payload [ 'started_at' ] )
105+ expect ( started_at . to_i ) . to eq ( import . created_at . to_i )
106+ end
107+ end
108+
80109 describe "validations" do
81110 subject { unsaved_import }
82111
You can’t perform that action at this time.
0 commit comments