File tree Expand file tree Collapse file tree 2 files changed +56
-1
lines changed
app/lib/matestack/ui/core Expand file tree Collapse file tree 2 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,10 @@ def initialize(component_instance, included_config)
13
13
@hash = { }
14
14
@node_start_id = 0
15
15
@component_instance = component_instance
16
- @included_config = included_config
17
16
component_instance . instance_variables . each do |component_instance_var_key |
18
17
self . instance_variable_set ( component_instance_var_key , component_instance . instance_variable_get ( component_instance_var_key ) )
19
18
end
19
+ @included_config = included_config
20
20
end
21
21
22
22
def method_missing meth , *args , &block
Original file line number Diff line number Diff line change @@ -1554,6 +1554,61 @@ def form_config
1554
1554
it "can have a label"
1555
1555
1556
1556
end
1557
+
1558
+ describe "Usage on Component Level" do
1559
+
1560
+ it "Example 1 - Async submit request with clientside payload from component-level" do
1561
+
1562
+ module Components end
1563
+
1564
+ class Components ::SomeComponent < Matestack ::Ui ::StaticComponent
1565
+
1566
+ def response
1567
+ components {
1568
+ form form_config , :include do
1569
+ form_input id : "my-test-input" , key : :foo , type : :text
1570
+ form_submit do
1571
+ button text : "Submit me!"
1572
+ end
1573
+ end
1574
+ }
1575
+ end
1576
+
1577
+ def form_config
1578
+ return {
1579
+ for : :my_object ,
1580
+ method : :post ,
1581
+ path : :success_form_test_path ,
1582
+ params : {
1583
+ id : 42
1584
+ }
1585
+ }
1586
+ end
1587
+ end
1588
+
1589
+ class ExamplePage < Matestack ::Ui ::Page
1590
+
1591
+ def response
1592
+ components {
1593
+ div do
1594
+ custom_someComponent
1595
+ end
1596
+ }
1597
+ end
1598
+
1599
+ end
1600
+
1601
+ visit "/example"
1602
+
1603
+ fill_in "my-test-input" , with : "bar"
1604
+ click_button "Submit me!"
1605
+
1606
+ expect_any_instance_of ( FormTestController ) . to receive ( :expect_params )
1607
+ . with ( hash_including ( my_object : { foo : "bar" } ) )
1608
+
1609
+ end
1610
+ end
1611
+
1557
1612
end
1558
1613
1559
1614
end
You can’t perform that action at this time.
0 commit comments