Skip to content

Commit

Permalink
Merge pull request #71 from mattslack/allow-strings
Browse files Browse the repository at this point in the history
Don't try to map Strings
  • Loading branch information
Jiri Kolarik committed Apr 7, 2016
2 parents 5d18c7d + 5826c62 commit d7766da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/x-editable-rails/view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def editable(object, method, options = {})
})

content_tag tag, html_options do
if %w(select checklist).include? data[:type].to_s
if %w(select checklist).include?(data[:type].to_s) && !source.is_a?(String)
source = normalize_source(source)
content = source.detect { |t| output_value == output_value_for(t[0]) }
content.present? ? content[1] : ""
Expand Down
8 changes: 8 additions & 0 deletions test/view_helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ def initialize(attributes={})
"ViewHelpers#editable should generate content tag with the current value"
end

test "editable should store the source url as a data attribute" do
subject = Subject.new
assert_match %r{<span[^>]+data-source="http://example.org"},
editable(subject, :name, type: "select",
source: "http://example.org"),
"ViewHelpers#editable should generate content tag with url source as a data attribute"
end

private

def view_helpers_test_subject_path(subject)
Expand Down

0 comments on commit d7766da

Please sign in to comment.