Permalink
Browse files

Fixed add_associated_link helper so that it produces unique IDs for t…

…he fields
  • Loading branch information...
1 parent 254728e commit 9e8e07b21cdbe0b029bdca5c54373a95582c0d85 @cjse cjse committed Aug 27, 2008
View
2 lib/attribute_fu/associated_form_helper.rb
@@ -89,7 +89,7 @@ def add_associated_link(name, object, opts = {})
@template.link_to_function(name, opts) do |page|
page << "if (typeof #{variable} == 'undefined') #{variable} = 0;"
- page << "new Insertion.Bottom(#{container}, new Template("+form_builder.render_associated_form(object, :fields_for => { :javascript => true }, :partial => partial).to_json+").evaluate({'number': --#{variable}}))"
+ page << "new Insertion.Bottom(#{container}, new Template("+form_builder.render_associated_form(object, :fields_for => { :javascript => true }, :partial => partial).to_json+").evaluate({'number': --#{variable}}).gsub(/__number_/, #{variable}))"
end
end
View
20 test/config/database.yml
@@ -1,15 +1,9 @@
development:
- adapter: mysql
- encoding: utf8
- database: attribute_fu_test
- username: root
- password:
- socket: /tmp/mysql.sock
-
+ adapter: sqlite3
+ database: db/development.sqlite3
+ timeout: 5000
+
test:
- adapter: mysql
- encoding: utf8
- database: attribute_fu_test
- username: root
- password:
- socket: /tmp/mysql.sock
+ adapter: sqlite3
+ database: db/test.sqlite3
+ timeout: 5000
View
1 test/db/.gitignore
@@ -0,0 +1 @@
+*.sqlite3
View
1 test/log/.gitignore
@@ -0,0 +1 @@
+*.log
View
6 test/test/unit/associated_form_helper_test.rb
@@ -160,7 +160,7 @@ def setup
should "produce the following link" do
# this is a way of testing the whole link
assert_equal %{
- <a class=\"something\" href=\"#\" onclick=\"if (typeof attribute_fu_comment_count == 'undefined') attribute_fu_comment_count = 0;\nnew Insertion.Bottom('comments', new Template(null).evaluate({'number': --attribute_fu_comment_count})); return false;\">Add Comment</a>
+ <a class=\"something\" href=\"#\" onclick=\"if (typeof attribute_fu_comment_count == 'undefined') attribute_fu_comment_count = 0;\nnew Insertion.Bottom('comments', new Template(null).evaluate({'number': --attribute_fu_comment_count}).gsub(/__number_/, attribute_fu_comment_count)); return false;\">Add Comment</a>
}.strip, @erbout
end
end
@@ -198,7 +198,7 @@ def setup
should "produce the following link" do
# this is a way of testing the whole link
assert_equal %{
- <a href=\"#\" onclick=\"if (typeof attribute_fu_comment_count == 'undefined') attribute_fu_comment_count = 0;\nnew Insertion.Bottom('something_comments', new Template(null).evaluate({'number': --attribute_fu_comment_count})); return false;\">Add Comment</a>
+ <a href=\"#\" onclick=\"if (typeof attribute_fu_comment_count == 'undefined') attribute_fu_comment_count = 0;\nnew Insertion.Bottom('something_comments', new Template(null).evaluate({'number': --attribute_fu_comment_count}).gsub(/__number_/, attribute_fu_comment_count)); return false;\">Add Comment</a>
}.strip, @erbout
end
end
@@ -236,7 +236,7 @@ def setup
should "produce the following link" do
# this is a way of testing the whole link
assert_equal %{
- <a href=\"#\" onclick=\"if (typeof attribute_fu_comment_count == 'undefined') attribute_fu_comment_count = 0;\nnew Insertion.Bottom($(this).up(&quot;.something_comments&quot;), new Template(null).evaluate({'number': --attribute_fu_comment_count})); return false;\">Add Comment</a>
+ <a href=\"#\" onclick=\"if (typeof attribute_fu_comment_count == 'undefined') attribute_fu_comment_count = 0;\nnew Insertion.Bottom($(this).up(&quot;.something_comments&quot;), new Template(null).evaluate({'number': --attribute_fu_comment_count}).gsub(/__number_/, attribute_fu_comment_count)); return false;\">Add Comment</a>
}.strip, @erbout
end
end

0 comments on commit 9e8e07b

Please sign in to comment.