Permalink
Browse files

join result of dependent_fields_for_select so return value can be use…

…d in a select unaltered
  • Loading branch information...
1 parent a96c7b7 commit 7981499cc5d1db48f479c3ea8e5df76bedadce26 @adamkittelson adamkittelson committed Mar 22, 2011
View
3 lib/index-tanked/active_record_defaults/class_companion.rb
@@ -43,11 +43,12 @@ def dependent_fields_as_strings
end
def dependent_fields_for_select(*additional_fields)
- if additional_fields.empty?
+ fields = if additional_fields.empty?
dependent_fields_as_strings
else
(dependent_fields_as_strings + additional_fields.map(&:to_s)).uniq
end
+ fields.join(', ')
end
def retry_on_error(options={}, &block)
View
6 test/unit/active_record_defaults/class_companion_test.rb
@@ -294,13 +294,13 @@ def slug
context "when no additional fields are passed" do
should "return all dependencies" do
- assert_same_elements %w{name id created_at}, @companion.dependent_fields_for_select
+ assert_same_elements 'name, id, created_at', @companion.dependent_fields_for_select
end
end
context "when additional fields are passed" do
should "return the dependencies plus whatever else is passed" do
- assert_same_elements %w{name id created_at your_mom}, @companion.dependent_fields_for_select("your_mom")
+ assert_same_elements 'name, id, created_at, your_mom', @companion.dependent_fields_for_select("your_mom")
end
end
end
@@ -318,7 +318,7 @@ def slug
end
should "return the dependencies as strings" do
- assert_same_elements %w{name id created_at}, @companion.dependent_fields_as_strings
+ assert_equal %w{name id created_at}, @companion.dependent_fields_as_strings
end
end

0 comments on commit 7981499

Please sign in to comment.