quby 5.0.0 → 5.0.5
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/README.markdown +11 -2
- data/app/assets/javascripts/quby/answers/validation.js +3 -1
- data/lib/quby/answers/services/answer_validator.rb +44 -0
- data/lib/quby/questionnaires/deserializer.rb +10 -5
- data/lib/quby/questionnaires/entities/charting/bar_chart.rb +1 -5
- data/lib/quby/questionnaires/entities/charting/chart.rb +5 -1
- data/lib/quby/questionnaires/entities/charting/radar_chart.rb +1 -5
- data/lib/quby/questionnaires/specs/api_specs.rb +7 -5
- data/lib/quby/version.rb +1 -1
- data/spec/features/charts_spec.rb +9 -2
- data/spec/features/editing_completed_answer_spec.rb +2 -2
- data/spec/features/question_dependencies/group_maximum_answered_spec.rb +65 -2
- data/spec/features/question_dependencies/group_minimum_answered_spec.rb +42 -2
- data/spec/features/question_dependencies/group_minmax_answered_spec.rb +44 -7
- data/spec/fixtures/questionnaire_with_chart.rb +1 -0
- data/spec/fixtures/scores_from_schema.rb +25 -0
- data/spec/quby/answers/entities/score_spec.rb +51 -44
- data/spec/quby/answers/services/answer_validator_spec.rb +50 -9
- data/spec/quby/questionnaires/entities/charting/bar_chart_spec.rb +2 -8
- data/spec/quby/questionnaires/entities/charting/radar_chart_spec.rb +0 -5
- data/spec/quby/questionnaires/entities/fields_spec.rb +2 -2
- data/spec/quby/questionnaires/entities/questionnaire_spec.rb +4 -2
- data/spec/quby/questionnaires/repos/disk_repo_spec.rb +3 -1
- data/spec/quby/questionnaires/repos/memory_repo_spec.rb +2 -1
- data/spec/spec_helper.rb +13 -2
- data/spec/support/examples_for_chart.rb +10 -0
- data/spec/support/validation_helpers.rb +9 -0
- data/spec/teaspoon_env.rb +32 -2
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a67424bdab14ce8f570e5e595dc58802061c049897617c36d17a84700fa48ce1
|
4
|
+
data.tar.gz: 298f5bd393f0aa58c9bdb8302fa35c9f615168c64adbc38427f64d74625c7fb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b267bd9f1df8cae932a0fd1359eb7551d3f6e5359eb63f7e8e8642317fae23f98870f15ad5a706f5a9ba39a3169043b9b9d8500e36030413194d926600f2cf1d
|
7
|
+
data.tar.gz: 20c2afb9a148fa86c197cdb3da6fd95ea84ce44a30e0b927357fb7752e9c9af263d2d81f39c5386fda955d17c734613214c89f2eed424436b24046a18b2529b0
|
data/README.markdown
CHANGED
@@ -45,13 +45,22 @@ To generate PDF files, the html_to_pdf docker container must be running and an e
|
|
45
45
|
ENV['HTML_TO_PDF_URL'] = 'http://127.0.0.1:7768'
|
46
46
|
```
|
47
47
|
|
48
|
+
## Docker
|
49
|
+
|
50
|
+
```bash
|
51
|
+
docker-compose build
|
52
|
+
docker-compose run test appraisal install # generate lockfiles in mounted local gemfiles. alernatively remove volume.
|
53
|
+
docker-compose run --rm test bundle exec appraisal rails60 rspec
|
54
|
+
docker-compose run --rm test bundle exec appraisal rails60 teaspoon -r spec/teaspoon_env.rb
|
55
|
+
```
|
56
|
+
|
48
57
|
## Testing
|
49
58
|
|
50
59
|
When testing with guard or teaspoon, choose the Rails version you want to use and set the teaspoon environment:
|
51
60
|
|
52
61
|
```ruby
|
53
|
-
bundle exec appraisal
|
54
|
-
TEASPOON_RAILS_ENV=test bundle exec appraisal
|
62
|
+
bundle exec appraisal rails60 bundle # install dependencies for Rails 6.0
|
63
|
+
TEASPOON_RAILS_ENV=test bundle exec appraisal rails60 guard
|
55
64
|
```
|
56
65
|
|
57
66
|
## Contributing to Quby
|
@@ -309,7 +309,9 @@
|
|
309
309
|
var hidden = 0;
|
310
310
|
|
311
311
|
for(var i = 0; i < groupItems.length; i++){
|
312
|
-
var inputs = $(groupItems[i]).find("input, textarea, select").not(":disabled, :hidden")
|
312
|
+
var inputs = $(groupItems[i]).find("input, textarea, select").not(":disabled, :hidden")
|
313
|
+
.add($(groupItems[i]).find("input.made-slider:hidden")); // slider inputs
|
314
|
+
|
313
315
|
if (inputs.length == 0) {
|
314
316
|
hidden++;
|
315
317
|
} else {
|
@@ -126,6 +126,11 @@ module Quby
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def validate_regexp(question, validation, value)
|
129
|
+
# We have decided not to allow bypassing this validation when
|
130
|
+
# aborted, since whatever is using this data further on is likely not
|
131
|
+
# built to take into account values that do not conform to the given
|
132
|
+
# format.
|
133
|
+
|
129
134
|
return if value.blank?
|
130
135
|
match = validation[:matcher].match(value)
|
131
136
|
unless match && match[0] == value
|
@@ -134,6 +139,11 @@ module Quby
|
|
134
139
|
end
|
135
140
|
|
136
141
|
def validate_minimum(question, validation, value)
|
142
|
+
# We have decided not to allow bypassing this validation when
|
143
|
+
# aborted, since whatever is using this data further on is likely not
|
144
|
+
# built to take into account values outside the intended range. (e.g.
|
145
|
+
# BMI calculation)
|
146
|
+
|
137
147
|
return if value.blank? || (question.type == :date && value.values.all?(&:empty?))
|
138
148
|
converted_answer_value = convert_answer_value(question, value)
|
139
149
|
if converted_answer_value < validation[:value]
|
@@ -142,7 +152,13 @@ module Quby
|
|
142
152
|
end
|
143
153
|
|
144
154
|
def validate_maximum(question, validation, value)
|
155
|
+
# We have decided not to allow bypassing this validation when
|
156
|
+
# aborted, since whatever is using this data further on is likely not
|
157
|
+
# built to take into account values outside the intended range. (e.g.
|
158
|
+
# BMI calculation)
|
159
|
+
|
145
160
|
return if value.blank? || (question.type == :date && value.values.all?(&:blank?))
|
161
|
+
|
146
162
|
converted_answer_value = convert_answer_value(question, value)
|
147
163
|
if converted_answer_value > validation[:value]
|
148
164
|
answer.send(:add_error, question, validation[:type], validation[:message] || "Exceeds maximum")
|
@@ -150,12 +166,24 @@ module Quby
|
|
150
166
|
end
|
151
167
|
|
152
168
|
def validate_too_many_checked(question, validation, value)
|
169
|
+
# We have decided not to allow bypassing this validation when
|
170
|
+
# aborted, since it's possible to make a decision about which fields
|
171
|
+
# to keep and which ones to blank. If you want to do anything at all
|
172
|
+
# with this completion, you'll need to decide that at some point
|
173
|
+
# anyway, so we think it's best to do that as early as possible.
|
174
|
+
|
153
175
|
if answer.send(question.uncheck_all_option) == 1 and value.values.reduce(:+) > 1
|
154
176
|
answer.send(:add_error, question, :too_many_checked, validation[:message] || "Invalid combination of options.")
|
155
177
|
end
|
156
178
|
end
|
157
179
|
|
158
180
|
def validate_not_all_checked(question, validation, value)
|
181
|
+
# We have decided not to allow bypassing this validation when
|
182
|
+
# aborted, since it's possible to make a decision about which fields
|
183
|
+
# to keep and which ones to blank. If you want to do anything at all
|
184
|
+
# with this completion, you'll need to decide that at some point
|
185
|
+
# anyway, so we think it's best to do that as early as possible.
|
186
|
+
|
159
187
|
if answer.send(question.check_all_option) == 1 and
|
160
188
|
value.values.reduce(:+) < value.length - (question.uncheck_all_option ? 1 : 0)
|
161
189
|
answer.send(:add_error, question, :not_all_checked, validation[:message] || "Invalid combination of options.")
|
@@ -163,18 +191,28 @@ module Quby
|
|
163
191
|
end
|
164
192
|
|
165
193
|
def validate_maximum_checked_allowed(question, validation, value)
|
194
|
+
# We have decided not to allow bypassing this validation when
|
195
|
+
# aborted, since it's possible to make a decision about which fields
|
196
|
+
# to keep and which ones to blank. If you want to do anything at all
|
197
|
+
# with this completion, you'll need to decide that at some point
|
198
|
+
# anyway, so we think it's best to do that as early as possible.
|
199
|
+
|
166
200
|
if value.values.reduce(:+) > question.maximum_checked_allowed.to_i
|
167
201
|
answer.send(:add_error, question, :maximum_checked_allowed, validation[:message] || "Too many options checked.")
|
168
202
|
end
|
169
203
|
end
|
170
204
|
|
171
205
|
def validate_minimum_checked_required(question, validation, value)
|
206
|
+
return if @answer.aborted
|
207
|
+
|
172
208
|
if value.values.reduce(:+) < question.minimum_checked_required.to_i
|
173
209
|
answer.send(:add_error, question, :minimum_checked_required, validation[:message] || "Not enough options checked.")
|
174
210
|
end
|
175
211
|
end
|
176
212
|
|
177
213
|
def validate_answer_group_minimum(question, validation, value)
|
214
|
+
return if @answer.aborted
|
215
|
+
|
178
216
|
answered = answer.send(:calc_answered, answer.question_groups[validation[:group]])
|
179
217
|
if answered < validation[:value]
|
180
218
|
answer.send(:add_error, question, :answer_group_minimum,
|
@@ -183,6 +221,12 @@ module Quby
|
|
183
221
|
end
|
184
222
|
|
185
223
|
def validate_answer_group_maximum(question, validation, value)
|
224
|
+
# We have decided not to allow bypassing this validation when
|
225
|
+
# aborted, since it's possible to make a decision about which fields
|
226
|
+
# to keep and which ones to blank. If you want to do anything at all
|
227
|
+
# with this completion, you'll need to decide that at some point
|
228
|
+
# anyway, so we think it's best to do that as early as possible.
|
229
|
+
|
186
230
|
answered = answer.send(:calc_answered, answer.question_groups[validation[:group]])
|
187
231
|
if answered > validation[:value]
|
188
232
|
answer.send(:add_error, question, :answer_group_maximum,
|
@@ -153,6 +153,7 @@ module Quby
|
|
153
153
|
table: table,
|
154
154
|
col_span: item_json.fetch("col_span"),
|
155
155
|
row_span: item_json.fetch("row_span"),
|
156
|
+
raw_content: item_json.fetch("raw_content", nil),
|
156
157
|
|
157
158
|
# only selectable via options passed in DSL, not via DSL methods
|
158
159
|
# many apply only to certain types of questions
|
@@ -377,17 +378,22 @@ module Quby
|
|
377
378
|
tick_interval: chart_json.fetch("tick_interval"),
|
378
379
|
plotbands: chart_json.fetch("plotbands").map do |plotband_json|
|
379
380
|
{
|
380
|
-
color: plotband_json.fetch("color")
|
381
|
+
color: plotband_json.fetch("color"),
|
381
382
|
from: plotband_json.fetch("from"),
|
382
383
|
to: plotband_json.fetch("to")
|
383
384
|
}
|
384
385
|
end,
|
386
|
+
plotlines: chart_json.fetch("plotlines") { [] }.map do |plotline_json|
|
387
|
+
{
|
388
|
+
color: plotline_json.fetch("color"),
|
389
|
+
value: plotline_json.fetch("value")
|
390
|
+
}
|
391
|
+
end
|
385
392
|
}
|
386
393
|
|
387
394
|
case chart_json.fetch("type")
|
388
395
|
when "bar_chart"
|
389
396
|
Quby::Questionnaires::Entities::Charting::BarChart.new(chart_json.fetch("key").to_sym,
|
390
|
-
plotlines: chart_json.fetch("plotlines"),
|
391
397
|
**base_args
|
392
398
|
)
|
393
399
|
when "line_chart"
|
@@ -399,8 +405,7 @@ module Quby
|
|
399
405
|
**base_args
|
400
406
|
)
|
401
407
|
when "radar_chart"
|
402
|
-
Quby::Questionnaires::Entities::Charting::
|
403
|
-
plotlines: chart_json.fetch("plotlines"),
|
408
|
+
Quby::Questionnaires::Entities::Charting::RadarChart.new(chart_json.fetch("key").to_sym,
|
404
409
|
**base_args
|
405
410
|
)
|
406
411
|
end
|
@@ -438,4 +443,4 @@ module Quby
|
|
438
443
|
end
|
439
444
|
end
|
440
445
|
end
|
441
|
-
end
|
446
|
+
end
|
@@ -7,12 +7,8 @@ module Quby
|
|
7
7
|
module Entities
|
8
8
|
module Charting
|
9
9
|
class BarChart < Chart
|
10
|
-
|
11
|
-
attr_accessor :plotlines
|
12
|
-
|
13
|
-
def initialize(key, plotlines: nil, **kwargs)
|
10
|
+
def initialize(key, **kwargs)
|
14
11
|
super(key, **kwargs)
|
15
|
-
self.plotlines = plotlines || []
|
16
12
|
end
|
17
13
|
end
|
18
14
|
end
|
@@ -60,7 +60,10 @@ module Quby
|
|
60
60
|
# @return [Array]
|
61
61
|
attr_accessor :plotbands
|
62
62
|
|
63
|
-
|
63
|
+
# @return [Array]
|
64
|
+
attr_accessor :plotlines
|
65
|
+
|
66
|
+
def initialize(key, title: nil, plottables: nil, y_categories: nil, y_range_categories: nil, chart_type: nil, y_range: nil, tick_interval: nil, plotbands: nil, plotlines: nil)
|
64
67
|
self.key = key.to_sym
|
65
68
|
self.title = title
|
66
69
|
self.plottables = plottables || []
|
@@ -70,6 +73,7 @@ module Quby
|
|
70
73
|
self.y_range = y_range
|
71
74
|
self.tick_interval = tick_interval
|
72
75
|
self.plotbands = plotbands || []
|
76
|
+
self.plotlines = plotlines || []
|
73
77
|
end
|
74
78
|
|
75
79
|
def type
|
@@ -7,12 +7,8 @@ module Quby
|
|
7
7
|
module Entities
|
8
8
|
module Charting
|
9
9
|
class RadarChart < Chart
|
10
|
-
|
11
|
-
attr_accessor :plotlines
|
12
|
-
|
13
|
-
def initialize(key, plotlines: nil, **kwargs)
|
10
|
+
def initialize(key, **kwargs)
|
14
11
|
super(key, **kwargs)
|
15
|
-
self.plotlines = plotlines || []
|
16
12
|
end
|
17
13
|
end
|
18
14
|
end
|
@@ -2,18 +2,20 @@
|
|
2
2
|
|
3
3
|
if defined?(RSpec)
|
4
4
|
RSpec.shared_examples 'a valid backend for the questionnaires api' do
|
5
|
+
let(:api) { Quby::Questionnaires::API.new(questionnaire_repo: repo) }
|
6
|
+
|
5
7
|
it 'supports finding a questionnaire' do
|
6
|
-
expect(
|
8
|
+
expect(api.find('simple').key).to eq('simple')
|
7
9
|
end
|
8
10
|
|
9
11
|
it 'supports checking whether a questionnaire exists' do
|
10
|
-
expect(
|
11
|
-
expect(
|
12
|
+
expect(api.exists? 'simple').to be_truthy
|
13
|
+
expect(api.exists? 'inexistant_questionnaire').to be_falsey
|
12
14
|
end
|
13
15
|
|
14
16
|
it 'supports finding all questionnaires' do
|
15
|
-
expect(
|
16
|
-
expect(
|
17
|
+
expect(api.all.map(&:key)).to include('simple')
|
18
|
+
expect(api.all.map(&:key)).to include('simple_with_outcome')
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
data/lib/quby/version.rb
CHANGED
@@ -25,8 +25,15 @@ feature 'Defining charts in a questionnaire' do
|
|
25
25
|
it 'supports plotbands' do
|
26
26
|
plotbands = questionnaire_with_chart.charts.first.plotbands
|
27
27
|
expect(plotbands).to eq([
|
28
|
-
{from: 30, to: 50, color:
|
29
|
-
{from: 50, to: 80, color:
|
28
|
+
{from: 30, to: 50, color: "yellow"},
|
29
|
+
{from: 50, to: 80, color: "red"}
|
30
|
+
])
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'supports plotlines' do
|
34
|
+
plotlines = questionnaire_with_chart.charts.first.plotlines
|
35
|
+
expect(plotlines).to eq([
|
36
|
+
{value: 20, color: "green"}
|
30
37
|
])
|
31
38
|
end
|
32
39
|
end
|
@@ -25,7 +25,7 @@ feature 'Editing a completed answer' do
|
|
25
25
|
expect(find('#answer_v_1_a2')).to be_checked
|
26
26
|
|
27
27
|
# make sure subquestions of selected answers are enabled
|
28
|
-
expect(find('#answer_v_1_a2_val')[:disabled]).to
|
29
|
-
expect(find('#answer_v_1_a1_val')[:disabled]).to
|
28
|
+
expect(find('#answer_v_1_a2_val')[:disabled]).to eq 'false'
|
29
|
+
expect(find('#answer_v_1_a1_val')[:disabled]).to eq 'true'
|
30
30
|
end
|
31
31
|
end
|
@@ -64,6 +64,13 @@ shared_examples 'group_maximum_answered_tests' do
|
|
64
64
|
expect_saved_value 'v_date_day', "10"
|
65
65
|
end
|
66
66
|
|
67
|
+
it 'is valid when only slider question filled in' do
|
68
|
+
set_slider_value('v_slider', '50')
|
69
|
+
run_validations
|
70
|
+
expect_no_errors
|
71
|
+
# expect_saved_value 'v_slider', "50" # occasional client side rounding issue :S
|
72
|
+
end
|
73
|
+
|
67
74
|
it 'is valid when only radio question is not filled' do
|
68
75
|
# select_radio_option 'v_radio', 'a1'
|
69
76
|
select_radio_option 'v_scale', 'a1'
|
@@ -76,6 +83,7 @@ shared_examples 'group_maximum_answered_tests' do
|
|
76
83
|
fill_in_question('v_date_year', '2013')
|
77
84
|
fill_in_question('v_date_month', '12')
|
78
85
|
fill_in_question('v_date_day', '10')
|
86
|
+
set_slider_value('v_slider', '50')
|
79
87
|
run_validations
|
80
88
|
expect_no_errors
|
81
89
|
# expect_saved_value 'v_radio', 'a1'
|
@@ -102,6 +110,7 @@ shared_examples 'group_maximum_answered_tests' do
|
|
102
110
|
fill_in_question('v_date_year', '2013')
|
103
111
|
fill_in_question('v_date_month', '12')
|
104
112
|
fill_in_question('v_date_day', '10')
|
113
|
+
set_slider_value('v_slider', '50')
|
105
114
|
run_validations
|
106
115
|
expect_no_errors
|
107
116
|
expect_saved_value 'v_radio', 'a1'
|
@@ -128,6 +137,7 @@ shared_examples 'group_maximum_answered_tests' do
|
|
128
137
|
fill_in_question('v_date_year', '2013')
|
129
138
|
fill_in_question('v_date_month', '12')
|
130
139
|
fill_in_question('v_date_day', '10')
|
140
|
+
set_slider_value('v_slider', '50')
|
131
141
|
run_validations
|
132
142
|
expect_no_errors
|
133
143
|
expect_saved_value 'v_radio', 'a1'
|
@@ -154,6 +164,7 @@ shared_examples 'group_maximum_answered_tests' do
|
|
154
164
|
fill_in_question('v_date_year', '2013')
|
155
165
|
fill_in_question('v_date_month', '12')
|
156
166
|
fill_in_question('v_date_day', '10')
|
167
|
+
set_slider_value('v_slider', '50')
|
157
168
|
run_validations
|
158
169
|
expect_no_errors
|
159
170
|
expect_saved_value 'v_radio', 'a1'
|
@@ -180,6 +191,7 @@ shared_examples 'group_maximum_answered_tests' do
|
|
180
191
|
fill_in_question('v_date_year', '2013')
|
181
192
|
fill_in_question('v_date_month', '12')
|
182
193
|
fill_in_question('v_date_day', '10')
|
194
|
+
set_slider_value('v_slider', '50')
|
183
195
|
run_validations
|
184
196
|
expect_no_errors
|
185
197
|
expect_saved_value 'v_radio', 'a1'
|
@@ -206,6 +218,7 @@ shared_examples 'group_maximum_answered_tests' do
|
|
206
218
|
fill_in_question('v_date_year', '2013')
|
207
219
|
fill_in_question('v_date_month', '12')
|
208
220
|
fill_in_question('v_date_day', '10')
|
221
|
+
set_slider_value('v_slider', '50')
|
209
222
|
run_validations
|
210
223
|
expect_no_errors
|
211
224
|
expect_saved_value 'v_radio', 'a1'
|
@@ -232,6 +245,7 @@ shared_examples 'group_maximum_answered_tests' do
|
|
232
245
|
fill_in_question('v_date_year', '2013')
|
233
246
|
fill_in_question('v_date_month', '12')
|
234
247
|
fill_in_question('v_date_day', '10')
|
248
|
+
set_slider_value('v_slider', '50')
|
235
249
|
run_validations
|
236
250
|
expect_no_errors
|
237
251
|
expect_saved_value 'v_radio', 'a1'
|
@@ -258,6 +272,7 @@ shared_examples 'group_maximum_answered_tests' do
|
|
258
272
|
# fill_in_question('v_date_year', '2013')
|
259
273
|
# fill_in_question('v_date_month', '12')
|
260
274
|
# fill_in_question('v_date_day', '10')
|
275
|
+
set_slider_value('v_slider', '50')
|
261
276
|
run_validations
|
262
277
|
expect_no_errors
|
263
278
|
expect_saved_value 'v_radio', 'a1'
|
@@ -272,6 +287,33 @@ shared_examples 'group_maximum_answered_tests' do
|
|
272
287
|
# expect_saved_value 'v_date_day', "10"
|
273
288
|
end
|
274
289
|
|
290
|
+
it 'is valid when only slider question is not filled' do
|
291
|
+
select_radio_option 'v_radio', 'a1'
|
292
|
+
select_radio_option 'v_scale', 'a1'
|
293
|
+
select_select_option 'v_select', 'a1'
|
294
|
+
check_option 'v_ck_a1'
|
295
|
+
uncheck_option 'v_ck_a2'
|
296
|
+
fill_in_question 'v_string', 'kittens!'
|
297
|
+
fill_in_question 'v_integer', '37'
|
298
|
+
fill_in_question 'v_float', '4.2'
|
299
|
+
fill_in_question('v_date_year', '2013')
|
300
|
+
fill_in_question('v_date_month', '12')
|
301
|
+
fill_in_question('v_date_day', '10')
|
302
|
+
# set_slider_value('v_slider', '50')
|
303
|
+
run_validations
|
304
|
+
expect_no_errors
|
305
|
+
expect_saved_value 'v_radio', 'a1'
|
306
|
+
expect_saved_value 'v_scale', 'a1'
|
307
|
+
expect_saved_value 'v_select', 'a1'
|
308
|
+
expect_saved_value 'v_check_box', {'v_ck_a1' => 1, 'v_ck_a2' => 0}
|
309
|
+
expect_saved_value 'v_string', 'kittens!'
|
310
|
+
expect_saved_value 'v_integer', "37"
|
311
|
+
expect_saved_value 'v_float', "4.2"
|
312
|
+
expect_saved_value 'v_date_year', "2013"
|
313
|
+
expect_saved_value 'v_date_month', "12"
|
314
|
+
expect_saved_value 'v_date_day', "10"
|
315
|
+
end
|
316
|
+
|
275
317
|
it 'is not valid when all questions are filled in' do
|
276
318
|
select_radio_option 'v_radio', 'a1'
|
277
319
|
select_radio_option 'v_scale', 'a1'
|
@@ -284,6 +326,7 @@ shared_examples 'group_maximum_answered_tests' do
|
|
284
326
|
fill_in_question('v_date_year', '2013')
|
285
327
|
fill_in_question('v_date_month', '12')
|
286
328
|
fill_in_question('v_date_day', '10')
|
329
|
+
set_slider_value('v_slider', '50')
|
287
330
|
run_validations
|
288
331
|
expect_errors_on_group
|
289
332
|
end
|
@@ -296,7 +339,7 @@ shared_examples 'group_maximum_answered' do
|
|
296
339
|
context 'maximum number of given answers in a group' do
|
297
340
|
let(:questionnaire) do
|
298
341
|
inject_questionnaire 'test', <<-END
|
299
|
-
n =
|
342
|
+
n = 8
|
300
343
|
|
301
344
|
panel do
|
302
345
|
question :v_radio, type: :radio, question_group: :group1, group_maximum_answered: n do
|
@@ -340,6 +383,12 @@ shared_examples 'group_maximum_answered' do
|
|
340
383
|
year_key: :v_date_year, month_key: :v_date_month, day_key: :v_date_day do
|
341
384
|
title "Enter a date"
|
342
385
|
end
|
386
|
+
|
387
|
+
question :v_slider, type: :float, as: :slider, size: 20, default_position: :hidden,
|
388
|
+
question_group: :group1, group_maximum_answered: n do
|
389
|
+
title "Slider"
|
390
|
+
validates_in_range 0..100
|
391
|
+
end
|
343
392
|
end; end_panel
|
344
393
|
END
|
345
394
|
end
|
@@ -350,7 +399,7 @@ shared_examples 'group_maximum_answered' do
|
|
350
399
|
context 'maximum number of given answers in a group, with a table in the mix' do
|
351
400
|
let(:questionnaire) do
|
352
401
|
inject_questionnaire 'test', <<-END
|
353
|
-
n =
|
402
|
+
n = 8
|
354
403
|
|
355
404
|
panel do
|
356
405
|
table columns: 20 do
|
@@ -396,6 +445,12 @@ shared_examples 'group_maximum_answered' do
|
|
396
445
|
title "Enter a date"
|
397
446
|
end
|
398
447
|
end
|
448
|
+
|
449
|
+
question :v_slider, type: :float, as: :slider, size: 20, default_position: :hidden,
|
450
|
+
question_group: :group1, group_maximum_answered: n do
|
451
|
+
title "Slider"
|
452
|
+
validates_in_range 0..100
|
453
|
+
end
|
399
454
|
end; end_panel
|
400
455
|
END
|
401
456
|
end
|
@@ -427,6 +482,13 @@ shared_examples 'group_maximum_answered' do
|
|
427
482
|
option :a1, value: 1, description: "Select Option 1"
|
428
483
|
option :a2, value: 2, description: "Select Option 2"
|
429
484
|
end
|
485
|
+
|
486
|
+
question :v_slider, type: :float, as: :slider, size: 20, default_position: :hidden,
|
487
|
+
default_invisible: true,
|
488
|
+
question_group: :grp1, group_maximum_answered: n do
|
489
|
+
title "Slider"
|
490
|
+
validates_in_range 0..100
|
491
|
+
end
|
430
492
|
end; end_panel
|
431
493
|
END
|
432
494
|
end
|
@@ -448,6 +510,7 @@ shared_examples 'group_maximum_answered' do
|
|
448
510
|
expect_error_on 'v_integer', 'answer_group_maximum'
|
449
511
|
expect_error_on 'v_float', 'answer_group_maximum'
|
450
512
|
expect_error_on 'v_date', 'answer_group_maximum'
|
513
|
+
expect_error_on 'v_slider', 'answer_group_maximum'
|
451
514
|
end
|
452
515
|
end
|
453
516
|
|