<commit_before># encoding: utf-8

# FIXME: These tests are flawed. Content is not being changed at all!

describe EvernoteNote do

  before(:example) do
    Setting['channel.evernote_notebooks'] = 'NOTEBOOK_GUID'
    Setting['advanced.instructions_required'] = '__PUBLISH'
    @evernote_request = FactoryGirl.build(:evernote_request)
  end

  subject { @evernote_request }

  describe '#update_necessary?' do

    describe '#calculate_updated_at' do
      context 'when a note is new' do
        # OPTIMIZE: This test is at the top to ensure that the note is new
        before { Setting['advanced.always_reset_on_create'] = false }
        its(:calculate_updated_at) { is_expected.to eq(Time.at(@evernote_request.cloud_note_data.updated / 1000)) }
      end
      context 'when a note is new and always_reset is true' do
        before { Setting['advanced.always_reset_on_create'] = true }
        its(:calculate_updated_at) { is_expected.to eq(Time.at(@evernote_request.cloud_note_data.created / 1000)) }
      end
    end

    context 'when note is in a required notebook' do
      before do
        @evernote_request.cloud_note_metadata[:notebookGuid] = 'NOTEBOOK_GUID'
      end
      # pending its(:update_necessary?) { is_expected.to eq(@evernote_request) }
    end

    context 'when note is not in a required notebook' do
      before do
        @evernote_request.cloud_note_metadata[:notebookGuid] = 'ANOTHER_NOTEBOOK_GUID'
      end
      its(:update_necessary?) { is_expected.to be_falsey }
    end

    context 'when cloud note is not active' do
      before do
        @evernote_request.cloud_note_metadata[:active] = false
      end
      its(:update_necessary?) { is_expected.to be_falsey }
      it 'destroys evernote_note' do
        expect(@evernote_note).to be_nil
      end
    end

    context 'when cloud note has not been updated' do
      before do
        @evernote_request.evernote_note.note.external_updated_at = 0
        @evernote_request.cloud_note_metadata[:updated] = 0
      end
      # pending its(:update_necessary?) { is_expected.to be_falsey }
      it 'undirtifies evernote_note' do<commit_msg>Fix (disabled) test<commit_after># encoding: utf-8

# FIXME: These tests are flawed. Content is not being changed at all!

describe EvernoteNote do

  before(:example) do
    Setting['channel.evernote_notebooks'] = 'NOTEBOOK_GUID'
    Setting['advanced.instructions_required'] = '__PUBLISH'
    @evernote_request = FactoryGirl.build(:evernote_request)
  end

  subject { @evernote_request }

  describe '#update_necessary?' do

    describe '#calculate_updated_at' do
      context 'when a note is new' do
        # OPTIMIZE: This test is at the top to ensure that the note is new
        before { Setting['advanced.always_reset_on_create'] = false }
        its(:calculate_updated_at) { is_expected.to eq(Time.at(@evernote_request.cloud_note_data.updated / 1000)) }
      end
      context 'when a note is new and always_reset is true' do
        before { Setting['advanced.always_reset_on_create'] = true }
        its(:calculate_updated_at) { is_expected.to eq(Time.at(@evernote_request.cloud_note_data.created / 1000)) }
      end
    end

    context 'when note is in a required notebook' do
      before do
        @evernote_request.cloud_note_metadata[:notebookGuid] = 'NOTEBOOK_GUID'
      end
      # pending its(:update_necessary?) { is_expected.to be_truthy }
    end

    context 'when note is not in a required notebook' do
      before do
        @evernote_request.cloud_note_metadata[:notebookGuid] = 'ANOTHER_NOTEBOOK_GUID'
      end
      its(:update_necessary?) { is_expected.to be_falsey }
    end

    context 'when cloud note is not active' do
      before do
        @evernote_request.cloud_note_metadata[:active] = false
      end
      its(:update_necessary?) { is_expected.to be_falsey }
      it 'destroys evernote_note' do
        expect(@evernote_note).to be_nil
      end
    end

    context 'when cloud note has not been updated' do
      before do
        @evernote_request.evernote_note.note.external_updated_at = 0
        @evernote_request.cloud_note_metadata[:updated] = 0
      end
      # pending its(:update_necessary?) { is_expected.to be_falsey }
      it 'undirtifies evernote_note' do
{'fraction_non_alphanumeric': 0.08380281690140845, 'fraction_numerical': 0.005164319248826291, 'mean_word_length': 3.2482552342971087, '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': '7540914', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1282, 'n_words': 341}