helena 1.0.0.rc1 → 1.0.0.rc2

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +171 -127
  4. data/README.md +1 -1
  5. data/app/controllers/helena/sessions_controller.rb +16 -17
  6. data/app/models/helena/label.rb +0 -1
  7. data/app/models/helena/question.rb +4 -9
  8. data/app/models/helena/questions/bipolar_radio_matrix.rb +6 -0
  9. data/app/models/helena/sub_question.rb +8 -1
  10. data/app/views/helena/questions/_bipolar_radio_matrix.html.haml +33 -0
  11. data/app/views/helena/questions/_checkbox_group.html.haml +1 -1
  12. data/app/views/helena/questions/_long_text.html.haml +1 -1
  13. data/app/views/helena/questions/_radio_group.html.haml +1 -1
  14. data/app/views/helena/questions/_radio_matrix.html.haml +6 -4
  15. data/app/views/helena/questions/_short_text.html.haml +1 -1
  16. data/app/views/helena/sessions/edit.html.slim +1 -1
  17. data/config/locales/en.yml +1 -2
  18. data/config/locales/models/question/en.yml +6 -2
  19. data/helena.gemspec +4 -3
  20. data/lib/helena/survey_importer.rb +4 -4
  21. data/lib/helena/version.rb +1 -1
  22. data/spec/controllers/helena/sessions_controller_spec.rb +15 -1
  23. data/spec/dummy/config/environments/test.rb +1 -1
  24. data/spec/dummy/config/routes.rb +0 -1
  25. data/spec/factories/helena/questions.rb +1 -0
  26. data/spec/factories/helena/sessions.rb +0 -1
  27. data/spec/features/helena/manage_session_spec.rb +38 -31
  28. data/spec/lib/survey_importer_spec.rb +4 -0
  29. data/spec/models/helena/answer_spec.rb +0 -2
  30. data/spec/models/helena/label_spec.rb +0 -2
  31. data/spec/models/helena/questions/bipolar_radio_matrix_spec.rb +39 -0
  32. data/spec/models/helena/sub_question_spec.rb +18 -0
  33. metadata +25 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99c25cfaf9b02dab3d017489cfee174c802b6049
4
- data.tar.gz: 26f27f12b6d08d631418cc7e7846f5b726f53c0a
3
+ metadata.gz: 390dd724977bdba8cd62758efcccd35fce495eee
4
+ data.tar.gz: e7ad85893364a0853ed95d85bbe94ab7d524dda1
5
5
  SHA512:
6
- metadata.gz: 61ac7c30e3374da1053c12c35c05825cb7b812fdc66c5ea3118f20cce9345616c2c1e07d260eedc0dc380a04b4b5f62180c1cf54723909fe17aca6d622d1bc39
7
- data.tar.gz: a7c729ae4775d4928e8934b4fef8fde8cc14e8fcf946522f22c8fbdb8b28d9ed4b05b3ec149f8e6326631c499b7aef39b80f90b8716f382c89fd7e024971fd4f
6
+ metadata.gz: 29c53f9f7e399ed5a64a41e93710de9f00c87da442ea194aaa0ce3d400043e202d0a0ef6a7cb46f161c27d82a92951481ed02af2e89ef8cd95fc5994daf2dca8
7
+ data.tar.gz: 7ad9e37117d15ab0f403d0d1df08fd59912a1ee60c23f2725cc20e25572e8c5277285bb54417d0e696e6ef50d880eade07b33c1fc8b2059e4a51f8b19bfc9259
data/Gemfile CHANGED
@@ -27,4 +27,5 @@ group :development, :test do
27
27
  gem 'bootstrap-sass'
28
28
  gem 'breadcrumbs_on_rails'
29
29
  gem 'coveralls', require: false
30
+ gem 'shoulda-matchers'
30
31
  end
data/Gemfile.lock CHANGED
@@ -1,152 +1,176 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- helena (1.0.0.rc1)
4
+ helena (1.0.0.rc2)
5
5
  bootstrap-sass (~> 3.2)
6
6
  breadcrumbs_on_rails (~> 2.3)
7
7
  haml-rails (~> 0.5)
8
8
  jquery-rails (~> 3.1)
9
- mongoid (~> 4.0.0.rc2)
9
+ mongoid (~> 4.0)
10
10
  mongoid-simple-tags (~> 0.1)
11
11
  mongoid_orderable (~> 4.1)
12
12
  rails (~> 4.1)
13
13
  rails-i18n (~> 4.0)
14
- sass-rails (~> 4.0.3)
14
+ responders (~> 2.0)
15
+ sass-rails (~> 5.0)
15
16
  simple_form (~> 3.1.0.rc2)
16
- slim (~> 2.1.0)
17
+ slim (~> 3.0)
17
18
 
18
19
  GEM
19
20
  remote: https://rubygems.org/
20
21
  specs:
21
- actionmailer (4.1.7)
22
- actionpack (= 4.1.7)
23
- actionview (= 4.1.7)
22
+ actionmailer (4.2.1)
23
+ actionpack (= 4.2.1)
24
+ actionview (= 4.2.1)
25
+ activejob (= 4.2.1)
24
26
  mail (~> 2.5, >= 2.5.4)
25
- actionpack (4.1.7)
26
- actionview (= 4.1.7)
27
- activesupport (= 4.1.7)
28
- rack (~> 1.5.2)
27
+ rails-dom-testing (~> 1.0, >= 1.0.5)
28
+ actionpack (4.2.1)
29
+ actionview (= 4.2.1)
30
+ activesupport (= 4.2.1)
31
+ rack (~> 1.6)
29
32
  rack-test (~> 0.6.2)
30
- actionview (4.1.7)
31
- activesupport (= 4.1.7)
33
+ rails-dom-testing (~> 1.0, >= 1.0.5)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
35
+ actionview (4.2.1)
36
+ activesupport (= 4.2.1)
32
37
  builder (~> 3.1)
33
38
  erubis (~> 2.7.0)
34
- activemodel (4.1.7)
35
- activesupport (= 4.1.7)
39
+ rails-dom-testing (~> 1.0, >= 1.0.5)
40
+ rails-html-sanitizer (~> 1.0, >= 1.0.1)
41
+ activejob (4.2.1)
42
+ activesupport (= 4.2.1)
43
+ globalid (>= 0.3.0)
44
+ activemodel (4.2.1)
45
+ activesupport (= 4.2.1)
36
46
  builder (~> 3.1)
