summaryrefslogtreecommitdiff
path: root/spec/serializers/status_entity_spec.rb
blob: 70402bac2e2c37ae8acff343a8645b6a76f30d29 (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
require 'spec_helper'

describe StatusEntity do
  let(:entity) { described_class.new(status) }

  let(:status) do
    Gitlab::Ci::Status::Success.new(double('object'), double('user'))
  end

  before do
    allow(status).to receive(:has_details?).and_return(true)
    allow(status).to receive(:details_path).and_return('some/path')
  end

  describe '#as_json' do
    subject { entity.as_json }

    it 'contains status details' do
      expect(subject).to include :text, :icon, :favicon, :label, :group
      expect(subject).to include :has_details, :details_path
      expect(subject[:favicon]).to match_asset_path('/assets/ci_favicons/favicon_status_success.ico')
    end

    it 'contains a dev namespaced favicon if dev env' do
      allow(Rails.env).to receive(:development?) { true }
      expect(entity.as_json[:favicon]).to match_asset_path('/assets/ci_favicons/dev/favicon_status_success.ico')
    end

    it 'contains a canary namespaced favicon if canary env' do
      stub_env('CANARY', 'true')
      expect(entity.as_json[:favicon]).to match_asset_path('/assets/ci_favicons/canary/favicon_status_success.ico')
    end
  end
end