acts_as_oqgraph 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{acts_as_oqgraph}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Stuart Coyle"]
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Stuart Coyle