Permalink
Browse files

Generated view specs use different IDs for each attribute.

- Fixes #504.
  • Loading branch information...
1 parent ff96af6 commit 88ed708b7cea2e23d9e50e4138d30da8aabbe44b @dchelimsky dchelimsky committed Feb 12, 2012
Showing with 5 additions and 1 deletion.
  1. +1 −0 Changelog.md
  2. +3 −0 lib/generators/rspec/scaffold/scaffold_generator.rb
  3. +1 −1 templates/generate_stuff.rb
View
@@ -7,6 +7,7 @@ Enhancments
Bug fixes
* mock_model(XXX).as_null_object.unknown_method returns self again
+* Generated view specs use different IDs for each attribute.
### 2.8.1 / 2012-01-04
@@ -146,6 +146,9 @@ def value_for(attribute)
case attribute.type
when :string
"#{attribute.name.titleize}".inspect
+ when :integer
+ @attribute_id_map ||= {}
+ @attribute_id_map[attribute] ||= (@attribute_id_map.keys.size + 1).to_s
@justinko
justinko Feb 13, 2012 Contributor

Can probably use next: @attribute_id_map.keys.size.next.to_s

@dchelimsky
dchelimsky Feb 13, 2012 Member

Seems good to me - feel free to make the change.

else
attribute.default.inspect
end
@@ -5,7 +5,7 @@
generate('mailer Notifications signup')
generate('model thing name:string')
generate('helper things')
-generate('scaffold widget name:string category:string instock:boolean --force')
+generate('scaffold widget name:string category:string instock:boolean foo_id:integer bar_id:integer --force')
generate('observer widget')
generate('scaffold gadget') # scaffold with no attributes
generate('scaffold admin/accounts name:string') # scaffold with nested resource

0 comments on commit 88ed708

Please sign in to comment.