<commit_before>require 'rails_helper'

RSpec.describe CuppedCoffeesController, type: :controller do
  let(:cupping) { create(:cupping) }
  let(:coffee) { create(:coffee) }
  let(:roaster) { create(:roaster) }
  let(:cupped_coffees) { create_list(:cupped_coffee, 2, cupping_id: cupping.id) }
  let(:cupped_coffee) { cupped_coffees.first }

  describe 'GET #index' do
    it 'collects all cuppeded coffees into @cupped_coffees' do
      cupped_coffees
      get :index, params: { cupping_id: cupping.id }, format: :json
      expect(assigns(:cupped_coffees)).to eq cupped_coffees
    end
  end

  describe 'GET #show' do
    it 'assigns the requested cupped_coffee as @cupped_coffee' do
      get :show, params: { id: cupped_coffee, cupping_id: cupping.id },
                 format: :json
      expect(assigns(:cupped_coffee)).to eq cupped_coffee
    end
  end

  describe 'POST #create' do
    context 'with vaild attributes' do
      it 'saves a new cupped_coffee in the database' do<commit_msg>Updates cupped_coffees controller specs to support token auth<commit_after>require 'rails_helper'

RSpec.describe CuppedCoffeesController, type: :controller do
  let(:cupping) { create(:cupping) }
  let(:coffee) { create(:coffee) }
  let(:roaster) { create(:roaster) }
  let(:cupped_coffees) { create_list(:cupped_coffee, 2, cupping_id: cupping.id) }
  let(:cupped_coffee) { cupped_coffees.first }

  before { login_user(User.find(cupping.host_id)) }

  describe 'GET #index' do
    it 'collects all cuppeded coffees into @cupped_coffees' do
      cupped_coffees
      get :index, params: { cupping_id: cupping.id }, format: :json
      expect(assigns(:cupped_coffees)).to eq cupped_coffees
    end
  end

  describe 'GET #show' do
    it 'assigns the requested cupped_coffee as @cupped_coffee' do
      get :show, params: { id: cupped_coffee, cupping_id: cupping.id },
                 format: :json
      expect(assigns(:cupped_coffee)).to eq cupped_coffee
    end
  end

  describe 'POST #create' do
    context 'with vaild attributes' do
      it 'saves a new cupped_coffee in the database' do
{'fraction_non_alphanumeric': 0.10320114667940755, 'fraction_numerical': 0.0009555661729574773, 'mean_word_length': 3.8811188811188813, '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': '5006113', 'n_tokens_mistral': 762, 'n_tokens_neox': 777, 'n_words': 186}