fe 2.1.9 → 2.1.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f80bfad3559c2f47bb6297a80dae9645ffe078100986ff735da80c8af903985d
4
- data.tar.gz: 31df747d0f5d44fb5db832eafe67176256de53f32d7bea7bf2dcca90d64219a8
3
+ metadata.gz: 1b53a2e7051a1d412fad535434c300275a075e512e693d7ac4007ab00a6fedfc
4
+ data.tar.gz: 28a168ce6df5ed1eedda2e9523d2784a9d0e01a2526d1e8c3708b77b3cfce481
5
5
  SHA512:
6
- metadata.gz: 67dc5b54f91a0c83c0c5bb2145b5d0669b8b90823341d2c67247bf83915f1bb9b06deeaa7f0ce5207982fd42dcb2b233efc91c51a53818d790db9149e3f9f143
7
- data.tar.gz: b709b379290e78641f48907cea8ea7d630131c0c7c501a265e4ddb09405ae32d4d7f9b841d8f994984aac0f86a2850a7c344cfb57f1a6158bdb04237fd4a1b12
6
+ metadata.gz: b902c50a56960f86d77911ffb67c09c4fd7df56a2995c971b395457015ea7848038d535116d5c1c4322aa6ba13c126592b3481c05f646dd9324758cb8240f2d5
7
+ data.tar.gz: a1890338895c3f944a2fd777050ce161e709a2f8a4d1084965ca6e18c2b6dbfefcb4a8fa52e90a4486ebb5c09c9c8254cff0ffe3e95732396ace1812d886fb62
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'bundler/setup'
2
2
  require 'thor'
3
3
 
4
4
  APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
5
- load 'rails/tasks/engine.rake' if File.exists? 'spec/dummy/Rakefile'
5
+ load 'rails/tasks/engine.rake' if File.exist? 'spec/dummy/Rakefile'
6
6
 
7
7
  Bundler::GemHelper.install_tasks
8
8
 
@@ -57,7 +57,7 @@ class Fe::Admin::ElementsController < ApplicationController
57
57
  @page_element = Fe::PageElement.create(element: @element, page: @page)
58
58
  format.js
59
59
  else
60
- format.js { render action: 'error.js.erb' }
60
+ format.js { render 'error' }
61
61
  end
62
62
  end
63
63
  end
@@ -70,7 +70,7 @@ class Fe::Admin::ElementsController < ApplicationController
70
70
  if @element.update(element_params)
71
71
  format.js
72
72
  else
73
- format.js { render action: 'error.js.erb' }
73
+ format.js { render 'error' }
74
74
  end
75
75
  end
76
76
  end
@@ -85,10 +85,10 @@ module Fe
85
85
  # set page conditional_id values to new ids based on old_id
86
86
  question_sheet.all_elements.each do |el|
87
87
  if el.conditional_type != "Fe::Page" && el.conditional_id.present?
88
- # noop
88
+ el.update(conditional_id: question_sheet.element_id_mappings[el.conditional_id])
89
89
  end
90
90
 
91
- # note that conditional elements are already translated to new ids in the element import so no need to do it here
91
+ # handle page conditionals separately since they use page.old_id instead of element_id_mappings
92
92
  if el.conditional_type == "Fe::Page" && el.conditional_id
93
93
  el.update(conditional_id: question_sheet.pages.detect{ |el2| el2.old_id == el.conditional_id }&.id)
94
94
  end
@@ -29,7 +29,7 @@
29
29
  <% session_key_name = Rails.application.config.session_options[:key] %>
