Skip to content

Commit

Permalink
allow creation of custom actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Cichra committed Feb 25, 2013
1 parent c02f60e commit bb30309
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/formtastic/helpers/action_helper.rb
Expand Up @@ -90,8 +90,9 @@ def action(method, options = {})
def default_action_type(method, options = {}) #:nodoc:
case method
when :submit then :input
when :reset then :input
when :reset then :input
when :cancel then :link
else method
end
end

Expand Down
10 changes: 10 additions & 0 deletions spec/helpers/action_helper_spec.rb
Expand Up @@ -270,6 +270,16 @@
end
end

context 'of unknown action' do
it "should try to load class named as the action" do
expect {
semantic_form_for(@new_post) do |builder|
builder.action(:destroy)
end
}.to raise_error(Formtastic::UnknownActionError, 'Unable to find action class for destroy')
end
end

describe 'when instantiated multiple times with the same action type' do
it "should be cached" do
concat(semantic_form_for(@new_post) do |builder|
Expand Down

0 comments on commit bb30309

Please sign in to comment.