summaryrefslogtreecommitdiff
path: root/spec/views/notify/pipeline_success_email.html.haml_spec.rb
blob: ecd096ee579e734e8cb6648ac7d3b9c4faa44a24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
require 'spec_helper'

describe 'notify/pipeline_success_email.html.haml' do
  include Devise::Test::ControllerHelpers

  let(:user) { create(:user) }
  let(:project) { create(:project) }
  let(:merge_request) { create(:merge_request, :simple, source_project: project) }

  let(:pipeline) do
    create(:ci_pipeline,
           project: project,
           user: user,
           ref: project.default_branch,
           sha: project.commit.sha,
           status: :success)
  end

  before do
    assign(:project, project)
    assign(:pipeline, pipeline)
    assign(:merge_request, merge_request)
  end

  context 'pipeline with user' do
    it 'renders the email correctly' do
      render

      expect(rendered).to have_content "Your pipeline has passed"
      expect(rendered).to have_content pipeline.project.name
      expect(rendered).to have_content pipeline.git_commit_message.truncate(50)
      expect(rendered).to have_content pipeline.commit.author_name
      expect(rendered).to have_content "##{pipeline.id}"
      expect(rendered).to have_content pipeline.user.name
    end
  end

  context 'pipeline without user' do
    before do
      pipeline.update_attribute(:user, nil)
    end

    it 'renders the email correctly' do
      render

      expect(rendered).to have_content "Your pipeline has passed"
      expect(rendered).to have_content pipeline.project.name
      expect(rendered).to have_content pipeline.git_commit_message.truncate(50)
      expect(rendered).to have_content pipeline.commit.author_name
      expect(rendered).to have_content "##{pipeline.id}"
      expect(rendered).to have_content "by API"
    end
  end
end