fixture_builder 0.5.2 → 0.5.3.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e4cfc50092c04b49b80830b479a2a1b1092397ceea1c9d4d1a95e10c196c240
4
- data.tar.gz: 29ae27d39da1fdead7bf37dadb1c40deea757f7d5e0f9923b293f50aa6d2cc8f
3
+ metadata.gz: dcb6a4593af9b6e65c0c66416661f0e83b8e90e302a5cae7bda3814f877a35df
4
+ data.tar.gz: c27a87f54ac741f46e539389a4e28083fc1a85ea3e770a1d5b1785d994f4c614
5
5
  SHA512:
6
- metadata.gz: 2a8100257b856a58751c5cf14d7bac16ed1a2f2b86cbf466b4ae6f5dd1e456b7d70c9ed988e8f17490736752dd1b355ed5251aaf7f887f2a004adf079bd9e1c3
7
- data.tar.gz: 5599b6ee38401778aceb139539d2dc0effd95bf3f5bfb4f2ba8714d48e568269b2015e898a313c13b268d7acbaaf7eed2c826bdff51d9d7a95f4f2657fe68042
6
+ metadata.gz: c08a939256623c0f800a097bd061f6ba05a9a2025b327216ae463c08df7b90e76b3437d202178cde20b668993b8ad13ee8383616c43167c11b5bce3fa6130f72
7
+ data.tar.gz: '084e3cfc6b326b0d77e2dfa93e5a9740850298375e933a045c035ddbf6565b5dd06d9d12bba82def4e154196fa6cd1bf6a20b067c97419b2c27f5f346911d88b'
@@ -310,4 +310,4 @@ class CreateFixtures
310
310
 
311
311
  Copyright (c) 2009 Ryan Dy & David Stevenson, released under the MIT license
312
312
 
313
- Currently maintained by [Chad Woolley](thewoolleyman@gmail.com)
313
+ Currently maintained by [Chad Woolley](mailto:thewoolleyman@gmail.com)
@@ -99,7 +99,7 @@ module FixtureBuilder
99
99
  table_klass = table_name.classify.constantize rescue nil
100
100
  if table_klass && table_klass < ActiveRecord::Base
101
101
  rows = table_klass.unscoped do
102
- table_klass.all.collect do |obj|
102
+ table_klass.order(:id).all.collect do |obj|
103
103
  attrs = obj.attributes.select { |attr_name| table_klass.column_names.include?(attr_name) }
104
104
  attrs.inject({}) do |hash, (attr_name, value)|
105
105
  hash[attr_name] = serialized_value_if_needed(table_klass, attr_name, value)
@@ -1,6 +1,6 @@
1
1
  require 'active_support/core_ext'
2
2
  require 'active_support/core_ext/string'
3
- require 'digest/md5'
3
+ require 'digest'
4
4
  require 'fileutils'
5
5
  require 'hashdiff'
6
6
 
@@ -17,7 +17,7 @@ module FixtureBuilder
17
17
 
18
18
  ACCESSIBLE_ATTRIBUTES = [:select_sql, :delete_sql, :skip_tables, :files_to_check, :record_name_fields,
19
19
  :fixture_builder_file, :fixture_directory, :after_build, :legacy_fixtures, :model_name_procs,
20
- :write_empty_files]
20
+ :write_empty_files, :use_sha1_digests]
21
21
  attr_accessor(*ACCESSIBLE_ATTRIBUTES)
22
22
 
23
23
  SCHEMA_FILES = ['db/schema.rb', 'db/development_structure.sql', 'db/test_structure.sql', 'db/production_structure.sql']
@@ -100,6 +100,10 @@ module FixtureBuilder
100
100
  @namer.name_model_with(model_class, &block)
101
101
  end
102
102
 
103
+ def use_sha1_digests
104
+ @use_sha1_digests ||= false
105
+ end
106
+
103
107
  def tables
104
108
  ActiveRecord::Base.connection.tables - skip_tables
105
109
  end
@@ -115,8 +119,9 @@ module FixtureBuilder
115
119
  private
116
120
 
117
121
  def file_hashes
122
+ algorithm = use_sha1_digests ? Digest::SHA1 : Digest::MD5
118
123
  files_to_check.inject({}) do |hash, filename|
119
- hash[filename] = Digest::MD5.hexdigest(File.read(filename))
124
+ hash[filename] = algorithm.hexdigest(File.read(filename))
120
125
  hash
121
126
  end
122
127
  end
@@ -1,3 +1,3 @@
1
1
  module FixtureBuilder
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.3.rc1'
3
3
  end
@@ -97,4 +97,23 @@ class FixtureBuilderTest < Test::Unit::TestCase
97
97
  generated_fixture = YAML.load(File.open(test_path("fixtures/magical_creatures.yml")))
98
98
  assert_equal "---\n- shading\n- rooting\n- seeding\n", generated_fixture['enty']['powers']
99
99
  end
100
+
101
+ def test_sha1_digests
102
+ create_and_blow_away_old_db
103
+ force_fixture_generation_due_to_differing_file_hashes
104
+
105
+ FixtureBuilder.configure do |fbuilder|
106
+ fbuilder.use_sha1_digests = true
107
+ fbuilder.files_to_check += Dir[test_path("*.rb")]
108
+ fbuilder.factory do
109
+ @enty = MagicalCreature.create(:name => 'Enty', :species => 'ent',
110
+ :powers => %w{shading rooting seeding})
111
+ end
112
+ first_modified_time = File.mtime(test_path("fixtures/magical_creatures.yml"))
113
+ fbuilder.factory do
114
+ end
115
+ second_modified_time = File.mtime(test_path("fixtures/magical_creatures.yml"))
116
+ assert_equal first_modified_time, second_modified_time
117
+ end
118
+ end
100
119
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixture_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Dy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-08-11 00:00:00.000000000 Z
13
+ date: 2019-10-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord