helena 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +15 -0
- data/.rubocop.yml +16 -0
- data/.travis.yml +6 -0
- data/Gemfile +31 -0
- data/Gemfile.lock +290 -0
- data/LICENSE +16 -0
- data/README.md +90 -0
- data/Rakefile +29 -0
- data/app/assets/images/helena/.keep +0 -0
- data/app/assets/images/helena/helena_mobile_view.jpg +0 -0
- data/app/assets/images/helena/icons/export.svg +29 -0
- data/app/assets/images/helena/swissmadesoftware.png +0 -0
- data/app/assets/javascripts/helena/application.js +4 -0
- data/app/assets/javascripts/helena/survey.js +2 -0
- data/app/assets/stylesheets/helena/admin/labels.css.sass +7 -0
- data/app/assets/stylesheets/helena/admin/layout.css.sass +6 -0
- data/app/assets/stylesheets/helena/admin/question_groups.css.sass +7 -0
- data/app/assets/stylesheets/helena/admin/questions.css.sass +9 -0
- data/app/assets/stylesheets/helena/admin/sessions.css.sass +5 -0
- data/app/assets/stylesheets/helena/admin/subquestions.css.sass +7 -0
- data/app/assets/stylesheets/helena/admin/versions.css.sass +9 -0
- data/app/assets/stylesheets/helena/application.css.sass +21 -0
- data/app/assets/stylesheets/helena/forms.css.sass +13 -0
- data/app/assets/stylesheets/helena/layout.css.sass +3 -0
- data/app/assets/stylesheets/helena/question_groups.css.sass +4 -0
- data/app/controllers/helena/admin/application_controller.rb +31 -0
- data/app/controllers/helena/admin/question_groups_controller.rb +78 -0
- data/app/controllers/helena/admin/questions/checkbox_groups_controller.rb +17 -0
- data/app/controllers/helena/admin/questions/checkbox_matrix_controller.rb +9 -0
- data/app/controllers/helena/admin/questions/long_texts_controller.rb +13 -0
- data/app/controllers/helena/admin/questions/radio_groups_controller.rb +17 -0
- data/app/controllers/helena/admin/questions/radio_matrix_controller.rb +9 -0
- data/app/controllers/helena/admin/questions/short_texts_controller.rb +13 -0
- data/app/controllers/helena/admin/questions/static_texts_controller.rb +13 -0
- data/app/controllers/helena/admin/questions_controller.rb +105 -0
- data/app/controllers/helena/admin/sessions_controller.rb +35 -0
- data/app/controllers/helena/admin/surveys_controller.rb +78 -0
- data/app/controllers/helena/admin/versions_controller.rb +71 -0
- data/app/controllers/helena/application_controller.rb +15 -0
- data/app/controllers/helena/concerns/questions/matrix_questions.rb +24 -0
- data/app/controllers/helena/sessions_controller.rb +93 -0
- data/app/controllers/helena/surveys_controller.rb +11 -0
- data/app/helpers/helena/application_helper.rb +4 -0
- data/app/models/helena/answer.rb +48 -0
- data/app/models/helena/boolean_answer.rb +5 -0
- data/app/models/helena/concerns/application_model.rb +19 -0
- data/app/models/helena/concerns/questions/requirable.rb +19 -0
- data/app/models/helena/concerns/questions/validates_one_label.rb +22 -0
- data/app/models/helena/integer_answer.rb +5 -0
- data/app/models/helena/label.rb +18 -0
- data/app/models/helena/question.rb +63 -0
- data/app/models/helena/question_group.rb +18 -0
- data/app/models/helena/questions/checkbox_group.rb +17 -0
- data/app/models/helena/questions/long_text.rb +9 -0
- data/app/models/helena/questions/radio_group.rb +12 -0
- data/app/models/helena/questions/radio_matrix.rb +24 -0
- data/app/models/helena/questions/short_text.rb +9 -0
- data/app/models/helena/questions/static_text.rb +7 -0
- data/app/models/helena/session.rb +76 -0
- data/app/models/helena/string_answer.rb +5 -0
- data/app/models/helena/sub_question.rb +27 -0
- data/app/models/helena/survey.rb +29 -0
- data/app/models/helena/survey_detail.rb +10 -0
- data/app/models/helena/version.rb +33 -0
- data/app/views/helena/admin/question_groups/_form.html.haml +3 -0
- data/app/views/helena/admin/question_groups/edit.html.haml +3 -0
- data/app/views/helena/admin/question_groups/index.html.haml +41 -0
- data/app/views/helena/admin/question_groups/new.html.haml +3 -0
- data/app/views/helena/admin/questions/_form.html.haml +15 -0
- data/app/views/helena/admin/questions/_labels.html.haml +24 -0
- data/app/views/helena/admin/questions/_sub_questions.html.haml +32 -0
- data/app/views/helena/admin/questions/edit.html.haml +3 -0
- data/app/views/helena/admin/questions/index.html.haml +49 -0
- data/app/views/helena/admin/questions/new.html.haml +3 -0
- data/app/views/helena/admin/sessions/index.html.haml +46 -0
- data/app/views/helena/admin/surveys/_form.html.haml +10 -0
- data/app/views/helena/admin/surveys/edit.html.haml +5 -0
- data/app/views/helena/admin/surveys/index.html.haml +35 -0
- data/app/views/helena/admin/surveys/new.html.haml +3 -0
- data/app/views/helena/admin/versions/_form.html.haml +5 -0
- data/app/views/helena/admin/versions/default_session_report.html.haml +17 -0
- data/app/views/helena/admin/versions/edit.html.haml +3 -0
- data/app/views/helena/admin/versions/index.html.haml +35 -0
- data/app/views/helena/admin/versions/new.html.haml +3 -0
- data/app/views/helena/questions/_checkbox_group.html.haml +17 -0
- data/app/views/helena/questions/_long_text.html.haml +8 -0
- data/app/views/helena/questions/_radio_group.html.haml +13 -0
- data/app/views/helena/questions/_radio_matrix.html.haml +27 -0
- data/app/views/helena/questions/_short_text.html.haml +8 -0
- data/app/views/helena/sessions/edit.html.haml +16 -0
- data/app/views/helena/sessions/end_message.html.haml +5 -0
- data/app/views/helena/surveys/_survey.html.haml +3 -0
- data/app/views/helena/surveys/index.html.haml +2 -0
- data/bin/rails +8 -0
- data/config/i18n-tasks.yml +3 -0
- data/config/initializers/simple_form.rb +162 -0
- data/config/initializers/simple_form_bootstrap.rb +132 -0
- data/config/locales/en.yml +20 -0
- data/config/locales/models/label/en.yml +14 -0
- data/config/locales/models/question/en.yml +47 -0
- data/config/locales/models/question_group/en.yml +11 -0
- data/config/locales/models/session/en.yml +10 -0
- data/config/locales/models/sub_question/en.yml +14 -0
- data/config/locales/models/survey/en.yml +6 -0
- data/config/locales/models/version/en.yml +12 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/views/admin/question_groups/en.yml +12 -0
- data/config/locales/views/admin/questions/en.yml +16 -0
- data/config/locales/views/admin/sessions/en.yml +11 -0
- data/config/locales/views/admin/surveys/en.yml +10 -0
- data/config/locales/views/admin/versions/en.yml +8 -0
- data/config/locales/views/sessions/en.yml +9 -0
- data/config/routes.rb +28 -0
- data/db/seeds.rb +182 -0
- data/gpl-3.0.txt +674 -0
- data/helena.gemspec +40 -0
- data/lib/helena/engine.rb +6 -0
- data/lib/helena/version.rb +3 -0
- data/lib/helena/version_publisher.rb +16 -0
- data/lib/helena.rb +10 -0
- data/lib/tasks/helena_tasks.rake +4 -0
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- data/spec/controllers/helena/admin/question_group_controller_spec.rb +59 -0
- data/spec/controllers/helena/admin/questions_controller_spec.rb +60 -0
- data/spec/controllers/helena/admin/sessions_controller_spec.rb +84 -0
- data/spec/controllers/helena/admin/survey_controller_spec.rb +89 -0
- data/spec/controllers/helena/admin/versions_controller_spec.rb +19 -0
- data/spec/controllers/helena/application_controller_spec.rb +15 -0
- data/spec/controllers/helena/sessions_controller_spec.rb +24 -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/controllers/application_controller.rb +9 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -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.haml +24 -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 +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -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 +14 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/seeds.rb +1 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/helena/answers.rb +24 -0
- data/spec/factories/helena/labels.rb +7 -0
- data/spec/factories/helena/question_groups.rb +6 -0
- data/spec/factories/helena/questions.rb +14 -0
- data/spec/factories/helena/sessions.rb +9 -0
- data/spec/factories/helena/sub_questions.rb +7 -0
- data/spec/factories/helena/survey_details.rb +6 -0
- data/spec/factories/helena/surveys.rb +7 -0
- data/spec/factories/helena/versions.rb +11 -0
- data/spec/features/helena/admin/manage_question_group_spec.rb +101 -0
- data/spec/features/helena/admin/manage_question_spec.rb +105 -0
- data/spec/features/helena/admin/manage_session_spec.rb +40 -0
- data/spec/features/helena/admin/manage_survey_spec.rb +141 -0
- data/spec/features/helena/admin/manage_version_spec.rb +74 -0
- data/spec/features/helena/admin/question_types/manage_checkbox_group_question_spec.rb +55 -0
- data/spec/features/helena/admin/question_types/manage_long_text_question_spec.rb +21 -0
- data/spec/features/helena/admin/question_types/manage_radio_group_question_spec.rb +59 -0
- data/spec/features/helena/admin/question_types/manage_radio_matrix_question_spec.rb +80 -0
- data/spec/features/helena/admin/question_types/manage_short_text_question_spec.rb +19 -0
- data/spec/features/helena/admin/question_types/manage_static_text_question_spec.rb +17 -0
- data/spec/features/helena/manage_session_spec.rb +284 -0
- data/spec/features/helena/manage_survey_spec.rb +24 -0
- data/spec/lib/version_publisher_spec.rb +26 -0
- data/spec/models/helena/answer_spec.rb +53 -0
- data/spec/models/helena/label_spec.rb +13 -0
- data/spec/models/helena/question_group_spec.rb +11 -0
- data/spec/models/helena/question_spec.rb +21 -0
- data/spec/models/helena/questions/radio_group_spec.rb +32 -0
- data/spec/models/helena/questions/radio_matrix_spec.rb +32 -0
- data/spec/models/helena/questions/short_text_spec.rb +10 -0
- data/spec/models/helena/session_spec.rb +20 -0
- data/spec/models/helena/sub_question_spec.rb +28 -0
- data/spec/models/helena/survey_spec.rb +14 -0
- data/spec/models/helena/version_spec.rb +15 -0
- data/spec/spec_helper.rb +43 -0
- metadata +485 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Question management' do
|
4
|
+
let!(:draft_version) { create :version, survey: create(:survey), version: 0 }
|
5
|
+
let!(:question_group) { create :question_group, version: draft_version }
|
6
|
+
|
7
|
+
scenario 'lists all question groups of a certain survey' do
|
8
|
+
first_question = create :question, question_text: 'Who are you?', question_group: question_group, position: 1
|
9
|
+
second_question = create :question, question_text: 'Imagine an inivisible pony. What color has ist?', question_group: question_group, position: 2
|
10
|
+
|
11
|
+
visit helena.admin_survey_question_group_questions_path(draft_version.survey, question_group)
|
12
|
+
|
13
|
+
within "#helena_#{dom_id first_question}" do
|
14
|
+
expect(page).to have_text 'Who are you?'
|
15
|
+
end
|
16
|
+
|
17
|
+
within "#helena_#{dom_id second_question}" do
|
18
|
+
expect(page).to have_text 'Imagine an inivisible pony. What color has ist?'
|
19
|
+
end
|
20
|
+
|
21
|
+
within '.breadcrumb' do
|
22
|
+
expect(page).to have_link 'Surveys', href: helena.admin_surveys_path
|
23
|
+
expect(page).to have_link draft_version.survey.name, href: helena.admin_survey_question_groups_path(draft_version.survey)
|
24
|
+
expect(page).to have_text question_group.title
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
scenario 'creates a new question' do
|
29
|
+
visit helena.new_admin_survey_question_group_question_path(draft_version.survey, question_group)
|
30
|
+
|
31
|
+
fill_in 'Code', with: 'a38'
|
32
|
+
fill_in 'Question text', with: 'Shall we go?'
|
33
|
+
|
34
|
+
within '.breadcrumb' do
|
35
|
+
expect(page).to have_text 'New question'
|
36
|
+
end
|
37
|
+
|
38
|
+
expect { click_button 'Save' }.to change { question_group.reload.questions.count }.by(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
scenario 'creating a new question errors when without entering a code' do
|
42
|
+
visit helena.new_admin_survey_question_group_question_path(draft_version.survey, question_group)
|
43
|
+
|
44
|
+
fill_in 'Code', with: ''
|
45
|
+
|
46
|
+
expect { click_button 'Save' }.to change { question_group.reload.questions.count }.by(0)
|
47
|
+
end
|
48
|
+
|
49
|
+
scenario 'edits a question' do
|
50
|
+
question = create :question, question_text: 'We are here?', question_group: question_group
|
51
|
+
|
52
|
+
visit helena.edit_admin_survey_question_group_question_path(draft_version.survey, question.question_group, question)
|
53
|
+
|
54
|
+
fill_in 'Question text', with: 'Are you sure?'
|
55
|
+
fill_in 'Code', with: 'b12'
|
56
|
+
|
57
|
+
click_button 'Save'
|
58
|
+
|
59
|
+
expect(question.reload.question_text).to eq 'Are you sure?'
|
60
|
+
expect(question.reload.code).to eq 'b12'
|
61
|
+
end
|
62
|
+
|
63
|
+
scenario 'edits a question errors when code text is empty' do
|
64
|
+
question = create :question, question_text: 'We are here?', question_group: question_group
|
65
|
+
|
66
|
+
visit helena.edit_admin_survey_question_group_question_path(draft_version.survey, question.question_group, question)
|
67
|
+
|
68
|
+
fill_in 'Code', with: ''
|
69
|
+
|
70
|
+
expect { click_button 'Save' }.not_to change { question.reload }
|
71
|
+
end
|
72
|
+
|
73
|
+
scenario 'moving a question' do
|
74
|
+
first_question = create :question, question_group: question_group, position: 1
|
75
|
+
second_question = create :question, question_group: question_group, position: 2
|
76
|
+
|
77
|
+
visit helena.admin_survey_question_group_questions_path(draft_version.survey, question_group)
|
78
|
+
|
79
|
+
within "#helena_#{dom_id first_question}" do
|
80
|
+
expect { click_link 'Move down' }.to change { first_question.reload.position }.from(1).to(2)
|
81
|
+
end
|
82
|
+
|
83
|
+
within "#helena_#{dom_id second_question}" do
|
84
|
+
expect { click_link 'Move down' }.to change { second_question.reload.position }.from(1).to(2)
|
85
|
+
end
|
86
|
+
|
87
|
+
within "#helena_#{dom_id second_question}" do
|
88
|
+
expect { click_link 'Move up' }.to change { second_question.reload.position }.from(2).to(1)
|
89
|
+
end
|
90
|
+
|
91
|
+
within "#helena_#{dom_id first_question}" do
|
92
|
+
expect { click_link 'Move up' }.to change { first_question.reload.position }.from(2).to(1)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
scenario 'deletes a question' do
|
97
|
+
question = create :question, question_group: question_group
|
98
|
+
|
99
|
+
visit helena.admin_survey_question_group_questions_path(draft_version.survey, question_group)
|
100
|
+
|
101
|
+
within "#helena_#{dom_id question}" do
|
102
|
+
expect { click_link 'Delete' }.to change { question_group.reload.questions.count }.by(-1)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include ActionView::RecordIdentifier
|
3
|
+
|
4
|
+
feature 'Session management' do
|
5
|
+
background do
|
6
|
+
@survey = create :survey
|
7
|
+
baseversion = @survey.versions.create version: 0
|
8
|
+
@version = Helena::VersionPublisher.publish baseversion
|
9
|
+
@version.save
|
10
|
+
end
|
11
|
+
|
12
|
+
scenario 'lists all sessions of a survey' do
|
13
|
+
session_not_completed = @survey.sessions.create version: @version, token: 'abc'
|
14
|
+
session_completed = @survey.sessions.create version: @version, token: 'xyz', completed: true
|
15
|
+
|
16
|
+
visit helena.admin_survey_sessions_path @survey
|
17
|
+
|
18
|
+
within "#helena_#{dom_id session_not_completed}" do
|
19
|
+
expect(page).to have_text 'less than a minute abc No'
|
20
|
+
end
|
21
|
+
|
22
|
+
within "#helena_#{dom_id session_completed}" do
|
23
|
+
expect(page).to have_text 'less than a minute xyz Yes'
|
24
|
+
end
|
25
|
+
|
26
|
+
within '.breadcrumb' do
|
27
|
+
expect(page).to have_text 'Surveys'
|
28
|
+
expect(page).to have_text @survey.name
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
scenario 'deletes a version' do
|
33
|
+
session = @survey.sessions.create
|
34
|
+
|
35
|
+
visit helena.admin_survey_sessions_path @survey
|
36
|
+
within "#helena_#{dom_id(session)}" do
|
37
|
+
expect { click_link 'Delete' }.to change { @survey.sessions.count }.by(-1)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Survey management' do
|
4
|
+
scenario 'lists all surveys' do
|
5
|
+
first_survey = create :survey, name: 'first', tag_list: 'foo, bar'
|
6
|
+
first_survey.versions.create version: 0
|
7
|
+
first_survey.versions.first.survey_detail = Helena::SurveyDetail.new(title: 'My first survey', description: 'I am very proud of it')
|
8
|
+
second_survey = create :survey, name: 'second', tag_list: 'cumulus, nimbus'
|
9
|
+
second_survey.versions.create version: 0
|
10
|
+
second_survey.versions.first.survey_detail = Helena::SurveyDetail.new(title: 'Another cool survey', description: 'Everybody likes it')
|
11
|
+
|
12
|
+
visit helena.admin_surveys_path
|
13
|
+
|
14
|
+
within "#helena_#{dom_id first_survey}" do
|
15
|
+
expect(page).to have_text 'first'
|
16
|
+
expect(page).to have_text 'My first survey'
|
17
|
+
expect(page).to have_text 'I am very proud of it'
|
18
|
+
expect(page).to have_text 'foo, bar'
|
19
|
+
end
|
20
|
+
|
21
|
+
within "#helena_#{dom_id second_survey}" do
|
22
|
+
expect(page).to have_text 'second'
|
23
|
+
expect(page).to have_text 'Another cool survey'
|
24
|
+
expect(page).to have_text 'Everybody likes it'
|
25
|
+
expect(page).to have_text 'cumulus, nimbus'
|
26
|
+
end
|
27
|
+
|
28
|
+
within '.breadcrumb' do
|
29
|
+
expect(page).to have_text 'Surveys'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
scenario 'creates a new surveys' do
|
34
|
+
visit helena.new_admin_survey_path
|
35
|
+
|
36
|
+
fill_in 'Name', with: 'More crazy stuff...'
|
37
|
+
fill_in 'Description', with: 'Once upon a time.'
|
38
|
+
fill_in 'Tag list', with: 'english, foo, 42'
|
39
|
+
|
40
|
+
within '.breadcrumb' do
|
41
|
+
expect(page).to have_text 'New Survey'
|
42
|
+
end
|
43
|
+
|
44
|
+
expect { click_button 'Save' }.to change { Helena::Survey.count }.by 1
|
45
|
+
end
|
46
|
+
|
47
|
+
scenario 'creates a new surveys errors without a name' do
|
48
|
+
visit helena.new_admin_survey_path
|
49
|
+
|
50
|
+
fill_in 'Name', with: ''
|
51
|
+
|
52
|
+
expect { click_button 'Save' }.to change { Helena::Survey.count }.by 0
|
53
|
+
end
|
54
|
+
|
55
|
+
scenario 'edits a survey' do
|
56
|
+
survey = create :survey, name: 'first'
|
57
|
+
survey.versions.create version: 0
|
58
|
+
survey.versions.first.survey_detail = Helena::SurveyDetail.new(title: 'My first survey', description: 'I am very proud of it')
|
59
|
+
|
60
|
+
visit helena.edit_admin_survey_path(survey)
|
61
|
+
|
62
|
+
fill_in 'Name', with: 'This is crazy'
|
63
|
+
fill_in 'Title', with: 'More crazy stuff...'
|
64
|
+
fill_in 'Description', with: 'Once upon a time.'
|
65
|
+
fill_in 'Tag list', with: 'english, foo, 42'
|
66
|
+
|
67
|
+
click_button 'Save'
|
68
|
+
|
69
|
+
within "#helena_#{dom_id survey}" do
|
70
|
+
expect(page).to have_text 'This is crazy'
|
71
|
+
expect(page).to have_text 'More crazy stuff...'
|
72
|
+
expect(page).to have_text 'Once upon a time.'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
scenario 'edits a survey fails when name is empty' do
|
77
|
+
survey = create :survey, name: 'the first one'
|
78
|
+
survey.versions.create version: 0
|
79
|
+
survey.versions.first.survey_detail = Helena::SurveyDetail.new(title: 'My first survey', description: 'I am very proud of it')
|
80
|
+
|
81
|
+
visit helena.edit_admin_survey_path(survey)
|
82
|
+
|
83
|
+
fill_in 'Name', with: ''
|
84
|
+
fill_in 'Description', with: 'Once upon a time.'
|
85
|
+
|
86
|
+
click_button 'Save'
|
87
|
+
|
88
|
+
expect(page).to have_text "Name can't be blank"
|
89
|
+
|
90
|
+
within '.breadcrumb' do
|
91
|
+
expect(page).to have_text 'the first one'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
scenario 'deletes a survey' do
|
96
|
+
survey = create :survey, name: 'the first one'
|
97
|
+
survey.versions.create version: 0
|
98
|
+
|
99
|
+
visit helena.admin_surveys_path
|
100
|
+
|
101
|
+
within "#helena_#{dom_id survey}" do
|
102
|
+
expect { click_link 'Delete' }.to change { Helena::Survey.count }.by(-1)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
scenario 'links to question groups of a survey' do
|
107
|
+
survey = create :survey, name: 'the first one'
|
108
|
+
survey.versions.create version: 0
|
109
|
+
|
110
|
+
visit helena.admin_surveys_path
|
111
|
+
|
112
|
+
within "#helena_#{dom_id survey}" do
|
113
|
+
expect(page).to have_link 'Question Groups', href: helena.admin_survey_question_groups_path(survey)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
scenario 'moving surveys' do
|
118
|
+
first_survey = create :survey, name: 'first', position: 1
|
119
|
+
first_survey.versions.create version: 0
|
120
|
+
second_survey = create :survey, name: 'second', position: 2
|
121
|
+
second_survey.versions.create version: 0
|
122
|
+
|
123
|
+
visit helena.admin_surveys_path
|
124
|
+
|
125
|
+
within "#helena_#{dom_id first_survey}" do
|
126
|
+
expect { click_link 'Move down' }.to change { first_survey.reload.position }.from(1).to(2)
|
127
|
+
end
|
128
|
+
|
129
|
+
within "#helena_#{dom_id second_survey}" do
|
130
|
+
expect { click_link 'Move down' }.to change { second_survey.reload.position }.from(1).to(2)
|
131
|
+
end
|
132
|
+
|
133
|
+
within "#helena_#{dom_id second_survey}" do
|
134
|
+
expect { click_link 'Move up' }.to change { second_survey.reload.position }.from(2).to(1)
|
135
|
+
end
|
136
|
+
|
137
|
+
within "#helena_#{dom_id first_survey}" do
|
138
|
+
expect { click_link 'Move up' }.to change { first_survey.reload.position }.from(2).to(1)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
include ActionView::RecordIdentifier
|
3
|
+
|
4
|
+
feature 'Version management' do
|
5
|
+
background do
|
6
|
+
@survey = create :survey
|
7
|
+
@baseversion = @survey.versions.create version: 0
|
8
|
+
end
|
9
|
+
|
10
|
+
scenario 'lists all versions of a survey' do
|
11
|
+
published_version = Helena::VersionPublisher.publish @baseversion
|
12
|
+
published_version.notes = 'bla bla'
|
13
|
+
published_version.save
|
14
|
+
|
15
|
+
visit helena.admin_survey_versions_path(@survey)
|
16
|
+
|
17
|
+
expect(page).not_to have_selector "#helena_#{dom_id @baseversion}" # Base version is always the working version
|
18
|
+
|
19
|
+
within "#helena_#{dom_id published_version}" do
|
20
|
+
expect(page).to have_text '1 bla bla 0 less than a minute'
|
21
|
+
end
|
22
|
+
|
23
|
+
within '.breadcrumb' do
|
24
|
+
expect(page).to have_text 'Surveys'
|
25
|
+
expect(page).to have_text @survey.name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
scenario 'publishing a new version on the base of base version' do
|
30
|
+
|
31
|
+
visit helena.new_admin_survey_version_path @survey
|
32
|
+
|
33
|
+
expect(find_field('version_session_report').value).to have_content '{{ survey_title }}'
|
34
|
+
|
35
|
+
fill_in 'Notes', with: 'Luke, I am your father!'
|
36
|
+
fill_in 'version_session_report', with: 'Foo Bar'
|
37
|
+
|
38
|
+
expect { click_button 'Save' }.to change { @survey.reload.versions.count }.by(1)
|
39
|
+
|
40
|
+
expect(@survey.reload.versions.last.session_report).to eq 'Foo Bar'
|
41
|
+
|
42
|
+
visit helena.new_admin_survey_version_path @survey
|
43
|
+
|
44
|
+
expect(find_field('version_session_report').value).to have_content 'Foo Bar'
|
45
|
+
end
|
46
|
+
|
47
|
+
scenario 'changing the session report for a version' do
|
48
|
+
published_version = Helena::VersionPublisher.publish @baseversion
|
49
|
+
published_version.notes = 'bla bla'
|
50
|
+
published_version.save
|
51
|
+
|
52
|
+
visit helena.edit_admin_survey_version_path(@survey, published_version)
|
53
|
+
|
54
|
+
fill_in 'Notes', with: 'Michael Knight, a lone crusader in a dangerous world. The world of the Knight Rider.'
|
55
|
+
fill_in 'version_session_report', with: 'A Man, a Car'
|
56
|
+
|
57
|
+
click_button 'Save'
|
58
|
+
|
59
|
+
expect(published_version.reload.notes).to eq 'Michael Knight, a lone crusader in a dangerous world. The world of the Knight Rider.'
|
60
|
+
expect(published_version.reload.session_report).to eq 'A Man, a Car'
|
61
|
+
end
|
62
|
+
|
63
|
+
scenario 'deletes a version' do
|
64
|
+
published_version = Helena::VersionPublisher.publish @baseversion
|
65
|
+
published_version.notes = 'bla bla'
|
66
|
+
published_version.save
|
67
|
+
|
68
|
+
visit helena.admin_survey_versions_path @survey
|
69
|
+
|
70
|
+
within "#helena_#{dom_id published_version }" do
|
71
|
+
expect { click_link 'Delete' }.to change { @survey.reload.versions.count }.by(-1)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Checkbox group question management' do
|
4
|
+
let!(:draft_version) { create :version, survey: create(:survey), version: 0 }
|
5
|
+
let!(:question_group) { create(:question_group, version: draft_version) }
|
6
|
+
|
7
|
+
scenario 'edits a question' do
|
8
|
+
question = create :checkbox_group_question, question_group: question_group
|
9
|
+
question.sub_questions.create(code: 'aperto', text: 'Aperto Snacks', value: 'Aperto', position: 1)
|
10
|
+
|
11
|
+
visit helena.edit_admin_survey_question_group_questions_checkbox_group_path(draft_version.survey, question.question_group, question)
|
12
|
+
|
13
|
+
check 'Required'
|
14
|
+
|
15
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_position', with: '2'
|
16
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_text', with: 'Avec Shop'
|
17
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_code', with: 'avec'
|
18
|
+
check 'questions_checkbox_group_sub_questions_attributes_0_preselected'
|
19
|
+
|
20
|
+
click_button 'Save'
|
21
|
+
|
22
|
+
expect(question.reload.sub_questions.first.position).to eq 2
|
23
|
+
expect(question.reload.sub_questions.first.text).to eq 'Avec Shop'
|
24
|
+
expect(question.reload.sub_questions.first.code).to eq 'avec'
|
25
|
+
expect(question.reload.required).to eq true
|
26
|
+
end
|
27
|
+
|
28
|
+
scenario 'adds a a sub question' do
|
29
|
+
question = create :checkbox_group_question, question_group: question_group
|
30
|
+
|
31
|
+
visit helena.edit_admin_survey_question_group_questions_checkbox_group_path(draft_version.survey, question.question_group, question)
|
32
|
+
|
33
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_position', with: '2'
|
34
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_text', with: 'Avec Shop'
|
35
|
+
fill_in 'questions_checkbox_group_sub_questions_attributes_0_code', with: 'avec'
|
36
|
+
check 'questions_checkbox_group_sub_questions_attributes_0_preselected'
|
37
|
+
|
38
|
+
click_button 'Save'
|
39
|
+
|
40
|
+
expect(question.reload.sub_questions.first.position).to eq 2
|
41
|
+
expect(question.reload.sub_questions.first.text).to eq 'Avec Shop'
|
42
|
+
expect(question.reload.sub_questions.first.code).to eq 'avec'
|
43
|
+
end
|
44
|
+
|
45
|
+
scenario 'removes a sub question' do
|
46
|
+
question = create :checkbox_group_question, question_group: question_group
|
47
|
+
question.sub_questions.create(code: 'aperto', text: 'Aperto Snacks', value: 'Aperto', position: 1)
|
48
|
+
|
49
|
+
visit helena.edit_admin_survey_question_group_question_path(draft_version.survey, question.question_group, question)
|
50
|
+
|
51
|
+
check 'questions_checkbox_group_sub_questions_attributes_0__destroy'
|
52
|
+
|
53
|
+
click_button 'Save'
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Long text question management' do
|
4
|
+
let!(:draft_version) { create :version, survey: create(:survey), version: 0 }
|
5
|
+
|
6
|
+
scenario 'edits a question' do
|
7
|
+
question = create :long_text_question, question_group: create(:question_group, version: draft_version)
|
8
|
+
|
9
|
+
visit helena.edit_admin_survey_question_group_question_path(draft_version.survey, question.question_group, question)
|
10
|
+
|
11
|
+
a_very_long_text = Faker::Lorem.paragraph(20)
|
12
|
+
|
13
|
+
fill_in 'Default value', with: a_very_long_text
|
14
|
+
check 'Required'
|
15
|
+
|
16
|
+
click_button 'Save'
|
17
|
+
|
18
|
+
expect(question.reload.default_value).to eq a_very_long_text
|
19
|
+
expect(question.reload.required).to eq true
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Radio group question management' do
|
4
|
+
let!(:draft_version) { create :version, survey: create(:survey), version: 0 }
|
5
|
+
let!(:question_group) { create(:question_group, version: draft_version) }
|
6
|
+
|
7
|
+
scenario 'edits a question' do
|
8
|
+
question = create :radio_group_question, question_group: question_group
|
9
|
+
question.labels << build(:label, text: 'Male', value: 'm', position: 1)
|
10
|
+
|
11
|
+
visit helena.edit_admin_survey_question_group_question_path(draft_version.survey, question.question_group, question)
|
12
|
+
|
13
|
+
check 'Required'
|
14
|
+
|
15
|
+
fill_in 'questions_radio_group_labels_attributes_0_position', with: '2'
|
16
|
+
fill_in 'questions_radio_group_labels_attributes_0_text', with: 'Female'
|
17
|
+
fill_in 'questions_radio_group_labels_attributes_0_value', with: 'f'
|
18
|
+
check 'questions_radio_group_labels_attributes_0_preselected'
|
19
|
+
|
20
|
+
click_button 'Save'
|
21
|
+
|
22
|
+
expect(question.reload.labels.first.position).to eq 2
|
23
|
+
expect(question.reload.labels.first.text).to eq 'Female'
|
24
|
+
expect(question.reload.labels.first.value).to eq 'f'
|
25
|
+
expect(question.reload.labels.first.preselected).to eq true
|
26
|
+
expect(question.reload.required).to eq true
|
27
|
+
end
|
28
|
+
|
29
|
+
scenario 'adds a an option' do
|
30
|
+
question = create :radio_group_question, question_group: question_group
|
31
|
+
|
32
|
+
visit helena.edit_admin_survey_question_group_questions_radio_group_path(draft_version.survey, question.question_group, question)
|
33
|
+
|
34
|
+
fill_in 'questions_radio_group_labels_attributes_0_position', with: '2'
|
35
|
+
fill_in 'questions_radio_group_labels_attributes_0_text', with: 'Female'
|
36
|
+
fill_in 'questions_radio_group_labels_attributes_0_value', with: 'f'
|
37
|
+
check 'questions_radio_group_labels_attributes_0_preselected'
|
38
|
+
|
39
|
+
click_button 'Save'
|
40
|
+
|
41
|
+
expect(question.reload.labels.first.position).to eq 2
|
42
|
+
expect(question.reload.labels.first.text).to eq 'Female'
|
43
|
+
expect(question.reload.labels.first.value).to eq 'f'
|
44
|
+
expect(question.reload.labels.first.preselected).to eq true
|
45
|
+
end
|
46
|
+
|
47
|
+
scenario 'removes an option' do
|
48
|
+
question = create :radio_group_question, question_group: question_group
|
49
|
+
question.labels << build(:label, text: 'Male', value: 'm', position: 1)
|
50
|
+
|
51
|
+
visit helena.edit_admin_survey_question_group_questions_radio_group_path(draft_version.survey, question.question_group, question)
|
52
|
+
|
53
|
+
check 'questions_radio_group_labels_attributes_0__destroy'
|
54
|
+
|
55
|
+
click_button 'Save'
|
56
|
+
|
57
|
+
expect(question.reload.labels).to be_empty
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Radio matrix question management' do
|
4
|
+
let!(:draft_version) { create :version, survey: create(:survey), version: 0 }
|
5
|
+
let!(:question_group) { create(:question_group, version: draft_version) }
|
6
|
+
|
7
|
+
scenario 'edits a question' do
|
8
|
+
question = create :radio_matrix_question, question_group: question_group
|
9
|
+
question.labels.create text: 'Strongly disagree', value: '-1', position: 1
|
10
|
+
question.sub_questions.create code: 'aperto', text: 'Aperto Snacks', value: 'Aperto', position: 1
|
11
|
+
|
12
|
+
visit helena.edit_admin_survey_question_group_question_path(draft_version.survey, question.question_group, question)
|
13
|
+
|
14
|
+
check 'Required'
|
15
|
+
|
16
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_position', with: '2'
|
17
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_text', with: 'Strongly agree'
|
18
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_value', with: '1'
|
19
|
+
check 'questions_radio_matrix_labels_attributes_0_preselected'
|
20
|
+
|
21
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_position', with: '2'
|
22
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_text', with: 'Avec Shop'
|
23
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_code', with: 'avec'
|
24
|
+
|
25
|
+
click_button 'Save'
|
26
|
+
|
27
|
+
expect(question.reload.labels.first.position).to eq 2
|
28
|
+
expect(question.reload.labels.first.text).to eq 'Strongly agree'
|
29
|
+
expect(question.reload.labels.first.value).to eq '1'
|
30
|
+
expect(question.reload.labels.first.preselected).to eq true
|
31
|
+
|
32
|
+
expect(question.reload.sub_questions.first.position).to eq 2
|
33
|
+
expect(question.reload.sub_questions.first.text).to eq 'Avec Shop'
|
34
|
+
expect(question.reload.sub_questions.first.code).to eq 'avec'
|
35
|
+
|
36
|
+
expect(question.reload.required).to eq true
|
37
|
+
end
|
38
|
+
|
39
|
+
scenario 'adds a an option' do
|
40
|
+
question = create :radio_matrix_question, question_group: question_group
|
41
|
+
|
42
|
+
visit helena.edit_admin_survey_question_group_questions_radio_matrix_path(draft_version.survey, question.question_group, question)
|
43
|
+
|
44
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_position', with: '2'
|
45
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_text', with: 'Strongly agree'
|
46
|
+
fill_in 'questions_radio_matrix_labels_attributes_0_value', with: '1'
|
47
|
+
check 'questions_radio_matrix_labels_attributes_0_preselected'
|
48
|
+
|
49
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_position', with: '2'
|
50
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_text', with: 'Avec Shop'
|
51
|
+
fill_in 'questions_radio_matrix_sub_questions_attributes_0_code', with: 'avec'
|
52
|
+
|
53
|
+
click_button 'Save'
|
54
|
+
|
55
|
+
expect(question.reload.labels.first.position).to eq 2
|
56
|
+
expect(question.reload.labels.first.text).to eq 'Strongly agree'
|
57
|
+
expect(question.reload.labels.first.value).to eq '1'
|
58
|
+
expect(question.reload.labels.first.preselected).to eq true
|
59
|
+
|
60
|
+
expect(question.reload.sub_questions.first.position).to eq 2
|
61
|
+
expect(question.reload.sub_questions.first.text).to eq 'Avec Shop'
|
62
|
+
expect(question.reload.sub_questions.first.code).to eq 'avec'
|
63
|
+
end
|
64
|
+
|
65
|
+
scenario 'removes an option' do
|
66
|
+
question = create :radio_matrix_question, question_group: question_group
|
67
|
+
question.labels.create text: 'Male', value: 'm', position: 1
|
68
|
+
question.sub_questions.create code: 'aperto', text: 'Aperto Snacks', value: 'Aperto', position: 1
|
69
|
+
|
70
|
+
visit helena.edit_admin_survey_question_group_questions_radio_matrix_path(draft_version.survey, question.question_group, question)
|
71
|
+
|
72
|
+
check 'questions_radio_matrix_labels_attributes_0__destroy'
|
73
|
+
check 'questions_radio_matrix_sub_questions_attributes_0__destroy'
|
74
|
+
|
75
|
+
click_button 'Save'
|
76
|
+
|
77
|
+
expect(question.reload.labels).to be_empty
|
78
|
+
expect(question.reload.sub_questions).to be_empty
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Short text question management' do
|
4
|
+
let!(:draft_version) { create :version, survey: create(:survey), version: 0 }
|
5
|
+
|
6
|
+
scenario 'edits a question' do
|
7
|
+
question = create :short_text_question, question_group: create(:question_group, version: draft_version)
|
8
|
+
|
9
|
+
visit helena.edit_admin_survey_question_group_question_path(question.question_group.version.survey, question.question_group, question)
|
10
|
+
|
11
|
+
fill_in 'Default value', with: 'Hey Hey!'
|
12
|
+
check 'Required'
|
13
|
+
|
14
|
+
click_button 'Save'
|
15
|
+
|
16
|
+
expect(question.reload.default_value).to eq 'Hey Hey!'
|
17
|
+
expect(question.reload.required).to eq true
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
feature 'Static text question management' do
|
4
|
+
let!(:draft_version) { create :version, survey: create(:survey), version: 0 }
|
5
|
+
|
6
|
+
scenario 'edits a question' do
|
7
|
+
question = create :static_text_question, question_group: create(:question_group, version: draft_version)
|
8
|
+
|
9
|
+
visit helena.edit_admin_survey_question_group_question_path(draft_version.survey, question.question_group, question)
|
10
|
+
|
11
|
+
fill_in 'Static text', with: 'This text will be displayed instead of an input'
|
12
|
+
|
13
|
+
click_button 'Save'
|
14
|
+
|
15
|
+
expect(question.reload.default_value).to eq 'This text will be displayed instead of an input'
|
16
|
+
end
|
17
|
+
end
|