Add avatar_url column, modify migration file

openid
Micha Wrobel 13 years ago
parent 54b13fa3a6
commit 0190c3f049

@ -5,9 +5,10 @@ class User < ActiveRecord::Base
def self.create_with_omniauth(auth)
create! do |user|
user.provider = auth["provider"]
user.uid = auth["uid"]
user.name = auth["info"]["name"]
user.provider = auth["provider"]
user.uid = auth["uid"]
user.name = auth["info"]["name"]
user.avatar_url = OauthHelper.get_avatar_url(auth)
end
end

@ -1,10 +1,11 @@
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :provider
t.string :uid
t.string :provider, :null => false
t.string :uid, :null => false
t.string :email
t.string :name
t.string :avatar_url
t.timestamps
end

@ -37,10 +37,11 @@ ActiveRecord::Schema.define(:version => 20120225124004) do
add_index "asciicasts", ["user_id"], :name => "index_asciicasts_on_user_id"
create_table "users", :force => true do |t|
t.string "provider"
t.string "uid"
t.string "provider", :null => false
t.string "uid", :null => false
t.string "email"
t.string "name"
t.string "avatar_url"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end

@ -6,5 +6,6 @@ FactoryGirl.define do
uid "1234"
email "foo@bar.com"
name "foo"
avatar_url ""
end
end

@ -27,7 +27,21 @@ describe User do
user.provider.should == provider
user.uid.should == uid
user.name.should == name
user.avatar_url.should be_nil
end
context "when avatar available" do
let(:avatar_url) { "http://foo.bar/avatar.jpg"}
before do
OauthHelper.stub(:get_avatar_url).and_return(avatar_url)
end
it "assigns avatar_url" do
user = User.create_with_omniauth(auth)
user.avatar_url.should == avatar_url
end
end
end
end

Loading…
Cancel
Save