helena 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +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
data/helena.gemspec
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
2
|
+
|
|
3
|
+
# Maintain your gem's version:
|
|
4
|
+
require 'helena/version'
|
|
5
|
+
|
|
6
|
+
# Describe your gem and declare its dependencies:
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.name = 'helena'
|
|
9
|
+
s.version = Helena::VERSION
|
|
10
|
+
s.authors = ['Markus Graf']
|
|
11
|
+
s.email = ['info@markusgraf.ch']
|
|
12
|
+
s.licenses = ['GPL-3']
|
|
13
|
+
s.homepage = 'https://github.com/gurix/helena'
|
|
14
|
+
s.summary = 'Helena is an online survey/test framework designed for agile
|
|
15
|
+
survey/test development, longitudinal studies and instant feedback.'
|
|
16
|
+
s.description = 'Helena is an online survey/test framework designed for agile
|
|
17
|
+
survey/test development, longitudinal studies and instant feedback.'
|
|
18
|
+
|
|
19
|
+
s.files = `git ls-files`.split("\n")
|
|
20
|
+
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
|
21
|
+
|
|
22
|
+
s.add_dependency 'rails', '~> 4.1'
|
|
23
|
+
s.add_dependency 'mongoid', '~> 4.0.0.rc2'
|
|
24
|
+
s.add_dependency 'mongoid_orderable', '~> 4.1'
|
|
25
|
+
s.add_dependency 'mongoid-simple-tags', '~> 0.1'
|
|
26
|
+
s.add_dependency 'haml-rails', '~> 0.5'
|
|
27
|
+
s.add_dependency 'jquery-rails', '~> 3.1'
|
|
28
|
+
s.add_dependency 'sass-rails', '~> 4.0.3' # version needed here http://stackoverflow.com/questions/22392862/undefined-method-environment-for-nilnilclass-when-importing-bootstrap
|
|
29
|
+
s.add_dependency 'bootstrap-sass', '~> 3.2'
|
|
30
|
+
s.add_dependency 'simple_form', '~> 3.1.0.rc2'
|
|
31
|
+
s.add_dependency 'breadcrumbs_on_rails', '~> 2.3'
|
|
32
|
+
s.add_dependency 'rails-i18n', '~> 4.0'
|
|
33
|
+
|
|
34
|
+
s.add_development_dependency 'rspec-rails', '~> 3'
|
|
35
|
+
s.add_development_dependency 'rspec-collection_matchers', '~> 1'
|
|
36
|
+
s.add_development_dependency 'factory_girl_rails', '~> 4.4'
|
|
37
|
+
s.add_development_dependency 'database_cleaner', '~> 1.3'
|
|
38
|
+
s.add_development_dependency 'ffaker', '~> 1.23'
|
|
39
|
+
s.add_development_dependency 'capybara', '~> 2.3'
|
|
40
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Helena
|
|
2
|
+
class VersionPublisher
|
|
3
|
+
def self.publish(version)
|
|
4
|
+
copied_version = version.dup
|
|
5
|
+
copied_version.survey = version.survey
|
|
6
|
+
copied_version.version = newest_version_of(version.survey) + 1
|
|
7
|
+
copied_version.created_at = DateTime.now
|
|
8
|
+
copied_version.updated_at = DateTime.now
|
|
9
|
+
copied_version
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.newest_version_of(survey)
|
|
13
|
+
survey.newest_version.version
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
data/lib/helena.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<%%= simple_form_for(@<%= singular_table_name %>) do |f| %>
|
|
2
|
+
<%%= f.error_notification %>
|
|
3
|
+
|
|
4
|
+
<div class="form-inputs">
|
|
5
|
+
<%- attributes.each do |attribute| -%>
|
|
6
|
+
<%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
|
|
7
|
+
<%- end -%>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div class="form-actions">
|
|
11
|
+
<%%= f.button :submit %>
|
|
12
|
+
</div>
|
|
13
|
+
<%% end %>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Helena::Admin::QuestionGroupsController do
|
|
4
|
+
routes { Helena::Engine.routes }
|
|
5
|
+
|
|
6
|
+
let!(:survey) { create :survey }
|
|
7
|
+
let!(:draft_version) { create :version, version: 0, survey: survey }
|
|
8
|
+
let!(:first_question_group) { create :question_group, position: 1, version: draft_version }
|
|
9
|
+
let!(:second_question_group) { create :question_group, position: 2, version: draft_version }
|
|
10
|
+
let!(:third_question_group) { create :question_group, position: 3, version: draft_version }
|
|
11
|
+
|
|
12
|
+
it 'moves a question group down with resort' do
|
|
13
|
+
patch :move_down, survey_id: survey, id: first_question_group
|
|
14
|
+
|
|
15
|
+
expect(first_question_group.reload.position).to eq 2
|
|
16
|
+
expect(second_question_group.reload.position).to eq 1
|
|
17
|
+
expect(third_question_group.reload.position).to eq 3
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'moves a question group up with resort' do
|
|
21
|
+
patch :move_up, survey_id: survey, id: third_question_group
|
|
22
|
+
|
|
23
|
+
expect(first_question_group.reload.position).to eq 1
|
|
24
|
+
expect(second_question_group.reload.position).to eq 3
|
|
25
|
+
expect(third_question_group.reload.position).to eq 2
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'does not moves a question group down when already the first with resort' do
|
|
29
|
+
patch :move_down, survey_id: survey, id: third_question_group
|
|
30
|
+
|
|
31
|
+
expect(first_question_group.reload.position).to eq 1
|
|
32
|
+
expect(second_question_group.reload.position).to eq 2
|
|
33
|
+
expect(third_question_group.reload.position).to eq 3
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'does not moves a question group up when already the first with resort' do
|
|
37
|
+
patch :move_up, survey_id: survey, id: first_question_group
|
|
38
|
+
|
|
39
|
+
expect(first_question_group.reload.position).to eq 1
|
|
40
|
+
expect(second_question_group.reload.position).to eq 2
|
|
41
|
+
expect(third_question_group.reload.position).to eq 3
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'resort after deleting a question group' do
|
|
45
|
+
delete :destroy, survey_id: survey, id: first_question_group
|
|
46
|
+
# Note: first is destroyed, the others moving along so second_question_group becomes first_question_group and so on.
|
|
47
|
+
expect(first_question_group.reload.position).to eq 1
|
|
48
|
+
expect(second_question_group.reload.position).to eq 2
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'counts position up when creating a new survey' do
|
|
52
|
+
post :create, survey_id: survey, question_group: { title: 'something' }
|
|
53
|
+
|
|
54
|
+
expect(first_question_group.reload.position).to eq 1
|
|
55
|
+
expect(second_question_group.reload.position).to eq 2
|
|
56
|
+
expect(third_question_group.reload.position).to eq 3
|
|
57
|
+
expect(draft_version.reload.question_groups.last.position).to eq 4
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Helena::Admin::QuestionsController do
|
|
4
|
+
routes { Helena::Engine.routes }
|
|
5
|
+
|
|
6
|
+
let(:survey) { create :survey }
|
|
7
|
+
let(:draft_version) { create :version, survey: survey, version: 0 }
|
|
8
|
+
let(:question_group) { create :question_group, version: draft_version }
|
|
9
|
+
let!(:first_question) { create :question, position: 1, question_group: question_group }
|
|
10
|
+
let!(:second_question) { create :question, position: 2, question_group: question_group }
|
|
11
|
+
let!(:third_question) { create :question, position: 3, question_group: question_group }
|
|
12
|
+
|
|
13
|
+
it 'moves a question down with resort' do
|
|
14
|
+
patch :move_down, survey_id: survey, question_group_id: question_group, id: first_question
|
|
15
|
+
|
|
16
|
+
expect(first_question.reload.position).to eq 2
|
|
17
|
+
expect(second_question.reload.position).to eq 1
|
|
18
|
+
expect(third_question.reload.position).to eq 3
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'moves a question up with resort' do
|
|
22
|
+
patch :move_up, survey_id: survey, question_group_id: question_group, id: third_question
|
|
23
|
+
|
|
24
|
+
expect(first_question.reload.position).to eq 1
|
|
25
|
+
expect(second_question.reload.position).to eq 3
|
|
26
|
+
expect(third_question.reload.position).to eq 2
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'does not moves a question down when already the first with resort' do
|
|
30
|
+
patch :move_down, survey_id: survey, question_group_id: question_group, id: third_question
|
|
31
|
+
|
|
32
|
+
expect(first_question.reload.position).to eq 1
|
|
33
|
+
expect(second_question.reload.position).to eq 2
|
|
34
|
+
expect(third_question.reload.position).to eq 3
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'does not moves a question up when already the first with resort' do
|
|
38
|
+
patch :move_up, survey_id: survey, question_group_id: question_group, id: first_question
|
|
39
|
+
|
|
40
|
+
expect(first_question.reload.position).to eq 1
|
|
41
|
+
expect(second_question.reload.position).to eq 2
|
|
42
|
+
expect(third_question.reload.position).to eq 3
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'resort after deleting a question' do
|
|
46
|
+
delete :destroy, survey_id: survey, question_group_id: question_group, id: first_question
|
|
47
|
+
# Note: first is destroyed, the others moving along so second_question_group becomes first_question_group and so on.
|
|
48
|
+
expect(first_question.reload.position).to eq 1
|
|
49
|
+
expect(second_question.reload.position).to eq 2
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'counts position up when creating a new survey' do
|
|
53
|
+
post :create, survey_id: survey, question_group_id: question_group, question: { question_text: 'something?', code: 'a38' }
|
|
54
|
+
|
|
55
|
+
expect(first_question.reload.position).to eq 1
|
|
56
|
+
expect(second_question.reload.position).to eq 2
|
|
57
|
+
expect(third_question.reload.position).to eq 3
|
|
58
|
+
expect(question_group.reload.questions.last.position).to eq 4
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Helena::Admin::SessionsController do
|
|
4
|
+
routes { Helena::Engine.routes }
|
|
5
|
+
|
|
6
|
+
let(:survey) { create :survey }
|
|
7
|
+
|
|
8
|
+
context 'without authorization' do
|
|
9
|
+
before { allow_any_instance_of(ApplicationController).to receive(:can_administer?).and_return false }
|
|
10
|
+
|
|
11
|
+
specify 'trying to list surveys throws an error' do
|
|
12
|
+
expect { get :index, survey_id: survey }.to raise_error(ActionController::RoutingError, 'Access Denied')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
specify 'trying to export surveys as json throws an error' do
|
|
16
|
+
expect { get :index, survey_id: survey, format: :json }.to raise_error(ActionController::RoutingError, 'Access Denied')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
specify 'trying to export surveys as csv throws an error' do
|
|
20
|
+
expect { get :index, survey_id: survey, format: :csv }.to raise_error(ActionController::RoutingError, 'Access Denied')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context 'with authorization' do
|
|
25
|
+
before do
|
|
26
|
+
create :session, survey: survey, answers: [
|
|
27
|
+
build(:string_answer, code: 'string_answer_1', value: 'abc'),
|
|
28
|
+
build(:integer_answer, code: 'integer_answer_1', value: '123')
|
|
29
|
+
]
|
|
30
|
+
create :session, survey: survey, answers: [
|
|
31
|
+
build(:string_answer, code: 'string_answer_2', value: 'def, xyz'),
|
|
32
|
+
build(:integer_answer, code: 'integer_answer_2', value: '456')
|
|
33
|
+
]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'return json result of all sessions' do
|
|
37
|
+
get :index, survey_id: survey, format: :json
|
|
38
|
+
|
|
39
|
+
first_result = ActiveSupport::JSON.decode(response.body).first
|
|
40
|
+
|
|
41
|
+
expect(first_result['answers'].first['code']).to eq 'string_answer_2'
|
|
42
|
+
expect(first_result['answers'].first['value']).to eq 'def, xyz'
|
|
43
|
+
expect(first_result['answers'].last['code']).to eq 'integer_answer_2'
|
|
44
|
+
expect(first_result['answers'].last['value']).to eq 456
|
|
45
|
+
|
|
46
|
+
last_result = ActiveSupport::JSON.decode(response.body).last
|
|
47
|
+
|
|
48
|
+
expect(last_result['answers'].first['code']).to eq 'string_answer_1'
|
|
49
|
+
expect(last_result['answers'].first['value']).to eq 'abc'
|
|
50
|
+
expect(last_result['answers'].last['code']).to eq 'integer_answer_1'
|
|
51
|
+
expect(last_result['answers'].last['value']).to eq 123
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'return csv result of all sessions' do
|
|
55
|
+
get :index, survey_id: survey, format: :csv
|
|
56
|
+
|
|
57
|
+
csv = CSV.parse(response.body)
|
|
58
|
+
%w(string_answer_2 integer_answer_2 string_answer_1 integer_answer_1).each do |code|
|
|
59
|
+
expect(csv.first).to include code
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
['456', 'def, xyz'].each do |value|
|
|
63
|
+
expect(csv[1]).to include value
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
%w(123 abc).each do |value|
|
|
67
|
+
expect(csv[2]).to include value
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
specify 'csv header for all sessions does not allow same column names for answers and session fields' do
|
|
72
|
+
create :session, survey: survey, answers: [
|
|
73
|
+
build(:boolean_answer, code: 'completed', value: true),
|
|
74
|
+
build(:string_answer, code: 'token', value: 'abcdefghijklmnopqrstuvwxyz')
|
|
75
|
+
]
|
|
76
|
+
get :index, survey_id: survey, format: :csv
|
|
77
|
+
|
|
78
|
+
csv = CSV.parse(response.body)
|
|
79
|
+
%w(answer_token answer_completed).each do |code|
|
|
80
|
+
expect(csv.first).to include code
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Helena::Admin::SurveysController do
|
|
4
|
+
routes { Helena::Engine.routes }
|
|
5
|
+
|
|
6
|
+
context 'without authorization' do
|
|
7
|
+
before { allow_any_instance_of(ApplicationController).to receive(:can_administer?).and_return false }
|
|
8
|
+
|
|
9
|
+
specify 'trying to list surveys throws an error' do
|
|
10
|
+
expect { get :index }.to raise_error(ActionController::RoutingError, 'Access Denied')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
specify 'trying to edit a survey throws an error' do
|
|
14
|
+
survey = create :survey
|
|
15
|
+
expect { get :edit, id: survey }.to raise_error(ActionController::RoutingError, 'Access Denied')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
specify 'trying to update a survey throws an error' do
|
|
19
|
+
survey = create :survey
|
|
20
|
+
expect { patch :update, id: survey }.to raise_error(ActionController::RoutingError, 'Access Denied')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
specify 'trying to delete a survey throws an error' do
|
|
24
|
+
survey = create :survey
|
|
25
|
+
expect { delete :destroy, id: survey }.to raise_error(ActionController::RoutingError, 'Access Denied')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
specify 'trying to add a survey throws an error' do
|
|
29
|
+
expect { get :new }.to raise_error(ActionController::RoutingError, 'Access Denied')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
specify 'trying to create a survey throws an error' do
|
|
33
|
+
expect { post :create, some: :data }.to raise_error(ActionController::RoutingError, 'Access Denied')
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
context 'with authorization' do
|
|
38
|
+
let!(:first_survey) { create :survey, position: 1, versions: [build(:base_version)] }
|
|
39
|
+
let!(:second_survey) { create :survey, position: 2, versions: [build(:base_version)] }
|
|
40
|
+
let!(:third_survey) { create :survey, position: 3, versions: [build(:base_version)] }
|
|
41
|
+
|
|
42
|
+
it 'moves a question group down with resort' do
|
|
43
|
+
patch :move_down, id: first_survey
|
|
44
|
+
expect(first_survey.reload.position).to eq 2
|
|
45
|
+
expect(second_survey.reload.position).to eq 1
|
|
46
|
+
expect(third_survey.reload.position).to eq 3
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'moves a question group up with resort' do
|
|
50
|
+
patch :move_up, id: third_survey
|
|
51
|
+
|
|
52
|
+
expect(first_survey.reload.position).to eq 1
|
|
53
|
+
expect(second_survey.reload.position).to eq 3
|
|
54
|
+
expect(third_survey.reload.position).to eq 2
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'does not moves a question group down when already the first with resort' do
|
|
58
|
+
patch :move_down, id: third_survey
|
|
59
|
+
|
|
60
|
+
expect(first_survey.reload.position).to eq 1
|
|
61
|
+
expect(second_survey.reload.position).to eq 2
|
|
62
|
+
expect(third_survey.reload.position).to eq 3
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'does not moves a question group up when already the first with resort' do
|
|
66
|
+
patch :move_up, id: first_survey
|
|
67
|
+
|
|
68
|
+
expect(first_survey.reload.position).to eq 1
|
|
69
|
+
expect(second_survey.reload.position).to eq 2
|
|
70
|
+
expect(third_survey.reload.position).to eq 3
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'resorts after deleting a question group' do
|
|
74
|
+
delete :destroy, id: first_survey
|
|
75
|
+
|
|
76
|
+
expect(second_survey.reload.position).to eq 1
|
|
77
|
+
expect(third_survey.reload.position).to eq 2
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it 'counts position up when creating a new survey' do
|
|
81
|
+
post :create, survey: { name: 'New Survey', language: 'en' }
|
|
82
|
+
|
|
83
|
+
expect(first_survey.reload.position).to eq 1
|
|
84
|
+
expect(second_survey.reload.position).to eq 2
|
|
85
|
+
expect(third_survey.reload.position).to eq 3
|
|
86
|
+
expect(Helena::Survey.find_by(name: 'New Survey').position).to eq 4
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Helena::SessionsController do
|
|
4
|
+
routes { Helena::Engine.routes }
|
|
5
|
+
|
|
6
|
+
let(:survey) { create :survey }
|
|
7
|
+
let(:session) do
|
|
8
|
+
baseversion = survey.versions.create version: 0
|
|
9
|
+
version = Helena::VersionPublisher.publish(baseversion)
|
|
10
|
+
version.save
|
|
11
|
+
create :session, survey: survey, version: version, answers: [
|
|
12
|
+
build(:string_answer, code: 'string_answer_1', value: 'abc'),
|
|
13
|
+
build(:integer_answer, code: 'integer_answer_1', value: '123')
|
|
14
|
+
]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'return json result of the current session' do
|
|
18
|
+
get :show, token: session.view_token, format: :json
|
|
19
|
+
|
|
20
|
+
result = ActiveSupport::JSON.decode(response.body)
|
|
21
|
+
expect(result['answer']['string_answer_1']).to eq 'abc'
|
|
22
|
+
expect(result['answer']['integer_answer_1']).to eq 123
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
!!!
|
|
2
|
+
%html
|
|
3
|
+
%head
|
|
4
|
+
%title= strip_tags(render_breadcrumbs separator: '/')
|
|
5
|
+
= stylesheet_link_tag 'helena/application', media: 'all'
|
|
6
|
+
= javascript_include_tag 'helena/application'
|
|
7
|
+
%meta{ name: 'viewport', content: 'initial-scale=1.0' }
|
|
8
|
+
= csrf_meta_tags
|
|
9
|
+
|
|
10
|
+
%body
|
|
11
|
+
.container
|
|
12
|
+
- flash.each do |name, messages|
|
|
13
|
+
%div{class: "alert alert-#{name == 'notice' ? 'success' : 'danger'}"}
|
|
14
|
+
- if messages.is_a?(String)
|
|
15
|
+
= messages
|
|
16
|
+
- else
|
|
17
|
+
%ul
|
|
18
|
+
- messages.each do |message|
|
|
19
|
+
%li= message
|
|
20
|
+
%h1.hidden
|
|
21
|
+
Helena
|
|
22
|
+
%ol.breadcrumb
|
|
23
|
+
= render_breadcrumbs tag: :li, separator: ''
|
|
24
|
+
= yield
|
data/spec/dummy/bin/rake
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
# Pick the frameworks you want:
|
|
4
|
+
require 'action_controller/railtie'
|
|
5
|
+
require 'action_mailer/railtie'
|
|
6
|
+
require 'sprockets/railtie'
|
|
7
|
+
require 'rails/mongoid'
|
|
8
|
+
|
|
9
|
+
Bundler.require(*Rails.groups)
|
|
10
|
+
require 'helena'
|
|
11
|
+
|
|
12
|
+
module Dummy
|
|
13
|
+
class Application < Rails::Application
|
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
15
|
+
# Application configuration should go into files in config/initializers
|
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
17
|
+
|
|
18
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
19
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
20
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
21
|
+
|
|
22
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
23
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
24
|
+
# config.i18n.default_locale = :de
|
|
25
|
+
config.i18n.enforce_available_locales = true
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Dummy::Application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
|
+
|
|
4
|
+
# In the development environment your application's code is reloaded on
|
|
5
|
+
# every request. This slows down response time but is perfect for development
|
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
|
7
|
+
config.cache_classes = false
|
|
8
|
+
|
|
9
|
+
# Do not eager load code on boot.
|
|
10
|
+
config.eager_load = false
|
|
11
|
+
|
|
12
|
+
# Show full error reports and disable caching.
|
|
13
|
+
config.consider_all_requests_local = true
|
|
14
|
+
config.action_controller.perform_caching = false
|
|
15
|
+
|
|
16
|
+
# Don't care if the mailer can't send.
|
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
|
18
|
+
|
|
19
|
+
# Print deprecation notices to the Rails logger.
|
|
20
|
+
config.active_support.deprecation = :log
|
|
21
|
+
|
|
22
|
+
# Raise an error on page load if there are pending migrations
|
|
23
|
+
# config.active_record.migration_error = :page_load
|
|
24
|
+
|
|
25
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
|
26
|
+
# This option may cause significant delays in view rendering with a large
|
|
27
|
+
# number of complex assets.
|
|
28
|
+
config.assets.debug = true
|
|
29
|
+
end
|