Sha256: c4a7b93264b7b73fd805aaed250950827e276400a0dd7ad4016fc4b0a85de03a

Contents?: true

Size: 1.7 KB

Versions: 10

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true
require 'test_helper'

module Shipit
  class StatusGroupTest < ActiveSupport::TestCase
    setup do
      @commit = shipit_commits(:second)
      @group = Status::Group.new(@commit, @commit.statuses_and_check_runs)
    end

    test "#description is a summary of the statuses" do
      assert_equal '2 / 3 checks OK', @group.description
    end

    test "#group? returns true" do
      assert_equal true, @group.group?
    end

    test "#target_url returns nil" do
      assert_nil @group.target_url
    end

    test "#state is significant's status state" do
      assert_equal %w(success success failure), @group.statuses.map(&:state)
      assert_equal 'failure', @group.state
    end

    test "#blocking? returns true if any of the status is blocking" do
      blocking_status = shipit_statuses(:soc_first)
      assert_predicate blocking_status, :blocking?
      Status::Group.new(blocking_status.commit, [blocking_status])
    end

    test ".compact returns a regular status if there is only one visible status" do
      status = Status::Group.compact(@commit, @commit.statuses.where(context: 'ci/travis'))
      assert_instance_of Status, status
    end

    test ".compact returns an unknown status if there is no visible status" do
      status = Status::Group.compact(@commit, @commit.statuses.where(context: 'ci/none'))
      assert_instance_of Status::Unknown, status
    end

    test "missing required status will have MissingRequiredStatus as placeholder" do
      @commit.stubs(:required_statuses).returns(%w(ci/very-important))
      status = Status::Group.compact(@commit, [])
      assert_instance_of Status::Missing, status
      assert_predicate status, :pending?
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shipit-engine-0.39.0 test/models/status/group_test.rb
shipit-engine-0.38.0 test/models/status/group_test.rb
shipit-engine-0.37.0 test/models/status/group_test.rb
shipit-engine-0.36.1 test/models/status/group_test.rb
shipit-engine-0.36.0 test/models/status/group_test.rb
shipit-engine-0.35.1 test/models/status/group_test.rb
shipit-engine-0.35.0 test/models/status/group_test.rb
shipit-engine-0.34.0 test/models/status/group_test.rb
shipit-engine-0.33.0 test/models/status/group_test.rb
shipit-engine-0.32.0 test/models/status/group_test.rb