helena_administration 0.0.2 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +5 -6
- data/Gemfile.lock +213 -157
- data/README.md +8 -7
- data/app/assets/stylesheets/helena_administration.css.sass +3 -2
- data/app/controllers/helena_administration/application_controller.rb +1 -7
- data/app/controllers/helena_administration/question_groups_controller.rb +2 -2
- data/app/controllers/helena_administration/questions/bipolar_radio_matrices_controller.rb +6 -0
- data/app/controllers/helena_administration/questions/{checkbox_matrix_controller.rb → checkbox_matrices_controller.rb} +1 -1
- data/app/controllers/helena_administration/questions/{radio_matrix_controller.rb → radio_matrices_controller.rb} +1 -1
- data/app/controllers/helena_administration/questions_controller.rb +4 -3
- data/app/controllers/helena_administration/sessions_controller.rb +46 -2
- data/app/controllers/helena_administration/versions_controller.rb +2 -2
- data/app/views/helena_administration/questions/_form.html.slim +1 -0
- data/config/routes.rb +3 -2
- data/helena_administration.gemspec +9 -6
- data/lib/helena_administration/version.rb +1 -1
- data/lib/helena_administration.rb +1 -1
- data/spec/controllers/dashboard_controller_spec.rb +1 -1
- data/spec/controllers/sessions_controller_spec.rb +69 -77
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/assets.rb +1 -1
- data/spec/features/dashboard/index.html.slim_spec.rb +1 -1
- data/spec/features/question_groups/manage_question_groups_spec.rb +1 -3
- data/spec/features/questions/manage_questions_spec.rb +6 -1
- data/spec/features/questions/question_types/manage_bipolar_radio_matrix_question_spec.rb +78 -0
- data/spec/features/questions/question_types/manage_checkbox_group_question_spec.rb +1 -1
- data/spec/features/questions/question_types/manage_long_text_question_spec.rb +1 -1
- data/spec/features/questions/question_types/manage_radio_group_question_spec.rb +1 -1
- data/spec/features/questions/question_types/manage_radio_matrix_question_spec.rb +1 -1
- data/spec/features/questions/question_types/manage_short_text_question_spec.rb +1 -1
- data/spec/features/questions/question_types/manage_static_text_question_spec.rb +1 -1
- data/spec/features/sessions/manage_sessions_spec.rb +3 -1
- data/spec/features/surveys/manage_survey_spec.rb +1 -1
- data/spec/features/versions/manage_version_spec.rb +1 -3
- data/spec/helpers/applicatin_helper_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -28
- metadata +48 -21
- data/spec/controllers/survey_controller_spec.rb +0 -36
- data/spec/dummy/app/decorators/controllers/helena_administration/application_controller_decorator.rb +0 -5
- data/spec/rails_helper.rb +0 -23
@@ -18,10 +18,11 @@ module HelenaAdministration
|
|
18
18
|
@question = @question_group.questions.build question_params
|
19
19
|
if @question.save
|
20
20
|
flash[:success] = t 'shared.actions.created'
|
21
|
+
respond_with @question, location: [@survey, @version, @question_group, @question]
|
21
22
|
else
|
22
|
-
flash
|
23
|
+
flash[:danger] = t 'shared.actions.error'
|
24
|
+
render 'new'
|
23
25
|
end
|
24
|
-
respond_with [@survey, @version, @question_group, @question]
|
25
26
|
end
|
26
27
|
|
27
28
|
def edit
|
@@ -78,7 +79,7 @@ module HelenaAdministration
|
|
78
79
|
end
|
79
80
|
|
80
81
|
def question_params
|
81
|
-
required_param.permit(permited_params + [:question_text, :code, :_type])
|
82
|
+
required_param.permit(permited_params + [:position, :question_text, :code, :_type])
|
82
83
|
end
|
83
84
|
|
84
85
|
def permited_params
|
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'csv'
|
1
2
|
module HelenaAdministration
|
2
3
|
class SessionsController < ApplicationController
|
3
|
-
|
4
|
+
include ActionController::Live
|
5
|
+
|
6
|
+
respond_to :html, :json, :csv
|
4
7
|
|
5
8
|
before_filter :load_survey, :add_breadcrumbs
|
6
9
|
before_filter :load_session, only: [:edit, :update, :destroy]
|
@@ -9,7 +12,9 @@ module HelenaAdministration
|
|
9
12
|
respond_to do |format|
|
10
13
|
@sessions = @survey.sessions.desc(:created_at)
|
11
14
|
format.json { render json: @sessions }
|
12
|
-
format.csv
|
15
|
+
format.csv do
|
16
|
+
render_csv
|
17
|
+
end
|
13
18
|
end
|
14
19
|
end
|
15
20
|
|
@@ -40,6 +45,29 @@ module HelenaAdministration
|
|
40
45
|
|
41
46
|
private
|
42
47
|
|
48
|
+
def render_csv
|
49
|
+
response.headers['Content-Disposition'] = "attachment; filename=#{@survey.name}.csv"
|
50
|
+
response.headers['Content-Type'] = 'text/csv'
|
51
|
+
|
52
|
+
# Write csv header once ...
|
53
|
+
response.stream.write CSV.generate_line(session_fields + question_codes)
|
54
|
+
|
55
|
+
# .. and generate a line for each session.
|
56
|
+
@sessions.each do |session|
|
57
|
+
response.stream.write CSV.generate_line(session_values(session) + answer_values(session, question_codes))
|
58
|
+
end
|
59
|
+
ensure
|
60
|
+
response.stream.close
|
61
|
+
end
|
62
|
+
|
63
|
+
def session_values(session)
|
64
|
+
session_fields.map { |field| session.attributes[field] }
|
65
|
+
end
|
66
|
+
|
67
|
+
def answer_values(session, answer_codes)
|
68
|
+
answer_codes.map { |code| session.answers.where(code: code).first.try(&:value) }
|
69
|
+
end
|
70
|
+
|
43
71
|
def add_breadcrumbs
|
44
72
|
add_breadcrumb t('shared.navigation.dashboard'), dashboard_index_path
|
45
73
|
add_breadcrumb Helena::Survey.model_name.human(count: 2), surveys_path
|
@@ -56,5 +84,21 @@ module HelenaAdministration
|
|
56
84
|
def session_params
|
57
85
|
params.require(:session).permit :token, :view_token, :answers_as_yaml, :completed, :last_question_group_id
|
58
86
|
end
|
87
|
+
|
88
|
+
def question_codes
|
89
|
+
@question_codes ||= unique_question_codes
|
90
|
+
end
|
91
|
+
|
92
|
+
# It could be possible that an answer code equals a session field. We add "answer_" in that case so that we get uniqe question codes for sure
|
93
|
+
def unique_question_codes
|
94
|
+
codes = @survey.versions.map(&:question_codes).flatten
|
95
|
+
codes.map do |code|
|
96
|
+
session_fields.include?(code) ? "answer_#{code}" : code
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def session_fields
|
101
|
+
Helena::Session.fields.keys
|
102
|
+
end
|
59
103
|
end
|
60
104
|
end
|
@@ -23,7 +23,7 @@ module HelenaAdministration
|
|
23
23
|
else
|
24
24
|
flash.now[:danger] = t 'shared.actions.error'
|
25
25
|
end
|
26
|
-
respond_with [@survey, @version]
|
26
|
+
respond_with @version, location: [@survey, @version]
|
27
27
|
end
|
28
28
|
|
29
29
|
def edit
|
@@ -38,7 +38,7 @@ module HelenaAdministration
|
|
38
38
|
flash.now[:danger] = t 'shared.actions.error'
|
39
39
|
add_breadcrumb t 'helena_administration.versions.version', version: @version.version
|
40
40
|
end
|
41
|
-
respond_with
|
41
|
+
respond_with @version, location: [:edit, @survey, @version]
|
42
42
|
end
|
43
43
|
|
44
44
|
def destroy
|
data/config/routes.rb
CHANGED
@@ -15,8 +15,9 @@ HelenaAdministration::Engine.routes.draw do
|
|
15
15
|
resources :static_texts, module: 'questions'
|
16
16
|
resources :radio_groups, module: 'questions'
|
17
17
|
resources :checkbox_groups, module: 'questions'
|
18
|
-
resources :
|
19
|
-
resources :
|
18
|
+
resources :radio_matrices, module: 'questions'
|
19
|
+
resources :bipolar_radio_matrices, module: 'questions'
|
20
|
+
resources :checkbox_matrices, module: 'questions'
|
20
21
|
end
|
21
22
|
end
|
22
23
|
end
|
@@ -18,20 +18,23 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
19
19
|
|
20
20
|
s.add_runtime_dependency 'kaminari', '~> 0.16'
|
21
|
-
s.add_runtime_dependency 'rails', '~> 4.
|
22
|
-
s.add_runtime_dependency 'slim-rails', '~>
|
23
|
-
s.add_runtime_dependency 'codemirror-rails', '~>
|
21
|
+
s.add_runtime_dependency 'rails', '~> 4.2'
|
22
|
+
s.add_runtime_dependency 'slim-rails', '~> 3.0'
|
23
|
+
s.add_runtime_dependency 'codemirror-rails', '~> 5'
|
24
24
|
s.add_dependency 'mongoid', '~> 4.0'
|
25
25
|
s.add_dependency 'mongoid_orderable', '~> 4.1'
|
26
26
|
s.add_dependency 'mongoid-simple-tags', '~> 0.1'
|
27
27
|
s.add_dependency 'haml-rails', '~> 0.5'
|
28
28
|
s.add_runtime_dependency 'html5-rails', '~> 0.1'
|
29
|
-
s.add_dependency 'jquery-rails', '~>
|
30
|
-
s.add_runtime_dependency 'sass-rails', '~>
|
29
|
+
s.add_dependency 'jquery-rails', '~> 4'
|
30
|
+
s.add_runtime_dependency 'sass-rails', '~> 5.0'
|
31
31
|
s.add_dependency 'bootstrap-sass', '~> 3.2'
|
32
32
|
s.add_dependency 'simple_form', '~> 3.1.0.rc2'
|
33
33
|
s.add_dependency 'breadcrumbs_on_rails', '~> 2.3'
|
34
34
|
s.add_dependency 'rails-i18n', '~> 4.0'
|
35
|
-
s.add_runtime_dependency 'font-awesome-
|
35
|
+
s.add_runtime_dependency 'font-awesome-sass', '~> 4.3.0'
|
36
36
|
s.add_runtime_dependency 'coffee-rails', '~> 4.1'
|
37
|
+
s.add_dependency 'responders', '~> 2.0'
|
38
|
+
|
39
|
+
s.add_development_dependency 'database_cleaner', '~> 1.3'
|
37
40
|
end
|
@@ -1,102 +1,94 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe HelenaAdministration::SessionsController do
|
4
4
|
routes { HelenaAdministration::Engine.routes }
|
5
5
|
|
6
6
|
let(:survey) { create :survey }
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
7
|
+
let(:version) { survey.versions.create version: 0 }
|
8
|
+
let(:question_group) { version.question_groups.create title: 'Abakadabara' }
|
9
|
+
|
10
|
+
before do
|
11
|
+
question_group.questions.create code: 'string_answer_1', question_text: 'Yo!', _type: Helena::Questions::LongText
|
12
|
+
question_group.questions.create code: 'integer_answer_1', question_text: 'Bo', _type: Helena::Questions::ShortText
|
13
|
+
|
14
|
+
question_group.questions.create code: 'string_answer_2', question_text: 'Hip', _type: Helena::Questions::LongText
|
15
|
+
question_group.questions.create code: 'integer_answer_2', question_text: 'Hop', _type: Helena::Questions::ShortText
|
16
|
+
|
17
|
+
create :session, survey: survey, answers: [
|
18
|
+
build(:string_answer, code: 'string_answer_1', value: 'abc'),
|
19
|
+
build(:integer_answer, code: 'integer_answer_1', value: '123')
|
20
|
+
]
|
21
|
+
create :session, survey: survey, answers: [
|
22
|
+
build(:string_answer, code: 'string_answer_2', value: 'def, xyz'),
|
23
|
+
build(:integer_answer, code: 'integer_answer_2', value: '456')
|
24
|
+
]
|
22
25
|
end
|
23
26
|
|
24
|
-
|
25
|
-
|
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
|
27
|
+
it 'return json result of all sessions' do
|
28
|
+
get :index, survey_id: survey, format: :json
|
38
29
|
|
39
|
-
|
30
|
+
first_result = ActiveSupport::JSON.decode(response.body).first
|
40
31
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
32
|
+
expect(first_result['answers'].first['code']).to eq 'string_answer_2'
|
33
|
+
expect(first_result['answers'].first['value']).to eq 'def, xyz'
|
34
|
+
expect(first_result['answers'].last['code']).to eq 'integer_answer_2'
|
35
|
+
expect(first_result['answers'].last['value']).to eq 456
|
45
36
|
|
46
|
-
|
37
|
+
last_result = ActiveSupport::JSON.decode(response.body).last
|
47
38
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
39
|
+
expect(last_result['answers'].first['code']).to eq 'string_answer_1'
|
40
|
+
expect(last_result['answers'].first['value']).to eq 'abc'
|
41
|
+
expect(last_result['answers'].last['code']).to eq 'integer_answer_1'
|
42
|
+
expect(last_result['answers'].last['value']).to eq 123
|
43
|
+
end
|
53
44
|
|
54
|
-
|
55
|
-
|
45
|
+
it 'return json result of all sessions' do
|
46
|
+
get :index, survey_id: survey, format: :json
|
56
47
|
|
57
|
-
|
48
|
+
first_result = ActiveSupport::JSON.decode(response.body).first
|
58
49
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
50
|
+
expect(first_result['answers'].first['code']).to eq 'string_answer_2'
|
51
|
+
expect(first_result['answers'].first['value']).to eq 'def, xyz'
|
52
|
+
expect(first_result['answers'].last['code']).to eq 'integer_answer_2'
|
53
|
+
expect(first_result['answers'].last['value']).to eq 456
|
63
54
|
|
64
|
-
|
55
|
+
last_result = ActiveSupport::JSON.decode(response.body).last
|
65
56
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
57
|
+
expect(last_result['answers'].first['code']).to eq 'string_answer_1'
|
58
|
+
expect(last_result['answers'].first['value']).to eq 'abc'
|
59
|
+
expect(last_result['answers'].last['code']).to eq 'integer_answer_1'
|
60
|
+
expect(last_result['answers'].last['value']).to eq 123
|
61
|
+
end
|
71
62
|
|
72
|
-
|
73
|
-
|
63
|
+
it 'return csv result of all sessions' do
|
64
|
+
get :index, survey_id: survey, format: :csv
|
74
65
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
66
|
+
csv = CSV.parse(response.body)
|
67
|
+
%w(string_answer_2 integer_answer_2 string_answer_1 integer_answer_1).each do |code|
|
68
|
+
expect(csv.first).to include code
|
69
|
+
end
|
79
70
|
|
80
|
-
|
81
|
-
|
82
|
-
|
71
|
+
['456', 'def, xyz'].each do |value|
|
72
|
+
expect(csv[1]).to include value
|
73
|
+
end
|
83
74
|
|
84
|
-
|
85
|
-
|
86
|
-
end
|
75
|
+
%w(123 abc).each do |value|
|
76
|
+
expect(csv[2]).to include value
|
87
77
|
end
|
78
|
+
end
|
88
79
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
80
|
+
specify 'csv header for all sessions does not allow same column names for answers and session fields' do
|
81
|
+
question_group.questions.create code: 'completed', question_text: 'Good', _type: Helena::Questions::LongText
|
82
|
+
question_group.questions.create code: 'token', question_text: 'Point', _type: Helena::Questions::ShortText
|
83
|
+
create :session, survey: survey, answers: [
|
84
|
+
build(:boolean_answer, code: 'completed', value: true),
|
85
|
+
build(:string_answer, code: 'token', value: 'abcdefghijklmnopqrstuvwxyz')
|
86
|
+
]
|
87
|
+
get :index, survey_id: survey, format: :csv
|
88
|
+
|
89
|
+
csv = CSV.parse(response.body)
|
90
|
+
%w(answer_token answer_completed).each do |code|
|
91
|
+
expect(csv.first).to include code
|
100
92
|
end
|
101
93
|
end
|
102
94
|
end
|
@@ -13,7 +13,7 @@ Rails.application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
config.
|
16
|
+
config.serve_static_files = true
|
17
17
|
config.static_cache_control = 'public, max-age=3600'
|
18
18
|
|
19
19
|
# Show full error reports and disable caching.
|
@@ -6,4 +6,4 @@ Rails.application.config.assets.version = '1.0'
|
|
6
6
|
# Precompile additional assets.
|
7
7
|
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
8
8
|
# Rails.application.config.assets.precompile += %w( search.js )
|
9
|
-
Rails.application.config.assets.precompile += %w( codemirror
|
9
|
+
Rails.application.config.assets.precompile += %w( codemirror* codemirror/**/* polyfills.js helena_administration.css )
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Question groups' do
|
4
|
-
|
5
4
|
let!(:survey) { create :survey }
|
6
5
|
let!(:version) { survey.versions.create version: 0 }
|
7
6
|
|
@@ -45,7 +44,6 @@ describe 'Question groups' do
|
|
45
44
|
|
46
45
|
expect(new_question_group.position).to eq 77
|
47
46
|
expect(new_question_group.title).to eq 'Foo Bar'
|
48
|
-
|
49
47
|
end
|
50
48
|
|
51
49
|
scenario 'User edits question_group' do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Questions' do
|
4
4
|
let!(:survey) { create :survey }
|
@@ -33,6 +33,7 @@ describe 'Questions' do
|
|
33
33
|
|
34
34
|
fill_in 'Code', with: 'a38'
|
35
35
|
fill_in 'Question text', with: 'Shall we go?'
|
36
|
+
fill_in 'Position', with: 32
|
36
37
|
|
37
38
|
within '.breadcrumbs' do
|
38
39
|
expect(page).to have_text 'New question'
|
@@ -47,6 +48,8 @@ describe 'Questions' do
|
|
47
48
|
fill_in 'Code', with: ''
|
48
49
|
|
49
50
|
expect { click_button 'Save' }.to change { question_group.reload.questions.count }.by(0)
|
51
|
+
|
52
|
+
expect(page).to have_content "can't be blank"
|
50
53
|
end
|
51
54
|
|
52
55
|
scenario 'edits a question' do
|
@@ -56,11 +59,13 @@ describe 'Questions' do
|
|
56
59
|
|
57
60
|
fill_in 'Question text', with: 'Are you sure?'
|
58
61
|
fill_in 'Code', with: 'b12'
|
62
|
+
fill_in 'Position', with: 42
|
59
63
|
|
60
64
|
click_button 'Save'
|
61
65
|
|
62
66
|
expect(question.reload.question_text).to eq 'Are you sure?'
|
63
67
|
expect(question.reload.code).to eq 'b12'
|
68
|
+
expect(question.reload.position).to eq 42
|
64
69
|
end
|
65
70
|
|
66
71
|
scenario 'edits a question errors when code text is empty' do
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Bipolar radio matrix question management' do
|
4
|
+
let!(:survey) { create :survey }
|
5
|
+
let!(:version) { survey.versions.create version: 0 }
|
6
|
+
let!(:question_group) { version.question_groups.create title: 'Abakadabara' }
|
7
|
+
let!(:question) { create :bipolar_radio_matrix_question, question_group: question_group }
|
8
|
+
|
9
|
+
scenario 'edits a question' do
|
10
|
+
question.labels.create text: 'Strongly disagree', value: '-1', position: 1
|
11
|
+
question.sub_questions.create code: 'aperto', text: 'Aperto Snacks', value: 'Aperto', position: 1
|
12
|
+
|
13
|
+
visit edit_survey_version_question_group_questions_bipolar_radio_matrix_path(survey, version, question_group, question)
|
14
|
+
|
15
|
+
check 'Required'
|
16
|
+
|
17
|
+
fill_in 'questions_bipolar_radio_matrix_labels_attributes_0_position', with: '2'
|
18
|
+
fill_in 'questions_bipolar_radio_matrix_labels_attributes_0_text', with: 'Strongly agree'
|
19
|
+
fill_in 'questions_bipolar_radio_matrix_labels_attributes_0_value', with: '1'
|
20
|
+
check 'questions_bipolar_radio_matrix_labels_attributes_0_preselected'
|
21
|
+
|
22
|
+
fill_in 'questions_bipolar_radio_matrix_sub_questions_attributes_0_position', with: '2'
|
23
|
+
fill_in 'questions_bipolar_radio_matrix_sub_questions_attributes_0_text', with: 'Avec Shop'
|
24
|
+
fill_in 'questions_bipolar_radio_matrix_sub_questions_attributes_0_code', with: 'avec'
|
25
|
+
|
26
|
+
click_button 'Save'
|
27
|
+
|
28
|
+
expect(question.reload.labels.first.position).to eq 2
|
29
|
+
expect(question.reload.labels.first.text).to eq 'Strongly agree'
|
30
|
+
expect(question.reload.labels.first.value).to eq '1'
|
31
|
+
expect(question.reload.labels.first.preselected).to eq true
|
32
|
+
|
33
|
+
expect(question.reload.sub_questions.first.position).to eq 2
|
34
|
+
expect(question.reload.sub_questions.first.text).to eq 'Avec Shop'
|
35
|
+
expect(question.reload.sub_questions.first.code).to eq 'avec'
|
36
|
+
|
37
|
+
expect(question.reload.required).to eq true
|
38
|
+
end
|
39
|
+
|
40
|
+
scenario 'adds a an option' do
|
41
|
+
visit edit_survey_version_question_group_questions_bipolar_radio_matrix_path(survey, version, question_group, question)
|
42
|
+
|
43
|
+
fill_in 'questions_bipolar_radio_matrix_labels_attributes_0_position', with: '2'
|
44
|
+
fill_in 'questions_bipolar_radio_matrix_labels_attributes_0_text', with: 'Strongly agree'
|
45
|
+
fill_in 'questions_bipolar_radio_matrix_labels_attributes_0_value', with: '1'
|
46
|
+
check 'questions_bipolar_radio_matrix_labels_attributes_0_preselected'
|
47
|
+
|
48
|
+
fill_in 'questions_bipolar_radio_matrix_sub_questions_attributes_0_position', with: '2'
|
49
|
+
fill_in 'questions_bipolar_radio_matrix_sub_questions_attributes_0_text', with: 'Avec Shop'
|
50
|
+
fill_in 'questions_bipolar_radio_matrix_sub_questions_attributes_0_code', with: 'avec'
|
51
|
+
|
52
|
+
click_button 'Save'
|
53
|
+
|
54
|
+
expect(question.reload.labels.first.position).to eq 2
|
55
|
+
expect(question.reload.labels.first.text).to eq 'Strongly agree'
|
56
|
+
expect(question.reload.labels.first.value).to eq '1'
|
57
|
+
expect(question.reload.labels.first.preselected).to eq true
|
58
|
+
|
59
|
+
expect(question.reload.sub_questions.first.position).to eq 2
|
60
|
+
expect(question.reload.sub_questions.first.text).to eq 'Avec Shop'
|
61
|
+
expect(question.reload.sub_questions.first.code).to eq 'avec'
|
62
|
+
end
|
63
|
+
|
64
|
+
scenario 'removes an option' do
|
65
|
+
question.labels.create text: 'Male', value: 'm', position: 1
|
66
|
+
question.sub_questions.create code: 'aperto', text: 'Aperto Snacks', value: 'Aperto', position: 1
|
67
|
+
|
68
|
+
visit edit_survey_version_question_group_questions_bipolar_radio_matrix_path(survey, version, question_group, question)
|
69
|
+
|
70
|
+
check 'questions_bipolar_radio_matrix_labels_attributes_0__destroy'
|
71
|
+
check 'questions_bipolar_radio_matrix_sub_questions_attributes_0__destroy'
|
72
|
+
|
73
|
+
click_button 'Save'
|
74
|
+
|
75
|
+
expect(question.reload.labels).to be_empty
|
76
|
+
expect(question.reload.sub_questions).to be_empty
|
77
|
+
end
|
78
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Sessions' do
|
4
4
|
let(:survey) { create :survey }
|
@@ -47,5 +47,7 @@ describe 'Sessions' do
|
|
47
47
|
expect(session.reload.answers.map(&:value)).to eq ['c', 4]
|
48
48
|
expect(session.reload.completed).to eq true
|
49
49
|
expect(session.reload.last_question_group_id).to eq second_question_group.id
|
50
|
+
|
51
|
+
expect(page).not_to have_content 'RuntimeError'
|
50
52
|
end
|
51
53
|
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Versions ' do
|
4
|
-
|
5
4
|
let!(:survey) { create :survey }
|
6
5
|
let!(:baseversion) { survey.versions.create version: 0 }
|
7
6
|
|
@@ -89,7 +88,6 @@ describe 'Versions ' do
|
|
89
88
|
within "##{dom_id(inactive_version)}" do
|
90
89
|
expect { click_link 'Delete' }.to change { survey.reload.versions.count }.by(-1)
|
91
90
|
end
|
92
|
-
|
93
91
|
end
|
94
92
|
|
95
93
|
scenario 'User can view version details' do
|