Commit e0189d3329ebbeaf784103cba24316ecbd6654bb
1 parent
bb8475aa
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
tests support for api signup on oauth_client plugin
Showing
1 changed file
with
28 additions
and
3 deletions
Show diff stats
plugins/oauth_client/test/unit/user_test.rb
@@ -42,12 +42,37 @@ class UserTest < ActiveSupport::TestCase | @@ -42,12 +42,37 @@ class UserTest < ActiveSupport::TestCase | ||
42 | user = User.create!(:email => 'testoauth@example.com', :login => 'testoauth', :oauth_providers => [provider]) | 42 | user = User.create!(:email => 'testoauth@example.com', :login => 'testoauth', :oauth_providers => [provider]) |
43 | end | 43 | end |
44 | 44 | ||
45 | - should 'save oauth token when create with oauth' do | ||
46 | - | 45 | + should 'save oauth data when create with oauth' do |
46 | + OauthClientPlugin::SignupDataStore.stubs(:get_oauth_data).returns({ | ||
47 | + :provider_id => provider.id, | ||
48 | + :credentials => { | ||
49 | + token: 'abcdef', | ||
50 | + any_field: 'abx' | ||
51 | + } | ||
52 | + }) | ||
53 | + user = User.create!(:email => 'testoauth@example.com', :login => 'testoauth', :oauth_providers => [], :oauth_signup_token => 'token') | ||
54 | + user.oauth_signup_token = 'token' | ||
55 | + assert user.oauth_user_providers.first.oauth_data.present? | ||
47 | end | 56 | end |
48 | 57 | ||
49 | - should 'note save oauth token when create with oauth' do | 58 | + should 'save oauth as a hash when creating user with oauth' do |
59 | + OauthClientPlugin::SignupDataStore.stubs(:get_oauth_data) | ||
60 | + .returns( | ||
61 | + { | ||
62 | + :provider_id => provider.id, | ||
63 | + :credentials => { | ||
64 | + token: 'abcdef', | ||
65 | + any_field: 'abx' | ||
66 | + } | ||
67 | + } | ||
68 | + ) | ||
69 | + user = User.create!(:email => 'testoauth@example.com', :login => 'testoauth', :oauth_providers => [], :oauth_signup_token => 'token') | ||
70 | + assert user.oauth_user_providers.first.oauth_data.is_a? Hash | ||
71 | + end | ||
50 | 72 | ||
73 | + should 'note save oauth user provider when user is not originated from oauth' do | ||
74 | + user = User.create!(:email => 'testoauth@example.com', :login => 'testoauth', :password => 'test', :password_confirmation => 'test') | ||
75 | + assert user.oauth_user_providers.count.eql? 0 | ||
51 | end | 76 | end |
52 | 77 | ||
53 | end | 78 | end |