Skip to content

Commit

Permalink
Stabilize order of records in YAML files
Browse files Browse the repository at this point in the history
Without this PR, some databases cause generated fixtures to appear in arbitrary order, which creates large diffs upon
minor modifications to the fixture structure.
  • Loading branch information
jackkinsella authored and thewoolleyman committed Aug 14, 2019
1 parent 2301dc9 commit 70115d2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fixture_builder/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def dump_tables
table_klass = table_name.classify.constantize rescue nil
if table_klass && table_klass < ActiveRecord::Base
rows = table_klass.unscoped do
table_klass.all.collect do |obj|
table_klass.order(:id).all.collect do |obj|
attrs = obj.attributes.select { |attr_name| table_klass.column_names.include?(attr_name) }
attrs.inject({}) do |hash, (attr_name, value)|
hash[attr_name] = serialized_value_if_needed(table_klass, attr_name, value)
Expand Down

0 comments on commit 70115d2

Please sign in to comment.