2019-12-05 07:50:04 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
2021-07-31 15:49:42 +00:00
|
|
|
require Rails.root.join 'spec/models/concerns/reauthorizable_shared.rb'
|
2019-12-05 07:50:04 +00:00
|
|
|
|
|
|
|
RSpec.describe Channel::FacebookPage do
|
2021-11-11 07:33:48 +00:00
|
|
|
before do
|
|
|
|
stub_request(:post, /graph.facebook.com/)
|
|
|
|
end
|
|
|
|
|
2020-09-04 13:43:47 +00:00
|
|
|
let(:channel) { create(:channel_facebook_page) }
|
2019-12-05 07:50:04 +00:00
|
|
|
|
|
|
|
it { is_expected.to validate_presence_of(:account_id) }
|
2020-01-07 17:29:17 +00:00
|
|
|
# it { is_expected.to validate_uniqueness_of(:page_id).scoped_to(:account_id) }
|
2019-12-05 07:50:04 +00:00
|
|
|
it { is_expected.to belong_to(:account) }
|
2021-11-18 05:02:29 +00:00
|
|
|
it { is_expected.to have_one(:inbox).dependent(:destroy_async) }
|
2020-09-04 13:43:47 +00:00
|
|
|
|
2020-09-29 19:42:32 +00:00
|
|
|
describe 'concerns' do
|
|
|
|
it_behaves_like 'reauthorizable'
|
2021-08-01 12:45:39 +00:00
|
|
|
|
|
|
|
context 'when prompt_reauthorization!' do
|
|
|
|
it 'calls channel notifier mail for facebook' do
|
|
|
|
admin_mailer = double
|
|
|
|
mailer_double = double
|
|
|
|
expect(AdministratorNotifications::ChannelNotificationsMailer).to receive(:with).and_return(admin_mailer)
|
|
|
|
expect(admin_mailer).to receive(:facebook_disconnect).with(channel.inbox).and_return(mailer_double)
|
|
|
|
expect(mailer_double).to receive(:deliver_later)
|
|
|
|
channel.prompt_reauthorization!
|
|
|
|
end
|
|
|
|
end
|
2020-09-29 19:42:32 +00:00
|
|
|
end
|
|
|
|
|
2020-09-04 13:43:47 +00:00
|
|
|
it 'has a valid name' do
|
|
|
|
expect(channel.name).to eq('Facebook')
|
|
|
|
end
|
2019-12-05 07:50:04 +00:00
|
|
|
end
|