<commit_before>require 'rails_helper'

describe ScheduledUpdateFeedJob do

  before :each do
    @feed = FactoryGirl.create :feed
    allow(FeedClient).to receive :fetch
  end

  it 'updates feed when the job runs' do
    expect(FeedClient).to receive(:fetch).with @feed

    ScheduledUpdateFeedJob.perform @feed.id
  end

  it 'recalculates unread entries count in feed' do
    # user is subscribed to @feed with 1 entry
    user = FactoryGirl.create :user

    entry = FactoryGirl.build :entry, feed_id: @feed.id
    @feed.entries << entry

    user.subscribe @feed.fetch_url

    # @feed has an incorrect unread entry count of 10 for user
    feed_subscription = FeedSubscription.where(user_id: user.id, feed_id: @feed.id).first
    feed_subscription.update unread_entries: 10

    ScheduledUpdateFeedJob.perform @feed.id

    # Unread count should be corrected
    expect(user.feed_unread_count(@feed)).to eq 1
  end
<commit_msg>Do not stub FeedClient.fetch in all ScheduledUpdateFeedJob tests.<commit_after>require 'rails_helper'

describe ScheduledUpdateFeedJob do

  before :each do
    @feed = FactoryGirl.create :feed
  end

  it 'updates feed when the job runs' do
    expect(FeedClient).to receive(:fetch).with @feed

    ScheduledUpdateFeedJob.perform @feed.id
  end

  it 'recalculates unread entries count in feed' do
    # user is subscribed to @feed with 1 entry
    user = FactoryGirl.create :user

    entry = FactoryGirl.build :entry, feed_id: @feed.id
    @feed.entries << entry

    user.subscribe @feed.fetch_url

    # @feed has an incorrect unread entry count of 10 for user
    feed_subscription = FeedSubscription.where(user_id: user.id, feed_id: @feed.id).first
    feed_subscription.update unread_entries: 10

    ScheduledUpdateFeedJob.perform @feed.id

    # Unread count should be corrected
    expect(user.feed_unread_count(@feed)).to eq 1
  end

{'fraction_non_alphanumeric': 0.0777422790202343, 'fraction_numerical': 0.006389776357827476, 'mean_word_length': 3.721105527638191, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '412225', 'n_tokens_mistral': 601, 'n_tokens_neox': 563, 'n_words': 178}