<commit_before>require 'spec_helper'

describe BuildMailer do
  describe 'finished_email' do
    let(:mail)  { BuildMailer.finished_email(build) }

    describe 'for a successful build' do
      let(:build) { Factory(:successful_build) }

      it 'subject' do
        mail.subject.should == '[Passed] svenfuchs/successful_build#1 (master - 62aae5f)'
      end

      it 'recipient' do
        mail.to.should == ['<EMAIL>']
      end

      it 'sender' do
        mail.from.should == ['<EMAIL>']
      end

      it 'displays the build number' do
        mail.body.encoded.should include(build.number.to_s)
      end

      it 'displays the status message' do
        mail.body.encoded.should include(build.status_message)
      end

      it 'is a multipart email' do
        mail.should be_multipart
      end

      context 'in HTML' do
        it 'escapes newlines in the commit message' do
          build.commit.message = "bar\nbaz"
          mail.body.encoded.should include("bar<br />baz")  # premailer converts <br> to <br />
        end

        it 'inlines css' do
          mail.body.encoded.should include('<div style="')
        end
      end
    end

    describe 'for a broken build' do
      let(:build) { Factory(:broken_build) }

      it 'subject' do
        mail.subject.should == '[Failed] svenfuchs/broken_build#1 (master - 62aae5f)'
      end

      it 'recipient' do
        mail.to.should == ['<EMAIL>']
      end

      it 'sender' do
        mail.from.should == ['<EMAIL>']
      end

      it 'displays the build number' do
        mail.body.encoded.should include(build.number.to_s)
      end

      it 'displays the status message' do
        mail.body.encoded.should include(build.status_message)
      end

      it 'is a multipart email' do
        mail.should be_multipart
      end
    end
  end
end
<commit_msg>Added specs for build_mailer to test for correct 'alert-message' css class<commit_after>require 'spec_helper'

describe BuildMailer do
  describe 'finished_email' do
    let(:mail)  { BuildMailer.finished_email(build) }

    describe 'for a successful build' do
      let(:build) { Factory(:successful_build) }

      it 'subject' do
        mail.subject.should == '[Passed] svenfuchs/successful_build#1 (master - 62aae5f)'
      end

      it 'recipient' do
        mail.to.should == ['<EMAIL>']
      end

      it 'sender' do
        mail.from.should == ['<EMAIL>']
      end

      it 'displays the build number' do
        mail.body.encoded.should include(build.number.to_s)
      end

      it 'displays the status message' do
        mail.body.encoded.should include(build.status_message)
      end

      it 'is a multipart email' do
        mail.should be_multipart
      end

      context 'in HTML' do
        it 'escapes newlines in the commit message' do
          build.commit.message = "bar\nbaz"
          mail.body.encoded.should include("bar<br />baz")  # premailer converts <br> to <br />
        end

        it 'inlines css' do
          mail.body.encoded.should include('<div style="')
        end

        it 'should have the "success" css class on alert-message' do
          mail.body.encoded.should include('<div class="alert-message block-message success"')
        end
      end
    end

    describe 'for a broken build' do
      let(:build) { Factory(:broken_build) }

      it 'subject' do
        mail.subject.should == '[Failed] svenfuchs/broken_build#1 (master - 62aae5f)'
      end

      it 'recipient' do
        mail.to.should == ['<EMAIL>']
      end

      it 'sender' do
        mail.from.should == ['<EMAIL>']
      end

      it 'displays the build number' do
        mail.body.encoded.should include(build.number.to_s)
      end

      it 'displays the status message' do
        mail.body.encoded.should include(build.status_message)
      end

      it 'is a multipart email' do
        mail.should be_multipart
      end

      context 'in HTML' do
        it 'should have the "error" css class on alert-message' do
          mail.body.encoded.should include('<div class="alert-message block-message error"')
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10207528957528958, 'fraction_numerical': 0.003861003861003861, 'mean_word_length': 2.161708619374523, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, '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': '799497', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1242, 'n_words': 363}