Skip to content

Commit d95155a

Browse files
committed
Merge pull request #156 from seuros/unused
remove unused field
2 parents 9c5f5f4 + e4ab58d commit d95155a

File tree

7 files changed

+13
-24
lines changed

7 files changed

+13
-24
lines changed

app/models/concerns/user_oauth.rb

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def apply_oauth(oauth)
2020
self.twitter_token = oauth[:credentials][:token]
2121
self.twitter_secret = oauth[:credentials][:secret]
2222
self.about = extract_from_oauth_extras(:description, oauth) if self.about.blank?
23-
self.joined_twitter_on = extract_joined_on(oauth) if self.joined_twitter_on.blank?
2423
when 'developer'
2524
logger.debug "Using the Developer Strategy for OmniAuth"
2625
logger.ap oauth, :debug
@@ -45,7 +44,6 @@ def for_omniauth(auth)
4544
if user = find_with_oauth(auth)
4645
user.apply_oauth(auth)
4746
user.save! if user.changed?
48-
return user
4947
else
5048
user = new(
5149
name: auth[:info][:name],
@@ -56,31 +54,21 @@ def for_omniauth(auth)
5654
user.avatar.download! avatar_url_for(auth) unless Rails.env.test?
5755
user.apply_oauth(auth)
5856
user.username = auth[:info][:nickname]
59-
return user
6057
end
58+
user
6159
end
6260

6361
def find_with_oauth(oauth)
6462
case oauth[:provider]
6563
when 'github'
66-
github_scope = (oauth[:uid] ? where(github_id: oauth[:uid]) : where(github: oauth[:info][:nickname]))
67-
raise "Not a unique github credential #{oauth[:uid] || oauth[:info][:nickname]}" if github_scope.count > 1
68-
return github_scope.first
64+
(oauth[:uid] ? find_by_github_id(oauth[:uid]) : find_by_github(oauth[:info][:nickname]))
6965
when 'linkedin'
70-
linkedin_scope = where(linkedin_id: oauth[:uid])
71-
raise "Not a unique linkedin credential #{oauth[:uid]}" if linkedin_scope.count > 1
72-
return linkedin_scope.first
66+
find_by_linkedin_id(oauth[:uid])
7367
when 'twitter'
74-
twitter_scope = where(twitter_id: oauth[:uid])
75-
raise "Not a unique twitter credential #{oauth[:uid]}" if twitter_scope.count > 1
76-
return twitter_scope.first
77-
when 'developer'
78-
fail 'Developer Strategy must not be used in production.' if Rails.env.production?
79-
developer_scope = where(email: oauth[:uid])
80-
raise "Looks like there's duplicate users for the email '#{oauth[:uid]}'. Check user ids: #{developer_scope.map(&:id).join(', ')}" if developer_scope.count > 1
81-
return developer_scope.first
68+
find_by_twitter_id(oauth[:uid])
8269
else
83-
raise "Unexpected provider: #{oauth[:provider]}"
70+
fail 'Developer Strategy must not be used in production.' if Rails.env.production?
71+
find_by_email(oauth[:uid])
8472
end
8573
end
8674

app/models/concerns/user_twitter.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def clear_twitter!
1414
self.twitter = nil
1515
self.twitter_token = nil
1616
self.twitter_secret = nil
17-
self.joined_twitter_on = nil
1817
save!
1918
end
2019
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class RemoveJoinedTwitterOnFromUser < ActiveRecord::Migration
2+
def up
3+
remove_column :users, :joined_twitter_on
4+
end
5+
6+
end

db/schema.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended to check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(:version => 20140801145543) do
14+
ActiveRecord::Schema.define(:version => 20140807214719) do
1515

1616
add_extension "citext"
1717

@@ -546,7 +546,6 @@
546546
t.string "referred_by"
547547
t.text "about"
548548
t.date "joined_github_on"
549-
t.date "joined_twitter_on"
550549
t.string "avatar"
551550
t.string "banner"
552551
t.datetime "remind_to_invite_team_members"

spec/controllers/users_controller_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@
247247
expect(assigns[:user].twitter_secret).to eq('8fRS1ZARd6Wm53wvvDwHNrBmZcW0H2aSwmQjuOTHl')
248248
expect(assigns[:user].twitter_id).to eq('6271932')
249249
expect(assigns[:user].location).to eq('San Francisco')
250-
expect(assigns[:user].joined_twitter_on).to eq(Date.parse('Wed May 23 21:14:29 +0000 2007'))
251250
expect(assigns[:user].about).to eq('Dad. Amateur Foodie. Founder Extraordinaire of @coderwall')
252251
end
253252
end

spec/fabricators/user_fabricator.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@
8282
# referred_by :string(255)
8383
# about :text
8484
# joined_github_on :date
85-
# joined_twitter_on :date
8685
# avatar :string(255)
8786
# banner :string(255)
8887
# remind_to_invite_team_members :datetime

spec/models/user_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@ class AlsoNotaBadge < BadgeBase
397397
# referred_by :string(255)
398398
# about :text
399399
# joined_github_on :date
400-
# joined_twitter_on :date
401400
# avatar :string(255)
402401
# banner :string(255)
403402
# remind_to_invite_team_members :datetime

0 commit comments

Comments
 (0)