[logaling-commit] logaling/logaling-command [master] fix a bug about Glossary#dupate

Back to archive index

null+****@clear***** null+****@clear*****
Sun Jan 15 11:47:40 JST 2012


KITAITI Makoto	2012-01-15 11:47:40 +0900 (Sun, 15 Jan 2012)

  New Revision: 715c99ff4130d077f3669bdda1817430acf7ec55

  Merged 8f8133b: Merge pull request #16 from KitaitiMakoto/improve-update-note-only

  Log:
    fix a bug about Glossary#dupate

  Modified files:
    lib/logaling/glossary.rb
    spec/logaling/glossary_spec.rb

  Modified: lib/logaling/glossary.rb (+7 -1)
===================================================================
--- lib/logaling/glossary.rb    2012-01-15 10:53:13 +0900 (795ecc7)
+++ lib/logaling/glossary.rb    2012-01-15 11:47:40 +0900 (edce4d3)
@@ -160,7 +160,13 @@ module Logaling
     end
 
     def bilingual_pair_exists_and_has_same_note?(glossary, source_term, target_term, note)
-      target_terms(glossary, source_term).any?{|data| data['target_term'] == target_term && data['note'] == note}
+      target_terms(glossary, source_term).any? do |data|
+        if note.empty?
+          data['target_term'] == target_term
+        else
+          data['target_term'] == target_term && data['note'] == note
+        end
+      end
     end
 
     def target_terms(glossary, source_term)

  Modified: spec/logaling/glossary_spec.rb (+7 -1)
===================================================================
--- spec/logaling/glossary_spec.rb    2012-01-15 10:53:13 +0900 (647e826)
+++ spec/logaling/glossary_spec.rb    2012-01-15 11:47:40 +0900 (b792ceb)
@@ -89,7 +89,13 @@ module Logaling
         }
       end
 
-      context 'with note arguments show exisiting bilingual pair and note ' do
+      context 'with note arguments show exisiting bilingual pair' do
+        it {
+          -> { glossary.update("user", "ユーザ", "ユーザ", "") }.should raise_error(Logaling::TermError)
+        }
+      end
+
+      context 'with note arguments show exisiting bilingual pair and note' do
         it {
           -> { glossary.update("user", "ユーザ", "ユーザ", "ユーザーではない") }.should raise_error(Logaling::TermError)
         }




More information about the logaling-commit mailing list
Back to archive index