acts_as_oqgraph 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/acts_as_oqgraph.gemspec +1 -1
- data/lib/graph_edge.rb +2 -1
- data/test/test_acts_as_oqgraph.rb +7 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/acts_as_oqgraph.gemspec
CHANGED
data/lib/graph_edge.rb
CHANGED
@@ -88,7 +88,8 @@ class GraphEdge < ActiveRecord::Base
|
|
88
88
|
def add_to_graph
|
89
89
|
connection.execute <<-EOS
|
90
90
|
INSERT INTO #{oqgraph_table_name} (origid, destid, weight)
|
91
|
-
VALUES (#{self.send(self.class.from_key)}, #{self.send(self.class.to_key)}, #{weight || 1.0})
|
91
|
+
VALUES (#{self.send(self.class.from_key)}, #{self.send(self.class.to_key)}, #{weight || 1.0})
|
92
|
+
ON DUPLICATE KEY UPDATE origid=#{self.send(self.class.from_key)};
|
92
93
|
EOS
|
93
94
|
end
|
94
95
|
|
@@ -192,4 +192,11 @@ class TestActsAsOqgraph < ActiveSupport::TestCase
|
|
192
192
|
assert_equal [@test_3] , @test_2.outgoing_nodes
|
193
193
|
end
|
194
194
|
|
195
|
+
def test_duplicate_links_ignored
|
196
|
+
@test_1.create_edge_to @test_2
|
197
|
+
assert_nothing_raised do
|
198
|
+
@test_1.create_edge_to @test_2
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
195
202
|
end
|