helena_administration 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +18 -0
- data/.travis.yml +6 -0
- data/Gemfile +44 -0
- data/Gemfile.lock +309 -0
- data/MIT-LICENSE +20 -0
- data/README.md +82 -0
- data/Rakefile +28 -0
- data/app/assets/images/helena_administration/.keep +0 -0
- data/app/assets/javascripts/helena_administration.js.coffee +20 -0
- data/app/assets/javascripts/polyfills.js +10 -0
- data/app/assets/stylesheets/_dashboard.sass +4 -0
- data/app/assets/stylesheets/_layout.sass +50 -0
- data/app/assets/stylesheets/_media_queries.scss +18 -0
- data/app/assets/stylesheets/_variables.sass +19 -0
- data/app/assets/stylesheets/helena_administration.css.sass +27 -0
- data/app/controllers/helena_administration/application_controller.rb +19 -0
- data/app/controllers/helena_administration/dashboard_controller.rb +11 -0
- data/app/controllers/helena_administration/import_surveys_controller.rb +40 -0
- data/app/controllers/helena_administration/question_groups_controller.rb +68 -0
- data/app/controllers/helena_administration/questions/checkbox_groups_controller.rb +15 -0
- data/app/controllers/helena_administration/questions/checkbox_matrix_controller.rb +7 -0
- data/app/controllers/helena_administration/questions/long_texts_controller.rb +11 -0
- data/app/controllers/helena_administration/questions/radio_groups_controller.rb +15 -0
- data/app/controllers/helena_administration/questions/radio_matrix_controller.rb +7 -0
- data/app/controllers/helena_administration/questions/short_texts_controller.rb +11 -0
- data/app/controllers/helena_administration/questions/static_texts_controller.rb +11 -0
- data/app/controllers/helena_administration/questions_controller.rb +96 -0
- data/app/controllers/helena_administration/sessions_controller.rb +60 -0
- data/app/controllers/helena_administration/surveys_controller.rb +71 -0
- data/app/controllers/helena_administration/versions_controller.rb +82 -0
- data/app/helpers/helena_administration/application_helper.rb +14 -0
- data/app/models/helena_administration/import_survey_form.rb +9 -0
- data/app/views/helena_administration/application/_chromeframe.html.slim +4 -0
- data/app/views/helena_administration/application/_flash_messages.html.haml +5 -0
- data/app/views/helena_administration/application/_head.html.slim +13 -0
- data/app/views/helena_administration/application/_header.html.slim +16 -0
- data/app/views/helena_administration/dashboard/index.html.slim +14 -0
- data/app/views/helena_administration/import_surveys/_form.html.slim +11 -0
- data/app/views/helena_administration/import_surveys/new.html.slim +1 -0
- data/app/views/helena_administration/kaminari/_first_page.html.slim +2 -0
- data/app/views/helena_administration/kaminari/_gap.html.slim +2 -0
- data/app/views/helena_administration/kaminari/_last_page.html.slim +2 -0
- data/app/views/helena_administration/kaminari/_next_page.html.slim +2 -0
- data/app/views/helena_administration/kaminari/_page.html.slim +2 -0
- data/app/views/helena_administration/kaminari/_paginator.html.slim +11 -0
- data/app/views/helena_administration/kaminari/_prev_page.html.slim +2 -0
- data/app/views/helena_administration/layouts/application.html.slim +13 -0
- data/app/views/helena_administration/question_groups/_form.html.slim +5 -0
- data/app/views/helena_administration/question_groups/edit.html.slim +1 -0
- data/app/views/helena_administration/question_groups/new.html.slim +1 -0
- data/app/views/helena_administration/question_groups/show.html.slim +60 -0
- data/app/views/helena_administration/questions/_form.html.slim +15 -0
- data/app/views/helena_administration/questions/_labels.html.slim +24 -0
- data/app/views/helena_administration/questions/_sub_questions.html.slim +32 -0
- data/app/views/helena_administration/questions/edit.html.slim +1 -0
- data/app/views/helena_administration/questions/new.html.slim +1 -0
- data/app/views/helena_administration/questions/show.html.slim +26 -0
- data/app/views/helena_administration/sessions/_form.html.slim +8 -0
- data/app/views/helena_administration/sessions/edit.html.slim +1 -0
- data/app/views/helena_administration/surveys/_form.html.slim +5 -0
- data/app/views/helena_administration/surveys/edit.html.slim +1 -0
- data/app/views/helena_administration/surveys/index.html.slim +34 -0
- data/app/views/helena_administration/surveys/new.html.slim +1 -0
- data/app/views/helena_administration/surveys/show.html.slim +120 -0
- data/app/views/helena_administration/versions/_form.html.slim +14 -0
- data/app/views/helena_administration/versions/edit.html.slim +1 -0
- data/app/views/helena_administration/versions/new.html.slim +1 -0
- data/app/views/helena_administration/versions/show.html.slim +68 -0
- data/app/views/layouts/helena_administration/application.html.slim +10 -0
- data/bin/rails +12 -0
- data/config/compass.rb +2 -0
- data/config/html5_rails.yml +26 -0
- data/config/locales/en.yml +21 -0
- data/config/locales/views/dashboard.en.yml +6 -0
- data/config/locales/views/import_surveys.en.yml +11 -0
- data/config/locales/views/question_groups.en.yml +5 -0
- data/config/locales/views/questions.en.yml +5 -0
- data/config/locales/views/surveys.en.yml +10 -0
- data/config/locales/views/versions.en.yml +11 -0
- data/config/routes.rb +24 -0
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/assets/0.8.0/application.css +799 -0
- data/coverage/assets/0.8.0/application.js +1559 -0
- data/coverage/assets/0.8.0/colorbox/border.png +0 -0
- data/coverage/assets/0.8.0/colorbox/controls.png +0 -0
- data/coverage/assets/0.8.0/colorbox/loading.gif +0 -0
- data/coverage/assets/0.8.0/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.8.0/favicon_green.png +0 -0
- data/coverage/assets/0.8.0/favicon_red.png +0 -0
- data/coverage/assets/0.8.0/favicon_yellow.png +0 -0
- data/coverage/assets/0.8.0/loading.gif +0 -0
- data/coverage/assets/0.8.0/magnify.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.8.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/helena_administration.gemspec +37 -0
- data/lib/helena_administration/engine.rb +13 -0
- data/lib/helena_administration/version.rb +3 -0
- data/lib/helena_administration.rb +15 -0
- data/lib/tasks/helena_administration_tasks.rake +4 -0
- data/spec/controllers/dashboard_controller_spec.rb +11 -0
- data/spec/controllers/sessions_controller_spec.rb +102 -0
- data/spec/controllers/survey_controller_spec.rb +36 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/decorators/controllers/helena_administration/application_controller_decorator.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +27 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +34 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +9 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/mongoid.yml +13 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/features/dashboard/index.html.slim_spec.rb +9 -0
- data/spec/features/question_groups/manage_question_groups_spec.rb +97 -0
- data/spec/features/questions/manage_questions_spec.rb +108 -0
- data/spec/features/questions/question_types/manage_checkbox_group_question_spec.rb +53 -0
- data/spec/features/questions/question_types/manage_long_text_question_spec.rb +22 -0
- data/spec/features/questions/question_types/manage_radio_group_question_spec.rb +57 -0
- data/spec/features/questions/question_types/manage_radio_matrix_question_spec.rb +78 -0
- data/spec/features/questions/question_types/manage_short_text_question_spec.rb +20 -0
- data/spec/features/questions/question_types/manage_static_text_question_spec.rb +18 -0
- data/spec/features/sessions/manage_sessions_spec.rb +51 -0
- data/spec/features/surveys/manage_survey_spec.rb +95 -0
- data/spec/features/versions/manage_version_spec.rb +113 -0
- data/spec/helpers/applicatin_helper_spec.rb +17 -0
- data/spec/rails_helper.rb +23 -0
- data/spec/spec_helper.rb +63 -0
- data/spec/support/.keep +0 -0
- metadata +455 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
54
|
+
</style>
|
55
|
+
</head>
|
56
|
+
|
57
|
+
<body>
|
58
|
+
<!-- This file lives in public/500.html -->
|
59
|
+
<div class="dialog">
|
60
|
+
<div>
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
62
|
+
</div>
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
64
|
+
</div>
|
65
|
+
</body>
|
66
|
+
</html>
|
File without changes
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe 'Question groups' do
|
4
|
+
|
5
|
+
let!(:survey) { create :survey }
|
6
|
+
let!(:version) { survey.versions.create version: 0 }
|
7
|
+
|
8
|
+
scenario 'Index site lists all question groups' do
|
9
|
+
version.question_groups.create title: 'Second question group', position: 123
|
10
|
+
version.question_groups.create title: 'First question group', position: 42
|
11
|
+
|
12
|
+
visit survey_version_path(survey, version)
|
13
|
+
|
14
|
+
within 'nav .breadcrumbs' do
|
15
|
+
expect(page).to have_content 'Version 0'
|
16
|
+
end
|
17
|
+
|
18
|
+
within 'table.question_groups tbody tr:nth-child(1)' do
|
19
|
+
expect(page).to have_content 'First question group'
|
20
|
+
end
|
21
|
+
|
22
|
+
within 'table.question_groups tbody tr:nth-child(2)' do
|
23
|
+
expect(page).to have_content 'Second question group'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
scenario 'User creates a new question group' do
|
28
|
+
visit survey_version_path(survey, version)
|
29
|
+
|
30
|
+
within 'table.question_groups' do
|
31
|
+
click_link 'New'
|
32
|
+
end
|
33
|
+
|
34
|
+
within 'nav .breadcrumbs' do
|
35
|
+
expect(page).to have_text 'New question group'
|
36
|
+
end
|
37
|
+
|
38
|
+
fill_in 'Position', with: 77
|
39
|
+
fill_in 'Title', with: 'Foo Bar'
|
40
|
+
check 'Allow participants to go back to the previous question group'
|
41
|
+
|
42
|
+
expect { click_button 'Save' }.to change { version.reload.question_groups.count }.by(1)
|
43
|
+
|
44
|
+
new_question_group = version.reload.question_groups.last
|
45
|
+
|
46
|
+
expect(new_question_group.position).to eq 77
|
47
|
+
expect(new_question_group.title).to eq 'Foo Bar'
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
scenario 'User edits question_group' do
|
52
|
+
question_group = version.question_groups.create title: 'Everybody lies!'
|
53
|
+
|
54
|
+
visit survey_version_path(survey, version)
|
55
|
+
|
56
|
+
within "##{dom_id(question_group)}" do
|
57
|
+
click_link 'Edit'
|
58
|
+
end
|
59
|
+
|
60
|
+
within 'nav .breadcrumbs' do
|
61
|
+
expect(page).to have_content 'Everybody lies!'
|
62
|
+
end
|
63
|
+
|
64
|
+
fill_in 'Position', with: 13
|
65
|
+
fill_in 'Title', with: 'Foo Bar'
|
66
|
+
|
67
|
+
click_button 'Save'
|
68
|
+
|
69
|
+
expect(question_group.reload.position).to eq 13
|
70
|
+
expect(question_group.reload.title).to eq 'Foo Bar'
|
71
|
+
end
|
72
|
+
|
73
|
+
scenario 'User deletes a question group' do
|
74
|
+
question_group = version.question_groups.create
|
75
|
+
|
76
|
+
visit survey_version_path(survey, version)
|
77
|
+
|
78
|
+
within "##{dom_id(question_group)}" do
|
79
|
+
expect { click_link 'Delete' }.to change { version.reload.question_groups.count }.by(-1)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
scenario 'User can view question_group details' do
|
84
|
+
question_group = version.question_groups.create title: 'Awesome new question group', position: 666
|
85
|
+
|
86
|
+
visit survey_version_question_group_path(survey, version, question_group)
|
87
|
+
|
88
|
+
within 'nav .breadcrumbs' do
|
89
|
+
expect(page).to have_content 'Awesome new question group'
|
90
|
+
end
|
91
|
+
|
92
|
+
within "##{dom_id(question_group)}" do
|
93
|
+
expect(page).to have_content '666'
|
94
|
+
expect(page).to have_content 'Awesome new question group'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe 'Questions' do
|
4
|
+
let!(:survey) { create :survey }
|
5
|
+
let!(:version) { survey.versions.create version: 0 }
|
6
|
+
let!(:question_group) { version.question_groups.create title: 'Abakadabara' }
|
7
|
+
|
8
|
+
scenario 'Index site lists all questions' do
|
9
|
+
question_group.questions.create code: 'second_question', question_text: 'Second question', position: 123, _type: Helena::Questions::LongText
|
10
|
+
question_group.questions.create code: 'first_question', question_text: 'First question', position: 42, _type: Helena::Questions::ShortText
|
11
|
+
|
12
|
+
visit survey_version_question_group_path(survey, version, question_group)
|
13
|
+
|
14
|
+
within 'nav .breadcrumbs' do
|
15
|
+
expect(page).to have_content 'Abakadabara'
|
16
|
+
end
|
17
|
+
|
18
|
+
within 'table.questions tbody tr:nth-child(1)' do
|
19
|
+
expect(page).to have_content 'first_question'
|
20
|
+
expect(page).to have_content 'First question'
|
21
|
+
expect(page).to have_content 'Short text'
|
22
|
+
end
|
23
|
+
|
24
|
+
within 'table.questions tbody tr:nth-child(2)' do
|
25
|
+
expect(page).to have_content 'second_question'
|
26
|
+
expect(page).to have_content 'Second question'
|
27
|
+
expect(page).to have_content 'Long text'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
scenario 'creates a new question' do
|
32
|
+
visit new_survey_version_question_group_question_path(survey, version, question_group)
|
33
|
+
|
34
|
+
fill_in 'Code', with: 'a38'
|
35
|
+
fill_in 'Question text', with: 'Shall we go?'
|
36
|
+
|
37
|
+
within '.breadcrumbs' do
|
38
|
+
expect(page).to have_text 'New question'
|
39
|
+
end
|
40
|
+
|
41
|
+
expect { click_button 'Save' }.to change { question_group.reload.questions.count }.by(1)
|
42
|
+
end
|
43
|
+
|
44
|
+
scenario 'creating a new question errors when without entering a code' do
|
45
|
+
visit new_survey_version_question_group_question_path(survey, version, question_group)
|
46
|
+
|
47
|
+
fill_in 'Code', with: ''
|
48
|
+
|
49
|
+
expect { click_button 'Save' }.to change { question_group.reload.questions.count }.by(0)
|
50
|
+
end
|
51
|
+
|
52
|
+
scenario 'edits a question' do
|
53
|
+
question = create :question, question_text: 'We are here?', question_group: question_group
|
54
|
+
|
55
|
+
visit edit_survey_version_question_group_question_path(survey, version, question_group, question)
|
56
|
+
|
57
|
+
fill_in 'Question text', with: 'Are you sure?'
|
58
|
+
fill_in 'Code', with: 'b12'
|
59
|
+
|
60
|
+
click_button 'Save'
|
61
|
+
|
62
|
+
expect(question.reload.question_text).to eq 'Are you sure?'
|
63
|
+
expect(question.reload.code).to eq 'b12'
|
64
|
+
end
|
65
|
+
|
66
|
+
scenario 'edits a question errors when code text is empty' do
|
67
|
+
question = create :question, question_text: 'We are here?', question_group: question_group
|
68
|
+
|
69
|
+
visit edit_survey_version_question_group_question_path(survey, version, question_group, question)
|
70
|
+
|
71
|
+
fill_in 'Code', with: ''
|
72
|
+
|
73
|
+
expect { click_button 'Save' }.not_to change { question.reload }
|
74
|
+
end
|
75
|
+
|
76
|
+
scenario 'User deletes a question' do
|
77
|
+
question_group.questions.create code: 'abc'
|
78
|
+
|
79
|
+
question = question_group.questions.find_by code: 'abc'
|
80
|
+
|
81
|
+
visit survey_version_question_group_path(survey, version, question_group)
|
82
|
+
|
83
|
+
within "##{dom_id(question)}" do
|
84
|
+
expect { click_link 'Delete' }.to change { question_group.reload.questions.count }.by(-1)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
scenario 'User can view question details' do
|
89
|
+
question_group.questions.create code: 'fish',
|
90
|
+
question_text: 'How much is the fish?',
|
91
|
+
position: 123,
|
92
|
+
_type: Helena::Questions::LongText
|
93
|
+
|
94
|
+
question = question_group.questions.find_by code: 'fish'
|
95
|
+
visit survey_version_question_group_question_path(survey, version, question_group, question)
|
96
|
+
|
97
|
+
within 'nav .breadcrumbs' do
|
98
|
+
expect(page).to have_content 'fish'
|
99
|
+
end
|
100
|
+
|
101
|
+
within "##{dom_id(question.reload)}" do
|
102
|
+
expect(page).to have_content 'fish'
|
103
|
+
expect(page).to have_content 'How much is the fish?'
|
104
|
+
expect(page).to have_content '123'
|
105
|
+
expect(page).to have_content 'Long text'
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe 'Checkbox group question management' do
|
4
|
+
let!(:survey) { create :survey }
|
5
|
+
let!(:version) { survey.versions.create version: 0 }
|
6
|
+
let!(:question_group) { version.question_groups.create title: 'Abakadabara' }
|
7
|
+
let!(:question) { create :checkbox_group_question, question_group: question_group }
|
8
|
+
|
9
|
+
scenario 'edits a question' do
|
10
|
+
question.sub_questions.create(code: 'aperto', text: 'Aperto Snacks', value: 'Aperto', position: 1)
|
11
|
+
|
12
|
+
visit edit_survey_version_question_group_questions_checkbox_group_path(survey, version, question_group, question)
|
13
|
+
|
14
|
+
check 'Required'
|
15
|
+
|
16
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_position', with: '2'
|
17
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_text', with: 'Avec Shop'
|
18
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_code', with: 'avec'
|
19
|
+
check 'questions_checkbox_group_sub_questions_attributes_0_preselected'
|
20
|
+
|
21
|
+
click_button 'Save'
|
22
|
+
|
23
|
+
expect(question.reload.sub_questions.first.position).to eq 2
|
24
|
+
expect(question.reload.sub_questions.first.text).to eq 'Avec Shop'
|
25
|
+
expect(question.reload.sub_questions.first.code).to eq 'avec'
|
26
|
+
expect(question.reload.required).to eq true
|
27
|
+
end
|
28
|
+
|
29
|
+
scenario 'adds a a sub question' do
|
30
|
+
visit edit_survey_version_question_group_questions_checkbox_group_path(survey, version, question_group, question)
|
31
|
+
|
32
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_position', with: '2'
|
33
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_text', with: 'Avec Shop'
|
34
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_code', with: 'avec'
|
35
|
+
check 'questions_checkbox_group_sub_questions_attributes_0_preselected'
|
36
|
+
|
37
|
+
click_button 'Save'
|
38
|
+
|
39
|
+
expect(question.reload.sub_questions.first.position).to eq 2
|
40
|
+
expect(question.reload.sub_questions.first.text).to eq 'Avec Shop'
|
41
|
+
expect(question.reload.sub_questions.first.code).to eq 'avec'
|
42
|
+
end
|
43
|
+
|
44
|
+
scenario 'removes a sub question' do
|
45
|
+
question.sub_questions.create(code: 'aperto', text: 'Aperto Snacks', value: 'Aperto', position: 1)
|
46
|
+
|
47
|
+
visit edit_survey_version_question_group_questions_checkbox_group_path(survey, version, question_group, question)
|
48
|
+
|
49
|
+
check 'questions_checkbox_group_sub_questions_attributes_0__destroy'
|
50
|
+
|
51
|
+
click_button 'Save'
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe 'Long text question management' do
|
4
|
+
let!(:survey) { create :survey }
|
5
|
+
let!(:version) { survey.versions.create version: 0 }
|
6
|
+
let!(:question_group) { version.question_groups.create title: 'Abakadabara' }
|
7
|
+
let!(:question) { create :long_text_question, question_group: question_group }
|
8
|
+
|
9
|
+
scenario 'edits a question' do
|
10
|
+
visit edit_survey_version_question_group_questions_long_text_path(survey, version, question_group, question)
|
11
|
+
|
12
|
+
a_very_long_text = Faker::Lorem.paragraph(20)
|
13
|
+
|
14
|
+
fill_in 'Default value', with: a_very_long_text
|
15
|
+
check 'Required'
|
16
|
+
|
17
|
+
click_button 'Save'
|
18
|
+
|
19
|
+
expect(question.reload.default_value).to eq a_very_long_text
|
20
|
+
expect(question.reload.required).to eq true
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe 'Radio group question management' do
|
4
|
+
let!(:survey) { create :survey }
|
5
|
+
let!(:version) { survey.versions.create version: 0 }
|
6
|
+
let!(:question_group) { version.question_groups.create title: 'Abakadabara' }
|
7
|
+
let!(:question) { create :radio_group_question, question_group: question_group }
|
8
|
+
|
9
|
+
scenario 'edits a question' do
|
10
|
+
question.labels << build(:label, text: 'Male', value: 'm', position: 1)
|
11
|
+
|
12
|
+
visit edit_survey_version_question_group_questions_radio_group_path(survey, version, question_group, question)
|
13
|
+
|
14
|
+
check 'Required'
|
15
|
+
|
16
|
+
fill_in 'questions_radio_group_labels_attributes_0_position', with: '2'
|
17
|
+
fill_in 'questions_radio_group_labels_attributes_0_text', with: 'Female'
|
18
|
+
fill_in 'questions_radio_group_labels_attributes_0_value', with: 'f'
|
19
|
+
check 'questions_radio_group_labels_attributes_0_preselected'
|
20
|
+
|
21
|
+
click_button 'Save'
|
22
|
+
|
23
|
+
expect(question.reload.labels.first.position).to eq 2
|
24
|
+
expect(question.reload.labels.first.text).to eq 'Female'
|
25
|
+
expect(question.reload.labels.first.value).to eq 'f'
|
26
|
+
expect(question.reload.labels.first.preselected).to eq true
|
27
|
+
expect(question.reload.required).to eq true
|
28
|
+
end
|
29
|
+
|
30
|
+
scenario 'adds a an option' do
|
31
|
+
visit edit_survey_version_question_group_questions_radio_group_path(survey, version, question_group, question)
|
32
|
+
|
33
|
+
fill_in 'questions_radio_group_labels_attributes_0_position', with: '2'
|
34
|
+
fill_in 'questions_radio_group_labels_attributes_0_text', with: 'Female'
|
35
|
+
fill_in 'questions_radio_group_labels_attributes_0_value', with: 'f'
|
36
|
+
check 'questions_radio_group_labels_attributes_0_preselected'
|
37
|
+
|
38
|
+
click_button 'Save'
|
39
|
+
|
40
|
+
expect(question.reload.labels.first.position).to eq 2
|
41
|
+
expect(question.reload.labels.first.text).to eq 'Female'
|
42
|
+
expect(question.reload.labels.first.value).to eq 'f'
|
43
|
+
expect(question.reload.labels.first.preselected).to eq true
|
44
|
+
end
|
45
|
+
|
46
|
+
scenario 'removes an option' do
|
47
|
+
question.labels << build(:label, text: 'Male', value: 'm', position: 1)
|
48
|
+
|
49
|
+
visit edit_survey_version_question_group_questions_radio_group_path(survey, version, question_group, question)
|
50
|
+
|
51
|
+
check 'questions_radio_group_labels_attributes_0__destroy'
|
52
|
+
|
53
|
+
click_button 'Save'
|
54
|
+
|
55
|
+
expect(question.reload.labels).to be_empty
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe 'Radio matrix question management' do
|
4
|
+
let!(:survey) { create :survey }
|
5
|
+
let!(:version) { survey.versions.create version: 0 }
|
6
|
+
let!(:question_group) { version.question_groups.create title: 'Abakadabara' }
|
7
|
+
let!(:question) { create :radio_matrix_question, question_group: question_group }
|
8
|
+
|
9
|
+
scenario 'edits a question' do
|
10
|
+
question.labels.create text: 'Strongly disagree', value: '-1', position: 1
|
11
|
+
question.sub_questions.create code: 'aperto', text: 'Aperto Snacks', value: 'Aperto', position: 1
|
12
|
+
|
13
|
+
visit edit_survey_version_question_group_questions_radio_matrix_path(survey, version, question_group, question)
|
14
|
+
|
15
|
+
check 'Required'
|
16
|
+
|
17
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_position', with: '2'
|
18
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_text', with: 'Strongly agree'
|
19
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_value', with: '1'
|
20
|
+
check 'questions_radio_matrix_labels_attributes_0_preselected'
|
21
|
+
|
22
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_position', with: '2'
|
23
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_text', with: 'Avec Shop'
|
24
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_code', with: 'avec'
|
25
|
+
|
26
|
+
click_button 'Save'
|
27
|
+
|
28
|
+
expect(question.reload.labels.first.position).to eq 2
|
29
|
+
expect(question.reload.labels.first.text).to eq 'Strongly agree'
|
30
|
+
expect(question.reload.labels.first.value).to eq '1'
|
31
|
+
expect(question.reload.labels.first.preselected).to eq true
|
32
|
+
|
33
|
+
expect(question.reload.sub_questions.first.position).to eq 2
|
34
|
+
expect(question.reload.sub_questions.first.text).to eq 'Avec Shop'
|
35
|
+
expect(question.reload.sub_questions.first.code).to eq 'avec'
|
36
|
+
|
37
|
+
expect(question.reload.required).to eq true
|
38
|
+
end
|
39
|
+
|
40
|
+
scenario 'adds a an option' do
|
41
|
+
visit edit_survey_version_question_group_questions_radio_matrix_path(survey, version, question_group, question)
|
42
|
+
|
43
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_position', with: '2'
|
44
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_text', with: 'Strongly agree'
|
45
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_value', with: '1'
|
46
|
+
check 'questions_radio_matrix_labels_attributes_0_preselected'
|
47
|
+
|
48
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_position', with: '2'
|
49
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_text', with: 'Avec Shop'
|
50
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_code', with: 'avec'
|
51
|
+
|
52
|
+
click_button 'Save'
|
53
|
+
|
54
|
+
expect(question.reload.labels.first.position).to eq 2
|
55
|
+
expect(question.reload.labels.first.text).to eq 'Strongly agree'
|
56
|
+
expect(question.reload.labels.first.value).to eq '1'
|
57
|
+
expect(question.reload.labels.first.preselected).to eq true
|
58
|
+
|
59
|
+
expect(question.reload.sub_questions.first.position).to eq 2
|
60
|
+
expect(question.reload.sub_questions.first.text).to eq 'Avec Shop'
|
61
|
+
expect(question.reload.sub_questions.first.code).to eq 'avec'
|
62
|
+
end
|
63
|
+
|
64
|
+
scenario 'removes an option' do
|
65
|
+
question.labels.create text: 'Male', value: 'm', position: 1
|
66
|
+
question.sub_questions.create code: 'aperto', text: 'Aperto Snacks', value: 'Aperto', position: 1
|
67
|
+
|
68
|
+
visit edit_survey_version_question_group_questions_radio_matrix_path(survey, version, question_group, question)
|
69
|
+
|
70
|
+
check 'questions_radio_matrix_labels_attributes_0__destroy'
|
71
|
+
check 'questions_radio_matrix_sub_questions_attributes_0__destroy'
|
72
|
+
|
73
|
+
click_button 'Save'
|
74
|
+
|
75
|
+
expect(question.reload.labels).to be_empty
|
76
|
+
expect(question.reload.sub_questions).to be_empty
|
77
|
+
end
|
78
|
+
end
|