Skip to content
Browse files

services are imported

  • Loading branch information...
1 parent 197cbcf commit d4dfcfc41d869b40708d6133b349520e06692db3 @tenderlove committed Dec 31, 2010
Showing with 20 additions and 0 deletions.
  1. +4 −0 app/models/account.rb
  2. +16 −0 test/unit/account_test.rb
View
4 app/models/account.rb
@@ -35,6 +35,10 @@ def self.import io
(record['portraits'] || []).each do |portrait|
account.portraits.create!(:url => portrait)
end
+
+ (record['services'] || []).each do |name, key|
+ account.services.create!(:name => name, :key => key)
+ end
end
end
end
View
16 test/unit/account_test.rb
@@ -90,4 +90,20 @@ def test_imports_portraits
account = Account.find_by_username 'aamine'
assert_equal 'http://jp.rubyist.net/magazine/?c=plugin;plugin=attach_download;p=0017-Hotlinks;file_name=aoki1.jpg', account.portraits.first.url
end
+
+ def test_imports_services
+ assert_difference('Service.count', 4) do
+ File.open(@yml, 'rb') { |f| Account.import f }
+ end
+
+ account = Account.find_by_username 'akira'
+ assert_equal 4, account.services.count
+
+ assert_equal [
+ ['twitter', 'arika'],
+ ['friendfeed', 'arika'],
+ ['iddy', 'arika'],
+ ['mixi', '1549'],
+ ].sort, account.services.map { |x| [x.name, x.key] }.sort
+ end
end

0 comments on commit d4dfcfc

Please sign in to comment.
Something went wrong with that request. Please try again.