37
- activerecord (4.1.7)
38
- activemodel (= 4.1.7)
39
- activesupport (= 4.1.7)
40
- arel (~> 5.0.0)
41
- activesupport (4.1.7)
42
- i18n (~> 0.6, >= 0.6.9)
47
+ activerecord (4.2.1)
48
+ activemodel (= 4.2.1)
49
+ activesupport (= 4.2.1)
50
+ arel (~> 6.0)
51
+ activesupport (4.2.1)
52
+ i18n (~> 0.7)
43
53
  json (~> 1.7, >= 1.7.7)
44
54
  minitest (~> 5.1)
45
- thread_safe (~> 0.1)
55
+ thread_safe (~> 0.3, >= 0.3.4)
46
56
  tzinfo (~> 1.1)
47
- addressable (2.3.6)
48
- arel (5.0.1.20140414130214)
49
- better_errors (2.0.0)
57
+ addressable (2.3.8)
58
+ arel (6.0.0)
59
+ autoprefixer-rails (5.1.10)
60
+ execjs
61
+ json
62
+ better_errors (2.1.1)
50
63
  coderay (>= 1.0.0)
51
64
  erubis (>= 2.6.6)
52
65
  rack (>= 0.9.0)
53
66
  binding_of_caller (0.7.2)
54
67
  debug_inspector (>= 0.0.1)
55
- bootstrap-sass (3.3.0.1)
56
- sass (~> 3.2)
68
+ bootstrap-sass (3.3.4.1)
69
+ autoprefixer-rails (>= 5.0.0.1)
70
+ sass (>= 3.2.19)
57
71
  breadcrumbs_on_rails (2.3.0)
58
72
  bson (2.3.0)
59
73
  builder (3.2.2)
60
- byebug (3.5.1)
61
- columnize (~> 0.8)
62
- debugger-linecache (~> 1.2)
63
- slop (~> 3.6)
74
+ byebug (4.0.5)
75
+ columnize (= 0.9.0)
64
76
  capybara (2.4.4)
65
77
  mime-types (>= 1.16)
66
78
  nokogiri (>= 1.3.3)
67
79
  rack (>= 1.0.0)
68
80
  rack-test (>= 0.5.4)
69
81
  xpath (~> 2.0)
70
- childprocess (0.5.5)
82
+ childprocess (0.5.6)
71
83
  ffi (~> 1.0, >= 1.0.11)
72
84
  coderay (1.1.0)
73
- columnize (0.8.9)
74
- connection_pool (2.0.0)
75
- coveralls (0.7.1)
76
- multi_json (~> 1.3)
77
- rest-client
78
- simplecov (>= 0.7)
79
- term-ansicolor
80
- thor
81
- database_cleaner (1.3.0)
85
+ columnize (0.9.0)
86
+ connection_pool (2.2.0)
87
+ coveralls (0.8.0)
88
+ multi_json (~> 1.10)
89
+ rest-client (>= 1.6.8, < 2)
90
+ simplecov (~> 0.9.1)
91
+ term-ansicolor (~> 1.3)
92
+ thor (~> 0.19.1)
93
+ database_cleaner (1.4.1)
82
94
  debug_inspector (0.0.2)
83
- debugger-linecache (1.2.0)
84
95
  diff-lcs (1.2.5)
85
96
  docile (1.1.5)
97
+ domain_name (0.5.24)
98
+ unf (>= 0.0.5, < 1.0.0)
86
99
  easy_translate (0.5.0)
87
100
  json
88
101
  thread
89
102
  thread_safe
90
103
  erubis (2.7.0)
104
+ execjs (2.5.2)
91
105
  factory_girl (4.5.0)
92
106
  activesupport (>= 3.0.0)
93
107
  factory_girl_rails (4.5.0)
94
108
  factory_girl (~> 4.5.0)
95
109
  railties (>= 3.0.0)
96
- ffaker (1.25.0)
97
- ffi (1.9.6)
98
- haml (4.0.5)
110
+ ffaker (1.32.1)
111
+ ffi (1.9.8)
112
+ globalid (0.3.5)
113
+ activesupport (>= 4.1.0)
114
+ haml (4.0.6)
99
115
  tilt
100
- haml-rails (0.5.3)
116
+ haml-rails (0.9.0)
101
117
  actionpack (>= 4.0.1)
102
118
  activesupport (>= 4.0.1)
103
- haml (>= 3.1, < 5.0)
119
+ haml (>= 4.0.6, < 5.0)
120
+ html2haml (>= 1.0.1)
104
121
  railties (>= 4.0.1)
105
- highline (1.6.21)
106
- hike (1.2.3)
107
- i18n (0.6.11)
108
- i18n-tasks (0.7.8)
122
+ highline (1.7.1)
123
+ html2haml (2.0.0)
124
+ erubis (~> 2.7.0)
125
+ haml (~> 4.0.0)
126
+ nokogiri (~> 1.6.0)
127
+ ruby_parser (~> 3.5)
128
+ http-cookie (1.0.2)
129
+ domain_name (~> 0.5)
130
+ i18n (0.7.0)
131
+ i18n-tasks (0.8.2)
109
132
  activesupport
110
133
  easy_translate (>= 0.5.0)
111
134
  erubis
112
135
  highline
113
136
  i18n
114
- slop (>= 3.5.0)
115
137
  term-ansicolor
116
138
  terminal-table
117
139
  jquery-rails (3.1.2)
118
140
  railties (>= 3.0, < 5.0)
119
141
  thor (>= 0.14, < 2.0)
120
- json (1.8.1)
142
+ json (1.8.2)
121
143
  launchy (2.4.3)
122
144
  addressable (~> 2.3)
145
+ loofah (2.0.1)
146
+ nokogiri (>= 1.5.9)
123
147
  mail (2.6.3)
124
148
  mime-types (>= 1.16, < 3)
125
149
  method_source (0.8.2)
126
150
  mime-types (2.4.3)
127
- mini_portile (0.6.1)
128
- minitest (5.4.2)
129
- mongoid (4.0.0)
151
+ mini_portile (0.6.2)
152
+ minitest (5.6.0)
153
+ mongoid (4.0.2)
130
154
  activemodel (~> 4.0)
131
155
  moped (~> 2.0.0)
132
156
  origin (~> 2.1)
133
157
  tzinfo (>= 0.3.37)
134
- mongoid-rspec (2.0.0.rc1)
158
+ mongoid-rspec (2.0.0)
135
159
  mongoid (~> 4.0.0)
136
160
  rake
137
- rspec (~> 3.0)
161
+ rspec (~> 3.1)
138
162
  mongoid-simple-tags (0.1.3)
139
163
  json (~> 1.8)
140
164
  mongoid (>= 3.0.3)
141
- mongoid_orderable (4.1.0)
165
+ mongoid_orderable (4.1.1)
142
166
  mongoid
143
- moped (2.0.1)
167
+ moped (2.0.4)
144
168
  bson (~> 2.2)
145
169
  connection_pool (~> 2.0)
