surveyor 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +38 -2
- data/VERSION +1 -1
- data/app/models/response_set.rb +1 -1
- data/app/models/validation_condition.rb +4 -2
- data/spec/models/response_set_spec.rb +7 -0
- data/spec/models/validation_condition_spec.rb +25 -2
- data/surveyor.gemspec +5 -4
- metadata +2 -2
data/README.md
CHANGED
@@ -7,12 +7,12 @@ Surveyor is a rails (gem) plugin, that brings surveys to your rails app. Before
|
|
7
7
|
As a plugin:
|
8
8
|
|
9
9
|
sudo gem install haml
|
10
|
-
script/plugin install git://github.com/breakpointer/surveyor.git -r 'tag v0.9.
|
10
|
+
script/plugin install git://github.com/breakpointer/surveyor.git -r 'tag v0.9.8'
|
11
11
|
|
12
12
|
Or as a gem plugin:
|
13
13
|
|
14
14
|
# in environment.rb
|
15
|
-
config.gem "surveyor", :version => '>=0.9.
|
15
|
+
config.gem "surveyor", :version => '>=0.9.8', :source => 'http://gemcutter.org'
|
16
16
|
|
17
17
|
sudo gem install gemcutter
|
18
18
|
gem tumble
|
@@ -109,6 +109,42 @@ Surveyor depends on Rails 2.3 and the SASS style sheet language, part of HAML (h
|
|
109
109
|
|
110
110
|
# Changes
|
111
111
|
|
112
|
+
0.9.8
|
113
|
+
|
114
|
+
* @current\_user.id if @current\_user isn't nil. Closes #37
|
115
|
+
|
116
|
+
0.9.7
|
117
|
+
|
118
|
+
* fixing typos
|
119
|
+
* remove surveyor controller from load\_once\_paths. fixes issue with dependencies and unloading in development. closes #36
|
120
|
+
|
121
|
+
0.9.6
|
122
|
+
|
123
|
+
* response set reports progress and mandatory questions completeness. closes #33
|
124
|
+
* adding correctness to response sets
|
125
|
+
* adding correctness to responses
|
126
|
+
|
127
|
+
0.9.5
|
128
|
+
|
129
|
+
* allow append for survey parser. closes #32
|
130
|
+
|
131
|
+
0.9.4
|
132
|
+
|
133
|
+
* making tinycode compatible with ruby 1.8.6
|
134
|
+
|
135
|
+
0.9.3
|
136
|
+
|
137
|
+
* fix for survey parser require
|
138
|
+
|
139
|
+
0.9.2
|
140
|
+
|
141
|
+
* fixing specs for namespacing and move of tinycode
|
142
|
+
* namespacing SurveyParser models to avoid conflict with model extensions
|
143
|
+
|
144
|
+
0.9.1
|
145
|
+
|
146
|
+
* fix for tinycode, more descriptive missing method
|
147
|
+
|
112
148
|
0.9.0
|
113
149
|
|
114
150
|
* validations in dsl and surveyor models
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.9
|
data/app/models/response_set.rb
CHANGED
@@ -112,7 +112,7 @@ class ResponseSet < ActiveRecord::Base
|
|
112
112
|
}
|
113
113
|
end
|
114
114
|
def is_answered?(question)
|
115
|
-
!is_unanswered?(question)
|
115
|
+
%w(label image).include?(question.display_type) or !is_unanswered?(question)
|
116
116
|
end
|
117
117
|
def is_unanswered?(question)
|
118
118
|
self.responses.detect{|r| r.question_id == question.id}.nil?
|
@@ -27,12 +27,14 @@ class ValidationCondition < ActiveRecord::Base
|
|
27
27
|
|
28
28
|
def is_valid?(response)
|
29
29
|
klass = response.answer.response_class
|
30
|
+
compare_to = Response.find_by_question_id_and_answer_id(self.question_id, self.answer_id) || self
|
30
31
|
case self.operator
|
31
32
|
when "==", "<", ">", "<=", ">="
|
32
|
-
response.as(klass).send(self.operator,
|
33
|
+
response.as(klass).send(self.operator, compare_to.as(klass))
|
33
34
|
when "!="
|
34
|
-
!(response.as(klass) ==
|
35
|
+
!(response.as(klass) == compare_to.as(klass))
|
35
36
|
when "=~"
|
37
|
+
return false if compare_to != self
|
36
38
|
!(response.as(klass).to_s =~ Regexp.new(self.regexp || "")).nil?
|
37
39
|
else
|
38
40
|
false
|
@@ -176,6 +176,13 @@ describe ResponseSet, "with mandatory questions" do
|
|
176
176
|
@response_set.mandatory_questions_complete?.should be_false
|
177
177
|
@response_set.progress_hash.should == {:questions => 3, :triggered => 3, :triggered_mandatory => 3, :triggered_mandatory_completed => 0}
|
178
178
|
end
|
179
|
+
it "should ignore labels and images" do
|
180
|
+
generate_responses(3, "mandatory", "responded")
|
181
|
+
Factory(:question, :survey_section => @section, :display_type => "label", :is_mandatory => true)
|
182
|
+
Factory(:question, :survey_section => @section, :display_type => "image", :is_mandatory => true)
|
183
|
+
@response_set.mandatory_questions_complete?.should be_true
|
184
|
+
@response_set.progress_hash.should == {:questions => 5, :triggered => 5, :triggered_mandatory => 5, :triggered_mandatory_completed => 5}
|
185
|
+
end
|
179
186
|
end
|
180
187
|
describe ResponseSet, "with mandatory, dependent questions" do
|
181
188
|
before(:each) do
|
@@ -56,7 +56,7 @@ describe ValidationCondition, "validating responses" do
|
|
56
56
|
def test_var(vhash, ahash, rhash)
|
57
57
|
v = Factory(:validation_condition, vhash)
|
58
58
|
a = Factory(:answer, ahash)
|
59
|
-
r = Factory(:response,
|
59
|
+
r = Factory(:response, {:answer => a, :question => a.question}.merge(rhash))
|
60
60
|
return v.is_valid?(r)
|
61
61
|
end
|
62
62
|
|
@@ -70,7 +70,7 @@ describe ValidationCondition, "validating responses" do
|
|
70
70
|
end
|
71
71
|
it "should validate a response by (in)equality" do
|
72
72
|
test_var({:operator => "!=", :datetime_value => Date.today + 1}, {:response_class => "date"}, {:datetime_value => Date.today}).should be_true
|
73
|
-
test_var({:operator => "==", :
|
73
|
+
test_var({:operator => "==", :string_value => "foo"}, {:response_class => "string"}, {:string_value => "foo"}).should be_true
|
74
74
|
end
|
75
75
|
it "should represent itself as a hash" do
|
76
76
|
@v = Factory(:validation_condition, :rule_key => "A")
|
@@ -79,4 +79,27 @@ describe ValidationCondition, "validating responses" do
|
|
79
79
|
@v.stub!(:is_valid?).and_return(false)
|
80
80
|
@v.to_hash("foo").should == {:A => false}
|
81
81
|
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe ValidationCondition, "validating responses by other responses" do
|
85
|
+
def test_var(v_hash, a_hash, r_hash, ca_hash, cr_hash)
|
86
|
+
ca = Factory(:answer, ca_hash)
|
87
|
+
cr = Factory(:response, cr_hash.merge(:answer => ca, :question => ca.question))
|
88
|
+
v = Factory(:validation_condition, v_hash.merge({:question_id => ca.question.id, :answer_id => ca.id}))
|
89
|
+
a = Factory(:answer, a_hash)
|
90
|
+
r = Factory(:response, r_hash.merge(:answer => a, :question => a.question))
|
91
|
+
return v.is_valid?(r)
|
92
|
+
end
|
93
|
+
it "should validate a response by integer comparison" do
|
94
|
+
test_var({:operator => ">"}, {:response_class => "integer"}, {:integer_value => 4}, {:response_class => "integer"}, {:integer_value => 3}).should be_true
|
95
|
+
test_var({:operator => "<="}, {:response_class => "integer"}, {:integer_value => 512}, {:response_class => "integer"}, {:integer_value => 4}).should be_false
|
96
|
+
end
|
97
|
+
it "should validate a response by (in)equality" do
|
98
|
+
test_var({:operator => "!="}, {:response_class => "date"}, {:datetime_value => Date.today}, {:response_class => "date"}, {:datetime_value => Date.today + 1}).should be_true
|
99
|
+
test_var({:operator => "=="}, {:response_class => "string"}, {:string_value => "donuts"}, {:response_class => "string"}, {:string_value => "donuts"}).should be_true
|
100
|
+
end
|
101
|
+
it "should not validate a response by regexp" do
|
102
|
+
test_var({:operator => "=~"}, {:response_class => "date"}, {:datetime_value => Date.today}, {:response_class => "date"}, {:datetime_value => Date.today + 1}).should be_false
|
103
|
+
test_var({:operator => "=~"}, {:response_class => "string"}, {:string_value => "donuts"}, {:response_class => "string"}, {:string_value => "donuts"}).should be_false
|
104
|
+
end
|
82
105
|
end
|
data/surveyor.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{surveyor}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.9"
|
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{2009-11-
|
12
|
+
s.date = %q{2009-11-16}
|
13
13
|
s.email = %q{yoon@northwestern.edu}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.md"
|
@@ -209,3 +209,4 @@ Gem::Specification.new do |s|
|
|
209
209
|
s.add_dependency(%q<haml>, [">= 0"])
|
210
210
|
end
|
211
211
|
end
|
212
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: surveyor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Chamberlain
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-11-
|
13
|
+
date: 2009-11-16 00:00:00 -06:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|