<commit_before>require 'rails_helper'

RSpec.describe ProjectDecorator do
  let(:project){ create(:project, about: 'Foo Bar http://www.foo.bar <javascript>xss()</javascript>"Click here":http://click.here') }

  describe "#state_warning_template" do
    subject{ project.state_warning_template }
    context "when project is in analysis" do
      let(:project){ Project.new state: 'in_analysis' }
      it{ is_expected.to eq('in_analysis_warning') }
    end

    context "when project is a draft" do
      let(:project){ Project.new state: 'draft' }
      it{ is_expected.to eq('draft_warning') }
    end
  end


  describe "#time_to_go" do
    let(:project){ build(:project) }
    let(:expires_at){ Time.zone.parse("23:00:00") }
    subject{ project.time_to_go }
    before do
      I18n.locale = :pt
      allow(project).to receive(:expires_at).and_return(expires_at)
    end

    context "when there is more than 1 day to go" do
      let(:expires_at){ Time.zone.now + 2.days }
      it{ is_expected.to eq({time:1, unit:"dia"}) }
    end

    context "when there is less than 1 day to go" do
      let(:expires_at){ Time.zone.now + 13.hours }<commit_msg>Fixes time_to_go spec<commit_after>require 'rails_helper'

RSpec.describe ProjectDecorator do
  let(:project){ create(:project, about: 'Foo Bar http://www.foo.bar <javascript>xss()</javascript>"Click here":http://click.here') }

  describe "#state_warning_template" do
    subject{ project.state_warning_template }
    context "when project is in analysis" do
      let(:project){ Project.new state: 'in_analysis' }
      it{ is_expected.to eq('in_analysis_warning') }
    end

    context "when project is a draft" do
      let(:project){ Project.new state: 'draft' }
      it{ is_expected.to eq('draft_warning') }
    end
  end


  describe "#time_to_go" do
    let(:project){ build(:project) }
    let(:expires_at){ Time.zone.parse("23:00:00") }
    subject{ project.time_to_go }
    before do
      I18n.locale = :pt
      allow(project).to receive(:expires_at).and_return(expires_at)
    end

    context "when there is more than 1 day to go but less than 2" do
      let(:expires_at){ Time.zone.now + 25.hours }
      it{ is_expected.to eq({time:1, unit:"dia"}) }
    end

    context "when there is less than 1 day to go" do
      let(:expires_at){ Time.zone.now + 13.hours }
{'fraction_non_alphanumeric': 0.1300256629597947, 'fraction_numerical': 0.01283147989734816, 'mean_word_length': 3.4383301707779887, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5313034', 'n_tokens_mistral': 803, 'n_tokens_neox': 755, 'n_words': 202}