146
170
  optionable (~> 0.2.0)
147
- multi_json (1.10.1)
148
- netrc (0.8.0)
149
- nokogiri (1.6.4.1)
171
+ multi_json (1.11.0)
172
+ netrc (0.10.3)
173
+ nokogiri (1.6.6.2)
150
174
  mini_portile (~> 0.6.0)
151
175
  optionable (0.2.0)
152
176
  origin (2.1.1)
@@ -154,104 +178,123 @@ GEM
154
178
  coderay (~> 1.1.0)
155
179
  method_source (~> 0.8.1)
156
180
  slop (~> 3.4)
157
- pry-byebug (2.0.0)
158
- byebug (~> 3.4)
181
+ pry-byebug (3.1.0)
182
+ byebug (~> 4.0)
159
183
  pry (~> 0.10)
160
- quiet_assets (1.0.3)
184
+ quiet_assets (1.1.0)
161
185
  railties (>= 3.1, < 5.0)
162
- rack (1.5.2)
163
- rack-test (0.6.2)
186
+ rack (1.6.0)
187
+ rack-test (0.6.3)
164
188
  rack (>= 1.0)
165
- rails (4.1.7)
166
- actionmailer (= 4.1.7)
167
- actionpack (= 4.1.7)
168
- actionview (= 4.1.7)
169
- activemodel (= 4.1.7)
170
- activerecord (= 4.1.7)
171
- activesupport (= 4.1.7)
189
+ rails (4.2.1)
190
+ actionmailer (= 4.2.1)
191
+ actionpack (= 4.2.1)
192
+ actionview (= 4.2.1)
193
+ activejob (= 4.2.1)
194
+ activemodel (= 4.2.1)
195
+ activerecord (= 4.2.1)
196
+ activesupport (= 4.2.1)
172
197
  bundler (>= 1.3.0, < 2.0)
173
- railties (= 4.1.7)
174
- sprockets-rails (~> 2.0)
175
- rails-i18n (4.0.3)
198
+ railties (= 4.2.1)
199
+ sprockets-rails
200
+ rails-deprecated_sanitizer (1.0.3)
201
+ activesupport (>= 4.2.0.alpha)
202
+ rails-dom-testing (1.0.6)
203
+ activesupport (>= 4.2.0.beta, < 5.0)
204
+ nokogiri (~> 1.6.0)
205
+ rails-deprecated_sanitizer (>= 1.0.1)
206
+ rails-html-sanitizer (1.0.2)
207
+ loofah (~> 2.0)
208
+ rails-i18n (4.0.4)
176
209
  i18n (~> 0.6)
177
210
  railties (~> 4.0)
178
- railties (4.1.7)
179
- actionpack (= 4.1.7)
180
- activesupport (= 4.1.7)
211
+ railties (4.2.1)
212
+ actionpack (= 4.2.1)
213
+ activesupport (= 4.2.1)
181
214
  rake (>= 0.8.7)
182
215
  thor (>= 0.18.1, < 2.0)
183
- rake (10.3.2)
184
- rest-client (1.7.2)
216
+ rake (10.4.2)
217
+ responders (2.1.0)
218
+ railties (>= 4.2.0, < 5)
219
+ rest-client (1.8.0)
220
+ http-cookie (>= 1.0.2, < 2.0)
185
221
  mime-types (>= 1.16, < 3.0)
186
222
  netrc (~> 0.7)
187
- rspec (3.1.0)
188
- rspec-core (~> 3.1.0)
189
- rspec-expectations (~> 3.1.0)
190
- rspec-mocks (~> 3.1.0)
191
- rspec-collection_matchers (1.0.0)
223
+ rspec (3.2.0)
224
+ rspec-core (~> 3.2.0)
225
+ rspec-expectations (~> 3.2.0)
226
+ rspec-mocks (~> 3.2.0)
227
+ rspec-collection_matchers (1.1.2)
192
228
  rspec-expectations (>= 2.99.0.beta1)
193
- rspec-core (3.1.7)
194
- rspec-support (~> 3.1.0)
195
- rspec-expectations (3.1.2)
229
+ rspec-core (3.2.3)
230
+ rspec-support (~> 3.2.0)
231
+ rspec-expectations (3.2.1)
196
232
  diff-lcs (>= 1.2.0, < 2.0)
197
- rspec-support (~> 3.1.0)
198
- rspec-mocks (3.1.3)
199
- rspec-support (~> 3.1.0)
200
- rspec-rails (3.1.0)
201
- actionpack (>= 3.0)
202
- activesupport (>= 3.0)
203
- railties (>= 3.0)
204
- rspec-core (~> 3.1.0)
205
- rspec-expectations (~> 3.1.0)
206
- rspec-mocks (~> 3.1.0)
207
- rspec-support (~> 3.1.0)
208
- rspec-support (3.1.2)
209
- ruby-progressbar (1.7.0)
210
- rubyzip (1.1.6)
211
- sass (3.2.19)
212
- sass-rails (4.0.4)
233
+ rspec-support (~> 3.2.0)
234
+ rspec-mocks (3.2.1)
235
+ diff-lcs (>= 1.2.0, < 2.0)
236
+ rspec-support (~> 3.2.0)
237
+ rspec-rails (3.2.1)
238
+ actionpack (>= 3.0, < 4.3)
239
+ activesupport (>= 3.0, < 4.3)
240
+ railties (>= 3.0, < 4.3)
241
+ rspec-core (~> 3.2.0)
242
+ rspec-expectations (~> 3.2.0)
243
+ rspec-mocks (~> 3.2.0)
244
+ rspec-support (~> 3.2.0)
245
+ rspec-support (3.2.2)
246
+ ruby-progressbar (1.7.5)
247
+ ruby_parser (3.6.6)
248
+ sexp_processor (~> 4.1)
249
+ rubyzip (1.1.7)
250
+ sass (3.4.13)
251
+ sass-rails (5.0.2)
213
252
  railties (>= 4.0.0, < 5.0)
214
- sass (~> 3.2.2)
215
- sprockets (~> 2.8, < 2.12)
216
- sprockets-rails (~> 2.0)
217
- selenium-webdriver (2.44.0)
253
+ sass (~> 3.1)
254
+ sprockets (>= 2.8, < 4.0)
255
+ sprockets-rails (>= 2.0, < 4.0)
256
+ tilt (~> 1.1)
257
+ selenium-webdriver (2.45.0)
218
258
  childprocess (~> 0.5)
219
259
  multi_json (~> 1.0)
220
260
  rubyzip (~> 1.0)
221
261
  websocket (~> 1.0)
