<commit_before>require 'spec_helper'

describe Link::Facilitator do
  before           { create_magic_assessments }
  before           { create_responses }
  let(:assessment) { @assessment_with_participants }
  let(:subject)    { Link::Facilitator }

  before do
    allow(assessment).to receive(:status).and_return(:consensus)
  end

  def links
    subject.new(assessment).execute
  end

  it 'returns a dashboard link when an assessment is not a draft' do
    allow(assessment).to receive(:status).and_return(:assessment)

    expect(links[:dashboard][:title]).to  eq("View Dashboard")
    expect(links[:dashboard][:active]).to eq(true)
    expect(links[:dashboard][:type]).to   eq(:dashboard)


    allow(assessment).to receive(:status).and_return(:draft)

    expect(links[:dashboard]).to be_nil

    expect(links[:finish][:title]).to  eq("Finish & Assign")
    expect(links[:finish][:active]).to eq(true)
    expect(links[:finish][:type]).to   eq(:finish)
  end

  describe 'dashboard' do
    it 'returns a dashboard link' do
      expect(links[:dashboard][:title]).to  eq("View Dashboard")
      expect(links[:dashboard][:active]).to eq(true)
      expect(links[:dashboard][:type]).to   eq(:dashboard)
    end
  end

  describe 'consensus' do
    it 'returns a new consensus link when there isnt one' do
      allow(assessment).to receive(:status).and_return(:assessment)

      expect(links[:consensus][:title]).to  eq("Create Consensus")
      expect(links[:consensus][:active]).to eq(true)
      expect(links[:consensus][:type]).to   eq(:new_consensus)
    end

    it 'returns a consensus link when is a consensus' do
      allow(assessment).to receive(:status).and_return(:consensus)

      expect(links[:consensus][:type]).to   eq(:consensus)
    end

    it 'returns a no consensus link when is a draft' do
      allow(assessment).to receive(:status).and_return(:draft)

      expect(links[:consensus]).to  eq(nil)
    end
  end

  describe 'report' do
    it 'returns no report link when is assessment' do
      allow(assessment).to receive(:status).and_return(:assessment)

      expect(links[:report]).to  eq(nil)
    end

    it 'returns no report link when is draft' do
      allow(assessment).to receive(:status).and_return(:draft)

      expect(links[:report]).to  eq(nil)
    end

    it 'returns an active report link when consensus is fully complete' do
      allow(assessment).to receive(:status).and_return(:consensus)
      allow(assessment).to receive(:fully_complete?).and_return(true)

      expect(links[:report][:active]).to eq(true)
    end
  end

  describe 'execute' do
    it 'only returns finish when is draft' do
      allow(assessment).to receive(:status).and_return(:draft)
      expect(links.length).to eq(1)
      expect(links[:finish][:title]).to eq('Finish & Assign')
    end

    it 'returns dashboard, report, and consensus finish when is fully complete' do
      allow(assessment).to receive(:status).and_return(:consensus)
      allow(assessment).to receive(:fully_complete?).and_return(true)

      expect(links.length).to eq(3)
      expect(links[:dashboard][:title]).to eq('View Dashboard')
      expect(links[:report][:title]).to eq('View Report')
      expect(links[:consensus][:title]).to eq('Consensus')
    end

    it 'returns dashboard and consensus finish when consensus but not  fully complete' do
      allow(assessment).to receive(:status).and_return(:consensus)
      allow(assessment).to receive(:fully_complete?).and_return(false)

      expect(links.length).to eq(2)
      expect(links[:dashboard][:title]).to eq('View Dashboard')
      expect(links[:consensus][:title]).to eq('Consensus')
    end
<commit_msg>Fixing specs<commit_after>require 'spec_helper'

describe Link::Facilitator do
  before           { create_magic_assessments }
  before           { create_responses }
  let(:assessment) { @assessment_with_participants }
  let(:subject)    { Link::Facilitator }

  before do
    allow(assessment).to receive(:status).and_return(:consensus)
  end

  def links
    subject.new(assessment).execute
  end

  it 'returns a dashboard link when an assessment is not a draft' do
    allow(assessment).to receive(:status).and_return(:assessment)

    expect(links[:dashboard][:title]).to  eq("View Dashboard")
    expect(links[:dashboard][:active]).to eq(true)
    expect(links[:dashboard][:type]).to   eq(:dashboard)


    allow(assessment).to receive(:status).and_return(:draft)

    expect(links[:dashboard]).to be_nil

    expect(links[:finish][:title]).to  eq("Finish & Assign")
    expect(links[:finish][:active]).to eq(true)
    expect(links[:finish][:type]).to   eq(:finish)
  end

  describe 'dashboard' do
    it 'returns a dashboard link' do
      expect(links[:dashboard][:title]).to  eq("View Dashboard")
      expect(links[:dashboard][:active]).to eq(true)
      expect(links[:dashboard][:type]).to   eq(:dashboard)
    end
  end

  describe 'consensus' do
    it 'returns a new consensus link when there isnt one' do
      allow(assessment).to receive(:status).and_return(:assessment)

      expect(links[:consensus][:title]).to  eq("Create Consensus")
      expect(links[:consensus][:active]).to eq(true)
      expect(links[:consensus][:type]).to   eq(:new_consensus)
    end

    it 'returns a consensus link when is a consensus' do
      allow(assessment).to receive(:status).and_return(:consensus)

      expect(links[:consensus][:type]).to   eq(:consensus)
    end

    it 'returns a no consensus link when is a draft' do
      allow(assessment).to receive(:status).and_return(:draft)

      expect(links[:consensus]).to  eq(nil)
    end
  end

  describe 'report' do
    it 'returns no report link when is assessment' do
      allow(assessment).to receive(:status).and_return(:assessment)

      expect(links[:report]).to  eq(nil)
    end

    it 'returns no report link when is draft' do
      allow(assessment).to receive(:status).and_return(:draft)

      expect(links[:report]).to  eq(nil)
    end

    it 'returns an active report link when consensus is fully complete' do
      allow(assessment).to receive(:status).and_return(:consensus)
      allow(assessment).to receive(:fully_complete?).and_return(true)

      expect(links[:report][:active]).to eq(true)
    end
  end

  describe 'execute' do
    it 'only returns finish when is draft' do
      allow(assessment).to receive(:status).and_return(:draft)
      expect(links.length).to eq(1)
      expect(links[:finish][:title]).to eq('Finish & Assign')
    end

    it 'returns dashboard, report, and consensus finish when is fully complete' do
      allow(assessment).to receive(:status).and_return(:consensus)
      allow(assessment).to receive(:fully_complete?).and_return(true)

      expect(links.length).to eq(3)
      expect(links[:dashboard][:title]).to eq('View Dashboard')
      expect(links[:report][:title]).to eq('View Report')
      expect(links[:consensus][:title]).to eq('View Consensus')
    end

    it 'returns dashboard and consensus finish when consensus but not  fully complete' do
      allow(assessment).to receive(:status).and_return(:consensus)
      allow(assessment).to receive(:fully_complete?).and_return(false)

      expect(links.length).to eq(2)
      expect(links[:dashboard][:title]).to eq('View Dashboard')
      expect(links[:consensus][:title]).to eq('View Consensus')
    end

{'fraction_non_alphanumeric': 0.13720961825838882, 'fraction_numerical': 0.0008151066431191414, 'mean_word_length': 3.9475806451612905, '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': '4605708', 'n_tokens_mistral': 2228, 'n_tokens_neox': 2170, 'n_words': 507}