]> cat aescling's git repositories - mastodon.git/commitdiff
Add spec for Identity.find_for_oauth (#9441)
authorysksn <bluewhale1982@gmail.com>
Thu, 6 Dec 2018 08:38:49 +0000 (17:38 +0900)
committerYamagishi Kazutoshi <ykzts@desire.sh>
Thu, 6 Dec 2018 08:38:49 +0000 (17:38 +0900)
spec/models/identity_spec.rb

index 53f35541022a15daf97abf51d392089659289a56..689c9b797f4f6327695af58cd2de248d51088c50 100644 (file)
@@ -1,5 +1,16 @@
 require 'rails_helper'
 
 RSpec.describe Identity, type: :model do
-  pending "add some examples to (or delete) #{__FILE__}"
+  describe '.find_for_oauth' do
+    let(:auth) { Fabricate(:identity, user: Fabricate(:user)) }
+
+    it 'calls .find_or_create_by' do
+      expect(described_class).to receive(:find_or_create_by).with(uid: auth.uid, provider: auth.provider)
+      described_class.find_for_oauth(auth)
+    end
+
+    it 'returns an instance of Identity' do
+      expect(described_class.find_for_oauth(auth)).to be_instance_of Identity
+    end
+  end
 end