Skip to content

Commit

Permalink
renamed username to uid
Browse files Browse the repository at this point in the history
  • Loading branch information
bcardarella committed Dec 13, 2012
1 parent 3646abc commit 410ffbc
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions db/migrate/20120227014023_create_easy_auth_identities.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
class CreateEasyAuthIdentities < ActiveRecord::Migration
def change
create_table :identities do |t|
t.string :username
t.string :uid
t.string :token
t.string :account_type
t.integer :account_id
t.string :type
t.timestamps
end

add_index :identities, :username
add_index :identities, :uid
end
end
2 changes: 1 addition & 1 deletion lib/easy_auth/models/identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module EasyAuth::Models::Identity

reverse_included do
belongs_to :account, :polymorphic => true
validates :username, :uniqueness => { :scope => :type }, :presence => true
validates :uid, :uniqueness => { :scope => :type }, :presence => true
end

module ClassMethods
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
ActiveRecord::Schema.define(:version => 20120227014023) do

create_table "identities", :force => true do |t|
t.string "username"
t.string "uid"
t.string "token"
t.string "account_type"
t.integer "account_id"
Expand All @@ -23,7 +23,7 @@
t.datetime "updated_at", :null => false
end

add_index "identities", ["username"], :name => "index_identities_on_username"
add_index "identities", ["uid"], :name => "index_identities_on_uid"

create_table "users", :force => true do |t|
t.string "email"
Expand Down
10 changes: 5 additions & 5 deletions spec/models/identity_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
require 'spec_helper'

describe EasyAuth::Models::Identity do
describe 'username' do
describe 'uid' do
subject { Identity.new }
before do
Identity.create(:username => 'testuser')
TestIdentity.create(:username => 'otheruser')
Identity.create(:uid => 'testuser')
TestIdentity.create(:uid => 'otheruser')
end
it { should have_valid(:username).when('otheruser') }
it { should_not have_valid(:username).when(nil, '', 'testuser') }
it { should have_valid(:uid).when('otheruser') }
it { should_not have_valid(:uid).when(nil, '', 'testuser') }
end
end
2 changes: 1 addition & 1 deletion spec/support/factories.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FactoryGirl.define do
factory :user do
email 'test@example.com'
identities { [TestIdentity.new(:username => 'testuser')] }
identities { [TestIdentity.new(:uid => 'testuser')] }
end
end

0 comments on commit 410ffbc

Please sign in to comment.