diff --git a/app/models/invitation.rb b/app/models/invitation.rb index 87bbcb775b334d88b343ea8bb319dfa646dc4064..d9752a4be243cd98e06759a626a77eb50f0545f8 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -36,7 +36,7 @@ class Invitation < ActiveRecord::Base if service == 'email' existing_user ||= User.where(:email => identifier).first else - existing_user ||= User.joins(:services).where(:services => {:provider => service, :uid => identifier}).first + existing_user ||= User.joins(:services).where(:services => {:type => "Services::#{service.titleize}", :uid => identifier}).first end existing_user diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index ac89fb63c8f1eed9508ef127ba52decd926f2bb1..bd10561b1eaea49f888c35e60c1cd02442435d13 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -83,7 +83,7 @@ describe ServicesController do describe '#finder' do before do - @service1 = Factory.create(:service, :provider => 'facebook') + @service1 = Services::Facebook.new @user.services << @service1 end @@ -97,9 +97,8 @@ describe ServicesController do describe '#invite' do before do - @service1 = Services::Facebook.create(:provider => 'facebook') @uid = "abc" - @invite_params = {:provider => @service1.provider, :uid => @uid, :aspect_id => @user.aspects.first.id} + @invite_params = {:provider => 'facebook', :uid => @uid, :aspect_id => @user.aspects.first.id} end it 'sets the subject' do diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb index ba18082894605654227571db1ec8fbf600715022..2e37559560c5a256fe6384e49d54bbdb76c417c4 100644 --- a/spec/models/invitation_spec.rb +++ b/spec/models/invitation_spec.rb @@ -92,7 +92,7 @@ describe Invitation do it 'by service' do uid = '123324234' - @users[0].services << Services::Facebook.create(:provider => 'facebook', :uid => uid) + @users[0].services << Services::Facebook.new(:uid => uid) @users[0].save @type = 'facebook' @@ -206,6 +206,7 @@ describe Invitation do :into => aspect, :message => @message} @invitee = Invitation.create_invitee(:service => 'email', :identifier => @email) + @valid_params[:existing_user] = @invitee end it 'creates no user' do @valid_params[:existing_user] = @invitee diff --git a/spec/models/services/facebook_spec.rb b/spec/models/services/facebook_spec.rb index 2cc8df8757206fd4a61bb444db39bae3dddb5157..70d718ac684383d1c0c13a80dd59fb6f502b55d8 100644 --- a/spec/models/services/facebook_spec.rb +++ b/spec/models/services/facebook_spec.rb @@ -32,7 +32,7 @@ describe Services::Facebook do @user2 = Factory.create(:user_with_aspect) @user2_fb_id = '820651' @user2_fb_name = 'Maxwell Salzberg' - @user2_service = Services::Facebook.create(:uid => @user2_fb_id, :access_token => "yo") + @user2_service = Services::Facebook.new(:uid => @user2_fb_id, :access_token => "yo") @user2.services << @user2_service @fb_list_hash = <<JSON {