30
30
  $('#<%= dom_id(attachment_field) %>_file_uploader').uploadify({
31
31
  uploader : '<%= asset_path "fe/uploadify/uploadify.swf" %>',
32
- script : '<%= save_file_fe_answer_sheet_page_path(@presenter.active_answer_sheet, @page, question_id: element_id, answer_sheet_type: @answer_sheet.class.name) %>',
32
+ script : '<%= save_file_fe_answer_sheet_page_path(@presenter.active_answer_sheet, @page, question_id: element_id, answer_sheet_type: @answer_sheet.class.name).html_safe %>',
33
33
  fileDesc : 'Pick a file',
34
34
  fileExt : '<%= attachment_field.content || "*.*" %>',
35
35
  auto : true,
@@ -64,7 +64,7 @@
64
64
  $('<%= base_element %> .remove_current').click(function() {
65
65
  $.ajax({
66
66
  type: 'DELETE',
67
- url: '<%= delete_file_fe_answer_sheet_page_path(@presenter.active_answer_sheet, @page, question_id: element_id, answer_sheet_type: @answer_sheet.class.name) %>',
67
+ url: '<%= delete_file_fe_answer_sheet_page_path(@presenter.active_answer_sheet, @page, question_id: element_id, answer_sheet_type: @answer_sheet.class.name).html_safe %>',
68
68
  success: function(result) {
69
69
  $.get("/fe/answer_sheets/<%= @answer_sheet.id %>/page/<%= @page.id %>/edit?answer_sheet_type=<%= @answer_sheet.class.name %>", function(data) {
70
70
  $('<%= base_element %>').replaceWith($(data).find('<%= base_element %>'))
@@ -98,7 +98,7 @@
98
98
 
99
99
  let $input = $("<%= base_element %> .upload_field").html5_upload({
100
100
  url: function(number) {
101
- return "<%= save_file_fe_answer_sheet_page_path(@presenter.active_answer_sheet, @page, question_id: element_id, answer_sheet_type: @answer_sheet.class.name) %>";
101
+ return "<%= save_file_fe_answer_sheet_page_path(@presenter.active_answer_sheet, @page, question_id: element_id, answer_sheet_type: @answer_sheet.class.name).html_safe %>";
102
102
  },
103
103
  sendBoundary: window.FormData || $.browser.mozilla,
104
104
  onStart: function(event, total) {
data/lib/fe/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fe
2
- VERSION = "2.1.9"
2
+ VERSION = "2.1.12"
3
3
  end
@@ -87,7 +87,7 @@ describe Fe::Admin::ElementsController, type: :controller do
87
87
  }.to change{Fe::Element.count}.by(0)
88
88
 
89
89
  expect(assigns(:page_element)).to be_nil
90
- expect(response).to render_template('error.js.erb')
90
+ expect(response).to render_template('error')
91
91
  end
92
92
  end
93
93
  context '#update' do
@@ -114,7 +114,7 @@ describe Fe::Admin::ElementsController, type: :controller do
114
114
 
115
115
  put :update, params: {element: { slug: "Illegal Chars: #@$!" }, question_sheet_id: question_sheet.id, page_id: page.id, id: element.id}, xhr: true
116
116
  expect(assigns(:element)).to eq(element)
117
- expect(response).to render_template('error.js.erb')
117
+ expect(response).to render_template('error')
118
118
  end
119
119
  end
120
120
  context '#destroy' do
@@ -25,7 +25,8 @@ module Dummy
25
25
  # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
26
26
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
27
27
  config.i18n.default_locale = :en
28
- config.action_view.raise_on_missing_translations = false
28
+ # In Rails 7+, this setting has moved to I18n
29
+ config.i18n.raise_on_missing_translations = false
29
30
  end
30
31
  end
31
32
 
@@ -1,5 +1,5 @@
1
1
  mysql: &mysql
2
- adapter: mysql<%= "2" unless ( ENV["TRAVIS_RUBY_VERSION"].include? "j" if ENV["TRAVIS_RUBY_VERSION"] ) %>
2
+ adapter: mysql<%= "2" unless (ENV["TRAVIS_RUBY_VERSION"].include? "j" if ENV["TRAVIS_RUBY_VERSION"]) %>
3
3
  username: root
4
4
  password:
5
5
 
@@ -9,20 +9,35 @@ postgresql: &postgresql
9
9
  password:
10
10
  min_messages: ERROR
11
11
 
12
+ sqlite3: &sqlite3
13
+ adapter: sqlite3
14
+
12
15
  defaults: &defaults
13
16
  pool: 5
14
17
  timeout: 5000
15
18
  host: localhost
16
- <<: *<%= ENV['DB'] || "mysql" %>
19
+ <<: *<%= ENV['DB'] || "sqlite3" %>
17
20
 
18
21
  development:
22
+ <% if (ENV['DB'] || "sqlite3") == "sqlite3" %>
23
+ database: db/fe_dev.sqlite3
24
+ <% else %>
19
25
  database: fe_dev
26
+ <% end %>
20
27
  <<: *defaults
21
28
 
22
29
  test:
30
+ <% if (ENV['DB'] || "sqlite3") == "sqlite3" %>
31
+ database: db/fe_test.sqlite3
32
+ <% else %>
23
33
  database: fe_test
34
+ <% end %>
24
35
  <<: *defaults
25
36
 
26
37
  production:
38
+ <% if (ENV['DB'] || "sqlite3") == "sqlite3" %>
39
+ database: db/fe_prod.sqlite3
40
+ <% else %>
27
41
  database: fe_prod
28
- <<: *defaults
42
+ <% end %>
43
+ <<: *defaults
Binary file
@@ -2,17 +2,16 @@
2
2
  # of editing this file, please use the migrations feature of Active Record to
3
3
  # incrementally modify your database, and then regenerate this schema definition.
4
4
  #
5
- # Note that this schema.rb definition is the authoritative source for your
6
- # database schema. If you need to create the application database on another
7
- # system, you should be using db:schema:load, not running all the migrations
8
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
- # you'll amass, the slower it'll run and the greater likelihood for issues).
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 20181108201746) do
14
-
15
- create_table "fe_addresses", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
13
+ ActiveRecord::Schema[7.2].define(version: 2018_11_08_201746) do
14
+ create_table "fe_addresses", force: :cascade do |t|
16
15
  t.datetime "startdate"
17
16
  t.datetime "enddate"
18
17
  t.string "address1"
@@ -29,38 +28,38 @@ ActiveRecord::Schema.define(version: 20181108201746) do
29
28
  t.datetime "updated_at"
30
29
  end
31
30
 
32
- create_table "fe_answer_sheet_question_sheets", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
31
+ create_table "fe_answer_sheet_question_sheets", force: :cascade do |t|
33
32
  t.integer "answer_sheet_id"
34
33
  t.integer "question_sheet_id"
35
34
  t.datetime "created_at"
36
35
  t.datetime "updated_at"
37
- t.index ["answer_sheet_id", "question_sheet_id"], name: "answer_sheet_question_sheet", using: :btree
36
+ t.index ["answer_sheet_id", "question_sheet_id"], name: "answer_sheet_question_sheet"
38
37
  end
39
38
 
40
- create_table "fe_answers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
39
+ create_table "fe_answers", force: :cascade do |t|
41
40
  t.integer "answer_sheet_id", null: false
42
41
  t.integer "question_id", null: false
43
- t.text "value", limit: 65535
42
+ t.text "value"
44
43
  t.integer "attachment_file_size"
45
44
  t.string "attachment_content_type"
46
45
  t.string "attachment_file_name"
47
46
  t.datetime "attachment_updated_at"
48
47
  t.datetime "created_at"
49
48
  t.datetime "updated_at"
50
- t.index ["answer_sheet_id", "question_id"], name: "answer_sheet_question", using: :btree
49
+ t.index ["answer_sheet_id", "question_id"], name: "answer_sheet_question"
51
50
  end
52
51
 
53
- create_table "fe_applications", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
52
+ create_table "fe_applications", force: :cascade do |t|
54
53
  t.integer "applicant_id"
55
54
  t.string "status"
56
55
  t.datetime "submitted_at"
57
56
  t.datetime "created_at"
58
57
  t.datetime "updated_at"
59
58
  t.string "locale", default: "en"
60
- t.index ["applicant_id"], name: "question_sheet_id", using: :btree
59
+ t.index ["applicant_id"], name: "question_sheet_id"
61
60
  end
62
61
 
63
- create_table "fe_conditions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
62
+ create_table "fe_conditions", force: :cascade do |t|
64
63
  t.integer "question_sheet_id", null: false
65
64
  t.integer "trigger_id", null: false
66
65
  t.string "expression", null: false
@@ -68,18 +67,18 @@ ActiveRecord::Schema.define(version: 20181108201746) do
68
67
  t.integer "toggle_id"
69
68
  t.datetime "created_at"
70
69
  t.datetime "updated_at"
71
- t.index ["question_sheet_id"], name: "index_fe_conditions_on_question_sheet_id", using: :btree
72
- t.index ["toggle_id"], name: "index_fe_conditions_on_toggle_id", using: :btree
73
- t.index ["toggle_page_id"], name: "index_fe_conditions_on_toggle_page_id", using: :btree
74
- t.index ["trigger_id"], name: "index_fe_conditions_on_trigger_id", using: :btree
70
+ t.index ["question_sheet_id"], name: "index_fe_conditions_on_question_sheet_id"
71
+ t.index ["toggle_id"], name: "index_fe_conditions_on_toggle_id"
72
+ t.index ["toggle_page_id"], name: "index_fe_conditions_on_toggle_page_id"
73
+ t.index ["trigger_id"], name: "index_fe_conditions_on_trigger_id"
75
74
  end
76
75
 
77
- create_table "fe_elements", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
76
+ create_table "fe_elements", force: :cascade do |t|
78
77
  t.integer "question_grid_id"
79
78
  t.string "kind", limit: 40, null: false
80
79
  t.string "style", limit: 40
81
80
  t.string "label"
82
- t.text "content", limit: 65535
81
+ t.text "content"
83
82
  t.boolean "required"
84
83
  t.string "slug", limit: 36
85
84
  t.integer "position"
@@ -97,41 +96,41 @@ ActiveRecord::Schema.define(version: 20181108201746) do
97
96
  t.datetime "updated_at"
98
97
  t.integer "related_question_sheet_id"
99
98
  t.integer "conditional_id"
100
- t.text "tooltip", limit: 65535
99
+ t.text "tooltip"
101
100
  t.boolean "hide_label", default: false
102
101
  t.boolean "hide_option_labels", default: false
103
102
  t.integer "max_length"
104
103
  t.string "conditional_type"
105
- t.text "conditional_answer", limit: 65535
104
+ t.text "conditional_answer"
106
105
  t.integer "choice_field_id"
107
106
  t.boolean "share", default: false
108
- t.text "label_translations", limit: 65535
109
- t.text "tip_translations", limit: 65535
110
- t.text "content_translations", limit: 65535
111
- t.index ["conditional_id"], name: "index_fe_elements_on_conditional_id", using: :btree
112
- t.index ["question_grid_id"], name: "index_fe_elements_on_question_grid_id", using: :btree
113
- t.index ["slug"], name: "index_fe_elements_on_slug", using: :btree
107
+ t.text "label_translations"
108
+ t.text "tip_translations"
109
+ t.text "content_translations"
110
+ t.index ["conditional_id"], name: "index_fe_elements_on_conditional_id"
111
+ t.index ["question_grid_id"], name: "index_fe_elements_on_question_grid_id"
112
+ t.index ["slug"], name: "index_fe_elements_on_slug"
114
113
  end
115
114
 
116
- create_table "fe_email_templates", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
115
+ create_table "fe_email_templates", force: :cascade do |t|
117
116
  t.string "name", limit: 1000, null: false
118
- t.text "content", limit: 65535
117
+ t.text "content"
119
118
  t.boolean "enabled"
120
119
  t.string "subject"
121
120
  t.datetime "created_at"
122
121
  t.datetime "updated_at"
123
122
  end
124
123
 
125
- create_table "fe_page_elements", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
124
+ create_table "fe_page_elements", force: :cascade do |t|
126
125
  t.integer "page_id"
127
126
  t.integer "element_id"
128
127
  t.integer "position"
129
128
  t.datetime "created_at"
130
129
  t.datetime "updated_at"
131
- t.index ["page_id", "element_id"], name: "page_element", using: :btree
130
+ t.index ["page_id", "element_id"], name: "page_element"
132
131
  end
133
132
 
134
- create_table "fe_pages", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
133
+ create_table "fe_pages", force: :cascade do |t|
135
134
  t.integer "question_sheet_id", null: false
136
135
  t.string "label", limit: 60, null: false
137
136
  t.integer "number"
@@ -139,11 +138,11 @@ ActiveRecord::Schema.define(version: 20181108201746) do
139
138
  t.boolean "hidden", default: false
140
139
  t.datetime "created_at"
141
140
  t.datetime "updated_at"
142
- t.text "all_element_ids", limit: 65535
143
- t.text "label_translations", limit: 65535
141
+ t.text "all_element_ids"
142
+ t.text "label_translations"
144
143
  end
145
144
 
146
- create_table "fe_people", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
145
+ create_table "fe_people", force: :cascade do |t|
147
146
  t.string "first_name", limit: 50
148
147
  t.string "last_name", limit: 50
149
148
  t.integer "user_id"
@@ -152,15 +151,15 @@ ActiveRecord::Schema.define(version: 20181108201746) do
152
151
  t.datetime "updated_at"
153
152
  end
154
153
 
155
- create_table "fe_question_sheets", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
154
+ create_table "fe_question_sheets", force: :cascade do |t|
156
155
  t.string "label", limit: 100, null: false
157
156
  t.boolean "archived", default: false
158
157
  t.datetime "created_at"
159
158
  t.datetime "updated_at"
160
- t.text "languages", limit: 65535
159
+ t.text "languages"
161
160
  end
162
161
 
163
- create_table "fe_references", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
162
+ create_table "fe_references", force: :cascade do |t|
164
163
  t.integer "question_id"
165
164
  t.integer "applicant_answer_sheet_id"
166
165
  t.datetime "email_sent_at"
@@ -180,11 +179,11 @@ ActiveRecord::Schema.define(version: 20181108201746) do
180
179
  t.integer "question_sheet_id"
181
180
  t.boolean "visible"
182
181
  t.string "visibility_cache_key"
183
- t.index ["applicant_answer_sheet_id"], name: "index_fe_references_on_applicant_answer_sheet_id", using: :btree
184
- t.index ["question_id"], name: "index_fe_references_on_question_id", using: :btree
182
+ t.index ["applicant_answer_sheet_id"], name: "index_fe_references_on_applicant_answer_sheet_id"
183
+ t.index ["question_id"], name: "index_fe_references_on_question_id"
185
184
  end
186
185
 
187
- create_table "fe_users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
186
+ create_table "fe_users", force: :cascade do |t|
188
187
  t.integer "user_id"
189
188
  t.datetime "last_login"
190
189
  t.string "type"
@@ -193,7 +192,7 @@ ActiveRecord::Schema.define(version: 20181108201746) do
193
192
  t.datetime "updated_at"
194
193
  end
195
194
 
196
- create_table "phone_numbers", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
195
+ create_table "phone_numbers", force: :cascade do |t|
197
196
  t.string "number"
198
197
  t.string "extensions"
199
198
  t.integer "person_id"
@@ -206,20 +205,19 @@ ActiveRecord::Schema.define(version: 20181108201746) do
206
205
  t.datetime "updated_at"
207
206
  end
208
207
 
209
- create_table "users", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
208
+ create_table "users", force: :cascade do |t|
210
209
  t.string "username"
211
210
  t.string "email"
212
211
  t.integer "person_id"
213
212
  end
214
213
 
215
- create_table "versions", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4" do |t|
214
+ create_table "versions", force: :cascade do |t|
216
215
  t.string "item_type", limit: 191, null: false
217
216
  t.integer "item_id", null: false
218
217
  t.string "event", null: false
219
218
  t.string "whodunnit"
220
- t.text "object", limit: 4294967295
219
+ t.text "object"
221
220
  t.datetime "created_at"
222
- t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id", using: :btree
221
+ t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
223
222
  end
224
-
225
- end
223
+ end
@@ -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.9
4
+ version: 2.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - CruGlobal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-30 00:00:00.000000000 Z
11
+ date: 2025-11-26 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,7 @@ 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
579
586
  - spec/dummy/db/migrate/20141203214017_core.fe_engine.rb
580
587
  - spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb
581
588
  - spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb
@@ -649,6 +656,7 @@ files:
649
656
  - spec/models/fe/question_grid_spec.rb
650
657
  - spec/models/fe/question_grid_with_total_spec.rb
651
658
  - spec/models/fe/question_set_spec.rb
659
+ - spec/models/fe/question_sheet_conditional_import_export_spec.rb
652
660
  - spec/models/fe/question_sheet_spec.rb
653
661
  - spec/models/fe/question_spec.rb
654
662
  - spec/models/fe/reference_question_spec.rb
@@ -728,6 +736,7 @@ test_files:
728
736
  - spec/dummy/config/routes.rb
729
737
  - spec/dummy/config/secrets.yml
730
738
  - spec/dummy/config.ru
739
+ - spec/dummy/db/fe_test.sqlite3
731
740
  - spec/dummy/db/migrate/20141203214017_core.fe_engine.rb
732
741
  - spec/dummy/db/migrate/20141203214018_create_reference_sheets.fe_engine.rb
733
742
  - spec/dummy/db/migrate/20141203214019_add_element_and_answer_fields.fe_engine.rb
@@ -801,6 +810,7 @@ test_files:
801
810
  - spec/models/fe/question_grid_spec.rb
802
811
  - spec/models/fe/question_grid_with_total_spec.rb
803
812
  - spec/models/fe/question_set_spec.rb
813
+ - spec/models/fe/question_sheet_conditional_import_export_spec.rb
804
814
  - spec/models/fe/question_sheet_spec.rb
805
815
  - spec/models/fe/question_spec.rb
806
816
  - spec/models/fe/reference_question_spec.rb