<commit_before>require "spec_helper"

describe ContainerSummaryHelper do
  REL_HASH_WITH_LINK = [:label, :image, :value, :link, :title]
  REL_HASH_WITHOUT_LINK = [:label, :image, :value]

  let(:container_project) { FactoryGirl.create(:container_project) }
  before do
    controller.send(:extend, ApplicationHelper)
    self.class.send(:include, ApplicationHelper)

    @record = FactoryGirl.create(:container_group, :container_project => container_project)
    FactoryGirl.create(:container, :container_group => @record)
    FactoryGirl.create(:container, :container_group => @record)

    login_as @user = FactoryGirl.create(:user)
  end

  context "single relationship link allowed" do
    it 'should return linked relationship' do
      @user.stub(:role_allows?).and_return(true)

      rel_hash = textual_container_project

      rel_hash.keys.should be == REL_HASH_WITH_LINK
      rel_hash[:value].should be == container_project.name
    end
  end

  context "single relationship link not allowed" do
    it 'should not return linked relationship' do
      @user.stub(:role_allows?).and_return(false)

      rel_hash = textual_container_project

      rel_hash.keys.should be == REL_HASH_WITHOUT_LINK
      rel_hash[:value].should be == container_project.name
    end
  end

  context "multiple relationships link allowed" do
    it 'should return linked relationship' do
      @user.stub(:role_allows?).and_return(true)

      rel_hash = textual_containers

      rel_hash.keys.should be == REL_HASH_WITH_LINK
      rel_hash[:value].should be == "2"
    end
  end

  context "multiple relationships link not allowed" do
    it 'should not return linked relationship' do
      @user.stub(:role_allows?).and_return(false)

      rel_hash = textual_containers

      rel_hash.keys.should be == REL_HASH_WITHOUT_LINK
      rel_hash[:value].should be == "2"
    end
  end<commit_msg>Create contexts around the methods that are being tested and use subject<commit_after>require "spec_helper"

describe ContainerSummaryHelper do
  REL_HASH_WITH_LINK = [:label, :image, :value, :link, :title]
  REL_HASH_WITHOUT_LINK = [:label, :image, :value]

  let(:container_project) { FactoryGirl.create(:container_project) }
  before do
    controller.send(:extend, ApplicationHelper)
    self.class.send(:include, ApplicationHelper)

    @record = FactoryGirl.create(:container_group, :container_project => container_project)
    FactoryGirl.create(:container, :container_group => @record)
    FactoryGirl.create(:container, :container_group => @record)

    login_as @user = FactoryGirl.create(:user)
  end

  context ".textual_container_project" do
    subject { textual_container_project }
    context "single relationship link allowed" do
      it 'should return linked relationship' do
        @user.stub(:role_allows?).and_return(true)

        subject.keys.should be == REL_HASH_WITH_LINK
        subject[:value].should be == container_project.name
      end
    end

    context "single relationship link not allowed" do
      it 'should not return linked relationship' do
        @user.stub(:role_allows?).and_return(false)

        subject.keys.should be == REL_HASH_WITHOUT_LINK
        subject[:value].should be == container_project.name
      end
    end
  end

  context ".textual_containers" do
    subject { textual_containers }
    context "multiple relationships link allowed" do
      it 'should return linked relationship' do
        @user.stub(:role_allows?).and_return(true)

        subject.keys.should be == REL_HASH_WITH_LINK
        subject[:value].should be == "2"
      end
    end

    context "multiple relationships link not allowed" do
      it 'should not return linked relationship' do
        @user.stub(:role_allows?).and_return(false)

        subject.keys.should be == REL_HASH_WITHOUT_LINK
        subject[:value].should be == "2"
      end
    end
  end
{'fraction_non_alphanumeric': 0.09477208344063869, 'fraction_numerical': 0.0010301313417460727, 'mean_word_length': 3.7598039215686274, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1547171', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1105, 'n_words': 280}