Created
October 12, 2017 20:22
-
-
Save jathayde/056666225f4b57f76de284b1816f1a40 to your computer and use it in GitHub Desktop.
Take 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FactoryGirl.define do | |
factory :issue do | |
before(:each) do | |
@lodge_issue = FactoryGirl.create(:lodge_issue) | |
@issue = @lodge_issue.issue | |
end | |
transient do | |
combined_value nil | |
end | |
association :issueable, factory: :lodge | |
quantity_issued { Faker::Number.number(2) } | |
description 'Test description for test issue' | |
oa_bb_category_id '1' | |
category_id '1' | |
issue_type_id '1' | |
border_color_id '1' | |
border_type_id '1' | |
background_color_id '1' | |
lettering_color_id '1' | |
fdl_bsa_color_id '1' | |
issue_type { | |
if combined_value | |
type_abbrev, | |
second_abbrev, | |
issue_number_val, | |
variety_val = combined_value.match(/([A-Z])([A-Z]?)([\d]*)([a-z])?/).captures | |
if second_abbrev | |
IssueType.find_by_abbreviation(second_abbrev) | |
elsif type_abbrev | |
IssueType.find_by_abbreviation(type_abbrev) | |
end | |
else | |
IssueType.order_by_rand.first | |
end | |
} | |
issue_number { | |
if combined_value | |
type_abbrev, | |
second_abbrev, | |
issue_number_val, | |
variety_val = combined_value.match(/([A-Z])([A-Z]?)([\d]*)([a-z])?/).captures | |
issue_number_val | |
else | |
Faker::Number.number(2) | |
end | |
} | |
variety { | |
if combined_value | |
type_abbrev, | |
second_abbrev, | |
issue_number_val, | |
variety_val = combined_value.match(/([A-Z])([A-Z]?)([\d]*)([a-z])?/).captures | |
variety_val | |
else | |
Faker::Lorem.character | |
end | |
} | |
end | |
factory :lodge_issue, class: "Issue" do | |
association :issueable, factory: :lodge | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment