<commit_before>require 'spec_helper'

describe 'src_images/_src_images.html' do

  subject {
    render partial: 'src_images/src_images',
           locals: { current_user: user }
  }

  let(:user) { FactoryGirl.create(:user) }
  let(:user2) { FactoryGirl.create(:user) }
  let(:src_images) { Kaminari.paginate_array([]).page(1) }

  context 'showing a set' do

    context 'when the user owns the set' do
      let(:src_set) { FactoryGirl.create(:src_set, user: user) }

      it 'shows the remove from set button' do
        assign :src_images, src_images
        assign :src_set, src_set
        subject

        expect(rendered).to contain /Remove 0 from Set/
      end

    end

    context "when the user doesn't own the set" do
      let(:src_set) { FactoryGirl.create(:src_set, user: user2) }

      it "doesn't show the remove from set button" do
        assign :src_images, src_images
        assign :src_set, src_set
        subject

        expect(rendered).to_not contain /Remove 0 from Set/
      end

    end

    context "when the user is not logged in" do
      let(:user) { nil }
      let(:src_set) { FactoryGirl.create(:src_set, user: user2) }

      it "doesn't show the remove from set button" do
        assign :src_images, src_images
        assign :src_set, src_set
        subject

        expect(rendered).to_not contain /Remove 0 from Set/
      end

      it "doesn't show the toolbar" do
        assign :src_images, src_images
        assign :src_set, src_set
        subject
<commit_msg>Don't call render in subject.<commit_after>require 'spec_helper'

describe 'src_images/_src_images.html' do

  let(:user) { FactoryGirl.create(:user) }
  let(:user2) { FactoryGirl.create(:user) }
  let(:src_images) { Kaminari.paginate_array([]).page(1) }

  context 'showing a set' do

    context 'when the user owns the set' do
      let(:src_set) { FactoryGirl.create(:src_set, user: user) }

      it 'shows the remove from set button' do
        assign :src_images, src_images
        assign :src_set, src_set
        render partial: 'src_images/src_images', locals: { current_user: user }

        expect(rendered).to contain /Remove 0 from Set/
      end

    end

    context "when the user doesn't own the set" do
      let(:src_set) { FactoryGirl.create(:src_set, user: user2) }

      it "doesn't show the remove from set button" do
        assign :src_images, src_images
        assign :src_set, src_set
        render partial: 'src_images/src_images', locals: { current_user: user }

        expect(rendered).to_not contain /Remove 0 from Set/
      end

    end

    context "when the user is not logged in" do
      let(:user) { nil }
      let(:src_set) { FactoryGirl.create(:src_set, user: user2) }

      it "doesn't show the remove from set button" do
        assign :src_images, src_images
        assign :src_set, src_set
        render partial: 'src_images/src_images', locals: { current_user: user }

        expect(rendered).to_not contain /Remove 0 from Set/
      end

      it "doesn't show the toolbar" do
        assign :src_images, src_images
        assign :src_set, src_set
        render partial: 'src_images/src_images', locals: { current_user: user }

{'fraction_non_alphanumeric': 0.09581772784019975, 'fraction_numerical': 0.004369538077403246, 'mean_word_length': 2.6839080459770117, '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': '1556728', 'n_tokens_mistral': 1042, 'n_tokens_neox': 972, 'n_words': 309}