<commit_before>require 'rails_helper'

RSpec.describe 'Media', type: :request do
  let(:params) { { } }
  let(:headers) { { } }
  describe 'GET' do
    let(:request) { get url, params: params, headers: headers }
    describe '/media' do
      let(:url) { media_path }

      describe 'response' do
        before { request }
        subject { response }
        it { is_expected.to have_http_status(200) }
      end
    end


    context 'given a medium' do
      before { medium }

      describe '/media/:id' do
        let(:url) { medium_path(medium) }

        describe 'translations' do
          let(:medium) { create(:medium, name_de: 'Fernsehen', name_en: 'Television') }

          context 'when logged in' do
            # let(:user) { create(:user) }
            let(:user) { create(:user, locale: 'en') }
            let(:headers) { super().merge(authenticated_header(user)) }

            describe 'response is translated according to user setting' do
              before { request }
              subject { parse_json(response.body, 'data/attributes/name') }
              pending('issue #183, user has no locale column yet') do
                it { is_expected.to eq 'Television' }
              end
            end
          end
        end<commit_msg>run `bundle exec rubocop -a`<commit_after>require 'rails_helper'

RSpec.describe 'Media', type: :request do
  let(:params) { {} }
  let(:headers) { {} }
  describe 'GET' do
    let(:request) { get url, params: params, headers: headers }
    describe '/media' do
      let(:url) { media_path }

      describe 'response' do
        before { request }
        subject { response }
        it { is_expected.to have_http_status(200) }
      end
    end

    context 'given a medium' do
      before { medium }

      describe '/media/:id' do
        let(:url) { medium_path(medium) }

        describe 'translations' do
          let(:medium) { create(:medium, name_de: 'Fernsehen', name_en: 'Television') }

          context 'when logged in' do
            # let(:user) { create(:user) }
            let(:user) { create(:user, locale: 'en') }
            let(:headers) { super().merge(authenticated_header(user)) }

            describe 'response is translated according to user setting' do
              before { request }
              subject { parse_json(response.body, 'data/attributes/name') }
              pending('issue #183, user has no locale column yet') do
                it { is_expected.to eq 'Television' }
              end
            end
          end
        end
{'fraction_non_alphanumeric': 0.11803921568627451, 'fraction_numerical': 0.004705882352941176, 'mean_word_length': 2.04778972520908, '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': '6796727', 'n_tokens_mistral': 739, 'n_tokens_neox': 705, 'n_words': 205}