222
- simple_form (3.1.0.rc2)
262
+ sexp_processor (4.5.0)
263
+ shoulda-matchers (2.8.0)
264
+ activesupport (>= 3.0.0)
265
+ simple_form (3.1.0)
223
266
  actionpack (~> 4.0)
224
267
  activemodel (~> 4.0)
225
- simplecov (0.9.1)
268
+ simplecov (0.9.2)
226
269
  docile (~> 1.1.0)
227
270
  multi_json (~> 1.0)
228
- simplecov-html (~> 0.8.0)
229
- simplecov-html (0.8.0)
230
- slim (2.1.0)
231
- temple (~> 0.6.9)
271
+ simplecov-html (~> 0.9.0)
272
+ simplecov-html (0.9.0)
273
+ slim (3.0.3)
274
+ temple (~> 0.7.3)
232
275
  tilt (>= 1.3.3, < 2.1)
233
276
  slop (3.6.0)
234
- sprockets (2.11.3)
235
- hike (~> 1.2)
236
- multi_json (~> 1.0)
277
+ sprockets (3.0.1)
237
278
  rack (~> 1.0)
238
- tilt (~> 1.1, != 1.3.0)
239
- sprockets-rails (2.2.0)
279
+ sprockets-rails (2.2.4)
240
280
  actionpack (>= 3.0)
241
281
  activesupport (>= 3.0)
242
282
  sprockets (>= 2.8, < 4.0)
243
- temple (0.6.10)
283
+ temple (0.7.5)
244
284
  term-ansicolor (1.3.0)
245
285
  tins (~> 1.0)
246
286
  terminal-table (1.4.5)
247
287
  thor (0.19.1)
248
- thread (0.1.4)
249
- thread_safe (0.3.4)
288
+ thread (0.2.0)
289
+ thread_safe (0.3.5)
250
290
  tilt (1.4.1)
251
- tins (1.3.3)
291
+ tins (1.3.5)
252
292
  tzinfo (1.2.2)
253
293
  thread_safe (~> 0.1)
254
- websocket (1.2.1)
294
+ unf (0.1.4)
295
+ unf_ext
296
+ unf_ext (0.0.7.1)
297
+ websocket (1.2.2)
255
298
  xpath (2.0.0)
256
299
  nokogiri (~> 1.3)
257
300
 
@@ -280,4 +323,5 @@ DEPENDENCIES
280
323
  rspec-rails (~> 3)
281
324
  ruby-progressbar
282
325
  selenium-webdriver
326
+ shoulda-matchers
283
327
  simple_form
data/README.md CHANGED
@@ -29,7 +29,7 @@ Add this line to your routes will and you will be good to go!
29
29
 
30
30
  mount Helena::Engine => '/helena'
31
31
 
32
- Since Version 1.0 the admin interface is no longer a part of the gem and was extracted to http://github.com/gurix/helena-admin.
32
+ Since Version 1.0 the admin interface is no longer a part of the gem and was extracted to http://github.com/gurix/helena_administration.
33
33
 
34
34
  ## TODOS
35
35
  * Support more question types, i.e Dates, Numeric inputs with validation, emails, ...
@@ -1,9 +1,10 @@
1
1
  module Helena
2
+ # TODO: Needs refactoring, is really ugly atm :-(
2
3
  class SessionsController < ApplicationController
3
- respond_to :html
4
-
5
- before_filter :load_session, only: [:edit, :update]
6
- after_filter :update_last_question_group_id, only: :update
4
+ before_action :load_session, only: [:edit, :update]
5
+ before_action :update_answers, only: :update
6
+ before_action :answer_errors, only: :update
7
+ after_action :update_last_question_group_id, only: :update
7
8
 
8
9
  def show
9
10
  @session = Helena::Session.find_by view_token: params[:token]
@@ -24,9 +25,6 @@ module Helena
24
25
  end
25
26
 
26
27
  def update
27
- @answers = update_answers
28
- @errors = answer_errors
29
-
30
28
  if @question_group.last? && @errors.blank?
31
29
  @session.update_attribute :completed, true
32
30
  render 'end_message'
@@ -43,6 +41,7 @@ module Helena
43
41
  @session = Helena::Session.find_by token: params[:token]
44
42
  @survey = @session.survey
45
43
  @version = @survey.versions.find @session.version_id
44
+ render text: 'Version not active', status: '404' unless @version && @version.active
46
45
  @question_group = question_group
47
46
  end
48
47
 
@@ -69,18 +68,18 @@ module Helena
69
68
  end
70
69
 
71
70
  def update_answers
72
- return session_answers unless session_params
73
-
74
- @question_group.question_codes.each do |question_code|
75
- @session.answers.where(code: question_code).delete
71
+ if session_params
72
+ @question_group.question_codes.each do |question_code|
73
+ @session.answers.where(code: question_code).delete
76
74
 
77
- value = session_params[:answers][question_code]
75
+ value = session_params[:answers][question_code]
78
76
 
79
- next if value.blank?
77
+ next if value.blank?
80
78
 
81
- @session.answers << Helena::Answer.build_generic(question_code, value, request.remote_ip)
79
+ @session.answers << Helena::Answer.build_generic(question_code, value, request.remote_ip)
80
+ end
82
81
  end
83
- session_answers
82
+ @answers = session_answers
84
83
  end
85
84
 
86
85
  def answer_errors
@@ -90,11 +89,11 @@ module Helena
90
89
  errors[question_code] = t("errors.messages.#{error_message}")
91
90
  end
92
91
  end
93
- errors
92
+ @errors = errors
94
93
  end
95
94
 
96
95
  def session_report
97
- Slim::Template.new { @version.session_report }.render.html_safe if @version.session_report
96
+ Slim::Template.new { @version.session_report }.render(self).html_safe if @version.session_report
98
97
  end
99
98
 
100
99
  def update_last_question_group_id
@@ -11,7 +11,6 @@ module Helena
11
11
 
12
12
  orderable
13
13
 
14
- validates :text, presence: true
15
14
  validates :value, presence: true
16
15
  validates :value, uniqueness: true
17
16
  end
@@ -3,21 +3,20 @@ module Helena
3
3
  include Helena::Concerns::ApplicationModel
4
4
  include Mongoid::Orderable
5
5
 
6
- CODE_FORMAT = /\A[a-z]([-\w]{,498}[a-z\d])?\Z/
7
-
8
6
  TYPES = [
9
7
  Helena::Questions::ShortText,
10
8
  Helena::Questions::LongText,
11
9
  Helena::Questions::StaticText,
12
10
  Helena::Questions::RadioGroup,
13
11
  Helena::Questions::CheckboxGroup,
14
- Helena::Questions::RadioMatrix
12
+ Helena::Questions::RadioMatrix,
13
+ Helena::Questions::BipolarRadioMatrix
15
14
  ]
