@@ -678,7 +678,47 @@ public function can_update_resource_and_ensure_computed_field_isnt_saved_to_data
678678 }
679679
680680 #[Test]
681- public function can_update_resource_and_ensure__field_isnt_saved_to_database ()
681+ public function can_update_resource_and_ensure_read_only_timestamp_field_doesnt_prevent_timestamp_update ()
682+ {
683+ $ postBlueprint = Blueprint::find ('runway::post ' );
684+
685+ Blueprint::shouldReceive ('find ' )->with ('user ' )->andReturn (new \Statamic \Fields \Blueprint );
686+ Blueprint::shouldReceive ('find ' )->with ('runway::author ' )->andReturn (new \Statamic \Fields \Blueprint );
687+ Blueprint::shouldReceive ('find ' )->with ('runway::post ' )->andReturn ($ postBlueprint ->ensureField ('updated_at ' , [
688+ 'type ' => 'date ' ,
689+ 'time_enabled ' => true ,
690+ 'visibility ' => 'read_only ' ,
691+ ]));
692+ Blueprint::shouldReceive ('getAdditionalNamespaces ' )->andReturn (collect (['runway ' => base_path ('resources/blueprints/runway ' )]))->zeroOrMoreTimes ();
693+
694+ $ post = Post::factory ()->create ();
695+ $ user = User::make ()->makeSuper ()->save ();
696+
697+ $ originalUpdatedAt = $ post ->updated_at ;
698+
699+ $ this ->travel (5 )->minutes ();
700+
701+ $ this
702+ ->actingAs ($ user )
703+ ->patch (cp_route ('runway.update ' , ['resource ' => 'post ' , 'model ' => $ post ->id ]), [
704+ 'published ' => true ,
705+ 'title ' => 'Santa is coming home ' ,
706+ 'slug ' => 'santa-is-coming-home ' ,
707+ 'body ' => $ post ->body ,
708+ 'author_id ' => [$ post ->author_id ],
709+ 'updated_at ' => $ originalUpdatedAt ->toIso8601ZuluString ('millisecond ' ),
710+ ])
711+ ->assertOk ()
712+ ->assertJsonStructure (['data ' , 'saved ' ]);
713+
714+ $ post ->refresh ();
715+
716+ $ this ->assertEquals ('Santa is coming home ' , $ post ->title );
717+ $ this ->assertTrue ($ post ->updated_at ->gt ($ originalUpdatedAt ));
718+ }
719+
720+ #[Test]
721+ public function can_update_resource_and_ensure_field_with_save_false_isnt_saved_to_database ()
682722 {
683723 $ post = Post::factory ()->create ();
684724 $ user = User::make ()->makeSuper ()->save ();
0 commit comments