BigW Consortium Gitlab

factory_spec.rb 1.13 KB
Newer Older
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
require 'spec_helper'

describe Gitlab::Ci::Status::External::Factory do
  let(:user) { create(:user) }
  let(:project) { resource.project }
  let(:status) { factory.fabricate! }
  let(:factory) { described_class.new(resource, user) }
  let(:external_url) { 'http://gitlab.com/status' }

  before do
    project.team << [user, :developer]
  end

  context 'when external status has a simple core status' do
    HasStatus::AVAILABLE_STATUSES.each do |simple_status|
      context "when core status is #{simple_status}" do
        let(:resource) do
          create(:generic_commit_status, status: simple_status,
                                         target_url: external_url)
        end

        let(:expected_status) do
          Gitlab::Ci::Status.const_get(simple_status.capitalize)
        end

        it "fabricates a core status #{simple_status}" do
          expect(status).to be_a expected_status
        end

        it 'extends core status with common methods' do
          expect(status).to have_details
          expect(status).not_to have_action
          expect(status.details_path).to eq external_url
        end
      end
    end
  end
end