16
15
 
17
16
  belongs_to :question_group, inverse_of: :questions
18
17
 
19
- embeds_many :labels, class_name: 'Helena::Label'
20
- embeds_many :sub_questions, class_name: 'Helena::SubQuestion'
18
+ embeds_many :labels, class_name: 'Helena::Label', cascade_callbacks: true
19
+ embeds_many :sub_questions, class_name: 'Helena::SubQuestion', cascade_callbacks: true
21
20
 
22
21
  accepts_nested_attributes_for :labels, allow_destroy: true, reject_if: :reject_labels
23
22
  accepts_nested_attributes_for :sub_questions, allow_destroy: true, reject_if: :reject_sub_questions
@@ -28,10 +27,6 @@ module Helena
28
27
  orderable scope: :question_group
29
28
 
30
29
  validates :code, presence: true
31
-
32
- # consist of lowercase characters or digits, not starting with a digit or underscore and not ending with an underscore
33
- # foo_32: correct, 32_foo: incorrect, _bar: incorrect, bar_: incorrect, FooBaar: incorrect
34
- validates :code, format: { with: CODE_FORMAT }
35
30
  validate :uniqueness_of_code
36
31
 
37
32
  def includes_labels?
@@ -0,0 +1,6 @@
1
+ module Helena
2
+ module Questions
3
+ class BipolarRadioMatrix < RadioMatrix
4
+ end
5
+ end
6
+ end
@@ -12,10 +12,17 @@ module Helena
12
12
 
13
13
  orderable
14
14
 
15
- validates :code, format: { with: Helena::Question::CODE_FORMAT }
16
15
  validate :uniqueness_of_code
17
16
  validates :text, presence: true, uniqueness: true
18
17
 
18
+ def splitted?
19
+ parts.size > 1
20
+ end
21
+
22
+ def parts
23
+ text.split '|'
24
+ end
25
+
19
26
  def uniqueness_of_code
20
27
  question_code_occurences = question.question_group.version.question_code_occurences
21
28
 
@@ -0,0 +1,33 @@
1
+ - label_width = "#{60 / question.labels.count}%"
2
+
3
+ .radio_matrix.form-group{ class: "#{'has-error' if errors.present?}" }
4
+ %label{class: "#{'text-danger' if errors.present?}"}
5
+ != question.question_text
6
+ = ' *' if question.required
7
+ .table-responsive
8
+ %table.table
9
+ %thead
10
+ %tr
11
+ %th
12
+ - question.labels.each do |label|
13
+ %th{ width: label_width }
14
+ = label.text
15
+ %th
16
+
17
+ %tbody
18
+ - question.sub_questions.each do |sub_question|
19
+ %tr
20
+ %td.text-right
21
+ = sub_question.parts.first
22
+ - if errors[sub_question.code]
23
+ .help-block.text-danger= errors[sub_question.code]
24
+ - question.labels.each do |label|
25
+ - checked = answers[sub_question.code].to_s == label.value.to_s if answers[sub_question.code].present?
26
+ - checked ||= (label.preselected? ? true : false)
27
+ %td{ width: label_width }
28
+ %label
29
+ = form.simple_fields_for :answers do |answer_form|
30
+ = answer_form.radio_button sub_question.code, label.value, checked: checked
31
+ %span.hide-text= label.text
32
+ %td
33
+ = sub_question.parts.last if sub_question.splitted?
@@ -1,6 +1,6 @@
1
1
  .checkbox_group.form-group{ class: "#{'has-error' if errors[question.code]}" }
2
2
  %label
3
- = question.question_text
3
+ != question.question_text
4
4
  = ' *' if question.required
5
5
  = form.simple_fields_for :answers do |answer_form|
6
6
  - question.sub_questions.each do |sub_question|
@@ -1,6 +1,6 @@
1
1
  .long_text.form-group{ class: "#{'has-error' if errors[question.code]}" }
2
2
  %label
3
- = question.question_text
3
+ != question.question_text
4
4
  = ' *' if question.required
5
5
  = form.simple_fields_for :answers do |answer_form|
6
6
  = answer_form.text_area question.code, value: answers[question.code], class: 'form-control'
@@ -1,6 +1,6 @@
1
1
  .radio_group.form-group{ class: "#{'has-error' if errors[question.code]}" }
2
2
  %label
3
- = question.question_text
3
+ != question.question_text
4
4
  = ' *' if question.required
5
5
  - question.labels.each do |label|
6
6
  .radio
@@ -1,6 +1,8 @@
1
+ - label_width = "#{80 / question.labels.count}%"
2
+
1
3
  .radio_matrix.form-group{ class: "#{'has-error' if errors.present?}" }
2
4
  %label{class: "#{'text-danger' if errors.present?}"}
3
- = question.question_text
5
+ != question.question_text
4
6
  = ' *' if question.required
5
7
  .table-responsive
6
8
  %table.table
@@ -8,19 +10,19 @@
8
10
  %tr
9
11
  %th
10
12
  - question.labels.each do |label|
11
- %th{ width: "#{80 / question.labels.count}%" }
13
+ %th{ width: label_width }
12
14
  = label.text
13
15
  %tbody
14
16
  - question.sub_questions.each do |sub_question|
15
17
  %tr
16
18
  %td
17
- = sub_question.text
19
+ = sub_question.parts.first
18
20
  - if errors[sub_question.code]
19
21
  .help-block.text-danger= errors[sub_question.code]
20
22
  - question.labels.each do |label|
21
23
  - checked = answers[sub_question.code].to_s == label.value.to_s if answers[sub_question.code].present?
22
24
  - checked ||= (label.preselected? ? true : false)
23
- %td{ width: "#{80 / question.labels.count}%" }
25
+ %td{ width: label_width }
24
26
  %label
25
27
  = form.simple_fields_for :answers do |answer_form|
26
28
  = answer_form.radio_button sub_question.code, label.value, checked: checked
@@ -1,6 +1,6 @@
1
1
  .short_text.form-group{ class: "#{'has-error' if errors[question.code]}" }
2
2
  %label
3
- = question.question_text
3
+ != question.question_text
4
4
  = ' *' if question.required
5
5
  = form.simple_fields_for :answers do |answer_form|
6
6
  = answer_form.text_field question.code, value: answers[question.code], class: 'form-control'
@@ -1,4 +1,4 @@
1
- = render 'progressbar' if @version.settings && @version.settings[:display_progressbar]
1
+ = render 'progressbar' if @version.settings && @version.settings[:display_progressbar] == "1"
2
2
  #survey_content
3
3
  h1.survey_title
4
4
  = @version.survey_detail.title
@@ -7,7 +7,7 @@ en:
7
7
  add: Add
8
8
  show: Show
9
9
  required: '* indicates required fields'
10
- code_hint: The code must consist only of lowercase letters, numbers and underscores. Don't begin with a digit or an underscore and don't end with an underscore.
10
+ code_hint: The code should consist only of lowercase letters, numbers and underscores. Don't begin with a digit or an underscore and don't end with an underscore.
11
11
  move_up: Move up
12
12
  move_down: Move down
13
13
  untitled: Untitled
@@ -17,4 +17,3 @@ en:
17
17
  updated: "'%{resource}' successfully updated"
18
18
  created: "'%{resource}' successfully created"
19
19
  error: Ooopss... something is wrong, please check your input
20
-
@@ -29,9 +29,13 @@ en:
29
29
  one: Radio Matrix
30
30
  other: Radio Matrice
31
31
 
32
+ 'helena/questions/bipolar_radio_matrix':
33
+ one: Bipolar Radio Matrix
34
+ other: Bipolar Radio Matrice
35
+
32
36
  'helena/questions/checkbox_matrix':
33
- one: Checkbox Matrix
34
- other: Checkbox Matrice
37
+ one: Checkbox Matrix
38
+ other: Checkbox Matrice
35
39
 
36
40
  attributes:
37
41
  'helena/question':
data/helena.gemspec CHANGED
@@ -20,17 +20,18 @@ survey/test development, longitudinal studies and instant feedback.'
20
20
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
21
21
 
22
22
  s.add_dependency 'rails', '~> 4.1'
23
- s.add_dependency 'mongoid', '~> 4.0.0.rc2'
23
+ s.add_dependency 'mongoid', '~> 4.0'
24
24
  s.add_dependency 'mongoid_orderable', '~> 4.1'
25
25
  s.add_dependency 'mongoid-simple-tags', '~> 0.1'
26
26
  s.add_dependency 'haml-rails', '~> 0.5'
27
- s.add_dependency 'slim', '~> 2.1.0'
27
+ s.add_dependency 'slim', '~> 3.0'
28
28
  s.add_dependency 'jquery-rails', '~> 3.1'
29
- 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 'sass-rails', '~> 5.0'
30
30
  s.add_dependency 'bootstrap-sass', '~> 3.2'
31
31
  s.add_dependency 'simple_form', '~> 3.1.0.rc2'
32
32
  s.add_dependency 'breadcrumbs_on_rails', '~> 2.3'
33
33
  s.add_dependency 'rails-i18n', '~> 4.0'
34
+ s.add_dependency 'responders', '~> 2.0'
34
35
 
35
36
  s.add_development_dependency 'rspec-rails', '~> 3'
36
37
  s.add_development_dependency 'rspec-collection_matchers', '~> 1'
@@ -14,7 +14,7 @@ module Helena
14
14
 
15
15
  def create_survey
16
16
  @survey = Helena::Survey.new @parsed.except('versions')
17
- return unless @survey.save
17
+ return unless @survey.save!
18
18
  return unless @parsed['versions']
19
19
  @parsed['versions'].each { |parsed_version| create_version parsed_version }
20
20
  end
@@ -22,7 +22,7 @@ module Helena
22
22
  def create_version(parsed_version)
23
23
  version = build_version(parsed_version)
24
24
 
25
- return unless version.save
25
+ return unless version.save!
26
26
  return unless parsed_version.last['question_groups']
27
27
  parsed_version.last['question_groups'].each { |parsed_question_group| create_question_group version, parsed_question_group }
28
28
  end
@@ -30,7 +30,7 @@ module Helena
30
30
  def create_question_group(version, parsed_question_group)
31
31
  question_group = version.question_groups.build parsed_question_group.last.except('questions')
32
32
  question_group.position = parsed_question_group.first
33
- return unless question_group.save
33
+ return unless question_group.save!
34
34
  return unless parsed_question_group.last['questions']
35
35
  parsed_question_group.last['questions'].each { |parsed_question| create_question question_group, parsed_question }
36
36
  end
@@ -38,7 +38,7 @@ module Helena
38
38
  def create_question(question_group, parsed_question)
39
39
  question = question_group.questions.build parsed_question.last
40
40
  question.position = parsed_question.first
41
- question.save
41
+ question.save!
42
42
  question
43
43
  end
44
44
 
@@ -1,3 +1,3 @@
1
1
  module Helena
2
- VERSION = '1.0.0.rc1'
2
+ VERSION = '1.0.0.rc2'
3
3
  end
@@ -4,7 +4,7 @@ describe Helena::SessionsController do
4
4
  routes { Helena::Engine.routes }
5
5
 
6
6
  let(:survey) { create :survey }
7
- let(:version) { survey.versions.create version: 0 }
7
+ let(:version) { survey.versions.create version: 0, question_groups: [build(:question_group)] }
8
8
  let(:session) do
9
9
  create :session, survey: survey, version: version, answers: [
10
10
  build(:string_answer, code: 'string_answer_1', value: 'abc'),
@@ -12,6 +12,20 @@ describe Helena::SessionsController do
12
12
  ]
13
13
  end
14
14
 
15
+ context 'version not active' do
16
+ before { version.update_attribute :active, false }
17
+
18
+ it 'raises not found when editing' do
19
+ get :edit, token: session.token
20
+ is_expected.to respond_with :not_found
21
+ end
22
+
23
+ it 'raises not found when updating' do
24
+ patch :update, token: session.token
25
+ is_expected.to respond_with :not_found
26
+ end
27
+ end
28
+
15
29
  it 'return json result of the current session' do
16
30
  get :show, token: session.view_token, format: :json
17
31
 
@@ -13,7 +13,7 @@ Dummy::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.serve_static_assets = true
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.
@@ -1,4 +1,3 @@
1
1
  Rails.application.routes.draw do
2
-
3
2
  mount Helena::Engine => '/helena'
4
3
  end
@@ -9,5 +9,6 @@ FactoryGirl.define do
9
9
  factory :radio_group_question, class: Helena::Questions::RadioGroup
10
10
  factory :checkbox_group_question, class: Helena::Questions::CheckboxGroup
11
11
  factory :radio_matrix_question, class: Helena::Questions::RadioMatrix
12
+ factory :bipolar_radio_matrix_question, class: Helena::Questions::BipolarRadioMatrix
12
13
  end
13
14
  end
@@ -4,6 +4,5 @@ FactoryGirl.define do
4
4
  end
5
5
 
6
6
  factory :session_without_token, class: Helena::Session do
7
-
8
7
  end
9
8
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  feature 'Session management' do
4
4
  let(:survey) { create :survey, name: 'dummy' }
5
- let(:base_version) { survey.versions.create version: 0 }
5
+ let(:base_version) { survey.versions.create version: 0, active: true }
6
6
  let!(:first_question_group) { base_version.question_groups.create title: 'Question Group 1' }
7
7
 
8
8
  background do
@@ -65,11 +65,10 @@ feature 'Session management' do
65
65
  position: 5)
66
66
 
67
67
  third_question_group.questions << satisfaction_matrix
68
- version = Helena::VersionPublisher.publish(base_version)
69
- version.settings = { display_progressbar: true }
70
- version.save
71
68
 
72
- session = survey.sessions.create version_id: version.id, token: 'abc'
69
+ base_version.update_attribute :settings, display_progressbar: '1'
70
+
71
+ session = survey.sessions.create version_id: base_version.id, token: 'abc'
73
72
 
74
73
  visit helena.edit_session_path(session.token)
75
74
 
@@ -114,7 +113,7 @@ feature 'Session management' do
114
113
  check('Oats')
115
114
  check('Meat')
116
115
 
117
- expect(page).to have_link 'Back', href: helena.edit_session_path(session.token, question_group: version.question_groups.find_by(position: 1))
116
+ expect(page).to have_link 'Back', href: helena.edit_session_path(session.token, question_group: base_version.question_groups.find_by(position: 1))
118
117
  expect { click_button 'Next' }.to change { session.reload.answers.count }.from(2).to(6)
119
118
  expect(session.reload.last_question_group_id).to eq third_question_group.id
120
119
 
@@ -147,7 +146,7 @@ feature 'Session management' do
147
146
  choose('session_answers_nothing_to_change_5')
148
147
  choose('session_answers_satisfied_with_life_7')
149
148
 
150
- expect(page).to have_link 'Back', href: helena.edit_session_path(session.token, question_group: version.question_groups.find_by(position: 2))
149
+ expect(page).to have_link 'Back', href: helena.edit_session_path(session.token, question_group: base_version.question_groups.find_by(position: 2))
151
150
  expect { click_button 'Save' }.to change { session.reload.answers.count }.from(6).to(11)
152
151
  end
153
152
 
@@ -171,10 +170,7 @@ feature 'Session management' do
171
170
  short_text_question = build :short_text_question, code: 'a_name', question_text: "What's your name?", required: true
172
171
  first_question_group.questions << short_text_question
173
172
 
174
- version = Helena::VersionPublisher.publish(base_version)
175
- version.save
176
-
177
- session = survey.sessions.create version_id: version.id, token: 'abc'
173
+ session = survey.sessions.create version_id: base_version.id, token: 'abc'
178
174
 
179
175
  visit helena.edit_session_path(session.token)
180
176
 
@@ -200,10 +196,7 @@ feature 'Session management' do
200
196
  long_text_question = build :long_text_question, code: 'selfdescription', question_text: 'Give a brief description of yourself', required: true
201
197
  first_question_group.questions << long_text_question
202
198
 
203
- version = Helena::VersionPublisher.publish(base_version)
204
- version.save
205
-
206
- session = survey.sessions.create version_id: version.id, token: 'abc'
199
+ session = survey.sessions.create version_id: base_version.id, token: 'abc'
207
200
 
208
201
  visit helena.edit_session_path(session.token)
209
202
 
@@ -224,15 +217,13 @@ feature 'Session management' do
224
217
 
225
218
  first_question_group.questions << all_and_everything
226
219
 
227
- version = Helena::VersionPublisher.publish(base_version)
228
- version.save
229
-
230
- session = survey.sessions.create version_id: version.id, token: 'abc'
220
+ session = survey.sessions.create version_id: base_version.id, token: 'abc'
231
221
 
232
222
  visit helena.edit_session_path(session.token)
233
223
 
234
224
  expect(page).to have_content 'What is the answer to the Ultimate Question of Life, the Universe, and Everything? *'
235
225
  expect { click_button 'Save' }.not_to change { session.reload.answers.count }
226
+
236
227
  expect(page).to have_content("can't be blank")
237
228
  end
238
229
 
@@ -247,10 +238,7 @@ feature 'Session management' do
247
238
 
248
239
  first_question_group.questions << food_allergy
249
240
 
250
- version = Helena::VersionPublisher.publish(base_version)
251
- version.save
252
-
253
- session = survey.sessions.create version_id: version.id, token: 'abc'
241
+ session = survey.sessions.create version_id: base_version.id, token: 'abc'
254
242
 
255
243
  visit helena.edit_session_path(session.token)
256
244
 
@@ -270,10 +258,7 @@ feature 'Session management' do
270
258
 
271
259
  first_question_group.questions << food_allergy
272
260
 
273
- version = Helena::VersionPublisher.publish(base_version)
274
- version.save
275
-
276
- session = survey.sessions.create version_id: version.id, token: 'abc'
261
+ session = survey.sessions.create version_id: base_version.id, token: 'abc'
277
262
 
278
263
  visit helena.edit_session_path(session.token)
279
264
 
@@ -304,10 +289,7 @@ feature 'Session management' do
304
289
 
305
290
  first_question_group.questions << satisfaction_matrix
306
291
 
307
- version = Helena::VersionPublisher.publish(base_version)
308
- version.save
309
-
310
- session = survey.sessions.create version_id: version.id, token: 'abc'
292
+ session = survey.sessions.create version_id: base_version.id, token: 'abc'
311
293
 
312
294
  visit helena.edit_session_path(session.token)
313
295
 
@@ -320,6 +302,31 @@ feature 'Session management' do
320
302
  expect(page).to have_content("can't be blank")
321
303
  end
322
304
 
305
+ scenario 'Displaying a bipolar radio matrix question"' do
306
+ radio_matrix = build :bipolar_radio_matrix_question, code: :satisfaction,
307
+ question_text: 'What do you like more?'
308
+
309
+ radio_matrix.labels << build(:label, value: 1, text: 'Yo')
310
+ radio_matrix.labels << build(:label, value: 2, text: "can't decide")
311
+ radio_matrix.labels << build(:label, value: 3, text: 'Yo')
312
+
313
+ radio_matrix.sub_questions << build(:sub_question, code: 'food', text: 'Ice cream|Cookies')
314
+ radio_matrix.sub_questions << build(:sub_question, code: 'drugs', text: 'Weed|Booze')
315
+ radio_matrix.sub_questions << build(:sub_question, code: 'pets', text: 'Cats|Dogs')
316
+ radio_matrix.sub_questions << build(:sub_question, code: 'not_splitted', text: 'I am not splitted')
317
+
318
+ first_question_group.questions << radio_matrix
319
+
320
+ session = survey.sessions.create version_id: base_version.id, token: 'abc'
321
+
322
+ visit helena.edit_session_path(session.token)
323
+
324
+ expect(page.all('table thead tr th').size).to eq 5
325
+ expect(page.find('table tbody tr:first td:first')).to have_content 'Ice cream'
326
+ expect(page.find('table tbody tr:last td:first')).to have_content 'I am not splitted'
327
+ expect(page.find('table tbody tr:last td:last').text).to be_empty
328
+ end
329
+
323
330
  scenario 'Allows to define whether a user an jump back for each question group seperately' do
