gmail_spec.rb 917 B

123456789101112131415161718192021222324252627
  1. require 'rails_helper'
  2. RSpec.describe 'Gmail XOAUTH2', type: :integration do # rubocop:disable RSpec/DescribeClass
  3. let(:channel) do
  4. create(:google_channel).tap(&:refresh_xoauth2!)
  5. end
  6. before do
  7. required_envs = %w[GMAIL_REFRESH_TOKEN GMAIL_CLIENT_ID GMAIL_CLIENT_SECRET GMAIL_USER]
  8. required_envs.each do |key|
  9. skip("NOTICE: Missing environment variable #{key} for test! (Please fill up: #{required_envs.join(' && ')})") if ENV[key].blank?
  10. end
  11. end
  12. context 'when probing inbound' do
  13. it 'succeeds' do
  14. result = EmailHelper::Probe.inbound(channel.options[:inbound])
  15. expect(result[:result]).to eq('ok')
  16. end
  17. end
  18. context 'when probing outbound' do
  19. it 'succeeds' do
  20. result = EmailHelper::Probe.outbound(channel.options[:outbound], ENV['GMAIL_USER'], "test gmail oauth unittest #{Random.new_seed}")
  21. expect(result[:result]).to eq('ok')
  22. end
  23. end
  24. end