Testing: Add convenience option to Channel factory

This commit is contained in:
Ryan Lue 2020-03-13 02:28:50 +08:00 committed by Thorsten Eckel
parent 227b2b25b3
commit c290a89a8b
2 changed files with 12 additions and 37 deletions

View file

@ -47,13 +47,9 @@ FactoryBot.define do
},
search: [
{
term: 'zammad',
term: search_term,
group_id: Group.first.id
},
{
term: 'hash_tag1',
group_id: Group.first.id
}
],
},
subscribed_to_webhook_id: external_credential.credentials[:webhook_id],
@ -65,6 +61,7 @@ FactoryBot.define do
external_credential { create(:twitter_credential) }
oauth_token { external_credential.credentials[:oauth_token] }
oauth_token_secret { external_credential.credentials[:oauth_token_secret] }
search_term { 'zammad' }
end
trait :legacy do

View file

@ -904,24 +904,15 @@ RSpec.describe Channel::Driver::Twitter do
end
describe 'Race condition: when #fetch finds a half-processed, outgoing tweet' do
subject!(:channel) { create(:twitter_channel, custom_options: custom_options) }
let(:custom_options) do
{
subject!(:channel) do
create(:twitter_channel,
search_term: 'zammadzammadzammad',
custom_options: {
user: {
# Must match connected Twitter account's user ID (on Twitter)--
# that's how #fetch distinguishes between agents' tweets and other people's.
id: '1205290247124217856'
# Must match outgoing tweet author Twitter user ID
id: '1205290247124217856',
},
sync: {
search: [
{
term: 'zammadzammadzammad',
group_id: Group.first.id
}
]
}
}
})
end
let!(:tweet) { create(:twitter_article, body: 'zammadzammadzammad') }
@ -969,20 +960,7 @@ RSpec.describe Channel::Driver::Twitter do
end
context 'for very common search terms' do
subject(:channel) { create(:twitter_channel, custom_options: custom_options) }
let(:custom_options) do
{
sync: {
search: [
{
term: 'coronavirus',
group_id: Group.first.id
}
]
}
}
end
subject(:channel) { create(:twitter_channel, search_term: 'coronavirus') }
let(:twitter_articles) { Ticket::Article.joins(:type).where(ticket_article_types: { name: 'twitter status' }) }