active_record_survey 0.1.46 → 0.1.47

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: 097cc70133bbf8a7186e9c6873c5d7b74b772e2f
4
- data.tar.gz: 20cb0b86665a6ec1858c782dde578b6a7005f9da
3
+ metadata.gz: db7d02e98f6dcacb15e74ed15c1694adb8d7b989
4
+ data.tar.gz: 21d3f34d72bd909c9cc7b0f55bb01bf426174668
5
5
  SHA512:
6
- metadata.gz: da323dfe54ca2c301bc3cbc50fdb5edb280feb38346fffbff6e31032c9ec5996620cebd38f61fe6253a7e43777fb719ca00ea1baeee7ccdd19b3fb34100336e8
7
- data.tar.gz: 7f8b23cfa0273126bffba10875947937ece3e742c356e0ebe26f4dbff20d2382bd9d2e498fadafd1675cce85f0a9e9d9f00ed5268b29734e6f21497af48896da
6
+ metadata.gz: d2f1460b9b14f498ea85882f229cc0f36d824f9e1bfbb41855fe908b59e91ac1b90ac76b69063b6ffcc47489eb0efe982e08d6f736a44813e344afdf399575c5
7
+ data.tar.gz: 3a14f13f378178a83eb06328d6de351851430c32605e74043445035b9fc08e7153cc327893737effc140a58a758059b9d74183186da7fd10dc16b3805fa7230c
@@ -91,18 +91,19 @@ module ActiveRecordSurvey
91
91
 
92
92
  # Gets index in sibling relationship
93
93
  def sibling_index
94
- if node_map = self.survey.node_maps.select { |i|
95
- i.node == self
96
- }.first
94
+ node_maps = self.survey.node_maps.includes(:node, parent: [:node])
95
+
96
+ if node_map = node_maps.select { |i| i.node == self }.first
97
+ parent = node_map.parent
97
98
 
98
- node_map.parent.children.each_with_index { |nm, i|
99
+ children = node_maps.select { |i| i.parent && i.parent.node === parent.node }
100
+
101
+ children.each_with_index { |nm, i|
99
102
  if nm == node_map
100
103
  return i
101
104
  end
102
105
  }
103
106
  end
104
-
105
- return 0
106
107
  end
107
108
 
108
109
  def sibling_index=index
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordSurvey
2
- VERSION = "0.1.46"
2
+ VERSION = "0.1.47"
3
3
  end
@@ -160,7 +160,7 @@ describe ActiveRecordSurvey::Node::Question, :question_spec => true do
160
160
  }
161
161
  end
162
162
  end
163
- describe "advanced case", :focus => true do
163
+ describe "advanced case" do
164
164
  before(:each) do
165
165
  @survey = FactoryGirl.build(:basic_survey2)
166
166
  @survey.save
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_survey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.46
4
+ version: 0.1.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Butch Marshall