active_record_survey 0.1.41 → 0.1.42
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbe716976900fa899ddff1304f5f0af1add82160
|
4
|
+
data.tar.gz: 9784ddb5461e775944ab103605ff4bdf5b72acfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb1f07e7e049696ffbe105476b15ce24e22f3479ebc587c342e506fc7ee68ee01a99f14a99949911f33ed80f826d34428af27e2af2ca8af3a7cb405e19a716ff
|
7
|
+
data.tar.gz: 38ff22b1e31e62a23870e35db8be76a0ca2439ff4c183bdf82752f64b0cd65a647484e91d346e89d0b7249292c24469520bfc9267277b80778ba0e11368f4695
|
@@ -24,6 +24,18 @@ module ActiveRecordSurvey
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
# All the connective edges
|
28
|
+
def edges
|
29
|
+
self.node_maps.select { |i| !i.marked_for_destruction? }.select { |i|
|
30
|
+
i.node && i.parent
|
31
|
+
}.collect { |i|
|
32
|
+
{
|
33
|
+
:source => i.parent.node.id,
|
34
|
+
:target => i.node.id,
|
35
|
+
}
|
36
|
+
}.uniq
|
37
|
+
end
|
38
|
+
|
27
39
|
def as_map(*args)
|
28
40
|
options = args.extract_options!
|
29
41
|
options[:node_maps] ||= self.node_maps
|
@@ -47,6 +47,15 @@ describe ActiveRecordSurvey::Survey, :survey_spec => true do
|
|
47
47
|
@survey.save
|
48
48
|
end
|
49
49
|
|
50
|
+
describe '#edges', :focus => true do
|
51
|
+
it 'should return an array of all the connective edges' do
|
52
|
+
edges = @survey.edges
|
53
|
+
|
54
|
+
expect(edges.length).to eq(16)
|
55
|
+
expect(edges).to eq([{:source=>1, :target=>2}, {:source=>1, :target=>12}, {:source=>1, :target=>13}, {:source=>2, :target=>3}, {:source=>3, :target=>4}, {:source=>3, :target=>8}, {:source=>12, :target=>9}, {:source=>9, :target=>10}, {:source=>9, :target=>11}, {:source=>13, :target=>5}, {:source=>5, :target=>6}, {:source=>5, :target=>7}, {:source=>4, :target=>5}, {:source=>8, :target=>9}, {:source=>10, :target=>5}, {:source=>11, :target=>5}])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
50
59
|
describe '#questions' do
|
51
60
|
it 'should return all the questions' do
|
52
61
|
expect(@survey.questions.length).to be (4)
|