surveyor 0.19.5 → 0.19.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +11 -0
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/ci-env.sh +1 -1
- data/features/step_definitions/parser_steps.rb +11 -0
- data/features/step_definitions/surveyor_steps.rb +10 -0
- data/features/surveyor.feature +16 -1
- data/features/surveyor_parser.feature +41 -1
- data/generators/surveyor/templates/assets/javascripts/jquery.surveyor.js +1 -1
- data/lib/formtastic/surveyor_builder.rb +2 -1
- data/lib/surveyor/models/response_methods.rb +3 -2
- data/lib/surveyor/parser.rb +1 -1
- data/spec/models/response_set_spec.rb +18 -2
- data/spec/models/response_spec.rb +16 -0
- data/surveyor.gemspec +6 -3
- data/testbed/Gemfile +1 -2
- metadata +24 -10
data/CHANGELOG
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
0.19.6
|
2
|
+
|
3
|
+
* fix parsing of group questions with dependencies. closes #160
|
4
|
+
* update homepage
|
5
|
+
* lock ci to ree-1.8.7-2010.02
|
6
|
+
* Fixed safari issue with conditional questions not hiding/showing.
|
7
|
+
* add checkbox + text renderer. closes #107
|
8
|
+
* add sass, since Haml will no longer do so
|
9
|
+
* adjusting testbed cucumber to avoid 'uninitialized constant Gherkin::Formatter::Model::PyString' error
|
10
|
+
* Fixed error when user answers a checkbox question.
|
11
|
+
|
1
12
|
0.19.5
|
2
13
|
|
3
14
|
* Fixed dependent questions not appearing under certain conditions. Closes #143.
|
data/Rakefile
CHANGED
@@ -7,9 +7,10 @@ begin
|
|
7
7
|
gem.name = "surveyor"
|
8
8
|
gem.summary = %Q{A rails (gem) plugin to enable surveys in your application}
|
9
9
|
gem.email = "yoon@northwestern.edu"
|
10
|
-
gem.homepage = "http://github.com/
|
10
|
+
gem.homepage = "http://github.com/NUBIC/surveyor"
|
11
11
|
gem.authors = ["Brian Chamberlain", "Mark Yoon"]
|
12
12
|
gem.add_dependency 'haml'
|
13
|
+
gem.add_dependency 'sass'
|
13
14
|
gem.add_dependency 'fastercsv'
|
14
15
|
gem.add_dependency 'formtastic'
|
15
16
|
gem.add_dependency 'uuid'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.19.
|
1
|
+
0.19.6
|
data/ci-env.sh
CHANGED
@@ -75,3 +75,14 @@ Then /^question "([^"]*)" should have correct answer "([^"]*)"$/ do |qr, ar|
|
|
75
75
|
q.correct_answer.should == q.answers.find_by_reference_identifier(ar)
|
76
76
|
end
|
77
77
|
|
78
|
+
Then /^(\d+) dependencies should depend on questions$/ do |x|
|
79
|
+
arr = Dependency.find_all_by_question_group_id(nil)
|
80
|
+
arr.size.should == 2
|
81
|
+
arr.each{|d| d.question.should_not be_nil}
|
82
|
+
end
|
83
|
+
|
84
|
+
Then /^(\d+) dependencies should depend on question groups$/ do |x|
|
85
|
+
arr = Dependency.find_all_by_question_id(nil)
|
86
|
+
arr.size.should == 2
|
87
|
+
arr.each{|d| d.question_group.should_not be_nil}
|
88
|
+
end
|
@@ -50,3 +50,13 @@ Then /^a dropdown should exist with the options "([^"]*)"$/ do |options_text|
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
53
|
+
|
54
|
+
Then /^there should be (\d+) checkboxes$/ do |count|
|
55
|
+
response.should have_selector('input[type=checkbox]', :count => count.to_i)
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
Then /^there should be (\d+) text areas$/ do |count|
|
60
|
+
response.should have_selector('textarea', :count => count.to_i)
|
61
|
+
end
|
62
|
+
|
data/features/surveyor.feature
CHANGED
@@ -153,4 +153,19 @@ Feature: Survey creation
|
|
153
153
|
And I press "Click here to finish"
|
154
154
|
Then there should be 1 response set with 1 response with:
|
155
155
|
| shrimp |
|
156
|
-
|
156
|
+
|
157
|
+
Scenario: Checkboxes with text area
|
158
|
+
Given the survey
|
159
|
+
"""
|
160
|
+
survey "Websites" do
|
161
|
+
section "Search engines" do
|
162
|
+
q "Have you ever used the following services?", :pick => :any
|
163
|
+
a "Yellowpages.com|Describe your experience", :text
|
164
|
+
a "Google.com|Describe your experience", :text
|
165
|
+
a "Bing.com|Describe your experience", :text
|
166
|
+
end
|
167
|
+
end
|
168
|
+
"""
|
169
|
+
When I start the "Websites" survey
|
170
|
+
Then there should be 3 checkboxes
|
171
|
+
And there should be 3 text areas
|
@@ -198,4 +198,44 @@ Feature: Survey creation
|
|
198
198
|
"""
|
199
199
|
Then there should be 5 dependencies
|
200
200
|
And question "copd_sh_1a" should have a dependency with rule "A"
|
201
|
-
And question "copd_sh_1ba" should have a dependency with rule "E"
|
201
|
+
And question "copd_sh_1ba" should have a dependency with rule "E"
|
202
|
+
|
203
|
+
Scenario: Dependencies on questions inside of a group
|
204
|
+
Given the survey
|
205
|
+
"""
|
206
|
+
survey "Phone Screen Questions" do
|
207
|
+
section "Phone Screen" do
|
208
|
+
q_diabetes "Diabetes", :pick => :one
|
209
|
+
a_yes "Yes"
|
210
|
+
a_no "No"
|
211
|
+
|
212
|
+
q_high_blood_preassure "High blood pressure?", :pick => :one
|
213
|
+
a_yes "Yes"
|
214
|
+
a_no "No"
|
215
|
+
|
216
|
+
group do
|
217
|
+
dependency :rule => "A"
|
218
|
+
condition_A :q_diabetes, "==", :a_yes
|
219
|
+
label "It looks like you are not eligible for this specific study at the time"
|
220
|
+
end
|
221
|
+
|
222
|
+
group "Eligible" do
|
223
|
+
dependency :rule => "A"
|
224
|
+
condition_A :q_diabetes, "==", :a_no
|
225
|
+
|
226
|
+
label "You're Eligible!"
|
227
|
+
|
228
|
+
label "You need medical clearance"
|
229
|
+
dependency :rule => "A"
|
230
|
+
condition_A :q_high_blood_preassure, "==", :a_yes
|
231
|
+
|
232
|
+
label "You don't need medical clearance"
|
233
|
+
dependency :rule => "A"
|
234
|
+
condition_A :q_high_blood_preassure, "==", :a_no
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
"""
|
239
|
+
Then there should be 4 dependencies
|
240
|
+
And 2 dependencies should depend on questions
|
241
|
+
And 2 dependencies should depend on question groups
|
@@ -25,7 +25,7 @@ jQuery(document).ready(function(){
|
|
25
25
|
// surveyor_controller returns a json object to show/hide elements and insert/remove ids e.g. {"ids": {"2" => 234}, "remove": {"4" => 21}, "hide":["question_12","question_13"],"show":["question_14"]}
|
26
26
|
jQuery.each(responseText.show, function(){ jQuery('#' + this).show("fast"); });
|
27
27
|
jQuery.each(responseText.hide, function(){ jQuery('#' + this).hide("fast"); });
|
28
|
-
jQuery.each(responseText.ids, function(k,v){ jQuery('#r_'+k+'_question_id').after('<input id="r_'+k+'_id" type="hidden" value="'+v+'" name="r['+k+'][id]"'); });
|
28
|
+
jQuery.each(responseText.ids, function(k,v){ jQuery('#r_'+k+'_question_id').after('<input id="r_'+k+'_id" type="hidden" value="'+v+'" name="r['+k+'][id]"/>'); });
|
29
29
|
jQuery.each(responseText.remove, function(k,v){ jQuery('#r_'+k+'_id[value="'+v+'"]').remove(); });
|
30
30
|
return false;
|
31
31
|
}
|
@@ -40,7 +40,8 @@ module Formtastic
|
|
40
40
|
)
|
41
41
|
li_content << basic_input_helper(:text_field, :string, :string_value, options) if options[:response_class] == "other_and_string"
|
42
42
|
li_content << basic_input_helper(:text_field, :string, :string_value, options) if %w(string other_and_string).include?(options[:response_class])
|
43
|
-
|
43
|
+
li_content << basic_input_helper(:text_area, :text, :text_value, options) if options[:response_class] == "text"
|
44
|
+
|
44
45
|
# li_options = value_as_class ? { :class => [method.to_s.singularize, value.to_s.downcase].join('_') } : {}
|
45
46
|
Formtastic::Util.html_safe(li_content)
|
46
47
|
end
|
@@ -19,8 +19,9 @@ module Surveyor
|
|
19
19
|
base.instance_eval do
|
20
20
|
def applicable_attributes(attrs)
|
21
21
|
result = HashWithIndifferentAccess.new(attrs)
|
22
|
-
|
23
|
-
|
22
|
+
answer_id = result[:answer_id].is_a?(Array) ? result[:answer_id].last : result[:answer_id] # checkboxes are arrays / radio buttons are not arrays
|
23
|
+
if result[:string_value] && Answer.exists?(answer_id)
|
24
|
+
answer = Answer.find(answer_id)
|
24
25
|
result.delete(:string_value) unless answer.response_class && answer.response_class.to_sym == :string
|
25
26
|
end
|
26
27
|
result
|
data/lib/surveyor/parser.rb
CHANGED
@@ -169,7 +169,7 @@ class Dependency < ActiveRecord::Base
|
|
169
169
|
|
170
170
|
# build and set context
|
171
171
|
if context[:question]
|
172
|
-
context[:dependency] = context[:question].build_dependency(
|
172
|
+
context[:dependency] = context[:question].build_dependency(args[0] || {})
|
173
173
|
elsif context[:question_group]
|
174
174
|
context[:dependency] = context[:question_group].build_dependency(args[0] || {})
|
175
175
|
end
|
@@ -82,7 +82,15 @@ describe ResponseSet do
|
|
82
82
|
"20" => {"question_id" => "10", "answer_id" => "201", "string_value" => "hi"}, # new string, filled
|
83
83
|
"21" => {"id" => "105", "question_id" => "11", "answer_id" => "211", "string_value" => ""}, # existing string, cleared
|
84
84
|
"22" => {"id" => "106", "question_id" => "12", "answer_id" => "221", "string_value" => "ho"}, # existing string, changed
|
85
|
-
"23" => {"id" => "107", "question_id" => "13", "answer_id" => "231", "string_value" => "hi"} # existing string, unchanged
|
85
|
+
"23" => {"id" => "107", "question_id" => "13", "answer_id" => "231", "string_value" => "hi"}, # existing string, unchanged
|
86
|
+
"24" => {"question_id" => "14", "answer_id" => [""], "string_value" => "foo"}, # new checkbox with string value, blank
|
87
|
+
"25" => {"question_id" => "15", "answer_id" => ["", "241"], "string_value" => "bar"}, # new checkbox with string value, checked
|
88
|
+
"26" => {"id" => "108", "question_id" => "14", "answer_id" => [""], "string_value" => "moo"}, # existing checkbox with string value, unchecked
|
89
|
+
"27" => {"id" => "109", "question_id" => "15", "answer_id" => ["", "251"], "string_value" => "mar"}, # existing checkbox with string value, left alone
|
90
|
+
"28" => {"question_id" => "16", "answer_id" => "", "string_value" => "foo"}, # new radio with string value, blank
|
91
|
+
"29" => {"question_id" => "17", "answer_id" => "261", "string_value" => "bar"}, # new radio with string value, selected
|
92
|
+
"30" => {"id" => "110", "question_id" => "18", "answer_id" => "271", "string_value" => "moo"}, # existing radio with string value, changed
|
93
|
+
"31" => {"id" => "111", "question_id" => "19", "answer_id" => "281", "string_value" => "mar"}, # existing radio with string value, unchanged
|
86
94
|
}
|
87
95
|
ResponseSet.reject_or_destroy_blanks(hash_of_hashes).should == {
|
88
96
|
# "11" => {"question_id" => "1", "answer_id" => [""]}, # new checkbox, blank
|
@@ -97,7 +105,15 @@ describe ResponseSet do
|
|
97
105
|
"20" => {"question_id" => "10", "answer_id" => "201", "string_value" => "hi"}, # new string, filled
|
98
106
|
"21" => {"id" => "105", "question_id" => "11", "answer_id" => "211", "string_value" => "", "_destroy" => "true"}, # existing string, cleared
|
99
107
|
"22" => {"id" => "106", "question_id" => "12", "answer_id" => "221", "string_value" => "ho"}, # existing string, changed
|
100
|
-
"23" => {"id" => "107", "question_id" => "13", "answer_id" => "231", "string_value" => "hi"} # existing string, unchanged
|
108
|
+
"23" => {"id" => "107", "question_id" => "13", "answer_id" => "231", "string_value" => "hi"}, # existing string, unchanged
|
109
|
+
# "24" => {"question_id" => "14", "answer_id" => [""], "string_value" => "foo"}, # new checkbox with string value, blank
|
110
|
+
"25" => {"question_id" => "15", "answer_id" => ["", "241"], "string_value" => "bar"}, # new checkbox with string value, checked
|
111
|
+
"26" => {"id" => "108", "question_id" => "14", "answer_id" => [""], "string_value" => "moo", "_destroy" => "true"}, # existing checkbox with string value, unchecked
|
112
|
+
"27" => {"id" => "109", "question_id" => "15", "answer_id" => ["", "251"], "string_value" => "mar"}, # existing checkbox with string value, left alone
|
113
|
+
# "28" => {"question_id" => "16", "answer_id" => "", "string_value" => "foo"}, # new radio with string value, blank
|
114
|
+
"29" => {"question_id" => "17", "answer_id" => "261", "string_value" => "bar"}, # new radio with string value, selected
|
115
|
+
"30" => {"id" => "110", "question_id" => "18", "answer_id" => "271", "string_value" => "moo"}, # existing radio with string value, changed
|
116
|
+
"31" => {"id" => "111", "question_id" => "19", "answer_id" => "281", "string_value" => "mar"}, # existing radio with string value, unchanged
|
101
117
|
}
|
102
118
|
end
|
103
119
|
it "should remove responses" do
|
@@ -91,4 +91,20 @@ describe Response, "applicable_attributes" do
|
|
91
91
|
bad = {"question_id"=>@who.id, "answer_id"=>@odoyle.id, "string_value"=>"Frank"}
|
92
92
|
Response.applicable_attributes(bad).should == {"question_id" => @who.id, "answer_id"=> @odoyle.id}
|
93
93
|
end
|
94
|
+
|
95
|
+
it "should have string_value if response_type is string and answer_id is an array (in the case of checkboxes)" do
|
96
|
+
good = {"question_id"=>@who.id, "answer_id"=>["", @odoyle.id], "string_value"=>"Frank"}
|
97
|
+
Response.applicable_attributes(good).should == {"question_id" => @who.id, "answer_id"=> ["", @odoyle.id]}
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should have ignore attribute if missing answer_id" do
|
101
|
+
ignore = {"question_id"=>@who.id, "answer_id"=>"", "string_value"=>"Frank"}
|
102
|
+
Response.applicable_attributes(ignore).should == {"question_id"=>@who.id, "answer_id"=>"", "string_value"=>"Frank"}
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should have ignore attribute if missing answer_id is an array" do
|
106
|
+
ignore = {"question_id"=>@who.id, "answer_id"=>[""], "string_value"=>"Frank"}
|
107
|
+
Response.applicable_attributes(ignore).should == {"question_id"=>@who.id, "answer_id"=>[""], "string_value"=>"Frank"}
|
108
|
+
end
|
109
|
+
|
94
110
|
end
|
data/surveyor.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{surveyor}
|
8
|
-
s.version = "0.19.
|
8
|
+
s.version = "0.19.6"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Brian Chamberlain", "Mark Yoon"]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-08}
|
13
13
|
s.email = %q{yoon@northwestern.edu}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.md"
|
@@ -148,7 +148,7 @@ Gem::Specification.new do |s|
|
|
148
148
|
"surveyor.gemspec",
|
149
149
|
"testbed/Gemfile"
|
150
150
|
]
|
151
|
-
s.homepage = %q{http://github.com/
|
151
|
+
s.homepage = %q{http://github.com/NUBIC/surveyor}
|
152
152
|
s.require_paths = ["lib"]
|
153
153
|
s.rubygems_version = %q{1.6.2}
|
154
154
|
s.summary = %q{A rails (gem) plugin to enable surveys in your application}
|
@@ -158,12 +158,14 @@ Gem::Specification.new do |s|
|
|
158
158
|
|
159
159
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
160
160
|
s.add_runtime_dependency(%q<haml>, [">= 0"])
|
161
|
+
s.add_runtime_dependency(%q<sass>, [">= 0"])
|
161
162
|
s.add_runtime_dependency(%q<fastercsv>, [">= 0"])
|
162
163
|
s.add_runtime_dependency(%q<formtastic>, [">= 0"])
|
163
164
|
s.add_runtime_dependency(%q<uuid>, [">= 0"])
|
164
165
|
s.add_development_dependency(%q<yard>, [">= 0"])
|
165
166
|
else
|
166
167
|
s.add_dependency(%q<haml>, [">= 0"])
|
168
|
+
s.add_dependency(%q<sass>, [">= 0"])
|
167
169
|
s.add_dependency(%q<fastercsv>, [">= 0"])
|
168
170
|
s.add_dependency(%q<formtastic>, [">= 0"])
|
169
171
|
s.add_dependency(%q<uuid>, [">= 0"])
|
@@ -171,6 +173,7 @@ Gem::Specification.new do |s|
|
|
171
173
|
end
|
172
174
|
else
|
173
175
|
s.add_dependency(%q<haml>, [">= 0"])
|
176
|
+
s.add_dependency(%q<sass>, [">= 0"])
|
174
177
|
s.add_dependency(%q<fastercsv>, [">= 0"])
|
175
178
|
s.add_dependency(%q<formtastic>, [">= 0"])
|
176
179
|
s.add_dependency(%q<uuid>, [">= 0"])
|
data/testbed/Gemfile
CHANGED
@@ -5,10 +5,9 @@ gem 'rspec', '~> 1.3'
|
|
5
5
|
gem 'rspec-rails', '1.3.3'
|
6
6
|
gem 'sqlite3-ruby', '1.2.5' # Using this version for ruby 1.8.7 compatibility reasons
|
7
7
|
gem 'webrat'
|
8
|
-
gem 'cucumber', '0.
|
8
|
+
gem 'cucumber', '~>0.9'
|
9
9
|
gem 'cucumber-rails', '0.3.2'
|
10
10
|
gem 'database_cleaner'
|
11
11
|
gem 'factory_girl'
|
12
|
-
gem 'uuid'
|
13
12
|
|
14
13
|
gem 'surveyor', :path => ".."
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: surveyor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 95
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 19
|
9
|
-
-
|
10
|
-
version: 0.19.
|
9
|
+
- 6
|
10
|
+
version: 0.19.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Chamberlain
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-06-
|
19
|
+
date: 2011-06-08 00:00:00 -05:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
type: :runtime
|
35
35
|
version_requirements: *id001
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
37
|
+
name: sass
|
38
38
|
prerelease: false
|
39
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
type: :runtime
|
49
49
|
version_requirements: *id002
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
|
-
name:
|
51
|
+
name: fastercsv
|
52
52
|
prerelease: false
|
53
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
54
54
|
none: false
|
@@ -62,7 +62,7 @@ dependencies:
|
|
62
62
|
type: :runtime
|
63
63
|
version_requirements: *id003
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
|
-
name:
|
65
|
+
name: formtastic
|
66
66
|
prerelease: false
|
67
67
|
requirement: &id004 !ruby/object:Gem::Requirement
|
68
68
|
none: false
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
type: :runtime
|
77
77
|
version_requirements: *id004
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
79
|
+
name: uuid
|
80
80
|
prerelease: false
|
81
81
|
requirement: &id005 !ruby/object:Gem::Requirement
|
82
82
|
none: false
|
@@ -87,8 +87,22 @@ dependencies:
|
|
87
87
|
segments:
|
88
88
|
- 0
|
89
89
|
version: "0"
|
90
|
-
type: :
|
90
|
+
type: :runtime
|
91
91
|
version_requirements: *id005
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: yard
|
94
|
+
prerelease: false
|
95
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
hash: 3
|
101
|
+
segments:
|
102
|
+
- 0
|
103
|
+
version: "0"
|
104
|
+
type: :development
|
105
|
+
version_requirements: *id006
|
92
106
|
description:
|
93
107
|
email: yoon@northwestern.edu
|
94
108
|
executables: []
|
@@ -231,7 +245,7 @@ files:
|
|
231
245
|
- surveyor.gemspec
|
232
246
|
- testbed/Gemfile
|
233
247
|
has_rdoc: true
|
234
|
-
homepage: http://github.com/
|
248
|
+
homepage: http://github.com/NUBIC/surveyor
|
235
249
|
licenses: []
|
236
250
|
|
237
251
|
post_install_message:
|