Skip to content

Commit

Permalink
Adding 'open_to' as a form helper data option ('data-fp-*')
Browse files Browse the repository at this point in the history
  • Loading branch information
smudge committed Feb 9, 2015
1 parent bc15c84 commit cc83395
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/helpers/filepicker_rails/form_helper.rb
Expand Up @@ -7,7 +7,7 @@ module FormHelper
:store_location, :store_access,
:store_container, :multiple]

FILEPICKER_OPTIONS_TO_CAMELIZE = [:max_size, :max_files]
FILEPICKER_OPTIONS_TO_CAMELIZE = [:max_size, :max_files, :open_to]

# Creates a filepicker field, accepts optional `options` hash for configuration.
#
Expand All @@ -30,6 +30,7 @@ module FormHelper
# - `:onchange` - The onchange event.
# - `:max_size` - The maximum file size allowed, in bytes.
# - `:max_files` - The maximum number of files.
# - `:open_to` - Open the picker to the given service. Ex: `COMPUTER`.
# - `:class` - Add a class to the input.
# - `:value` - Define the value of the input
#
Expand Down
5 changes: 5 additions & 0 deletions spec/helpers/form_helper_spec.rb
Expand Up @@ -122,6 +122,11 @@
expect(form.filepicker_field(:filepicker_url, max_files: 10)).to include(attribute)
end

it "have correct input with 'open_to'" do
attribute = %{data-fp-openTo="FACEBOOK"}
expect(form.filepicker_field(:filepicker_url, open_to: 'FACEBOOK')).to include(attribute)
end

it "have correct input with 'onchange'" do
attribute = %{onchange="track()"}
expect(form.filepicker_field(:filepicker_url, onchange: "track()")).to include(attribute)
Expand Down

0 comments on commit cc83395

Please sign in to comment.