<commit_before>require 'spec_helper'

describe SessionsController do

  describe "POST create" do
    describe "with valid params" do
      it "should return an auth_token" do
        user = create(:user, password: "<PASSWORD>")
        post :create, username: user.email, password: "<PASSWORD>"

        response.status.should == 201
        JSON.parse(response.body)["auth_token"].should == AuthToken.last.token
      end

    end

    describe "with invalid params" do
    end

  end
<commit_msg>Add invalid data tests for session controller<commit_after>require 'spec_helper'

describe SessionsController do

  describe "POST create" do
    describe "with valid params" do
      it "should return an auth_token" do
        user = create(:user, password: "<PASSWORD>")
        post :create, username: user.email, password: "<PASSWORD>"

        response.status.should == 201
        JSON.parse(response.body)["auth_token"].should == AuthToken.last.token
      end

    end

    describe "with invalid params" do

      it "should return a HTTP 401 code if the user doesn't exist" do
        post :create, username: "<EMAIL>", password: "<PASSWORD>"

        response.status.should == 401 # Unauthorized
      end

      it "should return a HTTP 401 code if the password is wrong" do
        user = create(:user, password: "<PASSWORD>")
        post :create, username: user.email, password: "<PASSWORD>"

        response.status.should == 401 # Unauthorized
      end
    end

  end

{'fraction_non_alphanumeric': 0.09966329966329966, 'fraction_numerical': 0.012121212121212121, 'mean_word_length': 2.8798955613577024, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2640967', 'n_tokens_mistral': 429, 'n_tokens_neox': 394, 'n_words': 142}