module FixtureFarm::ActiveRecordExtension
Public Instance Methods
candidate_fixtures_file_path()
click to toggle source
# File lib/fixture_farm/active_record_extension.rb, line 20 def candidate_fixtures_file_path klass = self.class loop do path = Rails.root.join('test', 'fixtures', "#{klass.to_s.underscore.pluralize}.yml") return path if klass >= ActiveRecord::Base || !klass.columns.map(&:name).include?(klass.inheritance_column) klass = klass.superclass end end
existing_fixtures_file_path()
click to toggle source
# File lib/fixture_farm/active_record_extension.rb, line 30 def existing_fixtures_file_path klass = self.class while klass < ActiveRecord::Base path = Rails.root.join('test', 'fixtures', "#{klass.to_s.underscore.pluralize}.yml") return path if File.exist?(path) klass = klass.superclass end nil end
fixture_name()
click to toggle source
# File lib/fixture_farm/active_record_extension.rb, line 5 def fixture_name require 'active_record/fixtures' return nil unless File.exist?(fixtures_file_path) fixtures = YAML.load_file(fixtures_file_path) fixtures.keys.find do |key| ActiveRecord::FixtureSet.identify(key) == id end end
fixtures_file_path()
click to toggle source
# File lib/fixture_farm/active_record_extension.rb, line 16 def fixtures_file_path existing_fixtures_file_path || candidate_fixtures_file_path end