Browse Source
It caused superclass mismatch errors. We can stop seeing this bug in local development by defining the class only in test environmentspull/1634/head
Jack
2 years ago
committed by
GitHub
1 changed files with 22 additions and 20 deletions
@ -1,25 +1,27 @@ |
|||||||
class FormFixture < Form |
if Rails.env.test? |
||||||
attr_accessor :sections, :subsections, :pages, :questions |
class FormFixture < Form |
||||||
end |
attr_accessor :sections, :subsections, :pages, :questions |
||||||
|
|
||||||
class FormFactory |
|
||||||
def initialize(year:, type:) |
|
||||||
@year = year |
|
||||||
@type = type |
|
||||||
end |
end |
||||||
|
|
||||||
def with_sections(sections) |
class FormFactory |
||||||
@sections = sections |
def initialize(year:, type:) |
||||||
self |
@year = year |
||||||
end |
@type = type |
||||||
|
end |
||||||
|
|
||||||
|
def with_sections(sections) |
||||||
|
@sections = sections |
||||||
|
self |
||||||
|
end |
||||||
|
|
||||||
def build |
def build |
||||||
form = FormFixture.new(nil, @year, [], @type) |
form = FormFixture.new(nil, @year, [], @type) |
||||||
@sections.each { |section| section.form = form } |
@sections.each { |section| section.form = form } |
||||||
form.sections = @sections |
form.sections = @sections |
||||||
form.subsections = form.sections.flat_map(&:subsections) |
form.subsections = form.sections.flat_map(&:subsections) |
||||||
form.pages = form.subsections.flat_map(&:pages) |
form.pages = form.subsections.flat_map(&:pages) |
||||||
form.questions = form.pages.flat_map(&:questions) |
form.questions = form.pages.flat_map(&:questions) |
||||||
form |
form |
||||||
|
end |
||||||
end |
end |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue