helena 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/.rubocop.yml +4 -0
  4. data/.travis.yml +5 -4
  5. data/Appraisals +12 -0
  6. data/Gemfile +8 -11
  7. data/Gemfile.lock +217 -200
  8. data/README.md +2 -3
  9. data/Rakefile +2 -0
  10. data/app/controllers/helena/sessions_controller.rb +2 -2
  11. data/app/models/helena/answer.rb +5 -3
  12. data/app/models/helena/concerns/application_model.rb +1 -1
  13. data/app/models/helena/question.rb +1 -1
  14. data/app/models/helena/question_group.rb +1 -1
  15. data/app/models/helena/questions/checkbox_group.rb +1 -1
  16. data/app/models/helena/session.rb +3 -3
  17. data/app/models/helena/version.rb +1 -1
  18. data/config/initializers/simple_form_bootstrap.rb +1 -1
  19. data/db/seeds.rb +7 -6
  20. data/gemfiles/rails_4.2.gemfile +22 -0
  21. data/gemfiles/rails_4.2.gemfile.lock +295 -0
  22. data/gemfiles/rails_5.1.gemfile +24 -0
  23. data/gemfiles/rails_5.1.gemfile.lock +305 -0
  24. data/helena.gemspec +7 -7
  25. data/lib/helena/engine.rb +2 -2
  26. data/lib/helena/survey_importer.rb +1 -1
  27. data/lib/helena/version.rb +1 -1
  28. data/lib/helena/version_publisher.rb +2 -2
  29. data/spec/controllers/helena/sessions_controller_spec.rb +5 -5
  30. data/spec/dummy/app/views/layouts/application.html.haml +1 -3
  31. data/spec/dummy/bin/rails +1 -1
  32. data/spec/dummy/config/environments/development.rb +2 -0
  33. data/spec/dummy/config/environments/test.rb +0 -4
  34. data/spec/dummy/config.ru +1 -1
  35. data/spec/factories/helena/answers.rb +7 -7
  36. data/spec/factories/helena/labels.rb +3 -2
  37. data/spec/factories/helena/question_groups.rb +3 -2
  38. data/spec/factories/helena/questions.rb +3 -2
  39. data/spec/factories/helena/sessions.rb +6 -2
  40. data/spec/factories/helena/sub_questions.rb +3 -2
  41. data/spec/factories/helena/survey_details.rb +4 -3
  42. data/spec/factories/helena/surveys.rb +2 -2
  43. data/spec/factories/helena/versions.rb +3 -1
  44. data/spec/features/helena/manage_session_spec.rb +5 -5
  45. data/spec/lib/version_publisher_spec.rb +1 -1
  46. data/spec/models/helena/answer_spec.rb +1 -1
  47. data/spec/models/helena/label_spec.rb +1 -1
  48. data/spec/models/helena/question_group_spec.rb +1 -1
  49. data/spec/models/helena/question_spec.rb +1 -1
  50. data/spec/models/helena/questions/bipolar_radio_matrix_spec.rb +1 -1
  51. data/spec/models/helena/questions/checkbox_group_spec.rb +1 -1
  52. data/spec/models/helena/questions/radio_group_spec.rb +1 -1
  53. data/spec/models/helena/questions/radio_matrix_spec.rb +1 -1
  54. data/spec/models/helena/questions/short_text_spec.rb +1 -1
  55. data/spec/models/helena/session_spec.rb +3 -3
  56. data/spec/models/helena/sub_question_spec.rb +1 -1
  57. data/spec/models/helena/survey_spec.rb +1 -1
  58. data/spec/models/helena/version_spec.rb +1 -1
  59. data/spec/spec_helper.rb +4 -7
  60. data/spec/support/rails_compatibility.rb +4 -0
  61. metadata +38 -39
@@ -4,7 +4,7 @@ module Helena
4
4
 
5
5
  field :code, type: String
6
6
  field :ip_address, type: String
7
- field :created_at, type: DateTime, default: -> { DateTime.now }
7
+ field :created_at, type: DateTime, default: -> { Time.now }
8
8
 
9
9
  embedded_in :session, inverse_of: :answers
10
10
 
@@ -17,7 +17,7 @@ module Helena
17
17
 
18
18
  def self.answer_class_for(value)
19
19
  case value
20
- when Fixnum
20
+ when Integer
21
21
  Helena::IntegerAnswer
22
22
  when TrueClass
23
23
  Helena::BooleanAnswer
@@ -41,7 +41,9 @@ module Helena
41
41
  end
42
42
 
43
43
  def self.integer?(str)
44
- Integer(str) rescue false
44
+ Integer(str)
45
+ rescue StandardError
46
+ false
45
47
  end
46
48
  end
47
49
  end
@@ -1,6 +1,6 @@
1
1
  module Helena
2
2
  module Concerns
3
- module ApplicationModel
3
+ module ApplicationModel
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  include Mongoid::Document
@@ -11,7 +11,7 @@ module Helena
11
11
  Helena::Questions::CheckboxGroup,
12
12
  Helena::Questions::RadioMatrix,
13
13
  Helena::Questions::BipolarRadioMatrix
14
- ]
14
+ ].freeze
15
15
 
16
16
  belongs_to :question_group, inverse_of: :questions
17
17
 
@@ -5,7 +5,7 @@ module Helena
5
5
 
6
6
  belongs_to :version
7
7
 
8
- has_many :questions, inverse_of: :question_group, class_name: 'Helena::Question', dependent: :destroy, autosave: true
8
+ has_many :questions, inverse_of: :question_group, class_name: 'Helena::Question', dependent: :destroy, autosave: true
9
9
 
10
10
  orderable scope: :version
11
11
 
@@ -9,7 +9,7 @@ module Helena
9
9
 
10
10
  def validate_answers_in(answers)
11
11
  errors = {}
12
- errors[code] = :blank if sub_questions.map { |sub_question| answers[sub_question.code] == 0 }.all? && required
12
+ errors[code] = :blank if sub_questions.map { |sub_question| answers[sub_question.code].zero? }.all? && required
13
13
  errors
14
14
  end
15
15
  end
@@ -24,7 +24,7 @@ module Helena
24
24
  end
25
25
 
26
26
  def answers_as_yaml=(yaml)
27
- parsed_answers = YAML.load yaml
27
+ parsed_answers = YAML.safe_load yaml
28
28
  update_answers parsed_answers
29
29
  remove_unparsed_answers parsed_answers
30
30
  end
@@ -46,8 +46,6 @@ module Helena
46
46
  Hash[*answers.map { |answer| [answer[:code], answer[:value]] }.flatten]
47
47
  end
48
48
 
49
- private
50
-
51
49
  def self.answer_codes
52
50
  answer_codes = []
53
51
  all.each do |session|
@@ -56,6 +54,8 @@ module Helena
56
54
  answer_codes
57
55
  end
58
56
 
57
+ private
58
+
59
59
  def generate_token(size)
60
60
  SecureRandom.base64(size).delete('/+=')[0, size]
61
61
  end
@@ -12,7 +12,7 @@ module Helena
12
12
 
13
13
  belongs_to :survey
14
14
 
15
- has_many :question_groups, inverse_of: :version, dependent: :destroy, class_name: 'Helena::QuestionGroup', autosave: true
15
+ has_many :question_groups, inverse_of: :version, dependent: :destroy, class_name: 'Helena::QuestionGroup', autosave: true
16
16
  has_many :sessions, inverse_of: :version, dependent: :destroy, class_name: 'Helena::Session'
17
17
 
18
18
  embeds_one :survey_detail, class_name: 'Helena::SurveyDetail'
@@ -1,5 +1,5 @@
1
1
  # Use this setup block to configure all options available in SimpleForm.
2
- SimpleForm.setup do |config|
2
+ SimpleForm.setup do |config| # rubocop:disable Metrics/BlockLength
3
3
  config.error_notification_class = 'alert alert-danger'
4
4
  config.button_class = 'btn btn-default'
5
5
  config.boolean_label_class = nil
data/db/seeds.rb CHANGED
@@ -1,8 +1,8 @@
1
- require 'factory_girl'
1
+ require 'factory_bot'
2
2
  require 'faker'
3
3
  require 'helena/survey_importer'
4
4
 
5
- include FactoryGirl::Syntax::Methods
5
+ include FactoryBot::Syntax::Methods
6
6
 
7
7
  puts 'Cleaning database ...'
8
8
  Mongoid.purge!
@@ -20,18 +20,19 @@ def publish(version)
20
20
  published_version.save
21
21
  published_version
22
22
  end
23
+
23
24
  # rubocop:disable Metrics/MethodLength
24
25
  def generate_sessions(survey, version)
25
- 3.times { survey.sessions << build(:session, version: version, updated_at: DateTime.now - rand(999), completed: false) }
26
+ 3.times { survey.sessions << build(:session, version: version, updated_at: Time.now - rand(999), completed: false) }
26
27
 
27
28
  3.times do
28
- session = build :session, version: version, updated_at: DateTime.now - rand(999), completed: true
29
+ session = build :session, version: version, updated_at: Time.now - rand(999), completed: true
29
30
  version.question_groups.map(&:questions).flatten.each do |question|
30
31
  case question
31
32
  when Helena::Questions::ShortText
32
- session.answers << build(:string_answer, code: question.code, value: Faker::Skill.tech_skill)
33
+ session.answers << build(:string_answer, code: question.code, value: Faker::Lorem.word)
33
34
  when Helena::Questions::LongText
34
- session.answers << build(:string_answer, code: question.code, value: Faker::Skill.tech_skill)
35
+ session.answers << build(:string_answer, code: question.code, value: Faker::Lorem.word)
35
36
  when Helena::Questions::RadioGroup
36
37
  session.answers << Helena::Answer.build_generic(question.code, question.labels.sample.value, Faker::Internet.ip_v4_address)
37
38
  when Helena::Questions::CheckboxGroup
@@ -0,0 +1,22 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", " ~> 4.2"
6
+ gem "mongoid-rspec", :group => [:development, :test]
7
+
8
+ group :development, :test do
9
+ gem "pry"
10
+ gem "pry-byebug"
11
+ gem "ruby-progressbar"
12
+ gem "better_errors"
13
+ gem "launchy"
14
+ gem "binding_of_caller"
15
+ gem "selenium-webdriver"
16
+ gem "simple_form"
17
+ gem "jquery-rails"
18
+ gem "bootstrap-sass"
19
+ gem "shoulda-matchers"
20
+ end
21
+
22
+ gemspec :path => "../"
@@ -0,0 +1,295 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ helena (1.3.0)
5
+ bootstrap-sass (~> 3.2)
6
+ browser (~> 2.0)
7
+ haml-rails (~> 1.0)
8
+ jquery-rails (~> 4.0)
9
+ mongoid (>= 4.0)
10
+ mongoid-simple-tags (~> 0.1)
11
+ mongoid-tree (~> 2.0)
12
+ mongoid_orderable (~> 4.1)
13
+ rails (>= 4.2)
14
+ rails-i18n (>= 4.0)
15
+ responders (~> 2.0)
16
+ sass-rails (~> 5.0)
17
+ simple_form (~> 3.2)
18
+ slim (~> 3.0)
19
+
20
+ GEM
21
+ remote: https://rubygems.org/
22
+ specs:
23
+ actionmailer (4.2.10)
24
+ actionpack (= 4.2.10)
25
+ actionview (= 4.2.10)
26
+ activejob (= 4.2.10)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 1.0, >= 1.0.5)
29
+ actionpack (4.2.10)
30
+ actionview (= 4.2.10)
31
+ activesupport (= 4.2.10)
32
+ rack (~> 1.6)
33
+ rack-test (~> 0.6.2)
34
+ rails-dom-testing (~> 1.0, >= 1.0.5)
35
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
36
+ actionview (4.2.10)
37
+ activesupport (= 4.2.10)
38
+ builder (~> 3.1)
39
+ erubis (~> 2.7.0)
40
+ rails-dom-testing (~> 1.0, >= 1.0.5)
41
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
42
+ activejob (4.2.10)
43
+ activesupport (= 4.2.10)
44
+ globalid (>= 0.3.0)
45
+ activemodel (4.2.10)
46
+ activesupport (= 4.2.10)
47
+ builder (~> 3.1)
48
+ activerecord (4.2.10)
49
+ activemodel (= 4.2.10)
50
+ activesupport (= 4.2.10)
51
+ arel (~> 6.0)
52
+ activesupport (4.2.10)
53
+ i18n (~> 0.7)
54
+ minitest (~> 5.1)
55
+ thread_safe (~> 0.3, >= 0.3.4)
56
+ tzinfo (~> 1.1)
57
+ addressable (2.5.2)
58
+ public_suffix (>= 2.0.2, < 4.0)
59
+ appraisal (2.2.0)
60
+ bundler
61
+ rake
62
+ thor (>= 0.14.0)
63
+ arel (6.0.4)
64
+ autoprefixer-rails (7.1.6)
65
+ execjs
66
+ better_errors (2.4.0)
67
+ coderay (>= 1.0.0)
68
+ erubi (>= 1.0.0)
69
+ rack (>= 0.9.0)
70
+ binding_of_caller (0.7.3)
71
+ debug_inspector (>= 0.0.1)
72
+ bootstrap-sass (3.3.7)
73
+ autoprefixer-rails (>= 5.2.1)
74
+ sass (>= 3.3.4)
75
+ browser (2.5.2)
76
+ bson (4.2.2)
77
+ builder (3.2.3)
78
+ byebug (9.1.0)
79
+ capybara (2.15.4)
80
+ addressable
81
+ mini_mime (>= 0.1.3)
82
+ nokogiri (>= 1.3.3)
83
+ rack (>= 1.0.0)
84
+ rack-test (>= 0.5.4)
85
+ xpath (~> 2.0)
86
+ childprocess (0.8.0)
87
+ ffi (~> 1.0, >= 1.0.11)
88
+ coderay (1.1.2)
89
+ concurrent-ruby (1.0.5)
90
+ crass (1.0.2)
91
+ debug_inspector (0.0.3)
92
+ diff-lcs (1.3)
93
+ erubi (1.7.0)
94
+ erubis (2.7.0)
95
+ execjs (2.7.0)
96
+ factory_bot (4.8.2)
97
+ activesupport (>= 3.0.0)
98
+ factory_bot_rails (4.8.2)
99
+ factory_bot (~> 4.8.2)
100
+ railties (>= 3.0.0)
101
+ faker (1.8.4)
102
+ i18n (~> 0.5)
103
+ ffi (1.9.18)
104
+ globalid (0.4.1)
105
+ activesupport (>= 4.2.0)
106
+ haml (5.0.4)
107
+ temple (>= 0.8.0)
108
+ tilt
109
+ haml-rails (1.0.0)
110
+ actionpack (>= 4.0.1)
111
+ activesupport (>= 4.0.1)
112
+ haml (>= 4.0.6, < 6.0)
113
+ html2haml (>= 1.0.1)
114
+ railties (>= 4.0.1)
115
+ html2haml (2.2.0)
116
+ erubis (~> 2.7.0)
117
+ haml (>= 4.0, < 6)
118
+ nokogiri (>= 1.6.0)
119
+ ruby_parser (~> 3.5)
120
+ i18n (0.9.1)
121
+ concurrent-ruby (~> 1.0)
122
+ jquery-rails (4.3.1)
123
+ rails-dom-testing (>= 1, < 3)
124
+ railties (>= 4.2.0)
125
+ thor (>= 0.14, < 2.0)
126
+ json (1.8.6)
127
+ launchy (2.4.3)
128
+ addressable (~> 2.3)
129
+ loofah (2.1.1)
130
+ crass (~> 1.0.2)
131
+ nokogiri (>= 1.5.9)
132
+ mail (2.7.0)
133
+ mini_mime (>= 0.1.1)
134
+ method_source (0.9.0)
135
+ mini_mime (0.1.4)
136
+ mini_portile2 (2.3.0)
137
+ minitest (5.10.3)
138
+ mongo (2.4.3)
139
+ bson (>= 4.2.1, < 5.0.0)
140
+ mongoid (5.2.1)
141
+ activemodel (~> 4.0)
142
+ mongo (>= 2.4.1, < 3.0.0)
143
+ origin (~> 2.3)
144
+ tzinfo (>= 0.3.37)
145
+ mongoid-rspec (3.0.0)
146
+ mongoid (~> 5.0)
147
+ rake
148
+ rspec (~> 3.3)
149
+ mongoid-simple-tags (0.1.3)
150
+ json (~> 1.8)
151
+ mongoid (>= 3.0.3)
152
+ mongoid-tree (2.1.0)
153
+ mongoid (>= 4.0, < 7.0)
154
+ mongoid_orderable (4.1.1)
155
+ mongoid
156
+ nokogiri (1.8.1)
157
+ mini_portile2 (~> 2.3.0)
158
+ origin (2.3.1)
159
+ pry (0.11.2)
160
+ coderay (~> 1.1.0)
161
+ method_source (~> 0.9.0)
162
+ pry-byebug (3.5.0)
163
+ byebug (~> 9.1)
164
+ pry (~> 0.10)
165
+ public_suffix (3.0.0)
166
+ rack (1.6.8)
167
+ rack-test (0.6.3)
168
+ rack (>= 1.0)
169
+ rails (4.2.10)
170
+ actionmailer (= 4.2.10)
171
+ actionpack (= 4.2.10)
172
+ actionview (= 4.2.10)
173
+ activejob (= 4.2.10)
174
+ activemodel (= 4.2.10)
175
+ activerecord (= 4.2.10)
176
+ activesupport (= 4.2.10)
177
+ bundler (>= 1.3.0, < 2.0)
178
+ railties (= 4.2.10)
179
+ sprockets-rails
180
+ rails-deprecated_sanitizer (1.0.3)
181
+ activesupport (>= 4.2.0.alpha)
182
+ rails-dom-testing (1.0.8)
183
+ activesupport (>= 4.2.0.beta, < 5.0)
184
+ nokogiri (~> 1.6)
185
+ rails-deprecated_sanitizer (>= 1.0.1)
186
+ rails-html-sanitizer (1.0.3)
187
+ loofah (~> 2.0)
188
+ rails-i18n (4.0.9)
189
+ i18n (~> 0.7)
190
+ railties (~> 4.0)
191
+ railties (4.2.10)
192
+ actionpack (= 4.2.10)
193
+ activesupport (= 4.2.10)
194
+ rake (>= 0.8.7)
195
+ thor (>= 0.18.1, < 2.0)
196
+ rake (12.2.1)
197
+ rb-fsevent (0.10.2)
198
+ rb-inotify (0.9.10)
199
+ ffi (>= 0.5.0, < 2)
200
+ responders (2.4.0)
201
+ actionpack (>= 4.2.0, < 5.3)
202
+ railties (>= 4.2.0, < 5.3)
203
+ rspec (3.7.0)
204
+ rspec-core (~> 3.7.0)
205
+ rspec-expectations (~> 3.7.0)
206
+ rspec-mocks (~> 3.7.0)
207
+ rspec-collection_matchers (1.1.3)
208
+ rspec-expectations (>= 2.99.0.beta1)
209
+ rspec-core (3.7.0)
210
+ rspec-support (~> 3.7.0)
211
+ rspec-expectations (3.7.0)
212
+ diff-lcs (>= 1.2.0, < 2.0)
213
+ rspec-support (~> 3.7.0)
214
+ rspec-mocks (3.7.0)
215
+ diff-lcs (>= 1.2.0, < 2.0)
216
+ rspec-support (~> 3.7.0)
217
+ rspec-rails (3.7.1)
218
+ actionpack (>= 3.0)
219
+ activesupport (>= 3.0)
220
+ railties (>= 3.0)
221
+ rspec-core (~> 3.7.0)
222
+ rspec-expectations (~> 3.7.0)
223
+ rspec-mocks (~> 3.7.0)
224
+ rspec-support (~> 3.7.0)
225
+ rspec-support (3.7.0)
226
+ ruby-progressbar (1.9.0)
227
+ ruby_parser (3.10.1)
228
+ sexp_processor (~> 4.9)
229
+ rubyzip (1.2.1)
230
+ sass (3.5.3)
231
+ sass-listen (~> 4.0.0)
232
+ sass-listen (4.0.0)
233
+ rb-fsevent (~> 0.9, >= 0.9.4)
234
+ rb-inotify (~> 0.9, >= 0.9.7)
235
+ sass-rails (5.0.6)
236
+ railties (>= 4.0.0, < 6)
237
+ sass (~> 3.1)
238
+ sprockets (>= 2.8, < 4.0)
239
+ sprockets-rails (>= 2.0, < 4.0)
240
+ tilt (>= 1.1, < 3)
241
+ selenium-webdriver (3.7.0)
242
+ childprocess (~> 0.5)
243
+ rubyzip (~> 1.0)
244
+ sexp_processor (4.10.0)
245
+ shoulda-matchers (3.1.2)
246
+ activesupport (>= 4.0.0)
247
+ simple_form (3.5.0)
248
+ actionpack (> 4, < 5.2)
249
+ activemodel (> 4, < 5.2)
250
+ slim (3.0.8)
251
+ temple (>= 0.7.6, < 0.9)
252
+ tilt (>= 1.3.3, < 2.1)
253
+ sprockets (3.7.1)
254
+ concurrent-ruby (~> 1.0)
255
+ rack (> 1, < 3)
256
+ sprockets-rails (3.2.1)
257
+ actionpack (>= 4.0)
258
+ activesupport (>= 4.0)
259
+ sprockets (>= 3.0.0)
260
+ temple (0.8.0)
261
+ thor (0.20.0)
262
+ thread_safe (0.3.6)
263
+ tilt (2.0.8)
264
+ tzinfo (1.2.4)
265
+ thread_safe (~> 0.1)
266
+ xpath (2.1.0)
267
+ nokogiri (~> 1.3)
268
+
269
+ PLATFORMS
270
+ ruby
271
+
272
+ DEPENDENCIES
273
+ appraisal
274
+ better_errors
275
+ binding_of_caller
276
+ bootstrap-sass
277
+ capybara (~> 2.3)
278
+ factory_bot_rails
279
+ faker (~> 1.4)
280
+ helena!
281
+ jquery-rails
282
+ launchy
283
+ mongoid-rspec
284
+ pry
285
+ pry-byebug
286
+ rails (~> 4.2)
287
+ rspec-collection_matchers (~> 1)
288
+ rspec-rails (~> 3)
289
+ ruby-progressbar
290
+ selenium-webdriver
291
+ shoulda-matchers
292
+ simple_form
293
+
294
+ BUNDLED WITH
295
+ 1.16.0.pre.3
@@ -0,0 +1,24 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "rails", "5.1"
7
+ gem "mongoid", ">= 6.0"
8
+ gem "mongoid-rspec", :git => "https://github.com/mongoid-rspec/mongoid-rspec.git", :group => [:development, :test]
9
+
10
+ group :development, :test do
11
+ gem "pry"
12
+ gem "pry-byebug"
13
+ gem "ruby-progressbar"
14
+ gem "better_errors"
15
+ gem "launchy"
16
+ gem "binding_of_caller"
17
+ gem "selenium-webdriver"
18
+ gem "simple_form"
19
+ gem "jquery-rails"
20
+ gem "bootstrap-sass"
21
+ gem "shoulda-matchers"
22
+ end
23
+
24
+ gemspec :path => "../"