<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)
            create(:version, :rubygem => rubygem)
          end
        end.reverse

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

      should respond_with :success
      should render_template :show
      should "assign the last 10 most downloaded gems" do
        assert_equal @rubygems[0..9], assigns[:rubygems]
        skip
      end
      should "assign the extra gems you own" do
        assert_equal [@rubygems.last], assigns[:extra_rubygems]
        skip
      end
    end

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

      should respond_with :success<commit_msg>Unskip some tests in profiles_controller_test.rb<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, :downloads => n * 100).tap do |rubygem|
            create(:ownership, :rubygem => rubygem, :user => @user)
            create(:version, :rubygem => rubygem)
          end
        end.reverse

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

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

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

      should respond_with :success
{'fraction_non_alphanumeric': 0.09090909090909091, 'fraction_numerical': 0.007939658594680429, 'mean_word_length': 2.255813953488372, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '517716', 'n_tokens_mistral': 782, 'n_tokens_neox': 739, 'n_words': 251}