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
@@ -7,14 +7,8 @@ module Quby::Questionnaires::Entities
|
|
7
7
|
describe BarChart do
|
8
8
|
it_behaves_like Chart
|
9
9
|
|
10
|
-
it '
|
11
|
-
|
12
|
-
expect(chart.plotlines).to eq([{value: 40, color: :red, width: 1, zIndex: 3}])
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'can set plotbands' do
|
16
|
-
chart = BarChart.new(:tot, plotbands: [{from: 40, to: 60, color: :red}])
|
17
|
-
expect(chart.plotbands).to eq([{from: 40, to: 60, color: :red}])
|
10
|
+
it 'has a type' do
|
11
|
+
expect(BarChart.new(:tot).type).to eq 'bar_chart'
|
18
12
|
end
|
19
13
|
end
|
20
14
|
end
|
@@ -10,11 +10,6 @@ module Quby::Questionnaires::Entities
|
|
10
10
|
it 'has a type' do
|
11
11
|
expect(RadarChart.new(:tot).type).to eq 'radar_chart'
|
12
12
|
end
|
13
|
-
|
14
|
-
it 'can set plotlines' do
|
15
|
-
chart = RadarChart.new(:tot, plotlines: [{value: 40, color: :red, width: 1, zIndex: 3}])
|
16
|
-
expect(chart.plotlines).to eq([{value: 40, color: :red, width: 1, zIndex: 3}])
|
17
|
-
end
|
18
13
|
end
|
19
14
|
end
|
20
15
|
end
|
@@ -102,8 +102,8 @@ module Quby::Questionnaires::Entities
|
|
102
102
|
{value: 2, interpretation: 'Very high'}
|
103
103
|
end
|
104
104
|
|
105
|
-
score_schema :tot, 'Total', [{key: :value, export_key:
|
106
|
-
{key: :interpretation, export_key:
|
105
|
+
score_schema :tot, 'Total', [{key: :value, export_key: :tot, label: 'Score'},
|
106
|
+
{key: :interpretation, export_key: :tot_i, label: 'Interpretation'}]
|
107
107
|
|
108
108
|
end
|
109
109
|
end
|
@@ -334,13 +334,15 @@ module Quby::Questionnaires::Entities
|
|
334
334
|
description_true: 'Test flag',
|
335
335
|
description_false: 'Test flag uit',
|
336
336
|
shows_questions: [:v_1],
|
337
|
-
hides_questions: []
|
337
|
+
hides_questions: [],
|
338
|
+
depends_on: []),
|
338
339
|
'test_test2' => Quby::Questionnaires::Entities::Flag.new(
|
339
340
|
key: :test_test2,
|
340
341
|
description_true: 'Test flag 2',
|
341
342
|
description_false: 'Test flag 2 uit',
|
342
343
|
shows_questions: [],
|
343
|
-
hides_questions: [:v_2]
|
344
|
+
hides_questions: [:v_2],
|
345
|
+
depends_on: []) })
|
344
346
|
end
|
345
347
|
end
|
346
348
|
|
@@ -13,7 +13,9 @@ module Quby::Questionnaires::Repos
|
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'when integrated' do
|
16
|
-
it_behaves_like 'a valid backend for the questionnaires api'
|
16
|
+
it_behaves_like 'a valid backend for the questionnaires api' do
|
17
|
+
let(:repo) { DiskRepo.new('./spec/fixtures') }
|
18
|
+
end
|
17
19
|
end
|
18
20
|
|
19
21
|
context 'in isolation' do
|
@@ -6,7 +6,8 @@ require 'spec_helper'
|
|
6
6
|
module Quby::Questionnaires::Repos
|
7
7
|
describe MemoryRepo do
|
8
8
|
it_behaves_like 'a valid backend for the questionnaires api' do
|
9
|
-
let(:repo) { MemoryRepo.new('simple' => File.read('./spec/fixtures/simple.rb')
|
9
|
+
let(:repo) { MemoryRepo.new('simple' => File.read('./spec/fixtures/simple.rb'),
|
10
|
+
'simple_with_outcome' => File.read('./spec/fixtures/simple_with_outcome.rb')) }
|
10
11
|
end
|
11
12
|
|
12
13
|
it_behaves_like 'a questionnaire repository' do
|
data/spec/spec_helper.rb
CHANGED
@@ -46,16 +46,27 @@ require 'quby/answers/specs'
|
|
46
46
|
require 'quby/questionnaires/specs'
|
47
47
|
|
48
48
|
Capybara.default_selector = :css
|
49
|
+
if ENV['SELENIUM_HOST'].present? && ENV['TEST_APP_PORT'].present?
|
50
|
+
# we live in docker-compose,
|
51
|
+
# dependencies can't easily link back to main service by using service name as hostname,
|
52
|
+
# so we find our ip.
|
53
|
+
docker_ip = `hostname -i`.strip
|
54
|
+
Capybara.app_host = "http://#{docker_ip}" #:#{ENV['TEST_APP_PORT']}"
|
55
|
+
Capybara.server_host = '0.0.0.0'
|
56
|
+
Capybara.server_port = ENV['TEST_APP_PORT']
|
57
|
+
selenium_url = "http://#{ENV['SELENIUM_HOST']}:#{ENV['SELENIUM_PORT']}/wd/hub"
|
58
|
+
end
|
59
|
+
Capybara.always_include_port = true
|
49
60
|
Capybara.register_driver :selenium_chrome_headless do |app|
|
50
61
|
options = Selenium::WebDriver::Chrome::Options.new
|
51
62
|
options.add_argument('--headless')
|
52
63
|
options.add_argument('--disable-gpu')
|
53
64
|
options.add_argument('--no-sandbox')
|
54
65
|
|
55
|
-
Capybara::Selenium::Driver.new
|
66
|
+
Capybara::Selenium::Driver.new app,
|
56
67
|
browser: :chrome,
|
68
|
+
url: selenium_url,
|
57
69
|
options: options
|
58
|
-
)
|
59
70
|
end
|
60
71
|
Capybara.javascript_driver = :selenium_chrome_headless
|
61
72
|
Capybara::Screenshot.register_driver(:selenium_chrome_headless) do |driver, path|
|
@@ -29,4 +29,14 @@ shared_examples_for Quby::Questionnaires::Entities::Charting::Chart do
|
|
29
29
|
it 'defaults y_range_categories to nil' do
|
30
30
|
expect(described_class.new('test').y_range_categories).to eq(nil)
|
31
31
|
end
|
32
|
+
|
33
|
+
it 'can set plotlines' do
|
34
|
+
chart = described_class.new(:tot, plotlines: [{value: 40, color: :red}])
|
35
|
+
expect(chart.plotlines).to eq([{value: 40, color: :red}])
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'can set plotbands' do
|
39
|
+
chart = described_class.new(:tot, plotbands: [{from: 40, to: 60, color: :red}])
|
40
|
+
expect(chart.plotbands).to eq([{from: 40, to: 60, color: :red}])
|
41
|
+
end
|
32
42
|
end
|
@@ -44,6 +44,11 @@ module ClientSideValidationHelpers
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
# sets it half-way
|
48
|
+
def set_slider_value(question_key, _value)
|
49
|
+
find("#item_#{question_key} .noUi-base", visible: false).click
|
50
|
+
end
|
51
|
+
|
47
52
|
def run_validations
|
48
53
|
within '#panel0.current' do
|
49
54
|
click_on 'Verder'
|
@@ -117,6 +122,10 @@ module ServerSideValidationHelpers
|
|
117
122
|
answer_to_submit[question_key] = option_key
|
118
123
|
end
|
119
124
|
|
125
|
+
def set_slider_value(question_key, value)
|
126
|
+
answer_to_submit[question_key] = value
|
127
|
+
end
|
128
|
+
|
120
129
|
def run_validations
|
121
130
|
answer.errors.clear
|
122
131
|
updates_answers.update(answer_to_submit)
|
data/spec/teaspoon_env.rb
CHANGED
@@ -18,9 +18,8 @@ unless defined? Rails
|
|
18
18
|
require 'jquery-ui-rails'
|
19
19
|
require 'combustion'
|
20
20
|
Combustion.path = 'spec/internal'
|
21
|
-
|
22
21
|
require 'quby'
|
23
|
-
require '
|
22
|
+
require 'selenium-webdriver'
|
24
23
|
require 'teaspoon-jasmine'
|
25
24
|
|
26
25
|
if Rails.env.test? || Rails.env.development?
|
@@ -45,6 +44,37 @@ Teaspoon.configure do |config|
|
|
45
44
|
# http://localhost:3000/jasmine to run your specs.
|
46
45
|
config.mount_at = "/teaspoon"
|
47
46
|
|
47
|
+
config.driver = :selenium
|
48
|
+
|
49
|
+
|
50
|
+
chrome_options = Selenium::WebDriver::Chrome::Options.new(args: ['headless', 'disable-gpu'])
|
51
|
+
desired_capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
52
|
+
chrome_options: chrome_options
|
53
|
+
)
|
54
|
+
options = if ENV['SELENIUM_HOST'].present?
|
55
|
+
docker_ip = `hostname -i`.strip
|
56
|
+
config.server_host = docker_ip
|
57
|
+
config.server_port = ENV['TEST_APP_PORT']
|
58
|
+
http_client = Selenium::WebDriver::Remote::Http::Default.new(read_timeout: 20)
|
59
|
+
{
|
60
|
+
client_driver: :remote,
|
61
|
+
selenium_options: {
|
62
|
+
url: "http://#{ENV['SELENIUM_HOST']}:#{ENV['SELENIUM_PORT']}/wd/hub",
|
63
|
+
http_client: http_client,
|
64
|
+
desired_capabilities: desired_capabilities
|
65
|
+
}
|
66
|
+
}
|
67
|
+
else
|
68
|
+
{
|
69
|
+
client_driver: :chrome,
|
70
|
+
selenium_options: {
|
71
|
+
desired_capabilities: desired_capabilities
|
72
|
+
}
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
config.driver_options = options
|
77
|
+
|
48
78
|
# This defaults to Rails.root if left nil. If you're testing an engine using a dummy application it can be useful to
|
49
79
|
# set this to your engines root.. E.g. `Teaspoon::Engine.root`
|
50
80
|
config.root = Quby::Engine.root
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2021-03-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -291,28 +291,28 @@ dependencies:
|
|
291
291
|
requirements:
|
292
292
|
- - ">="
|
293
293
|
- !ruby/object:Gem::Version
|
294
|
-
version:
|
294
|
+
version: 4.2.2
|
295
295
|
type: :runtime
|
296
296
|
prerelease: false
|
297
297
|
version_requirements: !ruby/object:Gem::Requirement
|
298
298
|
requirements:
|
299
299
|
- - ">="
|
300
300
|
- !ruby/object:Gem::Version
|
301
|
-
version:
|
301
|
+
version: 4.2.2
|
302
302
|
- !ruby/object:Gem::Dependency
|
303
303
|
name: jquery-ui-rails
|
304
304
|
requirement: !ruby/object:Gem::Requirement
|
305
305
|
requirements:
|
306
306
|
- - "~>"
|
307
307
|
- !ruby/object:Gem::Version
|
308
|
-
version:
|
308
|
+
version: 4.2.1
|
309
309
|
type: :runtime
|
310
310
|
prerelease: false
|
311
311
|
version_requirements: !ruby/object:Gem::Requirement
|
312
312
|
requirements:
|
313
313
|
- - "~>"
|
314
314
|
- !ruby/object:Gem::Version
|
315
|
-
version:
|
315
|
+
version: 4.2.1
|
316
316
|
- !ruby/object:Gem::Dependency
|
317
317
|
name: combustion
|
318
318
|
requirement: !ruby/object:Gem::Requirement
|
@@ -854,6 +854,7 @@ files:
|
|
854
854
|
- spec/fixtures/question_hiding.rb
|
855
855
|
- spec/fixtures/questionnaire_with_chart.rb
|
856
856
|
- spec/fixtures/score_test.rb
|
857
|
+
- spec/fixtures/scores_from_schema.rb
|
857
858
|
- spec/fixtures/simple.rb
|
858
859
|
- spec/fixtures/simple_with_outcome.rb
|
859
860
|
- spec/fixtures/subquestion_key_clash.rb
|
@@ -6600,7 +6601,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
6600
6601
|
- !ruby/object:Gem::Version
|
6601
6602
|
version: '0'
|
6602
6603
|
requirements: []
|
6603
|
-
rubygems_version: 3.
|
6604
|
+
rubygems_version: 3.0.3
|
6604
6605
|
signing_key:
|
6605
6606
|
specification_version: 4
|
6606
6607
|
summary: Questionnaire engine
|
@@ -12333,6 +12334,7 @@ test_files:
|
|
12333
12334
|
- spec/javascripts/spec_helper.coffee
|
12334
12335
|
- spec/fixtures/question_hiding.rb
|
12335
12336
|
- spec/fixtures/all_validations.rb
|
12337
|
+
- spec/fixtures/scores_from_schema.rb
|
12336
12338
|
- spec/fixtures/aged_score_interpretations.rb
|
12337
12339
|
- spec/fixtures/questionnaire_with_chart.rb
|
12338
12340
|
- spec/fixtures/simple.rb
|