Skip to content

fixed form component usage on component-level #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/lib/matestack/ui/core/component_node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ def initialize(component_instance, included_config)
@hash = {}
@node_start_id = 0
@component_instance = component_instance
@included_config = included_config
component_instance.instance_variables.each do |component_instance_var_key|
self.instance_variable_set(component_instance_var_key, component_instance.instance_variable_get(component_instance_var_key))
end
@included_config = included_config
end

def method_missing meth, *args, &block
Expand Down
55 changes: 55 additions & 0 deletions spec/usage/components/form_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,61 @@ def form_config
it "can have a label"

end

describe "Usage on Component Level" do

it "Example 1 - Async submit request with clientside payload from component-level" do

module Components end

class Components::SomeComponent < Matestack::Ui::StaticComponent

def response
components {
form form_config, :include do
form_input id: "my-test-input", key: :foo, type: :text
form_submit do
button text: "Submit me!"
end
end
}
end

def form_config
return {
for: :my_object,
method: :post,
path: :success_form_test_path,
params: {
id: 42
}
}
end
end

class ExamplePage < Matestack::Ui::Page

def response
components {
div do
custom_someComponent
end
}
end

end

visit "/example"

fill_in "my-test-input", with: "bar"
click_button "Submit me!"

expect_any_instance_of(FormTestController).to receive(:expect_params)
.with(hash_including(my_object: { foo: "bar" }))

end
end

end

end