Skip to content

Commit

Permalink
Support no provided source
Browse files Browse the repository at this point in the history
  • Loading branch information
QuinnHarris committed Apr 8, 2016
1 parent d7766da commit 513cf3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/x-editable-rails/view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def editable(object, method, options = {})
private

def normalize_source(source)
return [] unless source
source.map do |el|
if el.is_a? Array
el
Expand Down
4 changes: 4 additions & 0 deletions test/view_helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ def initialize(attributes={})
editable(subject_1, :content, type: "select", source: [{ text: "Foo", value: "foo" }, { text: "Bar", value: "bar" }]),
"ViewHelpers#editable should generate content tag with the current value"

refute_match %r{data-source=},
editable(subject_1, :content, type: "select"),
"ViewHelpers#editable should generate content tag without source"

subject_2 = Subject.new(active: true)

assert_match %r{<span[^>]+>Yes</span>},
Expand Down

0 comments on commit 513cf3e

Please sign in to comment.