<commit_before>require 'spec_helper'
require 'support/child_builder'

describe ChildImagesController do
  include LoggedIn
  include ChildBuilder
  include CustomMatchers
  describe "routing" do
    it "should have a route for a child current photo" do
      { :get => "/children/1/photo" }.should route_to(:controller => "child_images", :action => "show_photo", :child_id => "1")
    end

    it "should have a route for a child specific photo" do
      { :get => "/children/c1/photo/p1" }.should route_to(:controller => "child_images", :action => "show_photo", :child_id => "c1", :id => "p1")
    end
    it "should have a route for a child current thumbnail" do
      {:get => '/children/1/thumbnail'}.should route_to(:controller => "child_images", :action => "show_thumbnail", :child_id => "1")
    end
    it "should have a route for a child specific thumbnail" do
      { :get => "/children/c1/thumbnail/t1" }.should route_to(:controller => "child_images", :action => "show_thumbnail", :child_id => "c1", :id => "t1")
    end
  end

  describe "response" do
    it "should return current child's photo" do
      given_a_child.
          with_id("1").
          with_photo(uploadable_photo)

      get :show_photo, :child_id => "1"

      response.should represent_inline_attachment uploadable_photo
    end

    it "should return requested child's photo" do
      given_a_child.
          with_id("1")
          with_photo(uploadable_photo, "current").
          with_photo(uploadable_photo_jeff, "other", false)

      get :show_photo, :child_id => "1", :id => "other"

      response.should represent_inline_attachment uploadable_photo_jeff
    end

    it "should return current child's thumbnail" do
      given_a_child.
          with_id("1")
          with_photo(uploadable_photo)

      get :show_thumbnail, :child_id => "1"

      thumbnail = to_thumbnail(60, uploadable_photo.original_path)
      response.should represent_inline_attachment thumbnail
    end

    it "should return requested child's thumbnail" do
      given_a_child.
          with_id("1")
          with_photo(uploadable_photo_jeff).
          with_photo(uploadable_photo, "other", false)

      get :show_thumbnail, :child_id => "1", :id => "other"

      thumbnail = to_thumbnail(60, uploadable_photo.original_path)
      response.should represent_inline_attachment thumbnail
    end

    it "should return no photo available clip when no image is found" do
      given_a_child.
          with_id("1")
          with_no_photos

      get :show_photo, :child_id => "1"

      response.should represent_inline_attachment no_photo_clip
    end
  end
end
<commit_msg>Remove reference to old LoggedIn module. Switch to new fake_login.<commit_after>require 'spec_helper'
require 'support/child_builder'

describe ChildImagesController do
  include ChildBuilder
  include CustomMatchers
  before do
    fake_login
  end
  describe "routing" do
    it "should have a route for a child current photo" do
      { :get => "/children/1/photo" }.should route_to(:controller => "child_images", :action => "show_photo", :child_id => "1")
    end

    it "should have a route for a child specific photo" do
      { :get => "/children/c1/photo/p1" }.should route_to(:controller => "child_images", :action => "show_photo", :child_id => "c1", :id => "p1")
    end
    it "should have a route for a child current thumbnail" do
      {:get => '/children/1/thumbnail'}.should route_to(:controller => "child_images", :action => "show_thumbnail", :child_id => "1")
    end
    it "should have a route for a child specific thumbnail" do
      { :get => "/children/c1/thumbnail/t1" }.should route_to(:controller => "child_images", :action => "show_thumbnail", :child_id => "c1", :id => "t1")
    end
  end

  describe "response" do
    it "should return current child's photo" do
      given_a_child.
          with_id("1").
          with_photo(uploadable_photo)

      get :show_photo, :child_id => "1"

      response.should represent_inline_attachment uploadable_photo
    end

    it "should return requested child's photo" do
      given_a_child.
          with_id("1")
          with_photo(uploadable_photo, "current").
          with_photo(uploadable_photo_jeff, "other", false)

      get :show_photo, :child_id => "1", :id => "other"

      response.should represent_inline_attachment uploadable_photo_jeff
    end

    it "should return current child's thumbnail" do
      given_a_child.
          with_id("1")
          with_photo(uploadable_photo)

      get :show_thumbnail, :child_id => "1"

      thumbnail = to_thumbnail(60, uploadable_photo.original_path)
      response.should represent_inline_attachment thumbnail
    end

    it "should return requested child's thumbnail" do
      given_a_child.
          with_id("1")
          with_photo(uploadable_photo_jeff).
          with_photo(uploadable_photo, "other", false)

      get :show_thumbnail, :child_id => "1", :id => "other"

      thumbnail = to_thumbnail(60, uploadable_photo.original_path)
      response.should represent_inline_attachment thumbnail
    end

    it "should return no photo available clip when no image is found" do
      given_a_child.
          with_id("1")
          with_no_photos

      get :show_photo, :child_id => "1"

      response.should represent_inline_attachment no_photo_clip
    end
  end
end

{'fraction_non_alphanumeric': 0.10512581547064306, 'fraction_numerical': 0.009692451071761416, 'mean_word_length': 3.15968992248062, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 53, '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': '3394009', 'n_tokens_mistral': 1675, 'n_tokens_neox': 1628, 'n_words': 455}