Permalink
Browse files

allow creation of custom actions

  • Loading branch information...
1 parent 7270920 commit 287a0e909ed094946941813794b9afe77b1a7ddb @mikz mikz committed Feb 22, 2013
Showing with 12 additions and 1 deletion.
  1. +2 −1 lib/formtastic/helpers/action_helper.rb
  2. +10 −0 spec/helpers/action_helper_spec.rb
@@ -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
@@ -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|

0 comments on commit 287a0e9

Please sign in to comment.