Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

nicknames are imported

  • Loading branch information...
commit e06e00d937c240963e892f3720156f61ce7a3771 1 parent ad502d5
@tenderlove authored
Showing with 16 additions and 0 deletions.
  1. +4 −0 app/models/account.rb
  2. +12 −0 test/unit/account_test.rb
View
4 app/models/account.rb
@@ -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
View
12 test/unit/account_test.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.