<commit_before># encoding: UTF-8

require 'spec_helper'

describe 'src_images/_src_image.html' do
  let(:src_thumb) { mock_model(SrcThumb, width: 19, height: 78) }
  let(:src_image) do
    mock_model(SrcImage, work_in_progress: false, src_thumb: src_thumb)
  end
  let(:user) { FactoryGirl.create(:user) }

  before do
    view.stub(current_user: user)

    render partial: 'src_images/src_image',
           locals: { src_image: src_image }
  end

  context 'the image has been processed' do

    it 'shows the thumbnail' do
      expect(rendered).to match(src_thumb.id.to_s)
    end

    it 'puts the width in the image tag' do
      expect(rendered).to match('width="19"')
    end

    it 'puts the height in the image tag' do
      expect(rendered).to match('height="78"')
    end

    it 'has the id hash as data' do
      expect(rendered).to match("data-id=\"#{src_image.id_hash}\"")
    end

  end

  context 'the image has not been processed yet' do

    let(:src_image) { mock_model(SrcImage, work_in_progress: true) }

    it 'shows as under construction' do<commit_msg>Remove usage of stub.<commit_after># encoding: UTF-8

require 'spec_helper'

describe 'src_images/_src_image.html' do
  let(:src_thumb) { mock_model(SrcThumb, width: 19, height: 78) }
  let(:src_image) do
    mock_model(SrcImage, work_in_progress: false, src_thumb: src_thumb)
  end
  let(:user) { FactoryGirl.create(:user) }

  before do
    allow(view).to receive(:current_user).with(no_args).and_return(user)

    render partial: 'src_images/src_image',
           locals: { src_image: src_image }
  end

  context 'the image has been processed' do

    it 'shows the thumbnail' do
      expect(rendered).to match(src_thumb.id.to_s)
    end

    it 'puts the width in the image tag' do
      expect(rendered).to match('width="19"')
    end

    it 'puts the height in the image tag' do
      expect(rendered).to match('height="78"')
    end

    it 'has the id hash as data' do
      expect(rendered).to match("data-id=\"#{src_image.id_hash}\"")
    end

  end

  context 'the image has not been processed yet' do

    let(:src_image) { mock_model(SrcImage, work_in_progress: true) }

    it 'shows as under construction' do
{'fraction_non_alphanumeric': 0.1137290439510648, 'fraction_numerical': 0.008155867693701857, 'mean_word_length': 3.4248496993987976, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5210574', 'n_tokens_mistral': 781, 'n_tokens_neox': 737, 'n_words': 212}