@@ -619,7 +619,7 @@ def response
619
619
#
620
620
# end
621
621
622
- specify "follow_response option makes a transition follow controller redirects " do
622
+ specify "follow_response option makes a transition follow controllers' transition_to " do
623
623
624
624
class TestModelsController < ExampleController
625
625
include Matestack ::Ui ::Core ::ApplicationHelper
@@ -705,4 +705,88 @@ def response
705
705
706
706
end
707
707
708
+ specify "follow_response option makes a transition follow controllers' redirect_to" do
709
+
710
+ class TestModelsController < ExampleController
711
+ include Matestack ::Ui ::Core ::ApplicationHelper
712
+
713
+ def index
714
+ responder_for Pages ::FollowResponseExampleApp ::ExamplePage
715
+ end
716
+
717
+ def create
718
+ @test_model = TestModel . create title : params [ :title ]
719
+ redirect_to test_model_path ( id : @test_model . id )
720
+ end
721
+
722
+ def show
723
+ @test_model = TestModel . find params [ :id ]
724
+ responder_for Pages ::FollowResponseExampleApp ::TestModelPage
725
+ end
726
+ end
727
+
728
+ Rails . application . routes . append do
729
+ resources :test_models
730
+ end
731
+ Rails . application . reload_routes!
732
+
733
+ class Apps ::FollowResponseExampleApp < Matestack ::Ui ::App
734
+ def response
735
+ components {
736
+ heading size : 1 , text : "My Example App Layout"
737
+ main do
738
+ page_content
739
+ end
740
+ }
741
+ end
742
+ end
743
+
744
+ module Pages ::FollowResponseExampleApp
745
+ end
746
+
747
+ class Pages ::FollowResponseExampleApp ::ExamplePage < Matestack ::Ui ::Page
748
+ def response
749
+ components {
750
+ action action_config do
751
+ button text : "Click me!"
752
+ end
753
+ }
754
+ end
755
+
756
+ def action_config
757
+ return {
758
+ method : :post ,
759
+ path : :test_models_path ,
760
+ data : {
761
+ title : "A title for my new test object"
762
+ } ,
763
+ success : {
764
+ transition : {
765
+ follow_response : true
766
+ }
767
+ }
768
+ }
769
+ end
770
+
771
+ end
772
+
773
+ class Pages ::FollowResponseExampleApp ::TestModelPage < Matestack ::Ui ::Page
774
+ def response
775
+ components {
776
+ heading text : @test_model . title , size : 1
777
+ plain "This page has been loaded via redirect_to and follow_response."
778
+ }
779
+ end
780
+ end
781
+
782
+ visit "/test_models"
783
+
784
+ click_button "Click me!"
785
+
786
+ expect ( page ) . to have_no_text "Click me"
787
+ expect ( page ) . to have_text "A title for my new test object"
788
+ expect ( page ) . to have_text "This page has been loaded via redirect_to and follow_response."
789
+
790
+ end
791
+
708
792
end
0 commit comments