helena 0.3.3 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -4
  3. data/Gemfile +1 -2
  4. data/Gemfile.lock +88 -95
  5. data/README.md +10 -25
  6. data/app/controllers/helena/application_controller.rb +0 -10
  7. data/app/controllers/helena/sessions_controller.rb +17 -6
  8. data/app/models/helena/answer.rb +1 -2
  9. data/app/models/helena/concerns/application_model.rb +0 -9
  10. data/app/models/helena/concerns/questions/validates_one_label.rb +1 -1
  11. data/app/models/helena/question.rb +5 -5
  12. data/app/models/helena/question_group.rb +4 -3
  13. data/app/models/helena/session.rb +27 -0
  14. data/app/models/helena/survey.rb +2 -7
  15. data/app/models/helena/version.rb +6 -4
  16. data/app/views/helena/questions/_static_text.html.slim +1 -0
  17. data/app/views/helena/sessions/_progressbar.html.slim +9 -0
  18. data/app/views/helena/sessions/edit.html.slim +18 -0
  19. data/app/views/helena/sessions/{end_message.html.haml → end_message.html.slim} +1 -1
  20. data/config/locales/models/question_group/en.yml +1 -0
  21. data/config/locales/models/session/en.yml +4 -0
  22. data/config/locales/models/survey/en.yml +3 -0
  23. data/config/locales/views/sessions/en.yml +4 -0
  24. data/config/routes.rb +1 -25
  25. data/db/seeds.rb +12 -140
  26. data/db/swls_survey.en.yml +67 -0
  27. data/helena.gemspec +1 -0
  28. data/lib/helena/engine.rb +11 -0
  29. data/lib/helena/survey_importer.rb +52 -0
  30. data/lib/helena/version.rb +1 -1
  31. data/lib/helena/version_publisher.rb +34 -2
  32. data/lib/helena.rb +3 -0
  33. data/spec/controllers/helena/sessions_controller_spec.rb +8 -3
  34. data/spec/dummy/app/controllers/application_controller.rb +0 -4
  35. data/spec/factories/helena/labels.rb +0 -1
  36. data/spec/factories/helena/question_groups.rb +0 -1
  37. data/spec/factories/helena/questions.rb +0 -1
  38. data/spec/factories/helena/sub_questions.rb +0 -1
  39. data/spec/factories/helena/surveys.rb +0 -1
  40. data/spec/features/helena/manage_session_spec.rb +76 -16
  41. data/spec/lib/survey_importer_spec.rb +14 -0
  42. data/spec/lib/version_publisher_spec.rb +5 -4
  43. data/spec/models/helena/answer_spec.rb +0 -1
  44. data/spec/models/helena/question_group_spec.rb +2 -1
  45. data/spec/models/helena/question_spec.rb +12 -4
  46. data/spec/models/helena/questions/checkbox_group_spec.rb +17 -0
  47. data/spec/models/helena/questions/radio_group_spec.rb +6 -0
  48. data/spec/models/helena/questions/radio_matrix_spec.rb +7 -0
  49. data/spec/models/helena/session_spec.rb +50 -0
  50. data/spec/models/helena/survey_spec.rb +12 -1
  51. data/spec/models/helena/version_spec.rb +11 -2
  52. metadata +26 -73
  53. data/app/assets/images/helena/icons/export.svg +0 -29
  54. data/app/assets/stylesheets/helena/admin/labels.css.sass +0 -7
  55. data/app/assets/stylesheets/helena/admin/layout.css.sass +0 -6
  56. data/app/assets/stylesheets/helena/admin/question_groups.css.sass +0 -7
  57. data/app/assets/stylesheets/helena/admin/questions.css.sass +0 -9
  58. data/app/assets/stylesheets/helena/admin/sessions.css.sass +0 -5
  59. data/app/assets/stylesheets/helena/admin/subquestions.css.sass +0 -7
  60. data/app/assets/stylesheets/helena/admin/versions.css.sass +0 -9
  61. data/app/controllers/helena/admin/application_controller.rb +0 -31
  62. data/app/controllers/helena/admin/question_groups_controller.rb +0 -78
  63. data/app/controllers/helena/admin/questions/checkbox_groups_controller.rb +0 -17
  64. data/app/controllers/helena/admin/questions/checkbox_matrix_controller.rb +0 -9
  65. data/app/controllers/helena/admin/questions/long_texts_controller.rb +0 -13
  66. data/app/controllers/helena/admin/questions/radio_groups_controller.rb +0 -17
  67. data/app/controllers/helena/admin/questions/radio_matrix_controller.rb +0 -9
  68. data/app/controllers/helena/admin/questions/short_texts_controller.rb +0 -13
  69. data/app/controllers/helena/admin/questions/static_texts_controller.rb +0 -13
  70. data/app/controllers/helena/admin/questions_controller.rb +0 -105
  71. data/app/controllers/helena/admin/sessions_controller.rb +0 -35
  72. data/app/controllers/helena/admin/surveys_controller.rb +0 -78
  73. data/app/controllers/helena/admin/versions_controller.rb +0 -71
  74. data/app/controllers/helena/surveys_controller.rb +0 -11
  75. data/app/views/helena/admin/question_groups/_form.html.haml +0 -3
  76. data/app/views/helena/admin/question_groups/edit.html.haml +0 -3
  77. data/app/views/helena/admin/question_groups/index.html.haml +0 -41
  78. data/app/views/helena/admin/question_groups/new.html.haml +0 -3
  79. data/app/views/helena/admin/questions/_form.html.haml +0 -15
  80. data/app/views/helena/admin/questions/_labels.html.haml +0 -24
  81. data/app/views/helena/admin/questions/_sub_questions.html.haml +0 -32
  82. data/app/views/helena/admin/questions/edit.html.haml +0 -3
  83. data/app/views/helena/admin/questions/index.html.haml +0 -49
  84. data/app/views/helena/admin/questions/new.html.haml +0 -3
  85. data/app/views/helena/admin/sessions/index.html.haml +0 -46
  86. data/app/views/helena/admin/surveys/_form.html.haml +0 -10
  87. data/app/views/helena/admin/surveys/edit.html.haml +0 -5
  88. data/app/views/helena/admin/surveys/index.html.haml +0 -35
  89. data/app/views/helena/admin/surveys/new.html.haml +0 -3
  90. data/app/views/helena/admin/versions/_form.html.haml +0 -5
  91. data/app/views/helena/admin/versions/default_session_report.html.haml +0 -17
  92. data/app/views/helena/admin/versions/edit.html.haml +0 -3
  93. data/app/views/helena/admin/versions/index.html.haml +0 -35
  94. data/app/views/helena/admin/versions/new.html.haml +0 -3
  95. data/app/views/helena/sessions/edit.html.haml +0 -16
  96. data/app/views/helena/surveys/_survey.html.haml +0 -3
  97. data/app/views/helena/surveys/index.html.haml +0 -2
  98. data/config/locales/views/admin/question_groups/en.yml +0 -12
  99. data/config/locales/views/admin/questions/en.yml +0 -16
  100. data/config/locales/views/admin/sessions/en.yml +0 -11
  101. data/config/locales/views/admin/surveys/en.yml +0 -10
  102. data/config/locales/views/admin/versions/en.yml +0 -8
  103. data/spec/controllers/helena/admin/question_group_controller_spec.rb +0 -59
  104. data/spec/controllers/helena/admin/questions_controller_spec.rb +0 -60
  105. data/spec/controllers/helena/admin/sessions_controller_spec.rb +0 -84
  106. data/spec/controllers/helena/admin/survey_controller_spec.rb +0 -89
  107. data/spec/controllers/helena/admin/versions_controller_spec.rb +0 -19
  108. data/spec/controllers/helena/application_controller_spec.rb +0 -15
  109. data/spec/features/helena/admin/manage_question_group_spec.rb +0 -101
  110. data/spec/features/helena/admin/manage_question_spec.rb +0 -105
  111. data/spec/features/helena/admin/manage_session_spec.rb +0 -40
  112. data/spec/features/helena/admin/manage_survey_spec.rb +0 -141
  113. data/spec/features/helena/admin/manage_version_spec.rb +0 -74
  114. data/spec/features/helena/admin/question_types/manage_checkbox_group_question_spec.rb +0 -55
  115. data/spec/features/helena/admin/question_types/manage_long_text_question_spec.rb +0 -21
  116. data/spec/features/helena/admin/question_types/manage_radio_group_question_spec.rb +0 -59
  117. data/spec/features/helena/admin/question_types/manage_radio_matrix_question_spec.rb +0 -80
  118. data/spec/features/helena/admin/question_types/manage_short_text_question_spec.rb +0 -19
  119. data/spec/features/helena/admin/question_types/manage_static_text_question_spec.rb +0 -17
  120. data/spec/features/helena/manage_survey_spec.rb +0 -24
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Helena::Admin::VersionsController do
4
- routes { Helena::Engine.routes }
5
-
6
- let(:survey) { create :survey }
7
- let(:baseversion) { survey.versions.create version: 0 }
8
-
9
- context 'with authorization' do
10
- it 'deleting a version deletes also the associated sessions' do
11
- published_version = Helena::VersionPublisher.publish baseversion
12
- published_version.save
13
-
14
- create :session, survey: survey, version: published_version
15
-
16
- expect { delete :destroy, survey_id: survey, id: published_version }.to change { Helena::Session.count }.by(-1)
17
- end
18
- end
19
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Helena::ApplicationController do
4
- describe '.add_breadcrumb' do
5
- it 'names an empty element "Untitled"' do
6
- application_controller = Helena::ApplicationController.new
7
-
8
- application_controller.add_breadcrumb('')
9
- breadcrumbs = application_controller.add_breadcrumb(nil)
10
-
11
- expect(breadcrumbs.first.name).to eq 'Untitled'
12
- expect(breadcrumbs.last.name).to eq 'Untitled'
13
- end
14
- end
15
- end
@@ -1,101 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature 'Question group management' do
4
-
5
- let!(:survey) { create :survey }
6
- let!(:draft_version) { create :version, survey: survey, version: 0 }
7
-
8
- scenario 'lists all question groups of a certain survey' do
9
- first_question_group = create :question_group, title: 'Introduction', version: draft_version, position: 1
10
- second_question_group = create :question_group, title: 'Food behaviour', version: draft_version, position: 2
11
-
12
- visit helena.admin_survey_question_groups_path(survey)
13
-
14
- within "#helena_#{dom_id first_question_group}" do
15
- expect(page).to have_text '1 Introduction'
16
- end
17
-
18
- within "#helena_#{dom_id second_question_group}" do
19
- expect(page).to have_text '2 Food behaviour'
20
- end
21
-
22
- within '.breadcrumb' do
23
- expect(page).to have_text 'Surveys'
24
- expect(page).to have_text survey.name
25
- end
26
- end
27
-
28
- scenario 'creates a new question group' do
29
- visit helena.new_admin_survey_question_group_path(survey)
30
-
31
- fill_in 'Title', with: 'Welcome Message'
32
-
33
- within '.breadcrumb' do
34
- expect(page).to have_text 'New question group'
35
- end
36
-
37
- expect { click_button 'Save' }.to change { draft_version.reload.question_groups.count }.by(1)
38
- end
39
-
40
- scenario 'edits a question_group' do
41
- first_question_group = create :question_group, title: 'Some stupid questions', version: draft_version, position: 2
42
- second_question_group = create :question_group, title: 'Some final remarks', version: draft_version, position: 1
43
-
44
- visit helena.edit_admin_survey_question_group_path(survey, first_question_group)
45
-
46
- fill_in 'Title', with: 'Some serious question'
47
-
48
- click_button 'Save'
49
-
50
- within "#helena_#{dom_id first_question_group}" do
51
- expect(page).to have_text '2 Some serious question'
52
- end
53
-
54
- within "#helena_#{dom_id second_question_group}" do
55
- expect(page).to have_text '1 Some final remarks'
56
- end
57
- end
58
-
59
- scenario 'deletes a question group' do
60
- question_group = create :question_group, title: 'We do not use this anymore', version: draft_version
61
-
62
- visit helena.admin_survey_question_groups_path(survey)
63
-
64
- within "#helena_#{dom_id question_group}" do
65
- expect { click_link 'Delete' }.to change { draft_version.reload.question_groups.count }.by(-1)
66
- end
67
- end
68
-
69
- scenario 'links to questions of a question group' do
70
- question_group = create :question_group, title: 'We do not use this anymore', version: draft_version
71
-
72
- visit helena.admin_survey_question_groups_path(survey)
73
-
74
- within "#helena_#{dom_id question_group}" do
75
- expect(page).to have_link 'Questions', href: helena.admin_survey_question_group_questions_path(survey, question_group)
76
- end
77
- end
78
-
79
- scenario 'moving a question group' do
80
- first_question_group = create :question_group, version: draft_version, position: 1
81
- second_question_group = create :question_group, version: draft_version, position: 2
82
-
83
- visit helena.admin_survey_question_groups_path(survey)
84
-
85
- within "#helena_#{dom_id first_question_group}" do
86
- expect { click_link 'Move down' }.to change { first_question_group.reload.position }.from(1).to(2)
87
- end
88
-
89
- within "#helena_#{dom_id second_question_group}" do
90
- expect { click_link 'Move down' }.to change { second_question_group.reload.position }.from(1).to(2)
91
- end
92
-
93
- within "#helena_#{dom_id second_question_group}" do
94
- expect { click_link 'Move up' }.to change { second_question_group.reload.position }.from(2).to(1)
95
- end
96
-
97
- within "#helena_#{dom_id first_question_group}" do
98
- expect { click_link 'Move up' }.to change { first_question_group.reload.position }.from(2).to(1)
99
- end
100
- end
101
- end
@@ -1,105 +0,0 @@
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
@@ -1,40 +0,0 @@
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
@@ -1,141 +0,0 @@
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
@@ -1,74 +0,0 @@
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
@@ -1,55 +0,0 @@
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
@@ -1,21 +0,0 @@
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
@@ -1,59 +0,0 @@
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