Skip to content
Browse files

ApplicationUser追加

  • Loading branch information...
1 parent caa6002 commit a69c66e58b8ad0a0183098fc094c551059fe58e1 @naoya committed Aug 21, 2012
Showing with 50 additions and 0 deletions.
  1. +26 −0 app/application_user.rb
  2. +24 −0 spec/application_user_spec.rb
View
26 app/application_user.rb
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+## 最終的に iOS の Keychain に切り替える
+class ApplicationUser
+ attr_accessor :hatena_id, :password
+
+ def initialize
+ end
+
+ def save
+ App::Persistence['applicatoin_user'] = {
+ :hatena_id => @hatena_id,
+ :password => @password
+ }
+ self
+ end
+
+ def load
+ user = App::Persistence['applicatoin_user'] || {}
+ self.hatena_id = user[:hatena_id]
+ self.password = user[:password]
+ self
+ end
+
+ # def reset
+ # end
+end
View
24 spec/application_user_spec.rb
@@ -0,0 +1,24 @@
+describe "ApplicationUser" do
+ before do
+ @user = ApplicationUser.new
+ @user.hatena_id = "naoya"
+ @user.password = "password"
+ @user.save
+ end
+
+ it "should have saved information" do
+ @user.hatena_id.should == "naoya"
+ @user.password.should == "password"
+ end
+
+ it "should save hatena_id and password" do
+ @user.hatena_id = "new_id"
+ @user.password = "new_password"
+ @user.save
+
+ @new_user = ApplicationUser.new
+ @new_user.load
+ @new_user.hatena_id.should == "new_id"
+ @new_user.password.should == "new_password"
+ end
+end

0 comments on commit a69c66e

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