Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set User#zooniverse_id for panoptes-only users #1026

Merged
merged 1 commit into from
Jun 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class User < ActiveRecord::Base
before_validation :setup_unsubscribe_token, on: [:create]
before_validation :update_ouroboros_created
before_save :update_ouroboros_created
after_create :set_zooniverse_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume we don't want to add this to migrated users.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like it will since it happens with the ||=

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Just panoptes users that don't have a zooniverse_id


can_be_linked :membership, :all
can_be_linked :user_group, :all
Expand Down Expand Up @@ -196,6 +197,10 @@ def update_ouroboros_created
end
end

def set_zooniverse_id
self.zooniverse_id ||= "panoptes-#{ id }"
end

def setup_unsubscribe_token
if self.login
self.unsubscribe_token ||= UserUnsubscribeMessageVerifier.create_access_token(self.login)
Expand Down
6 changes: 6 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@
end
end

describe '#set_zooniverse_id' do
let(:user){ create :user }
subject{ user.zooniverse_id }
it{ is_expected.to eql "panoptes-#{ user.id }" }
end

describe "#unsubscribe_token" do

it "should not build one automatically on build" do
Expand Down