Sha256: 9959ca38bfdbe88f3c051931228965f3e8c671b507df4960d00a1c2196ef920f
Contents?: true
Size: 1.09 KB
Versions: 8
Compression:
Stored size: 1.09 KB
Contents
module ModelFactories def create_source(custom={}) create_model!(DataCatalog::Source, custom, { :title => "Healthcare Spending Data", :url => "http://data.gov/details/23", }) end def create_category(custom={}) create_model!(DataCatalog::Category, custom, { :name => "Sample Category", }) end def create_categorization(custom={}) create_model!(DataCatalog::Categorization, custom, { :source_id => "", :category_id => "", }) end def create_user(custom={}) create_model!(DataCatalog::User, custom, { :name => "Sample User", :email => "sample.user@inter.net", :role => "basic", }) end protected def create_model!(klass, custom, required) model = klass.create(required.merge(custom)) unless model.valid? raise "Invalid #{klass}: #{model.errors.errors.inspect}" end model end def new_model!(klass, custom, required) model = klass.new(required.merge(custom)) unless model.valid? raise "Invalid #{klass}: #{model.errors.errors.inspect}" end model end end
Version data entries
8 entries across 8 versions & 1 rubygems