Skip to content

Commit

Permalink
nicknames are imported
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Jan 1, 2011
1 parent ad502d5 commit e06e00d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/account.rb
Expand Up @@ -17,6 +17,10 @@ def self.import io
record['name'].each do |name|
account.names.create!(:value => name)
end

(record['nick'] || []).each do |name|
account.nicks.create!(:value => name)
end
end
end
end
12 changes: 12 additions & 0 deletions test/unit/account_test.rb
Expand Up @@ -50,4 +50,16 @@ def test_imports_names
n.value
}.sort
end

def test_imports_nicks
assert_difference('Nick.count', 3) do
File.open(@yml, 'rb') { |f| Account.import f }
end

account = Account.find_by_username('H_Konishi')
assert_equal [], account.nicks

account = Account.find_by_username('aamine')
assert_equal ['青木さん'], account.nicks.map { |x| x.value }
end
end

0 comments on commit e06e00d

Please sign in to comment.