<commit_before># frozen_string_literal: true

require "rails_helper"

RSpec.describe "Messages", type: :request do
  describe "GET /messages" do
    it "shouldn't be publicly accessible!" do
      get messages_path
      expect(response).to have_http_status(302)
    end
    it "should be accessible when logged in as admin" do
      user = users(:admin)
      sign_in user
      get messages_path
      expect(response).to have_http_status(200)
    end
  end
end<commit_msg>make sure user requesting the download can download the file<commit_after># frozen_string_literal: true

require "rails_helper"

RSpec.describe "Messages", type: :request do
  describe "GET /messages" do
    it "shouldn't be publicly accessible!" do
      get messages_path
      expect(response).to have_http_status(302)
    end
    it "should be accessible when logged in as admin" do
      user = users(:admin)
      sign_in user
      get messages_path
      expect(response).to have_http_status(200)
    end
  end

  describe "GET /messages/:id" do
    context "advisor" do
      let(:user) { users(:advisor) }

      before do
        sign_in user
      end

      it "should be able to download the download message" do
        collection = collections(:collection1)
        message = CollectionDownloadWorker.new.perform(collection.id, user.id)
        get message_path(message)
        expect(response).to have_http_status(200)
      end
    end

  end
end
{'fraction_non_alphanumeric': 0.075, 'fraction_numerical': 0.011111111111111112, 'mean_word_length': 3.013927576601671, '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': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1531119', 'n_tokens_mistral': 432, 'n_tokens_neox': 411, 'n_words': 136}