Generate unique reference in Paper factory

This commit is contained in:
Lars Henrik Mai 2016-02-20 07:47:43 +01:00
parent 9423847cb1
commit aa4a6b6958
2 changed files with 7 additions and 1 deletions

View file

@ -4,7 +4,7 @@ FactoryGirl.define do
factory :paper do factory :paper do
name { Faker::Lorem.sentence } name { Faker::Lorem.sentence }
url { Faker::Internet.url("ris.example.org") } url { Faker::Internet.url("ris.example.org") }
reference "MyString" sequence(:reference) { |n| FactoryHelper.reference(n) }
body "leipzig" body "leipzig"
published_at "2015-07-20 21:16:53" published_at "2015-07-20 21:16:53"
scraped_at "2015-07-20 21:16:53" scraped_at "2015-07-20 21:16:53"

View file

@ -20,4 +20,10 @@ module FactoryHelper
PAPER_TYPES.sample PAPER_TYPES.sample
end end
REFERENCE = "A-%05i/16"
def self.reference(seq)
REFERENCE % seq
end
end end