324
331
  second_question_group = base_version.question_groups.create title: 'Question Group 2', allow_to_go_back: true
325
332
  base_version.question_groups.create title: 'Question Group 3', allow_to_go_back: false
@@ -9,6 +9,10 @@ describe Helena::SurveyImporter do
9
9
  expect(survey.versions.first).to have_exactly(1).question_groups
10
10
  expect(survey.versions.first.question_groups.first).to have_exactly(1).questions
11
11
  expect(survey.versions.first.question_groups.first.questions.first).to have_exactly(7).labels
12
+ expect(survey.versions.first.question_groups.first.questions.first.labels.first.position).to eq 1
13
+ expect(survey.versions.first.question_groups.first.questions.first.labels.last.position).to eq 7
12
14
  expect(survey.versions.first.question_groups.first.questions.first).to have_exactly(5).sub_questions
15
+ expect(survey.versions.first.question_groups.first.questions.first.sub_questions.first.position).to eq 1
16
+ expect(survey.versions.first.question_groups.first.questions.first.sub_questions.last.position).to eq 5
13
17
  end
14
18
  end
@@ -1,7 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Helena::Answer do
4
-
5
4
  let(:survey) { create :survey }
6
5
  let(:version) { build :version, survey: survey }
7
6
  let(:session) { create :session, survey: survey, version: version }
@@ -48,5 +47,4 @@ describe Helena::Answer do
48
47
  expect(Helena::Answer.build_generic('bla', 'false', '192.168.0.1')).to be_kind_of(Helena::BooleanAnswer)
49
48
  end
50
49
  end
51
-
52
50
  end
@@ -1,9 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Helena::Label do
4
-
5
4
  it { expect(subject).to be_embedded_in(:question) }
6
- it { expect(subject).to validate_presence_of(:text) }
7
5
  it { expect(subject).to validate_presence_of(:value) }
8
6
  it { expect(subject).to validate_uniqueness_of(:value) }
9
7
 
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Helena::Questions::BipolarRadioMatrix do
4
+ let!(:version) { create :version, survey: create(:survey) }
5
+
6
+ let(:question_group) { build :question_group, version: version }
7
+
8
+ it 'has a valid factory' do
9
+ expect(build :bipolar_radio_matrix_question, question_group: question_group).to be_valid
10
+ end
11
+
12
+ it 'validates uniquness of label preselection' do
13
+ question = create :bipolar_radio_matrix_question, question_group: question_group
14
+ question.labels << build(:label, preselected: true)
15
+ question.labels << build(:label, preselected: true)
16
+ expect(question).not_to be_valid
17
+ end
18
+
19
+ it 'does not validates uniquness of label preselection for no preselection' do
20
+ question = create :bipolar_radio_matrix_question, question_group: question_group
21
+ question.labels << build(:label, preselected: false)
22
+ question.labels << build(:label, preselected: false)
23
+ expect(question).to be_valid
24
+ end
25
+
26
+ it 'does not validates uniquness of label preselection for one preselection' do
27
+ question = create :bipolar_radio_matrix_question, question_group: question_group
28
+ question.labels << build(:label, preselected: false)
29
+ question.labels << build(:label, preselected: false)
30
+ expect(question).to be_valid
31
+ end
32
+
33
+ it 'indicates that it includes sub_questions and labels' do
34
+ question = build :bipolar_radio_matrix_question, question_group: question_group
35
+
36
+ expect(question.includes_subquestions?).to eq true
37
+ expect(question.includes_labels?).to eq true
38
+ end
39
+ end
@@ -25,4 +25,22 @@ describe Helena::SubQuestion do
25
25
  it 'has a valid factory' do
26
26
  expect(build :sub_question, question: question).to be_valid
27
27
  end
28
+
29
+ describe 'splitting the sub_question text with a vertical bar "|" i.e for pair comparisions' do
30
+ it 'recognize splitted sub questions' do
31
+ normal_sub_question = build :sub_question, question: question, text: 'just an ordinary subquestion'
32
+
33
+ expect(normal_sub_question.splitted?).to be false
34
+
35
+ splitted_sub_question = build :sub_question, question: question, text: 'i am|splitted'
36
+
37
+ expect(splitted_sub_question.splitted?).to be true
38
+ end
39
+
40
+ it 'returns correct parts' do
41
+ splitted_sub_question = build :sub_question, question: question, text: 'first|last'
42
+
43
+ expect(splitted_sub_question.parts).to eq %w(first last)
44
+ end
45
+ end
28
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helena
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Graf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-17 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 4.0.0.rc2
33
+ version: '4.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 4.0.0.rc2
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mongoid_orderable
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 2.1.0
89
+ version: '3.0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 2.1.0
96
+ version: '3.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: jquery-rails
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 4.0.3
117
+ version: '5.0'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 4.0.3
124
+ version: '5.0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: bootstrap-sass
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '4.0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: responders
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '2.0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '2.0'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: rspec-rails
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -302,6 +316,7 @@ files:
302
316
  - app/models/helena/label.rb
303
317
  - app/models/helena/question.rb
304
318
  - app/models/helena/question_group.rb
319
+ - app/models/helena/questions/bipolar_radio_matrix.rb
305
320
  - app/models/helena/questions/checkbox_group.rb
306
321
  - app/models/helena/questions/long_text.rb
307
322
  - app/models/helena/questions/radio_group.rb
@@ -314,6 +329,7 @@ files:
314
329
  - app/models/helena/survey.rb
315
330
  - app/models/helena/survey_detail.rb
316
331
  - app/models/helena/version.rb
332
+ - app/views/helena/questions/_bipolar_radio_matrix.html.haml
317
333
  - app/views/helena/questions/_checkbox_group.html.haml
318
334
  - app/views/helena/questions/_long_text.html.haml
319
335
  - app/views/helena/questions/_radio_group.html.haml
@@ -401,6 +417,7 @@ files:
401
417
  - spec/models/helena/label_spec.rb
402
418
  - spec/models/helena/question_group_spec.rb
403
419
  - spec/models/helena/question_spec.rb
420
+ - spec/models/helena/questions/bipolar_radio_matrix_spec.rb
404
421
  - spec/models/helena/questions/checkbox_group_spec.rb
405
422
  - spec/models/helena/questions/radio_group_spec.rb
406
423
  - spec/models/helena/questions/radio_matrix_spec.rb