diff --git a/spec/factories/channel.rb b/spec/factories/channel.rb index 0b70039e3..71b280772 100644 --- a/spec/factories/channel.rb +++ b/spec/factories/channel.rb @@ -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 diff --git a/spec/models/channel/driver/twitter_spec.rb b/spec/models/channel/driver/twitter_spec.rb index 3144cc801..9f2447352 100644 --- a/spec/models/channel/driver/twitter_spec.rb +++ b/spec/models/channel/driver/twitter_spec.rb @@ -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 - { - 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' - }, - sync: { - search: [ - { - term: 'zammadzammadzammad', - group_id: Group.first.id - } - ] - } - } + subject!(:channel) do + create(:twitter_channel, + search_term: 'zammadzammadzammad', + custom_options: { + user: { + # Must match outgoing tweet author Twitter user ID + id: '1205290247124217856', + }, + }) 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' }) }