fe 2.1.9 → 2.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/controllers/fe/admin/elements_controller.rb +2 -2
- data/app/models/fe/question_sheet.rb +2 -2
- data/lib/fe/version.rb +1 -1
- data/spec/controllers/fe/admin/elements_controller_spec.rb +2 -2
- data/spec/dummy/config/application.rb +2 -1
- data/spec/dummy/config/database.yml +18 -3
- data/spec/dummy/db/fe_test.sqlite3 +0 -0
- data/spec/dummy/db/fe_test.sqlite3-shm +0 -0
- data/spec/dummy/db/fe_test.sqlite3-wal +0 -0
- data/spec/dummy/db/schema.rb +49 -51
- data/spec/dummy/log/test.log +240722 -0
- data/spec/dummy/tmp/local_secret.txt +1 -0
- data/spec/models/fe/question_sheet_conditional_import_export_spec.rb +121 -0
- metadata +23 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bcd498b63228decf76bc00fc7d5b9d4fe880213b7c28c13fd574dcba078b29debc9f8010b8932c4cd304f09562c64e1a01609ed87eeac0553d73b674582b4913
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
describe Fe::QuestionSheet, 'conditional import/export', type: :model do
|
|
4
|
+
let!(:temp_yaml_file) { Rails.root.join('tmp', 'test_export.yml') }
|
|
5
|
+
|
|
6
|
+
after do
|
|
7
|
+
File.delete(temp_yaml_file) if File.exist?(temp_yaml_file)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
context 'conditional element and page mapping during export/import' do
|
|
11
|
+
it 'should preserve conditional relationships after export and import' do
|
|
12
|
+
# Create question sheet with two pages
|
|
13
|
+
question_sheet = create(:question_sheet, label: "Conditional Test Sheet")
|
|
14
|
+
|
|
15
|
+
# Page 1 - contains element-to-element conditional
|
|
16
|
+
page1 = create(:page, question_sheet: question_sheet, label: "Personal Info", number: 1)
|
|
17
|
+
|
|
18
|
+
# Page 2 - target for page conditional
|
|
19
|
+
page2 = create(:page, question_sheet: question_sheet, label: "Additional Details", number: 2)
|
|
20
|
+
|
|
21
|
+
# Page 1: Simple text field
|
|
22
|
+
name_field = create(:text_field_element, label: "Your Name")
|
|
23
|
+
create(:page_element, page: page1, element: name_field)
|
|
24
|
+
|
|
25
|
+
# Page 1: Yes/No question that controls visibility of next element on same page
|
|
26
|
+
has_spouse_field = create(:choice_field_element,
|
|
27
|
+
label: "Are you married?",
|
|
28
|
+
style: "yes-no",
|
|
29
|
+
content: "Yes\r\nNo",
|
|
30
|
+
conditional_type: "Fe::Element"
|
|
31
|
+
)
|
|
32
|
+
create(:page_element, page: page1, element: has_spouse_field)
|
|
33
|
+
|
|
34
|
+
# Page 1: Element conditionally shown based on previous yes/no
|
|
35
|
+
spouse_name_field = create(:text_field_element, label: "Spouse Name")
|
|
36
|
+
create(:page_element, page: page1, element: spouse_name_field)
|
|
37
|
+
|
|
38
|
+
# Page 1: Yes/No question that controls visibility of entire next page
|
|
39
|
+
has_children_field = create(:choice_field_element,
|
|
40
|
+
label: "Do you have children?",
|
|
41
|
+
style: "yes-no",
|
|
42
|
+
content: "Yes\r\nNo",
|
|
43
|
+
conditional_type: "Fe::Page"
|
|
44
|
+
)
|
|
45
|
+
create(:page_element, page: page1, element: has_children_field)
|
|
46
|
+
|
|
47
|
+
# Page 2: Simple text field (entire page controlled by has_children_field)
|
|
48
|
+
children_details_field = create(:text_field_element, label: "Tell us about your children")
|
|
49
|
+
create(:page_element, page: page2, element: children_details_field)
|
|
50
|
+
|
|
51
|
+
# Set up the conditionals properly
|
|
52
|
+
page1.reload
|
|
53
|
+
page2.reload
|
|
54
|
+
|
|
55
|
+
# Update all_element_ids for proper ordering
|
|
56
|
+
page1.update_column(:all_element_ids, "#{name_field.id},#{has_spouse_field.id},#{spouse_name_field.id},#{has_children_field.id}")
|
|
57
|
+
page2.update_column(:all_element_ids, "#{children_details_field.id}")
|
|
58
|
+
|
|
59
|
+
# Set up conditional relationships
|
|
60
|
+
has_spouse_field.reload
|
|
61
|
+
has_spouse_field.update!(conditional_id: spouse_name_field.id)
|
|
62
|
+
|
|
63
|
+
has_children_field.reload
|
|
64
|
+
has_children_field.update!(conditional_id: page2.id)
|
|
65
|
+
|
|
66
|
+
# Verify setup
|
|
67
|
+
expect(has_spouse_field.conditional_type).to eq("Fe::Element")
|
|
68
|
+
expect(has_spouse_field.conditional_id).to eq(spouse_name_field.id)
|
|
69
|
+
expect(has_children_field.conditional_type).to eq("Fe::Page")
|
|
70
|
+
expect(has_children_field.conditional_id).to eq(page2.id)
|
|
71
|
+
|
|
72
|
+
# Export to YAML
|
|
73
|
+
File.write(temp_yaml_file, question_sheet.export_to_yaml)
|
|
74
|
+
expect(File.exist?(temp_yaml_file)).to be true
|
|
75
|
+
|
|
76
|
+
# Store original IDs for comparison
|
|
77
|
+
original_spouse_element_id = spouse_name_field.id
|
|
78
|
+
original_page2_id = page2.id
|
|
79
|
+
original_has_spouse_conditional_id = has_spouse_field.conditional_id
|
|
80
|
+
original_has_children_conditional_id = has_children_field.conditional_id
|
|
81
|
+
|
|
82
|
+
# Import from YAML (creates new sheet with new IDs)
|
|
83
|
+
imported_sheet = Fe::QuestionSheet.create_from_yaml(temp_yaml_file)
|
|
84
|
+
|
|
85
|
+
# Verify basic structure
|
|
86
|
+
expect(imported_sheet.pages.count).to eq(2)
|
|
87
|
+
expect(imported_sheet.all_elements.count).to eq(5)
|
|
88
|
+
|
|
89
|
+
# Get imported elements by their labels
|
|
90
|
+
imported_page1 = imported_sheet.pages.find_by(label: "Personal Info")
|
|
91
|
+
imported_page2 = imported_sheet.pages.find_by(label: "Additional Details")
|
|
92
|
+
|
|
93
|
+
imported_name_field = imported_sheet.all_elements.find_by(label: "Your Name")
|
|
94
|
+
imported_has_spouse_field = imported_sheet.all_elements.find_by(label: "Are you married?")
|
|
95
|
+
imported_spouse_name_field = imported_sheet.all_elements.find_by(label: "Spouse Name")
|
|
96
|
+
imported_has_children_field = imported_sheet.all_elements.find_by(label: "Do you have children?")
|
|
97
|
+
imported_children_details_field = imported_sheet.all_elements.find_by(label: "Tell us about your children")
|
|
98
|
+
|
|
99
|
+
# Verify all elements were imported
|
|
100
|
+
expect(imported_name_field).to be_present
|
|
101
|
+
expect(imported_has_spouse_field).to be_present
|
|
102
|
+
expect(imported_spouse_name_field).to be_present
|
|
103
|
+
expect(imported_has_children_field).to be_present
|
|
104
|
+
expect(imported_children_details_field).to be_present
|
|
105
|
+
|
|
106
|
+
# Verify IDs are different (new database records)
|
|
107
|
+
expect(imported_spouse_name_field.id).not_to eq(original_spouse_element_id)
|
|
108
|
+
expect(imported_page2.id).not_to eq(original_page2_id)
|
|
109
|
+
|
|
110
|
+
# Verify element-to-element conditional was properly mapped
|
|
111
|
+
expect(imported_has_spouse_field.conditional_type).to eq("Fe::Element")
|
|
112
|
+
expect(imported_has_spouse_field.conditional_id).to eq(imported_spouse_name_field.id)
|
|
113
|
+
expect(imported_has_spouse_field.conditional_id).not_to eq(original_has_spouse_conditional_id)
|
|
114
|
+
|
|
115
|
+
# Verify element-to-page conditional was properly mapped
|
|
116
|
+
expect(imported_has_children_field.conditional_type).to eq("Fe::Page")
|
|
117
|
+
expect(imported_has_children_field.conditional_id).to eq(imported_page2.id)
|
|
118
|
+
expect(imported_has_children_field.conditional_id).not_to eq(original_has_children_conditional_id)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- CruGlobal
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-11-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -17,6 +17,9 @@ dependencies:
|
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: 5.0.7
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '8'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -24,6 +27,9 @@ dependencies:
|
|
|
24
27
|
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: 5.0.7
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '8'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: acts_as_list
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -576,6 +582,9 @@ files:
|
|
|
576
582
|
- spec/dummy/config/locales/en.yml
|
|
577
583
|
- spec/dummy/config/routes.rb
|
|
578
584
|
- spec/dummy/config/secrets.yml
|
|
585
|
+
- spec/dummy/db/fe_test.sqlite3
|
|
586
|
+
- spec/dummy/db/fe_test.sqlite3-shm
|
|
587
|
+
- spec/dummy/db/fe_test.sqlite3-wal
|
|
579
588
|
- spec/dummy/db/migrate/20141203214017_core.fe_engine.rb
|
|
580
589
|
- spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb
|
|
581
590
|
- spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb
|
|
@@ -603,10 +612,12 @@ files:
|
|
|
603
612
|
- spec/dummy/db/migrate/20160204164613_add_visible_and_visibility_cache_key_to_reference_sheets.fe_engine.rb
|
|
604
613
|
- spec/dummy/db/migrate/20181108201746_create_versions.rb
|
|
605
614
|
- spec/dummy/db/schema.rb
|
|
615
|
+
- spec/dummy/log/test.log
|
|
606
616
|
- spec/dummy/public/404.html
|
|
607
617
|
- spec/dummy/public/422.html
|
|
608
618
|
- spec/dummy/public/500.html
|
|
609
619
|
- spec/dummy/public/favicon.ico
|
|
620
|
+
- spec/dummy/tmp/local_secret.txt
|
|
610
621
|
- spec/factories/answer_sheet_question_sheets.rb
|
|
611
622
|
- spec/factories/answer_sheets.rb
|
|
612
623
|
- spec/factories/answers.rb
|
|
@@ -649,6 +660,7 @@ files:
|
|
|
649
660
|
- spec/models/fe/question_grid_spec.rb
|
|
650
661
|
- spec/models/fe/question_grid_with_total_spec.rb
|
|
651
662
|
- spec/models/fe/question_set_spec.rb
|
|
663
|
+
- spec/models/fe/question_sheet_conditional_import_export_spec.rb
|
|
652
664
|
- spec/models/fe/question_sheet_spec.rb
|
|
653
665
|
- spec/models/fe/question_spec.rb
|
|
654
666
|
- spec/models/fe/reference_question_spec.rb
|
|
@@ -662,7 +674,7 @@ files:
|
|
|
662
674
|
homepage: http://cru.org
|
|
663
675
|
licenses: []
|
|
664
676
|
metadata: {}
|
|
665
|
-
post_install_message:
|
|
677
|
+
post_install_message:
|
|
666
678
|
rdoc_options: []
|
|
667
679
|
require_paths:
|
|
668
680
|
- lib
|
|
@@ -678,7 +690,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
678
690
|
version: '0'
|
|
679
691
|
requirements: []
|
|
680
692
|
rubygems_version: 3.3.27
|
|
681
|
-
signing_key:
|
|
693
|
+
signing_key:
|
|
682
694
|
specification_version: 4
|
|
683
695
|
summary: Form Engine
|
|
684
696
|
test_files:
|
|
@@ -728,6 +740,9 @@ test_files:
|
|
|
728
740
|
- spec/dummy/config/routes.rb
|
|
729
741
|
- spec/dummy/config/secrets.yml
|
|
730
742
|
- spec/dummy/config.ru
|
|
743
|
+
- spec/dummy/db/fe_test.sqlite3
|
|
744
|
+
- spec/dummy/db/fe_test.sqlite3-shm
|
|
745
|
+
- spec/dummy/db/fe_test.sqlite3-wal
|
|
731
746
|
- spec/dummy/db/migrate/20141203214017_core.fe_engine.rb
|
|
732
747
|
- spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb
|
|
733
748
|
- spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb
|
|
@@ -755,10 +770,12 @@ test_files:
|
|
|
755
770
|
- spec/dummy/db/migrate/20160204164613_add_visible_and_visibility_cache_key_to_reference_sheets.fe_engine.rb
|
|
756
771
|
- spec/dummy/db/migrate/20181108201746_create_versions.rb
|
|
757
772
|
- spec/dummy/db/schema.rb
|
|
773
|
+
- spec/dummy/log/test.log
|
|
758
774
|
- spec/dummy/public/404.html
|
|
759
775
|
- spec/dummy/public/422.html
|
|
760
776
|
- spec/dummy/public/500.html
|
|
761
777
|
- spec/dummy/public/favicon.ico
|
|
778
|
+
- spec/dummy/tmp/local_secret.txt
|
|
762
779
|
- spec/factories/answer_sheet_question_sheets.rb
|
|
763
780
|
- spec/factories/answer_sheets.rb
|
|
764
781
|
- spec/factories/answers.rb
|
|
@@ -801,6 +818,7 @@ test_files:
|
|
|
801
818
|
- spec/models/fe/question_grid_spec.rb
|
|
802
819
|
- spec/models/fe/question_grid_with_total_spec.rb
|
|
803
820
|
- spec/models/fe/question_set_spec.rb
|
|
821
|
+
- spec/models/fe/question_sheet_conditional_import_export_spec.rb
|
|
804
822
|
- spec/models/fe/question_sheet_spec.rb
|
|
805
823
|
- spec/models/fe/question_spec.rb
|
|
806
824
|
- spec/models/fe/reference_question_spec.rb
|