Changeset 1338

Show
Ignore:
Timestamp:
02/12/08 16:58:18 (1 year ago)
Author:
yuanying
Message:

translation spec are added.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.jalcedo.babel.database/trunk/models/babel/file.rb

    r1337 r1338  
    33class File < ActiveRecord::Base 
    44  set_primary_key 'file_id' 
     5  has_many :strings, :dependent => :destroy 
    56end 
    67end 
  • org.jalcedo.babel.database/trunk/models/babel/translation.rb

    r1337 r1338  
    33class Translation < ActiveRecord::Base 
    44  set_primary_key 'translation_id' 
     5   
     6  belongs_to :string, :foreign_key => "string_id" 
     7  belongs_to :language, :foreign_key => "language_id" 
     8  belongs_to :user, :foreign_key => "userid" 
    59end 
    610end 
  • org.jalcedo.babel.database/trunk/resources/babel_tests-setup.sql

    r1337 r1338  
    317317insert into project_versions set project_id = "eclipse", version = "3.3", is_active = 1; 
    318318 
    319 insert into files values 
    320 
    321   1, 'eclipse', '3.3', 'org.eclipse.ui/plugin.properties', 1 
    322 ); 
     319insert into files values(1, 'eclipse', '3.3', 'org.eclipse.ui/plugin.properties', 1); 
     320 
     321insert into strings values(1, 1, 'category.file.name', 'File', 1, NOW(), 1); 
     322insert into strings values(2, 1, 'category.edit.name', 'Edit', 1, NOW(), 1); 
     323insert into strings values(3, 1, 'category.help.name', 'Help', 1, NOW(), 1); 
    323324 
    324325 
  • org.jalcedo.babel.database/trunk/spec/babel/string_spec.rb

    r1337 r1338  
    11require 'init' 
    22require 'babel/string' 
    3  
    4 load File.join(APP_ROOT, 'spec', 'initializer.rb') 
    5  
    6 load File.join(APP_ROOT, 'spec', 'terminalizer.rb') 
  • org.jalcedo.babel.database/trunk/spec/babel/translation_spec.rb

    r1337 r1338  
    44require 'babel/user' 
    55require 'babel/translation' 
    6  
    7 load File.join(APP_ROOT, 'spec', 'initializer.rb') 
    86 
    97describe Babel::Translation, 'when translating to Japanease for the first time.' do 
     
    1412    @test_user = Babel::User.find_by_username('babel@eclipse.org') 
    1513  end 
     14   
     15  before(:each) do 
     16    @translation = Babel::Translation.new 
     17    @translation.string = @file_menu_string 
     18    @translation.language = @japanease 
     19    @translation.user = @test_user 
     20    @translation.value = 'ファイル' 
     21    @translation.save! 
     22  end 
     23   
     24  after(:each) do 
     25    @translation.destroy 
     26  end 
    1627 
    17   it 'should add new translation.' 
     28  it 'should new translation is active.' do 
     29    @translation.is_active.should == 1 
     30  end 
    1831end 
    1932 
     
    2437    @japanease = Babel::Language.find_by_iso_code('ja') 
    2538    @test_user = Babel::User.find_by_username('babel@eclipse.org') 
     39     
     40    @old_translation = Babel::Translation.new 
     41    @old_translation = Babel::Translation.new 
     42    @old_translation.string = @edit_menu_string 
     43    @old_translation.language = @japanease 
     44    @old_translation.user = @test_user 
     45    @old_translation.value = 'へんしゅー' 
     46    @old_translation.save! 
     47     
     48    @translation = Babel::Translation.new 
     49    @translation.string = @edit_menu_string 
     50    @translation.language = @japanease 
     51    @translation.user = @test_user 
     52    @translation.value = '編集' 
     53    @translation.save! 
     54  end 
     55 
     56  after(:all) do 
     57    Babel::Translation.delete_all 
    2658  end 
    2759   
    28   it 'should old translation is not active.' 
     60  it 'should old translation is not active.' do 
     61    @_old_translation = Babel::Translation.find_by_translation_id(@old_translation.translation_id) 
     62    @_old_translation.is_active.should == 0 
     63  end 
    2964end 
    3065 
     
    3570    @japanease = Babel::Language.find_by_iso_code('ja') 
    3671    @test_user = Babel::User.find_by_username('babel@eclipse.org') 
     72     
     73    @old_old_translation = Babel::Translation.new 
     74    @old_old_translation = Babel::Translation.new 
     75    @old_old_translation.string = @help_menu_string 
     76    @old_old_translation.language = @japanease 
     77    @old_old_translation.user = @test_user 
     78    @old_old_translation.user.is_active = 0 
     79    @old_old_translation.created_on = Time.now.last_month 
     80    @old_old_translation.value = 'ヘルプ' 
     81    @old_old_translation.save! 
     82     
     83    @old_translation = Babel::Translation.new 
     84    @old_translation = Babel::Translation.new 
     85    @old_translation.string = @help_menu_string 
     86    @old_translation.language = @japanease 
     87    @old_translation.user = @test_user 
     88    @old_translation.user.is_active = 1 
     89    @old_old_translation.created_on = Time.now.last_year 
     90    @old_translation.value = 'ヘルプププ' 
     91    @old_translation.save! 
     92     
    3793  end 
    3894   
    39   it 'should not add new translation.' 
     95  after(:all) do 
     96    Babel::Translation.delete_all 
     97  end 
     98   
     99  it 'should not register same value for active translation.' do 
     100    @translation = Babel::Translation.new 
     101    @translation.string = @help_menu_string 
     102    @translation.language = @japanease 
     103    @translation.user = @test_user 
     104    @translation.value = 'ヘルプププ' 
     105    lambda { @translation.save! }.should raise_error 
     106  end 
     107   
     108  it 'should register same value for non active translation.' do 
     109    @translation = Babel::Translation.new 
     110    @translation.string = @help_menu_string 
     111    @translation.language = @japanease 
     112    @translation.user = @test_user 
     113    @translation.value = 'ヘルプ' 
     114    lambda { @translation.save! }.should_not raise_error 
     115  end 
    40116end 
    41  
    42 load File.join(APP_ROOT, 'spec', 'terminalizer.rb') 
  • org.jalcedo.babel.database/trunk/spec/initializer.rb

    r1337 r1338  
    11require 'init' 
    22 
    3 require 'babel/string' 
    43require 'babel/translation' 
    54 
    6 Babel::String.create( 
    7   :file_id => 1, 
    8   :name => 'category.file.name', 
    9   :value => 'File', 
    10   :userid => 1, 
    11   :is_active => 1 
    12 
    13 edit_menu = Babel::String.create( 
    14   :file_id => 1, 
    15   :name => 'category.edit.name', 
    16   :value => 'Edit', 
    17   :userid => 1, 
    18   :is_active => 1 
    19 
    20 help_menu = Babel::String.create( 
    21   :file_id => 1, 
    22   :name => 'category.help.name', 
    23   :value => 'Help', 
    24   :userid => 1, 
    25   :is_active => 1 
    26 
    27  
    28 Babel::Translation.create( 
    29   :string_id => edit_menu.id, 
    30   :language_id => 3, 
    31   :version => '3.3', 
    32   :value => 'へんしゅー', 
    33   :userid => 1 
    34 
    35  
    36 Babel::Translation.create( 
    37   :string_id => help_menu.id, 
    38   :language_id => 3, 
    39   :version => '3.3', 
    40   :value => 'ヘルプ', 
    41   :userid => 1 
    42 
     5# Babel::Translation.create( 
     6#   :string_id => 2, 
     7#   :language_id => 3, 
     8#   :version => '3.3', 
     9#   :value => 'へんしゅー', 
     10#   :userid => 1 
     11# ) 
     12#  
     13# Babel::Translation.create( 
     14#   :string_id => 3, 
     15#   :language_id => 3, 
     16#   :version => '3.3', 
     17#   :value => 'ヘルプ', 
     18#   :userid => 1 
     19# ) 
  • org.jalcedo.babel.database/trunk/spec/terminalizer.rb

    r1337 r1338  
    11 
    2 Babel::Translation.delete_all 
    3 Babel::String.delete_all 
     2# Babel::Translation.delete_all