<commit_before>require 'test_helper'

class ProfilesControllerTest < ActionController::TestCase

  context "for a user that doesn't exist" do
    should "throw a not found" do
      assert_raise ActiveRecord::RecordNotFound do
        get :show, :id => "unknown"
      end
    end
  end

  context "when logged in" do
    setup do
      @user = create(:user)
      sign_in_as(@user)
    end

    context "on GET to show" do
      setup do
        @rubygems = (0..10).map do |n|
          create(:rubygem, :downloads => n * 100).tap do |rubygem|
            create(:ownership, :rubygem => rubygem, :user => @user)
          end
        end.reverse

        get :show, :id => @user.handle
      end

      should respond_with :success
      should render_template :show
      should assign_to(:user) { @user }
      should "assign the last 10 most downloaded gems" do
        assert_equal @rubygems[0..9], assigns[:rubygems]
        pending
      end
      should "assign the extra gems you own" do
        assert_equal [@rubygems.last], assigns[:extra_rubygems]
        pending
      end
    end

    context "on GET to show with handle" do
      setup do
        get :show, :id => @user.handle
      end
<commit_msg>Issue #438<commit_after>require 'test_helper'

class ProfilesControllerTest < ActionController::TestCase

  context "for a user that doesn't exist" do
    should "throw a not found" do
      assert_raise ActiveRecord::RecordNotFound do
        get :show, :id => "unknown"
      end
    end
  end

  context "when logged in" do
    setup do
      @user = create(:user)
      sign_in_as(@user)
    end

    context "on GET to show" do
      setup do
        @rubygems = (0..10).map do |n|
          create(:rubygem_with_downloads, :downloads => n * 100).tap do |rubygem|
            create(:ownership, :rubygem => rubygem, :user => @user)
          end
        end.reverse

        get :show, :id => @user.handle
      end

      should respond_with :success
      should render_template :show
      should assign_to(:user) { @user }
      should "assign the last 10 most downloaded gems" do
        assert_equal @rubygems[0..9], assigns[:rubygems]
        pending
      end
      should "assign the extra gems you own" do
        assert_equal [@rubygems.last], assigns[:extra_rubygems]
        pending
      end
    end

    context "on GET to show with handle" do
      setup do
        get :show, :id => @user.handle
      end

{'fraction_non_alphanumeric': 0.09206219312602291, 'fraction_numerical': 0.009410801963993453, 'mean_word_length': 2.2171052631578947, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3620842', 'n_tokens_mistral': 767, 'n_tokens_neox': 723, 'n_words': 245}