<commit_before>require 'test_helper'

class JsonTest < ActiveSupport::TestCase
  attr_reader :now, :build, :repository

  def setup
    @now = Time.now
    Time.stubs(:now).returns(now)

    @build = Factory.create(:build, :started_at => now, :committed_at => now)
    @repository = build.repository
    super
  end

  test 'as_json(:for => :job) includes everything required for the resque build job (2)' do
    expected = { 'id' => build.id, 'number' => '1', 'commit' => '<PASSWORD>' }
    assert_equal_hashes expected, build.as_json(:for => :job)

    expected = { 'id' => repository.id, :slug => 'svenfuchs/minimal' }
    assert_equal_hashes expected, repository.as_json(:for => :job)
  end

  test 'as_json(:for => :"build:queued") includes everything required for the build:scheduled event (4)' do
    expected = { 'id' => build.id, 'number' => build.number }
    assert_equal_hashes expected, build.as_json(:for => :'build:queued')

    expected = { 'id' => repository.id, :slug => repository.slug }<commit_msg>Fixing tests that were failing after https://github.com/travis-ci/travis-ci/commit/430ee596d832bb2b939e524b7cc7d9a0eb7ea488 commit<commit_after>require 'test_helper'

class JsonTest < ActiveSupport::TestCase
  attr_reader :now, :build, :repository

  def setup
    @now = Time.now
    Time.stubs(:now).returns(now)

    @build = Factory.create(:build, :started_at => now, :committed_at => now)
    @repository = build.repository
    super
  end

  test 'as_json(:for => :job) includes everything required for the resque build job (2)' do
    expected = { 'id' => build.id, 'number' => '1', 'commit' => '<PASSWORD>ef', 'branch' => 'master' }
    assert_equal_hashes expected, build.as_json(:for => :job)

    expected = { 'id' => repository.id, :slug => 'svenfuchs/minimal' }
    assert_equal_hashes expected, repository.as_json(:for => :job)
  end

  test 'as_json(:for => :"build:queued") includes everything required for the build:scheduled event (4)' do
    expected = { 'id' => build.id, 'number' => build.number }
    assert_equal_hashes expected, build.as_json(:for => :'build:queued')

    expected = { 'id' => repository.id, :slug => repository.slug }
{'fraction_non_alphanumeric': 0.15204409738171795, 'fraction_numerical': 0.013780431786862656, 'mean_word_length': 4.260869565217392, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 38, 'https://': 1, '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': '4786887', 'n_tokens_mistral': 736, 'n_tokens_neox': 714, 'n_words': 177}