<commit_before>RSpec.describe 'hyrax/base/show.html.erb', type: :view do
  let(:work_solr_document) do
    SolrDocument.new(id: '999',
                     title_tesim: ['My Title'],
                     creator_tesim: ['<NAME>', '<NAME>'],
                     date_modified_dtsi: '2011-04-01',
                     has_model_ssim: ['GenericWork'],
                     depositor_tesim: depositor.user_key,
                     description_tesim: ['Lorem ipsum lorem ipsum.'],
                     keyword_tesim: ['bacon', 'sausage', 'eggs'],
                     rights_statement_tesim: ['http://example.org/rs/1'],
                     date_created_tesim: ['1984-01-02'])
  end

  let(:file_set_solr_document) do
    SolrDocument.new(id: '123',
                     title_tesim: ['My FileSet'],
                     depositor_tesim: depositor.user_key)
  end

  let(:ability) { double }

  let(:presenter) do
    Hyrax::WorkShowPresenter.new(work_solr_document, ability, request)
  end

  let(:workflow_presenter) do
    double('workflow_presenter', badge: 'Foobar')
  end

  let(:representative_presenter) do
    Hyrax::FileSetPresenter.new(file_set_solr_document, ability)
  end

  let(:page) { Capybara::Node::Simple.new(rendered) }

  let(:request) { double('request', host: 'test.host') }

  let(:depositor) do
    stub_model(User,
               user_key: 'bob',
               twitter_handle: 'bot4lib')
  end

  before do
    allow(presenter).to receive(:workflow).and_return(workflow_presenter)
    allow(presenter).to receive(:representative_presenter).and_return(representative_presenter)
    allow(presenter).to receive(:representative_id).and_return('123')
    allow(presenter).to receive(:tweeter).and_return("@#{depositor.twitter_handle}")
    allow(controller).to receive(:current_user).and_return(depositor)
    allow(User).to receive(:find_by_user_key).and_return(depositor.user_key)
    allow(view).to receive(:blacklight_config).and_return(Blacklight::Configuration.new)
    allow(view).to receive(:signed_in?)
    allow(view).to receive(:on_the_dashboard?).and_return(false)
    stub_template 'hyrax/base/_metadata.html.erb' => ''
    stub_template 'hyrax/base/_relationships.html.erb' => ''
    stub_template 'hyrax/base/_show_actions.html.erb' => ''
    stub_template 'hyrax/base/_social_media.html.erb' => ''
    stub_template 'hyrax/base/_citations.html.erb' => ''
    stub_template 'hyrax/base/_items.html.erb' => ''
    stub_template 'hyrax/base/_workflow_actions_widget.html.erb' => ''
    stub_template '_masthead.html.erb' => ''
    assign(:presenter, presenter)
    render template: 'hyrax/base/show.html.erb', layout: 'layouts/hyrax/1_column'
  end

  it 'shows workflow badge' do
    expect(page).to have_content 'Foobar'
  end

  describe 'UniversalViewer integration' do
    before do
      allow(presenter).to receive(:universal_viewer?).and_return(viewer_enabled)
      render template: 'hyrax/base/show.html.erb'
    end

    context 'when presenter says it is enabled' do
      let(:viewer_enabled) { true }

      it 'renders the UniversalViewer' do
        expect(page).to have_selector 'div.viewer'
      end
    end

    context 'when presenter says it is enabled' do
      let(:viewer_enabled) { false }

      it 'omits the UniversalViewer' do
        expect(page).not_to have_selector 'div.viewer'
      end
    end
  end<commit_msg>Fix typo in show view spec description<commit_after>RSpec.describe 'hyrax/base/show.html.erb', type: :view do
  let(:work_solr_document) do
    SolrDocument.new(id: '999',
                     title_tesim: ['My Title'],
                     creator_tesim: ['Do<NAME>', '<NAME>'],
                     date_modified_dtsi: '2011-04-01',
                     has_model_ssim: ['GenericWork'],
                     depositor_tesim: depositor.user_key,
                     description_tesim: ['Lorem ipsum lorem ipsum.'],
                     keyword_tesim: ['bacon', 'sausage', 'eggs'],
                     rights_statement_tesim: ['http://example.org/rs/1'],
                     date_created_tesim: ['1984-01-02'])
  end

  let(:file_set_solr_document) do
    SolrDocument.new(id: '123',
                     title_tesim: ['My FileSet'],
                     depositor_tesim: depositor.user_key)
  end

  let(:ability) { double }

  let(:presenter) do
    Hyrax::WorkShowPresenter.new(work_solr_document, ability, request)
  end

  let(:workflow_presenter) do
    double('workflow_presenter', badge: 'Foobar')
  end

  let(:representative_presenter) do
    Hyrax::FileSetPresenter.new(file_set_solr_document, ability)
  end

  let(:page) { Capybara::Node::Simple.new(rendered) }

  let(:request) { double('request', host: 'test.host') }

  let(:depositor) do
    stub_model(User,
               user_key: 'bob',
               twitter_handle: 'bot4lib')
  end

  before do
    allow(presenter).to receive(:workflow).and_return(workflow_presenter)
    allow(presenter).to receive(:representative_presenter).and_return(representative_presenter)
    allow(presenter).to receive(:representative_id).and_return('123')
    allow(presenter).to receive(:tweeter).and_return("@#{depositor.twitter_handle}")
    allow(controller).to receive(:current_user).and_return(depositor)
    allow(User).to receive(:find_by_user_key).and_return(depositor.user_key)
    allow(view).to receive(:blacklight_config).and_return(Blacklight::Configuration.new)
    allow(view).to receive(:signed_in?)
    allow(view).to receive(:on_the_dashboard?).and_return(false)
    stub_template 'hyrax/base/_metadata.html.erb' => ''
    stub_template 'hyrax/base/_relationships.html.erb' => ''
    stub_template 'hyrax/base/_show_actions.html.erb' => ''
    stub_template 'hyrax/base/_social_media.html.erb' => ''
    stub_template 'hyrax/base/_citations.html.erb' => ''
    stub_template 'hyrax/base/_items.html.erb' => ''
    stub_template 'hyrax/base/_workflow_actions_widget.html.erb' => ''
    stub_template '_masthead.html.erb' => ''
    assign(:presenter, presenter)
    render template: 'hyrax/base/show.html.erb', layout: 'layouts/hyrax/1_column'
  end

  it 'shows workflow badge' do
    expect(page).to have_content 'Foobar'
  end

  describe 'UniversalViewer integration' do
    before do
      allow(presenter).to receive(:universal_viewer?).and_return(viewer_enabled)
      render template: 'hyrax/base/show.html.erb'
    end

    context 'when presenter says it is enabled' do
      let(:viewer_enabled) { true }

      it 'renders the UniversalViewer' do
        expect(page).to have_selector 'div.viewer'
      end
    end

    context 'when presenter says it is disabled' do
      let(:viewer_enabled) { false }

      it 'omits the UniversalViewer' do
        expect(page).not_to have_selector 'div.viewer'
      end
    end
  end
{'fraction_non_alphanumeric': 0.12691401648998824, 'fraction_numerical': 0.008244994110718492, 'mean_word_length': 3.1803076923076925, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 2, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '814119', 'n_tokens_mistral': 2321, 'n_tokens_neox': 2200, 'n_words': 373}