<commit_before>require 'rails_helper'

describe Admin::ReportsController do
  render_views

  let(:user) { Fabricate(:user, admin: true) }
  before do
    sign_in user, scope: :user
  end

  describe 'GET #index' do
    it 'returns http success with no filters' do
      allow(Report).to receive(:unresolved).and_return(Report.all)
      get :index

      expect(response).to have_http_status(:success)
      expect(Report).to have_received(:unresolved)
    end

    it 'returns http success with resolved filter' do
      allow(Report).to receive(:resolved).and_return(Report.all)
      get :index, params: { resolved: 1 }

      expect(response).to have_http_status(:success)
      expect(Report).to have_received(:resolved)
    end
  end

  describe 'GET #show' do
    it 'returns http success' do
      report = Fabricate(:report)

      get :show, params: { id: report }
      expect(response).to have_http_status(:success)
    end
  end

  describe 'PUT #update' do
    describe 'with an unknown outcome' do
      it 'rejects the change' do
        report = Fabricate(:report)
        put :update, params: { id: report, outcome: 'unknown' }

        expect(response).to have_http_status(:missing)
      end
    end

    describe 'with an outcome of `resolve`' do
      it 'resolves the report' do
        report = Fabricate(:report)<commit_msg>Cover Admin::ReportsController more (#3346)<commit_after>require 'rails_helper'

describe Admin::ReportsController do
  render_views

  let(:user) { Fabricate(:user, admin: true) }
  before do
    sign_in user, scope: :user
  end

  describe 'GET #index' do
    it 'returns http success with no filters' do
      specified = Fabricate(:report, action_taken: false)
      Fabricate(:report, action_taken: true)

      get :index

      reports = assigns(:reports).to_a
      expect(reports.size).to eq 1
      expect(reports[0]).to eq specified
      expect(response).to have_http_status(:success)
    end

    it 'returns http success with resolved filter' do
      specified = Fabricate(:report, action_taken: true)
      Fabricate(:report, action_taken: false)

      get :index, params: { resolved: 1 }

      reports = assigns(:reports).to_a
      expect(reports.size).to eq 1
      expect(reports[0]).to eq specified

      expect(response).to have_http_status(:success)
    end
  end

  describe 'GET #show' do
    it 'renders report' do
      report = Fabricate(:report)

      get :show, params: { id: report }

      expect(assigns(:report)).to eq report
      expect(response).to have_http_status(:success)
    end
  end

  describe 'PUT #update' do
    describe 'with an unknown outcome' do
      it 'rejects the change' do
        report = Fabricate(:report)
        put :update, params: { id: report, outcome: 'unknown' }

        expect(response).to have_http_status(:missing)
      end
    end

    describe 'with an outcome of `resolve`' do
      it 'resolves the report' do
        report = Fabricate(:report)
{'fraction_non_alphanumeric': 0.10114247311827956, 'fraction_numerical': 0.003360215053763441, 'mean_word_length': 3.050340136054422, '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': '3011804', 'n_tokens_mistral': 921, 'n_tokens_neox': 868, 'n_words': 268}